@tsiky/components-r19 1.0.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 (287) hide show
  1. package/.prettierignore +4 -0
  2. package/.prettierrc +9 -0
  3. package/.storybook/main.ts +17 -0
  4. package/.storybook/preview.ts +21 -0
  5. package/.storybook/vitest.setup.ts +7 -0
  6. package/README.md +69 -0
  7. package/chart.ts +1 -0
  8. package/eslint.config.js +40 -0
  9. package/index.html +13 -0
  10. package/index.ts +33 -0
  11. package/package.json +63 -0
  12. package/public/vite.svg +1 -0
  13. package/src/App.css +42 -0
  14. package/src/App.tsx +12 -0
  15. package/src/assets/accessibility.png +0 -0
  16. package/src/assets/accessibility.svg +1 -0
  17. package/src/assets/addon-library.png +0 -0
  18. package/src/assets/assets.png +0 -0
  19. package/src/assets/avif-test-image.avif +0 -0
  20. package/src/assets/context.png +0 -0
  21. package/src/assets/discord.svg +1 -0
  22. package/src/assets/docs.png +0 -0
  23. package/src/assets/figma-plugin.png +0 -0
  24. package/src/assets/github.svg +1 -0
  25. package/src/assets/react.svg +1 -0
  26. package/src/assets/share.png +0 -0
  27. package/src/assets/styling.png +0 -0
  28. package/src/assets/testing.png +0 -0
  29. package/src/assets/theming.png +0 -0
  30. package/src/assets/tutorials.svg +1 -0
  31. package/src/assets/youtube.svg +1 -0
  32. package/src/components/AddItemModal/AddItemModal.module.css +72 -0
  33. package/src/components/AddItemModal/AddItemModal.tsx +82 -0
  34. package/src/components/AddItemModal/index.ts +1 -0
  35. package/src/components/Alert/Alert.css +54 -0
  36. package/src/components/Alert/Alert.stories.tsx +82 -0
  37. package/src/components/Alert/Alert.tsx +85 -0
  38. package/src/components/Alert/AlertContext.tsx +200 -0
  39. package/src/components/Alert/AlertModels.ts +34 -0
  40. package/src/components/Alert/index.ts +3 -0
  41. package/src/components/AnnouncementPanel/FlexRowContainer.css +17 -0
  42. package/src/components/AnnouncementPanel/FlexRowContainer.stories.tsx +329 -0
  43. package/src/components/AnnouncementPanel/FlexRowContainer.tsx +24 -0
  44. package/src/components/AnnouncementPanel/ListBox/CounterListBox.css +56 -0
  45. package/src/components/AnnouncementPanel/ListBox/CounterListBox.stories.tsx +292 -0
  46. package/src/components/AnnouncementPanel/ListBox/CounterListBox.tsx +106 -0
  47. package/src/components/AnnouncementPanel/ListBox/SimpleListBox.css +57 -0
  48. package/src/components/AnnouncementPanel/ListBox/SimpleListBox.stories.tsx +189 -0
  49. package/src/components/AnnouncementPanel/ListBox/SimpleListBox.tsx +138 -0
  50. package/src/components/AnnouncementPanel/ListBox/TrendListBox.css +61 -0
  51. package/src/components/AnnouncementPanel/ListBox/TrendListBox.stories.tsx +257 -0
  52. package/src/components/AnnouncementPanel/ListBox/TrendListBox.tsx +90 -0
  53. package/src/components/AnnouncementPanel/ListBox/index.ts +3 -0
  54. package/src/components/AnnouncementPanel/ListContentContainer.css +23 -0
  55. package/src/components/AnnouncementPanel/ListContentContainer.stories.tsx +212 -0
  56. package/src/components/AnnouncementPanel/ListContentContainer.tsx +33 -0
  57. package/src/components/AnnouncementPanel/index.ts +3 -0
  58. package/src/components/BandChart/index.tsx +282 -0
  59. package/src/components/Button/Button.module.css +165 -0
  60. package/src/components/Button/Button.stories.ts +132 -0
  61. package/src/components/Button/Button.tsx +55 -0
  62. package/src/components/Button/button.css +29 -0
  63. package/src/components/Button/index.ts +2 -0
  64. package/src/components/ChartContainer/ChartContainer.css +116 -0
  65. package/src/components/ChartContainer/ChartContainer.stories.tsx +159 -0
  66. package/src/components/ChartContainer/ChartContainer.tsx +155 -0
  67. package/src/components/ChartContainer/index.ts +1 -0
  68. package/src/components/Charts/area-chart-admission/AreaChartAdmission.stories.tsx +65 -0
  69. package/src/components/Charts/area-chart-admission/AreaChartAdmission.tsx +89 -0
  70. package/src/components/Charts/area-chart-admission/content.json +48 -0
  71. package/src/components/Charts/area-chart-hospitalisation/AreaChartHospitalisation.stories.tsx +141 -0
  72. package/src/components/Charts/area-chart-hospitalisation/AreaChartHospitalisation.tsx +262 -0
  73. package/src/components/Charts/area-chart-hospitalisation/content.json +55 -0
  74. package/src/components/Charts/bar-chart/BarChart.stories.tsx +50 -0
  75. package/src/components/Charts/bar-chart/BarChart.tsx +132 -0
  76. package/src/components/Charts/bar-chart/content.json +15 -0
  77. package/src/components/Charts/boxplot-chart/BoxPlotChart.stories.tsx +63 -0
  78. package/src/components/Charts/boxplot-chart/BoxPlotChart.tsx +114 -0
  79. package/src/components/Charts/boxplot-chart/boxUtils.ts +22 -0
  80. package/src/components/Charts/boxplot-chart/content.json +11 -0
  81. package/src/components/Charts/mixed-chart/MixedChart.stories.tsx +83 -0
  82. package/src/components/Charts/mixed-chart/MixedChart.tsx +625 -0
  83. package/src/components/Charts/mixed-chart/content.json +34 -0
  84. package/src/components/Charts/sankey-adaptation/sankey.tsx +70 -0
  85. package/src/components/Charts/sankey-chart/SankeyChart.stories.tsx +69 -0
  86. package/src/components/Charts/sankey-chart/SankeyChart.tsx +155 -0
  87. package/src/components/Charts/sankey-chart/content.json +15 -0
  88. package/src/components/Charts/stacked-column/StackedColumn.stories.tsx +72 -0
  89. package/src/components/Charts/stacked-column/StackedColumn.tsx +406 -0
  90. package/src/components/Charts/stacked-column/content.json +37 -0
  91. package/src/components/Charts/stacked-column-one-hundred-percent/StackedColumnOneHundredPercent.stories.tsx +43 -0
  92. package/src/components/Charts/stacked-column-one-hundred-percent/StackedColumnOneHundredPercent.tsx +75 -0
  93. package/src/components/Charts/stacked-column-one-hundred-percent/content.json +6 -0
  94. package/src/components/CircularProgress/CircularProgress.css +79 -0
  95. package/src/components/CircularProgress/CircularProgress.stories.tsx +251 -0
  96. package/src/components/CircularProgress/CircularProgress.tsx +101 -0
  97. package/src/components/CircularProgress/index.ts +2 -0
  98. package/src/components/Configure.mdx +369 -0
  99. package/src/components/DayStatCard/DayStatCard.css +50 -0
  100. package/src/components/DayStatCard/DayStatCard.stories.tsx +273 -0
  101. package/src/components/DayStatCard/DayStatCard.tsx +69 -0
  102. package/src/components/DayStatCard/index.ts +2 -0
  103. package/src/components/DraggableSwitcher/DraggableSwitcherButton.tsx +58 -0
  104. package/src/components/DraggableSwitcher/context/useDraggableSwitcher.tsx +45 -0
  105. package/src/components/DraggableSwitcher/index.ts +2 -0
  106. package/src/components/DropdownMenu/DropdownMenu.css +100 -0
  107. package/src/components/DropdownMenu/DropdownMenu.stories.tsx +174 -0
  108. package/src/components/DropdownMenu/DropdownMenu.tsx +106 -0
  109. package/src/components/DropdownMenu/index.ts +1 -0
  110. package/src/components/DynamicForm/DynamicFom.stories.ts +773 -0
  111. package/src/components/DynamicForm/DynamicForm.module.css +468 -0
  112. package/src/components/DynamicForm/DynamicForm.tsx +224 -0
  113. package/src/components/DynamicForm/index.ts +3 -0
  114. package/src/components/DynamicForm/tools/form-metadata.ts +82 -0
  115. package/src/components/DynamicForm/tools/validation.ts +168 -0
  116. package/src/components/DynamicInput/DynamicInput.module.css +126 -0
  117. package/src/components/DynamicInput/DynamicInput.stories.ts +350 -0
  118. package/src/components/DynamicInput/DynamicInput.tsx +144 -0
  119. package/src/components/DynamicInput/index.ts +2 -0
  120. package/src/components/DynamicInput/input/CheckboxInput.tsx +41 -0
  121. package/src/components/DynamicInput/input/ColorInput.tsx +46 -0
  122. package/src/components/DynamicInput/input/DateInput.tsx +57 -0
  123. package/src/components/DynamicInput/input/FileInput.tsx +174 -0
  124. package/src/components/DynamicInput/input/InputWrapper.tsx +26 -0
  125. package/src/components/DynamicInput/input/RadioInput.tsx +46 -0
  126. package/src/components/DynamicInput/input/RangeInput.tsx +46 -0
  127. package/src/components/DynamicInput/input/SelectInput.tsx +75 -0
  128. package/src/components/DynamicInput/input/TextInput.tsx +101 -0
  129. package/src/components/DynamicInput/input/TextareaInput.tsx +47 -0
  130. package/src/components/DynamicInput/input/assets/ColorInput.module.css +48 -0
  131. package/src/components/DynamicInput/input/assets/DateInput.module.css +83 -0
  132. package/src/components/DynamicInput/input/assets/FileInput.module.css +133 -0
  133. package/src/components/DynamicInput/input/assets/RangeInput.module.css +169 -0
  134. package/src/components/DynamicInput/input/assets/SelectInput.module.css +95 -0
  135. package/src/components/DynamicInput/input/index.ts +10 -0
  136. package/src/components/DynamicTable/AdvancedFilters.tsx +196 -0
  137. package/src/components/DynamicTable/ColumnSorter.tsx +185 -0
  138. package/src/components/DynamicTable/Pagination.tsx +115 -0
  139. package/src/components/DynamicTable/TableBody.tsx +42 -0
  140. package/src/components/DynamicTable/TableCell.tsx +30 -0
  141. package/src/components/DynamicTable/TableHeader.tsx +34 -0
  142. package/src/components/DynamicTable/TableRow.tsx +56 -0
  143. package/src/components/DynamicTable/TableauDynamic.stories.ts +1014 -0
  144. package/src/components/DynamicTable/TableauDynamique.module.css +1287 -0
  145. package/src/components/DynamicTable/TableauDynamique.tsx +154 -0
  146. package/src/components/DynamicTable/filters/BooleanFilter.tsx +30 -0
  147. package/src/components/DynamicTable/filters/DateFilter.tsx +28 -0
  148. package/src/components/DynamicTable/filters/DateRangeFilter.tsx +51 -0
  149. package/src/components/DynamicTable/filters/FilterRenderer.tsx +117 -0
  150. package/src/components/DynamicTable/filters/MultiSelectFilter.tsx +59 -0
  151. package/src/components/DynamicTable/filters/NumberFilter.tsx +37 -0
  152. package/src/components/DynamicTable/filters/OperatorFilter.tsx +64 -0
  153. package/src/components/DynamicTable/filters/SelectFilter.tsx +69 -0
  154. package/src/components/DynamicTable/filters/TextFilter.tsx +39 -0
  155. package/src/components/DynamicTable/filters/index.ts +9 -0
  156. package/src/components/DynamicTable/hooks/index.ts +2 -0
  157. package/src/components/DynamicTable/hooks/useAsyncActions.ts +36 -0
  158. package/src/components/DynamicTable/hooks/useFilters.ts +142 -0
  159. package/src/components/DynamicTable/hooks/useTableData.ts +216 -0
  160. package/src/components/DynamicTable/index.ts +11 -0
  161. package/src/components/DynamicTable/tools/filterTypes.ts +118 -0
  162. package/src/components/DynamicTable/tools/index.ts +3 -0
  163. package/src/components/DynamicTable/tools/tableConfig.ts +96 -0
  164. package/src/components/DynamicTable/tools/tableTypes.ts +63 -0
  165. package/src/components/EntryControl/EntryControl.module.css +218 -0
  166. package/src/components/EntryControl/EntryControl.stories.tsx +71 -0
  167. package/src/components/EntryControl/EntryControl.tsx +117 -0
  168. package/src/components/EntryControl/index.ts +2 -0
  169. package/src/components/Grid/Grid.stories.tsx +94 -0
  170. package/src/components/Grid/Grid.tsx +214 -0
  171. package/src/components/Grid/grid.css +285 -0
  172. package/src/components/Grid/index.ts +2 -0
  173. package/src/components/Header/Header.stories.tsx +164 -0
  174. package/src/components/Header/Header.tsx +59 -0
  175. package/src/components/Header/header.css +31 -0
  176. package/src/components/Header/index.ts +1 -0
  177. package/src/components/IconText/IconText..stories.tsx +135 -0
  178. package/src/components/IconText/IconText.css +43 -0
  179. package/src/components/IconText/IconText.tsx +43 -0
  180. package/src/components/IconText/index.ts +1 -0
  181. package/src/components/LanguageSelector/LanguageSelector.css +31 -0
  182. package/src/components/LanguageSelector/LanguageSelector.stories.tsx +38 -0
  183. package/src/components/LanguageSelector/LanguageSelector.tsx +37 -0
  184. package/src/components/LanguageSelector/index.ts +1 -0
  185. package/src/components/Logo/Logo.css +89 -0
  186. package/src/components/Logo/Logo.stories.tsx +79 -0
  187. package/src/components/Logo/Logo.tsx +22 -0
  188. package/src/components/Logo/index.ts +2 -0
  189. package/src/components/MetricsPanel/MetricsItem.tsx +128 -0
  190. package/src/components/MetricsPanel/MetricsPanel.module.css +636 -0
  191. package/src/components/MetricsPanel/MetricsPanel.stories.tsx +692 -0
  192. package/src/components/MetricsPanel/MetricsPanel.tsx +282 -0
  193. package/src/components/MetricsPanel/PanelHeader.tsx +19 -0
  194. package/src/components/MetricsPanel/SummaryCard.tsx +61 -0
  195. package/src/components/MetricsPanel/index.ts +4 -0
  196. package/src/components/MetricsPanel/renderers/CompactRenderer.tsx +125 -0
  197. package/src/components/MetricsPanel/renderers/ImageCard.tsx +62 -0
  198. package/src/components/MetricsPanel/renderers/PertinenceCard.tsx +55 -0
  199. package/src/components/MetricsPanel/tools/MetricsPanelTypes.ts +62 -0
  200. package/src/components/MetricsPanel/tools/chooseDefaultRender.ts +50 -0
  201. package/src/components/MetricsPanel/tools/colorUtils.ts +39 -0
  202. package/src/components/MetricsPanel/tools/index.ts +2 -0
  203. package/src/components/ModuleHeader/ModuleHeader.css +37 -0
  204. package/src/components/ModuleHeader/ModuleHeader.stories.tsx +37 -0
  205. package/src/components/ModuleHeader/ModuleHeader.tsx +42 -0
  206. package/src/components/ModuleHeader/index.ts +1 -0
  207. package/src/components/ModuleSideBar/ModuleSideBar.css +227 -0
  208. package/src/components/ModuleSideBar/ModuleSideBar.stories.tsx +40 -0
  209. package/src/components/ModuleSideBar/ModuleSideBar.tsx +155 -0
  210. package/src/components/ModuleSideBar/index.ts +1 -0
  211. package/src/components/NavBar/NavBar.css +58 -0
  212. package/src/components/NavBar/NavBar.stories.tsx +169 -0
  213. package/src/components/NavBar/NavBar.tsx +100 -0
  214. package/src/components/NavBar/NavContext.tsx +30 -0
  215. package/src/components/NavBar/index.ts +2 -0
  216. package/src/components/NavItem/NavItem.css +29 -0
  217. package/src/components/NavItem/NavItem.tsx +58 -0
  218. package/src/components/NavItem/index.ts +1 -0
  219. package/src/components/Page/Dashboard.tsx +93 -0
  220. package/src/components/Page/Page.stories.ts +33 -0
  221. package/src/components/Page/Page.tsx +73 -0
  222. package/src/components/Page/page.css +81 -0
  223. package/src/components/PerformanceCard/PerformanceCard.module.css +232 -0
  224. package/src/components/PerformanceCard/PerformanceCard.stories.tsx +441 -0
  225. package/src/components/PerformanceCard/PerformanceCard.tsx +198 -0
  226. package/src/components/PerformanceCard/defaultHistogramRenderer.tsx +32 -0
  227. package/src/components/PerformanceCard/tools/types.ts +50 -0
  228. package/src/components/PerformanceCard/tools/usePerformanceCard.ts +93 -0
  229. package/src/components/PeriodRange/PeriodRange.module.css +158 -0
  230. package/src/components/PeriodRange/PeriodRange.stories.tsx +66 -0
  231. package/src/components/PeriodRange/PeriodRange.tsx +130 -0
  232. package/src/components/PeriodSelect/PeriodSelect.module.css +65 -0
  233. package/src/components/PeriodSelect/PeriodSelect.stories.tsx +40 -0
  234. package/src/components/PeriodSelect/PeriodSelect.tsx +42 -0
  235. package/src/components/PeriodSelect/index.ts +1 -0
  236. package/src/components/ScrollableHorizontale/ScrollableHorizontale.css +40 -0
  237. package/src/components/ScrollableHorizontale/ScrollableHorizontale.stories.tsx +133 -0
  238. package/src/components/ScrollableHorizontale/ScrollableHorizontale.tsx +29 -0
  239. package/src/components/ScrollableHorizontale/index.ts +1 -0
  240. package/src/components/SearchBar/SearchBar.css +40 -0
  241. package/src/components/SearchBar/SearchBar.stories.tsx +36 -0
  242. package/src/components/SearchBar/SearchBar.tsx +30 -0
  243. package/src/components/SearchBar/index.ts +1 -0
  244. package/src/components/SectionTitle/SectionTitle.css +21 -0
  245. package/src/components/SectionTitle/SectionTitle.stories.tsx +39 -0
  246. package/src/components/SectionTitle/SectionTitle.tsx +18 -0
  247. package/src/components/SideComponent/PatientEditor.tsx +64 -0
  248. package/src/components/SideComponent/SideComponent.css +179 -0
  249. package/src/components/SideComponent/SideComponent.stories.tsx +547 -0
  250. package/src/components/SideComponent/SideComponent.tsx +243 -0
  251. package/src/components/SideComponent/hooks/useBodyScrollLock.ts +15 -0
  252. package/src/components/SideComponent/index.ts +2 -0
  253. package/src/components/SideComponent/portal.ts +11 -0
  254. package/src/components/SubNavBar/SubNavBar.tsx +41 -0
  255. package/src/components/SubNavBar/index.ts +1 -0
  256. package/src/components/Switcher/Switcher.css +65 -0
  257. package/src/components/Switcher/Switcher.stories.tsx +153 -0
  258. package/src/components/Switcher/Switcher.tsx +83 -0
  259. package/src/components/Switcher/index.ts +1 -0
  260. package/src/components/Title/Title.stories.tsx +18 -0
  261. package/src/components/Title/Title.tsx +26 -0
  262. package/src/components/Title/index.ts +1 -0
  263. package/src/components/TranslationKey/TranslationKey.css +272 -0
  264. package/src/components/TranslationKey/TranslationKey.stories.tsx +50 -0
  265. package/src/components/TranslationKey/TranslationKey.tsx +245 -0
  266. package/src/components/TranslationKey/index.ts +1 -0
  267. package/src/components/TrendItem/TrendItem.css +36 -0
  268. package/src/components/TrendItem/TrendItem.stories.tsx +276 -0
  269. package/src/components/TrendItem/TrendItem.tsx +46 -0
  270. package/src/components/TrendItem/index.ts +1 -0
  271. package/src/components/TrendList/TrendList.css +16 -0
  272. package/src/components/TrendList/TrendList.stories.tsx +337 -0
  273. package/src/components/TrendList/TrendList.tsx +45 -0
  274. package/src/components/TrendList/index.ts +1 -0
  275. package/src/components/theme/ThemeSwitcherButton.tsx +64 -0
  276. package/src/components/theme/context/ThemeContext.tsx +61 -0
  277. package/src/components/theme/context/index.ts +2 -0
  278. package/src/components/theme/context/useThemeSwitcher.ts +18 -0
  279. package/src/components/theme/index.ts +1 -0
  280. package/src/index.css +68 -0
  281. package/src/main.tsx +10 -0
  282. package/src/vite-env.d.ts +1 -0
  283. package/tsconfig.app.json +27 -0
  284. package/tsconfig.json +4 -0
  285. package/tsconfig.node.json +25 -0
  286. package/vite.config.ts +43 -0
  287. package/vitest.shims.d.ts +1 -0
@@ -0,0 +1,154 @@
1
+ 'use client';
2
+
3
+ import React, { useState, useRef, useEffect } from 'react';
4
+ import TableHeader from './TableHeader';
5
+ import TableBody from './TableBody';
6
+ import Pagination from './Pagination';
7
+ import ColumnSorter from './ColumnSorter';
8
+ import AdvancedFilters from './AdvancedFilters';
9
+ import type { TableauDynamiqueProps, SortConfig } from './tools/tableTypes';
10
+ import type { FilterConfig, AppliedFilter } from './tools/filterTypes';
11
+ import styles from './TableauDynamique.module.css';
12
+ import { useTableData } from './hooks/useTableData';
13
+
14
+ export interface EnhancedTableauDynamiqueProps<T> extends TableauDynamiqueProps<T> {
15
+ columnFilterable?: boolean;
16
+ filterConfig?: FilterConfig[];
17
+ externalFilters?: AppliedFilter[];
18
+ onFiltersChange?: (filters: AppliedFilter[]) => void;
19
+ onApplyFilters?: (filters: AppliedFilter[]) => void;
20
+ filtersControlled?: boolean;
21
+ debounceTimeout?: number;
22
+ getRowStyle?: (row: T) => React.CSSProperties;
23
+ background?: string;
24
+ }
25
+
26
+ export const TableauDynamique = <T,>({
27
+ columns = [],
28
+ data = [],
29
+ pagination = { pageSize: 10, currentPage: 1 },
30
+ onRowClick,
31
+ searchTerm = '',
32
+ className = '',
33
+ filterConfig = [],
34
+ externalFilters = [],
35
+ onFiltersChange,
36
+ onApplyFilters,
37
+ filtersControlled = false,
38
+ debounceTimeout = 300,
39
+ getRowStyle,
40
+ background,
41
+ onNewPage,
42
+ }: EnhancedTableauDynamiqueProps<T>) => {
43
+ const [sortConfig, setSortConfig] = useState<SortConfig>({ key: null, direction: 'asc' });
44
+ const [currentPage, setCurrentPage] = useState(pagination.currentPage ?? 1);
45
+ const [pageSize, setPageSize] = useState(pagination.pageSize ?? 10);
46
+
47
+ const [filtersExpanded, setFiltersExpanded] = useState(false);
48
+ const containerRef = useRef<HTMLDivElement | null>(null);
49
+ const [internalFilters, setInternalFilters] = useState<AppliedFilter[]>([]);
50
+ const appliedFilters = filtersControlled ? externalFilters : internalFilters;
51
+
52
+ const { paginatedData, sortedData, totalPages, startIndex } = useTableData<T>(
53
+ data,
54
+ columns,
55
+ searchTerm,
56
+ sortConfig,
57
+ currentPage,
58
+ pageSize,
59
+ appliedFilters
60
+ );
61
+
62
+ useEffect(() => {
63
+ const safeTotal = Math.max(1, Math.floor(totalPages));
64
+ if (currentPage > safeTotal) {
65
+ setCurrentPage(safeTotal);
66
+ }
67
+ if (currentPage < 1) {
68
+ setCurrentPage(1);
69
+ }
70
+ }, [totalPages]);
71
+
72
+ const handleFiltersChange = (filters: AppliedFilter[]) => {
73
+ if (!filtersControlled) setInternalFilters(filters);
74
+ onFiltersChange?.(filters);
75
+ setCurrentPage(1);
76
+ };
77
+
78
+ const handleApplyFilters = (filters: AppliedFilter[]) => {
79
+ if (!filtersControlled) setInternalFilters(filters);
80
+ onApplyFilters?.(filters);
81
+ setCurrentPage(1);
82
+ setFiltersExpanded(false);
83
+ if (containerRef.current)
84
+ containerRef.current.style.setProperty('--filters-panel-height', `0px`);
85
+ };
86
+
87
+ const handlePageChange = (page: number) => setCurrentPage(page);
88
+ const handlePageSizeChange = (size: number) => {
89
+ setPageSize(size);
90
+ setCurrentPage(1);
91
+ };
92
+
93
+ const handlePanelHeightChange = (h: number) => {
94
+ if (containerRef.current) {
95
+ containerRef.current.style.setProperty('--filters-panel-height', `${Math.round(h)}px`);
96
+ }
97
+ };
98
+
99
+ return (
100
+ <div
101
+ ref={containerRef}
102
+ className={`${styles.container} ${className} ${filtersExpanded ? 'filters-open' : ''}`}
103
+ style={{ background }}
104
+ >
105
+ <div className={styles.tableControls}>
106
+ <div className={styles.controlsRight}>
107
+ <ColumnSorter columns={columns} sortConfig={sortConfig} onSort={setSortConfig} />
108
+ {filterConfig.length > 0 && (
109
+ <AdvancedFilters
110
+ filters={filterConfig}
111
+ externalFilters={externalFilters}
112
+ onFiltersChange={handleFiltersChange}
113
+ onApply={handleApplyFilters}
114
+ isControlled={filtersControlled}
115
+ debounceTimeout={debounceTimeout}
116
+ resultsCount={sortedData.length}
117
+ expanded={filtersExpanded}
118
+ onToggle={(v: boolean | ((prevState: boolean) => boolean)) => setFiltersExpanded(v)}
119
+ panelPlacement='top'
120
+ onPanelHeightChange={handlePanelHeightChange}
121
+ />
122
+ )}
123
+ </div>
124
+ </div>
125
+
126
+ <div className={styles.topPagination}>
127
+ <Pagination
128
+ currentPage={currentPage}
129
+ totalPages={Math.max(1, totalPages)}
130
+ pageSize={pageSize}
131
+ totalItems={sortedData.length}
132
+ onPageChange={handlePageChange}
133
+ onPageSizeChange={handlePageSizeChange}
134
+ onNewPage={onNewPage}
135
+ />
136
+ </div>
137
+
138
+ <div className={styles.tableWrapper} data-table-wrapper>
139
+ <table className={styles.table}>
140
+ <TableHeader columns={columns} />
141
+ <TableBody
142
+ data={paginatedData}
143
+ columns={columns}
144
+ onRowClick={onRowClick}
145
+ startIndex={startIndex}
146
+ getRowStyle={getRowStyle}
147
+ />
148
+ </table>
149
+ </div>
150
+ </div>
151
+ );
152
+ };
153
+
154
+ export default TableauDynamique;
@@ -0,0 +1,30 @@
1
+ import React from 'react';
2
+ import styles from '../TableauDynamique.module.css';
3
+
4
+ interface BooleanFilterConfig {
5
+ label: string;
6
+ }
7
+
8
+ interface BooleanFilterProps {
9
+ config: BooleanFilterConfig;
10
+ value: boolean | '';
11
+ onChange: (value: boolean | '') => void;
12
+ disabled?: boolean;
13
+ }
14
+
15
+ const BooleanFilter: React.FC<BooleanFilterProps> = ({ config, value, onChange, disabled }) => {
16
+ return (
17
+ <select
18
+ value={value === '' ? '' : String(value)}
19
+ onChange={(e) => onChange(e.target.value === '' ? '' : e.target.value === 'true')}
20
+ disabled={disabled}
21
+ className={styles.filterSelect}
22
+ >
23
+ <option value=''>{`Filtrer ${config.label}...`}</option>
24
+ <option value='true'>Oui</option>
25
+ <option value='false'>Non</option>
26
+ </select>
27
+ );
28
+ };
29
+
30
+ export default BooleanFilter;
@@ -0,0 +1,28 @@
1
+ import React from 'react';
2
+ import styles from '../TableauDynamique.module.css';
3
+
4
+ interface DateFilterConfig {
5
+ label: string;
6
+ }
7
+
8
+ interface DateFilterProps {
9
+ config: DateFilterConfig;
10
+ value: string;
11
+ onChange: (value: string) => void;
12
+ disabled?: boolean;
13
+ }
14
+
15
+ const DateFilter: React.FC<DateFilterProps> = ({ config, value, onChange, disabled }) => {
16
+ return (
17
+ <input
18
+ type='date'
19
+ value={value || ''}
20
+ onChange={(e) => onChange(e.target.value)}
21
+ placeholder={`Filtrer ${config.label}...`}
22
+ disabled={disabled}
23
+ className={styles.filterInput}
24
+ />
25
+ );
26
+ };
27
+
28
+ export default DateFilter;
@@ -0,0 +1,51 @@
1
+ import React from 'react';
2
+ import styles from '../TableauDynamique.module.css';
3
+
4
+ interface DateRange {
5
+ start: string;
6
+ end: string;
7
+ }
8
+
9
+ interface DateRangeFilterConfig {
10
+ label: string;
11
+ }
12
+
13
+ interface DateRangeFilterProps {
14
+ config: DateRangeFilterConfig;
15
+ value: DateRange;
16
+ onChange: (value: DateRange) => void;
17
+ disabled?: boolean;
18
+ }
19
+
20
+ const DateRangeFilter: React.FC<DateRangeFilterProps> = ({ value, onChange, disabled }) => {
21
+ const safeValue = value || {};
22
+ const handleStartChange = (e: React.ChangeEvent<HTMLInputElement>) => {
23
+ onChange({ ...safeValue, start: e.target.value });
24
+ };
25
+
26
+ const handleEndChange = (e: React.ChangeEvent<HTMLInputElement>) => {
27
+ onChange({ ...safeValue, end: e.target.value });
28
+ };
29
+
30
+ return (
31
+ <div className={styles.dateRangeContainer}>
32
+ <input
33
+ type='date'
34
+ value={safeValue.start || ''}
35
+ onChange={handleStartChange}
36
+ disabled={disabled}
37
+ className={styles.filterInput}
38
+ />
39
+ <span className={styles.rangeSeparator}>→</span>
40
+ <input
41
+ type='date'
42
+ value={safeValue.end || ''}
43
+ onChange={handleEndChange}
44
+ disabled={disabled}
45
+ className={styles.filterInput}
46
+ />
47
+ </div>
48
+ );
49
+ };
50
+
51
+ export default DateRangeFilter;
@@ -0,0 +1,117 @@
1
+ // components/TableauDynamique/filters/FilterRenderer.tsx
2
+ import type { FilterConfig } from '../tools/filterTypes';
3
+ import TextFilter from './TextFilter';
4
+ import NumberFilter from './NumberFilter';
5
+ import SelectFilter from './SelectFilter';
6
+ import OperatorFilter from './OperatorFilter';
7
+ import DateFilter from './DateFilter';
8
+ import DateRangeFilter from './DateRangeFilter';
9
+ import BooleanFilter from './BooleanFilter';
10
+ import MultiSelectFilter from './MultiSelectFilter';
11
+
12
+ interface FilterRendererProps {
13
+ config: FilterConfig;
14
+ value: unknown;
15
+ onChange: (value: unknown) => void;
16
+ disabled?: boolean;
17
+ }
18
+
19
+ const FilterRenderer: React.FC<FilterRendererProps> = ({ config, value, onChange, disabled }) => {
20
+ switch (config.type) {
21
+ case 'text':
22
+ case 'search':
23
+ return (
24
+ <TextFilter
25
+ config={config}
26
+ value={value as string}
27
+ onChange={onChange}
28
+ disabled={disabled}
29
+ />
30
+ );
31
+
32
+ case 'number':
33
+ return (
34
+ <NumberFilter
35
+ config={config}
36
+ value={value as number}
37
+ onChange={onChange}
38
+ disabled={disabled}
39
+ />
40
+ );
41
+
42
+ case 'range':
43
+ return (
44
+ <NumberFilter
45
+ config={config}
46
+ value={value as number}
47
+ onChange={onChange}
48
+ disabled={disabled}
49
+ />
50
+ );
51
+
52
+ case 'select':
53
+ return (
54
+ <SelectFilter
55
+ config={config}
56
+ value={value as string | number | boolean}
57
+ onChange={onChange}
58
+ disabled={disabled}
59
+ />
60
+ );
61
+
62
+ case 'operator':
63
+ return (
64
+ <OperatorFilter
65
+ config={config}
66
+ value={value as { operator: string; value: string }}
67
+ onChange={onChange}
68
+ disabled={disabled}
69
+ />
70
+ );
71
+
72
+ case 'multiselect':
73
+ return (
74
+ <MultiSelectFilter
75
+ config={config}
76
+ value={value as string[]}
77
+ onChange={onChange}
78
+ disabled={disabled}
79
+ />
80
+ );
81
+
82
+ case 'date':
83
+ return (
84
+ <DateFilter
85
+ config={config}
86
+ value={value as string}
87
+ onChange={onChange}
88
+ disabled={disabled}
89
+ />
90
+ );
91
+
92
+ case 'daterange':
93
+ return (
94
+ <DateRangeFilter
95
+ config={config}
96
+ value={(value as { start: string; end: string }) ?? { start: '', end: '' }}
97
+ onChange={onChange}
98
+ disabled={disabled}
99
+ />
100
+ );
101
+
102
+ case 'boolean':
103
+ return (
104
+ <BooleanFilter
105
+ config={config}
106
+ value={value as boolean}
107
+ onChange={onChange}
108
+ disabled={disabled}
109
+ />
110
+ );
111
+
112
+ default:
113
+ return <div>Type de filtre non supporté: {(config as FilterConfig).type}</div>;
114
+ }
115
+ };
116
+
117
+ export default FilterRenderer;
@@ -0,0 +1,59 @@
1
+ import React, { useEffect, useState } from 'react';
2
+ import styles from '../TableauDynamique.module.css';
3
+ import type { MultiSelectFilterConfig, OperatorOption } from '../tools/filterTypes';
4
+
5
+ interface MultiSelectFilterProps {
6
+ config: MultiSelectFilterConfig;
7
+ value: (string | number)[];
8
+ onChange: (value: (string | number)[]) => void;
9
+ disabled?: boolean;
10
+ }
11
+
12
+ const MultiSelectFilter: React.FC<MultiSelectFilterProps> = ({
13
+ config,
14
+ value,
15
+ onChange,
16
+ disabled,
17
+ }) => {
18
+ const [options, setOptions] = useState<OperatorOption[]>([]);
19
+
20
+ useEffect(() => {
21
+ const loadOptions = async () => {
22
+ if (config.asyncOptions) {
23
+ try {
24
+ const asyncOptions = await config.asyncOptions();
25
+ setOptions(asyncOptions ?? []);
26
+ } catch (err) {
27
+ console.error('Erreur chargement options MultiSelect:', err);
28
+ setOptions([]);
29
+ }
30
+ } else {
31
+ setOptions(config.options ?? []);
32
+ }
33
+ };
34
+ loadOptions();
35
+ }, [config]);
36
+
37
+ const handleChange = (e: React.ChangeEvent<HTMLSelectElement>) => {
38
+ const selectedValues = Array.from(e.target.selectedOptions, (opt) => opt.value);
39
+ onChange(selectedValues);
40
+ };
41
+
42
+ return (
43
+ <select
44
+ multiple
45
+ value={value.map(String)}
46
+ onChange={handleChange}
47
+ disabled={disabled}
48
+ className={styles.filterMultiSelect}
49
+ >
50
+ {options.map((opt, idx) => (
51
+ <option key={idx} value={String(opt.value)}>
52
+ {opt.label}
53
+ </option>
54
+ ))}
55
+ </select>
56
+ );
57
+ };
58
+
59
+ export default MultiSelectFilter;
@@ -0,0 +1,37 @@
1
+ import React, { useState } from 'react';
2
+ import styles from '../TableauDynamique.module.css';
3
+
4
+ interface NumberFilterConfig {
5
+ label: string;
6
+ placeholder?: string;
7
+ }
8
+
9
+ interface NumberFilterProps {
10
+ config: NumberFilterConfig;
11
+ value: number | '';
12
+ onChange: (value: number | '') => void;
13
+ disabled?: boolean;
14
+ }
15
+
16
+ const NumberFilter: React.FC<NumberFilterProps> = ({ config, value, onChange, disabled }) => {
17
+ const [inputValue, setInputValue] = useState<number | ''>(value || '');
18
+
19
+ const handleChange = (e: React.ChangeEvent<HTMLInputElement>) => {
20
+ const newValue = e.target.value === '' ? '' : Number(e.target.value);
21
+ setInputValue(newValue);
22
+ onChange(newValue);
23
+ };
24
+
25
+ return (
26
+ <input
27
+ type='number'
28
+ value={inputValue}
29
+ onChange={handleChange}
30
+ placeholder={config.placeholder || `Filtrer ${config.label}...`}
31
+ disabled={disabled}
32
+ className={styles.filterInput}
33
+ />
34
+ );
35
+ };
36
+
37
+ export default NumberFilter;
@@ -0,0 +1,64 @@
1
+ // components/TableauDynamique/filters/OperatorFilter.tsx
2
+ import { useState, useEffect } from 'react';
3
+ import styles from '../TableauDynamique.module.css';
4
+ import type { OperatorFilterConfig } from '../tools/filterTypes';
5
+
6
+ interface OperatorFilterProps {
7
+ config: OperatorFilterConfig;
8
+ value: { operator: string; value: string };
9
+ onChange: (value: { operator: string; value: string }) => void;
10
+ disabled?: boolean;
11
+ }
12
+
13
+ const OperatorFilter: React.FC<OperatorFilterProps> = ({
14
+ config,
15
+ value,
16
+ onChange,
17
+ disabled = false,
18
+ }) => {
19
+ const [operator, setOperator] = useState(value?.operator || '');
20
+ const [filterValue, setFilterValue] = useState(value?.value || '');
21
+
22
+ useEffect(() => {
23
+ if (operator && filterValue) {
24
+ onChange({ operator, value: filterValue });
25
+ }
26
+ }, [operator, filterValue, onChange]);
27
+
28
+ const handleOperatorChange = (e: React.ChangeEvent<HTMLSelectElement>) => {
29
+ setOperator(e.target.value);
30
+ };
31
+
32
+ const handleValueChange = (e: React.ChangeEvent<HTMLInputElement>) => {
33
+ setFilterValue(e.target.value);
34
+ };
35
+
36
+ return (
37
+ <div className={styles.operatorFilterContainer}>
38
+ <select
39
+ value={operator}
40
+ onChange={handleOperatorChange}
41
+ disabled={disabled}
42
+ className={styles.operatorSelect}
43
+ >
44
+ <option value=''>Sélectionner un opérateur</option>
45
+ {config.operators.map((op) => (
46
+ <option key={String(op.value)} value={String(op.value)}>
47
+ {op.label}
48
+ </option>
49
+ ))}
50
+ </select>
51
+
52
+ <input
53
+ type='text'
54
+ value={filterValue}
55
+ onChange={handleValueChange}
56
+ placeholder='Valeur'
57
+ disabled={disabled || !operator}
58
+ className={styles.operatorInput}
59
+ />
60
+ </div>
61
+ );
62
+ };
63
+
64
+ export default OperatorFilter;
@@ -0,0 +1,69 @@
1
+ // components/TableauDynamique/filters/SelectFilter.tsx
2
+ import { useState, useEffect } from 'react';
3
+ import styles from '../TableauDynamique.module.css';
4
+ import type { SelectFilterConfig } from '../tools/filterTypes';
5
+
6
+ interface SelectFilterProps {
7
+ config: SelectFilterConfig;
8
+ value: string | number | boolean;
9
+ onChange: (value: string | number | boolean) => void;
10
+ disabled?: boolean;
11
+ }
12
+
13
+ const SelectFilter: React.FC<SelectFilterProps> = ({
14
+ config,
15
+ value,
16
+ onChange,
17
+ disabled = false,
18
+ }) => {
19
+ // eslint-disable-next-line @typescript-eslint/no-explicit-any
20
+ const [options, setOptions] = useState<any[]>([]);
21
+ const [isLoading, setIsLoading] = useState(false);
22
+
23
+ useEffect(() => {
24
+ const loadOptions = async () => {
25
+ if (config.asyncOptions) {
26
+ setIsLoading(true);
27
+ try {
28
+ const asyncOptions = await config.asyncOptions();
29
+ setOptions(asyncOptions);
30
+ } catch (error) {
31
+ console.error('Error loading options:', error);
32
+ } finally {
33
+ setIsLoading(false);
34
+ }
35
+ } else {
36
+ setOptions(config.options || []);
37
+ }
38
+ };
39
+
40
+ loadOptions();
41
+ }, [config]);
42
+
43
+ const handleChange = (e: React.ChangeEvent<HTMLSelectElement>) => {
44
+ const newValue = e.target.value;
45
+ onChange(newValue);
46
+ };
47
+
48
+ if (isLoading) {
49
+ return <div>Chargement...</div>;
50
+ }
51
+
52
+ return (
53
+ <select
54
+ value={String(value || '')}
55
+ onChange={handleChange}
56
+ disabled={disabled}
57
+ className={styles.filterInput}
58
+ >
59
+ <option value=''>Select...</option>
60
+ {options.map((option) => (
61
+ <option key={option.value} value={option.value}>
62
+ {option.label}
63
+ </option>
64
+ ))}
65
+ </select>
66
+ );
67
+ };
68
+
69
+ export default SelectFilter;
@@ -0,0 +1,39 @@
1
+ // components/TableauDynamique/filters/TextFilter.tsx
2
+ import { useState, useEffect } from 'react';
3
+ import styles from '../TableauDynamique.module.css';
4
+
5
+ interface TextFilterProps {
6
+ // eslint-disable-next-line @typescript-eslint/no-explicit-any
7
+ config: any;
8
+ value: unknown;
9
+ onChange: (value: string) => void;
10
+ disabled?: boolean;
11
+ }
12
+
13
+ const TextFilter: React.FC<TextFilterProps> = ({ config, value, onChange, disabled = false }) => {
14
+ const [inputValue, setInputValue] = useState('');
15
+
16
+ useEffect(() => {
17
+ // Convertir la valeur en string peu importe son type d'origine
18
+ setInputValue(typeof value === 'string' ? value : String(value || ''));
19
+ }, [value]);
20
+
21
+ const handleChange = (e: React.ChangeEvent<HTMLInputElement>) => {
22
+ const newValue = e.target.value;
23
+ setInputValue(newValue);
24
+ onChange(newValue);
25
+ };
26
+
27
+ return (
28
+ <input
29
+ type='text'
30
+ value={inputValue}
31
+ onChange={handleChange}
32
+ placeholder={config.placeholder || `Filtrer ${config.label}...`}
33
+ disabled={disabled}
34
+ className={styles.filterInput}
35
+ />
36
+ );
37
+ };
38
+
39
+ export default TextFilter;
@@ -0,0 +1,9 @@
1
+ export * from './BooleanFilter';
2
+ export * from './DateFilter';
3
+ export * from './MultiSelectFilter';
4
+ export * from './NumberFilter';
5
+ export * from './SelectFilter';
6
+ export * from './TextFilter';
7
+ export * from './SelectFilter';
8
+ export * from './FilterRenderer';
9
+ export * from './OperatorFilter';
@@ -0,0 +1,2 @@
1
+ export * from './useFilters';
2
+ export * from './useTableData';