@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,70 @@
1
+ // MySankeyChart.tsx
2
+
3
+ import React from 'react';
4
+ import { ResponsiveSankey } from '@nivo/sankey';
5
+ import type { SankeyDataProps } from '@nivo/sankey';
6
+ // Définissez vos données avec le type approprié pour une meilleure intégrité
7
+ const data: SankeyDataProps = {
8
+ nodes: [
9
+ { id: 'start', color: '#61cdbb' },
10
+ { id: 'process_a', color: '#97e6a6' },
11
+ { id: 'process_b', color: '#e8c1a0' },
12
+ { id: 'end_result', color: '#f1e15b' },
13
+ ],
14
+ links: [
15
+ { source: 'start', target: 'process_a', value: 100 },
16
+ { source: 'start', target: 'process_b', value: 50 },
17
+ { source: 'process_a', target: 'end_result', value: 75 },
18
+ { source: 'process_a', target: 'process_b', value: 25 },
19
+ { source: 'process_b', target: 'end_result', value: 75 },
20
+ ],
21
+ };
22
+
23
+ const MySankeyChart: React.FC = () => {
24
+ return (
25
+ <div style={{ height: '500px', width: '100%' }}>
26
+ <ResponsiveSankey
27
+ data={data}
28
+ margin={{ top: 10, right: 10, bottom: 10, left: 10 }}
29
+ align='justify'
30
+ colors={{ scheme: 'category10' }}
31
+ nodeOpacity={1}
32
+ nodeThickness={18}
33
+ nodeInnerPadding={8}
34
+ nodeSpacing={24}
35
+ linkOpacity={0.5}
36
+ nodeBorderWidth={0}
37
+ nodeBorderColor={{
38
+ from: 'color',
39
+ modifiers: [['darker', 0.8]],
40
+ }}
41
+ // Active l'affichage des étiquettes
42
+ enableLabels={true}
43
+ // Positionne les étiquettes à l'extérieur des nœuds
44
+ labelPosition='outside'
45
+ // Oriente les étiquettes horizontalement
46
+ labelOrientation='horizontal'
47
+ // Ajoute un espacement entre les nœuds et les étiquettes
48
+ labelPadding={16}
49
+ // Personnalise la couleur du texte des étiquettes
50
+ labelTextColor={{
51
+ from: 'color',
52
+ modifiers: [['darker', 1.5]],
53
+ }}
54
+ animate={true}
55
+ motionConfig='stiff'
56
+ // Personnalise les styles via le thème
57
+ theme={{
58
+ labels: {
59
+ text: {
60
+ fontSize: 14,
61
+ fontWeight: 'bold',
62
+ },
63
+ },
64
+ }}
65
+ />
66
+ </div>
67
+ );
68
+ };
69
+
70
+ export default MySankeyChart;
@@ -0,0 +1,69 @@
1
+ import type { Meta, StoryObj } from '@storybook/react-vite';
2
+ import SankeyChart, { type SankeyLink } from './SankeyChart';
3
+ import demoContent from './content.json';
4
+
5
+ const demoLinks: SankeyLink[] = demoContent.links;
6
+
7
+ const meta: Meta<typeof SankeyChart> = {
8
+ title: 'Charts/SankeyChart',
9
+ component: SankeyChart,
10
+ tags: ['autodocs'],
11
+ parameters: { layout: 'fullscreen' },
12
+ argTypes: {
13
+ links: { control: 'object', description: 'Array of { source, target, value }' },
14
+ height: { control: 'number' },
15
+ nodeWidth: { control: 'number' },
16
+ enableToolbar: { control: 'boolean' },
17
+ annotatePercent: { control: 'boolean' },
18
+ },
19
+ };
20
+
21
+ export default meta;
22
+ type Story = StoryObj<typeof SankeyChart>;
23
+
24
+ export const Default: Story = {
25
+ args: {
26
+ links: demoLinks,
27
+ height: 480,
28
+ nodeWidth: 12,
29
+ enableToolbar: true,
30
+ annotatePercent: true,
31
+ },
32
+ };
33
+
34
+ export const Compact: Story = {
35
+ args: {
36
+ links: demoLinks,
37
+ height: 320,
38
+ nodeWidth: 8,
39
+ enableToolbar: false,
40
+ annotatePercent: true,
41
+ },
42
+ };
43
+
44
+ export const NoAnnotation: Story = {
45
+ args: {
46
+ links: demoLinks,
47
+ height: 420,
48
+ nodeWidth: 12,
49
+ enableToolbar: false,
50
+ annotatePercent: false,
51
+ },
52
+ };
53
+
54
+ export const ExampleWithCustomLinks: Story = {
55
+ args: {
56
+ links: [
57
+ { source: 'A', target: 'X', value: 50 },
58
+ { source: 'A', target: 'Y', value: 30 },
59
+ { source: 'A', target: 'Z', value: 20 },
60
+ { source: 'B', target: 'X', value: 10 },
61
+ { source: 'B', target: 'Y', value: 40 },
62
+ { source: 'B', target: 'Z', value: 50 },
63
+ ],
64
+ height: 420,
65
+ nodeWidth: 12,
66
+ enableToolbar: true,
67
+ annotatePercent: true,
68
+ },
69
+ };
@@ -0,0 +1,155 @@
1
+ import React, { useEffect, useRef } from 'react';
2
+ import { color } from 'storybook/internal/theming';
3
+
4
+ export type SankeyLink = { source: string; target: string; value: number; color?: string };
5
+
6
+ interface Props {
7
+ links?: SankeyLink[];
8
+ height?: number;
9
+ nodeWidth?: number;
10
+ enableToolbar?: boolean;
11
+ annotatePercent?: boolean;
12
+ maxLeftFraction?: number;
13
+ className?: string;
14
+ }
15
+
16
+ const SankeyChart: React.FC<Props> = ({
17
+ links,
18
+ height = 480,
19
+ nodeWidth = 5,
20
+ enableToolbar = false,
21
+ annotatePercent = true,
22
+ maxLeftFraction = 0.45,
23
+ className,
24
+ }) => {
25
+ const containerRef = useRef<HTMLDivElement | null>(null);
26
+
27
+ useEffect(() => {
28
+ let sInstance: { render: (d: unknown) => void; destroy?: () => void } | null = null;
29
+ let mounted = true;
30
+
31
+ (async () => {
32
+ try {
33
+ const mod = await import('apexsankey');
34
+ const ApexSankey = mod?.default as unknown;
35
+
36
+ if (!mounted) return;
37
+ const mountEl = containerRef.current;
38
+ if (!mountEl) return;
39
+
40
+ const defaultLinks: SankeyLink[] = [
41
+ { source: 'non-seniors', target: 'retour', value: 73.9 },
42
+ { source: 'non-seniors', target: 'hospitalisations', value: 23.9 },
43
+ { source: 'non-seniors', target: 'transfert', value: 2.1 },
44
+ { source: 'non-seniors', target: 'maison_medicale_de_garde', value: 0.1 },
45
+ { source: 'non-seniors', target: 'deces', value: 0.1 },
46
+ { source: 'seniors', target: 'retour', value: 75.6 },
47
+ { source: 'seniors', target: 'hospitalisations', value: 20.4 },
48
+ { source: 'seniors', target: 'transfert', value: 3.1 },
49
+ { source: 'seniors', target: 'maison_medicale_de_garde', value: 0.1 },
50
+ { source: 'seniors', target: 'deces', value: 0.8 },
51
+ ];
52
+ const usedLinks = links && links.length ? links : defaultLinks;
53
+
54
+ const nodeSet = new Set<string>();
55
+ usedLinks.forEach((l) => {
56
+ nodeSet.add(l.source);
57
+ nodeSet.add(l.target);
58
+ });
59
+
60
+ const orderedNodes = [
61
+ 'non-seniors',
62
+ 'seniors',
63
+ 'retour',
64
+ 'hospitalisations',
65
+ 'transfert',
66
+ 'maison_medicale_de_garde',
67
+ 'deces',
68
+ ].filter((id) => nodeSet.has(id));
69
+ for (const id of nodeSet) if (!orderedNodes.includes(id)) orderedNodes.push(id);
70
+
71
+ const totalsBySource: Record<string, number> = {};
72
+ const totalsByTarget: Record<string, number> = {};
73
+ let overall = 0;
74
+ usedLinks.forEach((l) => {
75
+ totalsBySource[l.source] = (totalsBySource[l.source] || 0) + (l.value ?? 0);
76
+ totalsByTarget[l.target] = (totalsByTarget[l.target] || 0) + (l.value ?? 0);
77
+ overall += l.value ?? 0;
78
+ });
79
+
80
+ const nodes = orderedNodes.map((id) => {
81
+ let title = id;
82
+ if (annotatePercent) {
83
+ const srcVal = totalsBySource[id];
84
+ if (typeof srcVal === 'number' && overall > 0) {
85
+ const pct = Math.round((srcVal / overall) * 1000) / 10;
86
+ title = `${id} (${pct}%)`;
87
+ } else {
88
+ const t = totalsByTarget[id];
89
+ if (typeof t === 'number' && overall > 0) {
90
+ const pct = Math.round((t / overall) * 1000) / 10;
91
+ title = `${id} (${pct}%)`;
92
+ }
93
+ }
94
+ }
95
+ return { id, title };
96
+ });
97
+
98
+ const edges = usedLinks.map((l) => ({
99
+ source: l.source,
100
+ target: l.target,
101
+ value: l.value,
102
+ }));
103
+ const data = { nodes, edges };
104
+
105
+ const parent = mountEl?.parentElement;
106
+ const containerWidth = parent ? parent.clientWidth || 420 : mountEl?.clientWidth || 420;
107
+
108
+ const graphOptions = {
109
+ nodeWidth,
110
+ fontFamily:
111
+ "Inter, system-ui, -apple-system, 'Segoe UI', Roboto, 'Helvetica Neue', Arial",
112
+ fontWeight: '600',
113
+ fontColor: 'var(--color-text)',
114
+ height,
115
+ enableToolbar,
116
+ viewPortWidth: containerWidth,
117
+ viewPortHeight: height,
118
+ width: containerWidth,
119
+ nodeAlignment: 'top',
120
+ colors: {
121
+ text: 'var(--color-text)',
122
+ background: '#fff',
123
+ },
124
+ linkOpacity: 0.6,
125
+ canvasStyle: {},
126
+ };
127
+
128
+ // constructor type
129
+ const SankeyCtor = ApexSankey as unknown as new (
130
+ el: Element,
131
+ opts: unknown
132
+ ) => { render: (d: unknown) => void; destroy?: () => void };
133
+ sInstance = new SankeyCtor(mountEl as Element, graphOptions as unknown);
134
+ sInstance.render(data as unknown);
135
+ } catch (err) {
136
+ console.error('Erreur lors du rendu ApexSankey :', err);
137
+ }
138
+ })();
139
+
140
+ return () => {
141
+ mounted = false;
142
+ try {
143
+ if (sInstance && typeof sInstance.destroy === 'function') sInstance.destroy();
144
+ } catch {
145
+ /* noop */
146
+ }
147
+ };
148
+ }, [links, height, nodeWidth, enableToolbar, annotatePercent, maxLeftFraction]);
149
+
150
+ return (
151
+ <div ref={containerRef} className={className} style={{ height: height, overflow: 'hidden' }} />
152
+ );
153
+ };
154
+
155
+ export default SankeyChart;
@@ -0,0 +1,15 @@
1
+ {
2
+ "links": [
3
+ { "source": "non-seniors", "target": "retour", "value": 73.9 },
4
+ { "source": "non-seniors", "target": "hospitalisations", "value": 23.9 },
5
+ { "source": "non-seniors", "target": "transfert", "value": 2.1 },
6
+ { "source": "non-seniors", "target": "maison_medicale_de_garde", "value": 0.1 },
7
+ { "source": "non-seniors", "target": "deces", "value": 0.1 },
8
+
9
+ { "source": "seniors", "target": "retour", "value": 75.6 },
10
+ { "source": "seniors", "target": "hospitalisations", "value": 20.4 },
11
+ { "source": "seniors", "target": "transfert", "value": 3.1 },
12
+ { "source": "seniors", "target": "maison_medicale_de_garde", "value": 0.1 },
13
+ { "source": "seniors", "target": "deces", "value": 0.8 }
14
+ ]
15
+ }
@@ -0,0 +1,72 @@
1
+ // src/stories/Tension.stories.tsx
2
+ import type { Meta, StoryObj } from '@storybook/react-vite';
3
+ import Tension, { type TensionData } from './StackedColumn';
4
+ import sampleData from './content.json';
5
+
6
+ const meta: Meta<typeof Tension> = {
7
+ title: 'Charts/StackedColumn',
8
+ component: Tension,
9
+ parameters: {
10
+ layout: 'fullscreen', // <-- passe la canvas en plein écran
11
+ },
12
+ // décorateur global pour ce fichier : conteneur full-screen responsive
13
+ decorators: [
14
+ (Story) => {
15
+ const usedHeight =
16
+ typeof window !== 'undefined' ? Math.max(300, window.innerHeight - 80) : 350;
17
+ return (
18
+ <div
19
+ style={{
20
+ width: '100%',
21
+ height: '100vh',
22
+ display: 'flex',
23
+ alignItems: 'stretch',
24
+ justifyContent: 'center',
25
+ padding: 20,
26
+ boxSizing: 'border-box',
27
+ background: '#fff',
28
+ }}
29
+ >
30
+ {/* wrapper qui limite la largeur et donne toute la hauteur au chart */}
31
+ <div style={{ width: '100%', maxWidth: 1200, height: usedHeight }}>
32
+ <Story />
33
+ </div>
34
+ </div>
35
+ );
36
+ },
37
+ ],
38
+ };
39
+ export default meta;
40
+
41
+ type Story = StoryObj<typeof Tension>;
42
+
43
+ const computedHeight = typeof window !== 'undefined' ? Math.max(300, window.innerHeight - 80) : 350;
44
+
45
+ export const Default: Story = {
46
+ args: {
47
+ data: sampleData as unknown as TensionData,
48
+ // Pas de config fourni -> le composant utilisera son defaultConfig interne
49
+ height: computedHeight,
50
+ },
51
+ };
52
+
53
+ export const WithoutHistogram: Story = {
54
+ args: {
55
+ data: sampleData as unknown as TensionData,
56
+ // on fournit uniquement l'override voulu ; le composant fusionne avec son defaultConfig
57
+ config: { showHistogram: false },
58
+ height: computedHeight,
59
+ },
60
+ };
61
+
62
+ export const OnlyLines: Story = {
63
+ args: {
64
+ data: sampleData as unknown as TensionData,
65
+ config: {
66
+ showHistogram: false,
67
+ bubble: { visible: false },
68
+ rangeBands: [],
69
+ },
70
+ height: computedHeight,
71
+ },
72
+ };