@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.
- package/.prettierignore +4 -0
- package/.prettierrc +9 -0
- package/.storybook/main.ts +17 -0
- package/.storybook/preview.ts +21 -0
- package/.storybook/vitest.setup.ts +7 -0
- package/README.md +69 -0
- package/chart.ts +1 -0
- package/eslint.config.js +40 -0
- package/index.html +13 -0
- package/index.ts +33 -0
- package/package.json +63 -0
- package/public/vite.svg +1 -0
- package/src/App.css +42 -0
- package/src/App.tsx +12 -0
- package/src/assets/accessibility.png +0 -0
- package/src/assets/accessibility.svg +1 -0
- package/src/assets/addon-library.png +0 -0
- package/src/assets/assets.png +0 -0
- package/src/assets/avif-test-image.avif +0 -0
- package/src/assets/context.png +0 -0
- package/src/assets/discord.svg +1 -0
- package/src/assets/docs.png +0 -0
- package/src/assets/figma-plugin.png +0 -0
- package/src/assets/github.svg +1 -0
- package/src/assets/react.svg +1 -0
- package/src/assets/share.png +0 -0
- package/src/assets/styling.png +0 -0
- package/src/assets/testing.png +0 -0
- package/src/assets/theming.png +0 -0
- package/src/assets/tutorials.svg +1 -0
- package/src/assets/youtube.svg +1 -0
- package/src/components/AddItemModal/AddItemModal.module.css +72 -0
- package/src/components/AddItemModal/AddItemModal.tsx +82 -0
- package/src/components/AddItemModal/index.ts +1 -0
- package/src/components/Alert/Alert.css +54 -0
- package/src/components/Alert/Alert.stories.tsx +82 -0
- package/src/components/Alert/Alert.tsx +85 -0
- package/src/components/Alert/AlertContext.tsx +200 -0
- package/src/components/Alert/AlertModels.ts +34 -0
- package/src/components/Alert/index.ts +3 -0
- package/src/components/AnnouncementPanel/FlexRowContainer.css +17 -0
- package/src/components/AnnouncementPanel/FlexRowContainer.stories.tsx +329 -0
- package/src/components/AnnouncementPanel/FlexRowContainer.tsx +24 -0
- package/src/components/AnnouncementPanel/ListBox/CounterListBox.css +56 -0
- package/src/components/AnnouncementPanel/ListBox/CounterListBox.stories.tsx +292 -0
- package/src/components/AnnouncementPanel/ListBox/CounterListBox.tsx +106 -0
- package/src/components/AnnouncementPanel/ListBox/SimpleListBox.css +57 -0
- package/src/components/AnnouncementPanel/ListBox/SimpleListBox.stories.tsx +189 -0
- package/src/components/AnnouncementPanel/ListBox/SimpleListBox.tsx +138 -0
- package/src/components/AnnouncementPanel/ListBox/TrendListBox.css +61 -0
- package/src/components/AnnouncementPanel/ListBox/TrendListBox.stories.tsx +257 -0
- package/src/components/AnnouncementPanel/ListBox/TrendListBox.tsx +90 -0
- package/src/components/AnnouncementPanel/ListBox/index.ts +3 -0
- package/src/components/AnnouncementPanel/ListContentContainer.css +23 -0
- package/src/components/AnnouncementPanel/ListContentContainer.stories.tsx +212 -0
- package/src/components/AnnouncementPanel/ListContentContainer.tsx +33 -0
- package/src/components/AnnouncementPanel/index.ts +3 -0
- package/src/components/BandChart/index.tsx +282 -0
- package/src/components/Button/Button.module.css +165 -0
- package/src/components/Button/Button.stories.ts +132 -0
- package/src/components/Button/Button.tsx +55 -0
- package/src/components/Button/button.css +29 -0
- package/src/components/Button/index.ts +2 -0
- package/src/components/ChartContainer/ChartContainer.css +116 -0
- package/src/components/ChartContainer/ChartContainer.stories.tsx +159 -0
- package/src/components/ChartContainer/ChartContainer.tsx +155 -0
- package/src/components/ChartContainer/index.ts +1 -0
- package/src/components/Charts/area-chart-admission/AreaChartAdmission.stories.tsx +65 -0
- package/src/components/Charts/area-chart-admission/AreaChartAdmission.tsx +89 -0
- package/src/components/Charts/area-chart-admission/content.json +48 -0
- package/src/components/Charts/area-chart-hospitalisation/AreaChartHospitalisation.stories.tsx +141 -0
- package/src/components/Charts/area-chart-hospitalisation/AreaChartHospitalisation.tsx +262 -0
- package/src/components/Charts/area-chart-hospitalisation/content.json +55 -0
- package/src/components/Charts/bar-chart/BarChart.stories.tsx +50 -0
- package/src/components/Charts/bar-chart/BarChart.tsx +132 -0
- package/src/components/Charts/bar-chart/content.json +15 -0
- package/src/components/Charts/boxplot-chart/BoxPlotChart.stories.tsx +63 -0
- package/src/components/Charts/boxplot-chart/BoxPlotChart.tsx +114 -0
- package/src/components/Charts/boxplot-chart/boxUtils.ts +22 -0
- package/src/components/Charts/boxplot-chart/content.json +11 -0
- package/src/components/Charts/mixed-chart/MixedChart.stories.tsx +83 -0
- package/src/components/Charts/mixed-chart/MixedChart.tsx +625 -0
- package/src/components/Charts/mixed-chart/content.json +34 -0
- package/src/components/Charts/sankey-adaptation/sankey.tsx +70 -0
- package/src/components/Charts/sankey-chart/SankeyChart.stories.tsx +69 -0
- package/src/components/Charts/sankey-chart/SankeyChart.tsx +155 -0
- package/src/components/Charts/sankey-chart/content.json +15 -0
- package/src/components/Charts/stacked-column/StackedColumn.stories.tsx +72 -0
- package/src/components/Charts/stacked-column/StackedColumn.tsx +406 -0
- package/src/components/Charts/stacked-column/content.json +37 -0
- package/src/components/Charts/stacked-column-one-hundred-percent/StackedColumnOneHundredPercent.stories.tsx +43 -0
- package/src/components/Charts/stacked-column-one-hundred-percent/StackedColumnOneHundredPercent.tsx +75 -0
- package/src/components/Charts/stacked-column-one-hundred-percent/content.json +6 -0
- package/src/components/CircularProgress/CircularProgress.css +79 -0
- package/src/components/CircularProgress/CircularProgress.stories.tsx +251 -0
- package/src/components/CircularProgress/CircularProgress.tsx +101 -0
- package/src/components/CircularProgress/index.ts +2 -0
- package/src/components/Configure.mdx +369 -0
- package/src/components/DayStatCard/DayStatCard.css +50 -0
- package/src/components/DayStatCard/DayStatCard.stories.tsx +273 -0
- package/src/components/DayStatCard/DayStatCard.tsx +69 -0
- package/src/components/DayStatCard/index.ts +2 -0
- package/src/components/DraggableSwitcher/DraggableSwitcherButton.tsx +58 -0
- package/src/components/DraggableSwitcher/context/useDraggableSwitcher.tsx +45 -0
- package/src/components/DraggableSwitcher/index.ts +2 -0
- package/src/components/DropdownMenu/DropdownMenu.css +100 -0
- package/src/components/DropdownMenu/DropdownMenu.stories.tsx +174 -0
- package/src/components/DropdownMenu/DropdownMenu.tsx +106 -0
- package/src/components/DropdownMenu/index.ts +1 -0
- package/src/components/DynamicForm/DynamicFom.stories.ts +773 -0
- package/src/components/DynamicForm/DynamicForm.module.css +468 -0
- package/src/components/DynamicForm/DynamicForm.tsx +224 -0
- package/src/components/DynamicForm/index.ts +3 -0
- package/src/components/DynamicForm/tools/form-metadata.ts +82 -0
- package/src/components/DynamicForm/tools/validation.ts +168 -0
- package/src/components/DynamicInput/DynamicInput.module.css +126 -0
- package/src/components/DynamicInput/DynamicInput.stories.ts +350 -0
- package/src/components/DynamicInput/DynamicInput.tsx +144 -0
- package/src/components/DynamicInput/index.ts +2 -0
- package/src/components/DynamicInput/input/CheckboxInput.tsx +41 -0
- package/src/components/DynamicInput/input/ColorInput.tsx +46 -0
- package/src/components/DynamicInput/input/DateInput.tsx +57 -0
- package/src/components/DynamicInput/input/FileInput.tsx +174 -0
- package/src/components/DynamicInput/input/InputWrapper.tsx +26 -0
- package/src/components/DynamicInput/input/RadioInput.tsx +46 -0
- package/src/components/DynamicInput/input/RangeInput.tsx +46 -0
- package/src/components/DynamicInput/input/SelectInput.tsx +75 -0
- package/src/components/DynamicInput/input/TextInput.tsx +101 -0
- package/src/components/DynamicInput/input/TextareaInput.tsx +47 -0
- package/src/components/DynamicInput/input/assets/ColorInput.module.css +48 -0
- package/src/components/DynamicInput/input/assets/DateInput.module.css +83 -0
- package/src/components/DynamicInput/input/assets/FileInput.module.css +133 -0
- package/src/components/DynamicInput/input/assets/RangeInput.module.css +169 -0
- package/src/components/DynamicInput/input/assets/SelectInput.module.css +95 -0
- package/src/components/DynamicInput/input/index.ts +10 -0
- package/src/components/DynamicTable/AdvancedFilters.tsx +196 -0
- package/src/components/DynamicTable/ColumnSorter.tsx +185 -0
- package/src/components/DynamicTable/Pagination.tsx +115 -0
- package/src/components/DynamicTable/TableBody.tsx +42 -0
- package/src/components/DynamicTable/TableCell.tsx +30 -0
- package/src/components/DynamicTable/TableHeader.tsx +34 -0
- package/src/components/DynamicTable/TableRow.tsx +56 -0
- package/src/components/DynamicTable/TableauDynamic.stories.ts +1014 -0
- package/src/components/DynamicTable/TableauDynamique.module.css +1287 -0
- package/src/components/DynamicTable/TableauDynamique.tsx +154 -0
- package/src/components/DynamicTable/filters/BooleanFilter.tsx +30 -0
- package/src/components/DynamicTable/filters/DateFilter.tsx +28 -0
- package/src/components/DynamicTable/filters/DateRangeFilter.tsx +51 -0
- package/src/components/DynamicTable/filters/FilterRenderer.tsx +117 -0
- package/src/components/DynamicTable/filters/MultiSelectFilter.tsx +59 -0
- package/src/components/DynamicTable/filters/NumberFilter.tsx +37 -0
- package/src/components/DynamicTable/filters/OperatorFilter.tsx +64 -0
- package/src/components/DynamicTable/filters/SelectFilter.tsx +69 -0
- package/src/components/DynamicTable/filters/TextFilter.tsx +39 -0
- package/src/components/DynamicTable/filters/index.ts +9 -0
- package/src/components/DynamicTable/hooks/index.ts +2 -0
- package/src/components/DynamicTable/hooks/useAsyncActions.ts +36 -0
- package/src/components/DynamicTable/hooks/useFilters.ts +142 -0
- package/src/components/DynamicTable/hooks/useTableData.ts +216 -0
- package/src/components/DynamicTable/index.ts +11 -0
- package/src/components/DynamicTable/tools/filterTypes.ts +118 -0
- package/src/components/DynamicTable/tools/index.ts +3 -0
- package/src/components/DynamicTable/tools/tableConfig.ts +96 -0
- package/src/components/DynamicTable/tools/tableTypes.ts +63 -0
- package/src/components/EntryControl/EntryControl.module.css +218 -0
- package/src/components/EntryControl/EntryControl.stories.tsx +71 -0
- package/src/components/EntryControl/EntryControl.tsx +117 -0
- package/src/components/EntryControl/index.ts +2 -0
- package/src/components/Grid/Grid.stories.tsx +94 -0
- package/src/components/Grid/Grid.tsx +214 -0
- package/src/components/Grid/grid.css +285 -0
- package/src/components/Grid/index.ts +2 -0
- package/src/components/Header/Header.stories.tsx +164 -0
- package/src/components/Header/Header.tsx +59 -0
- package/src/components/Header/header.css +31 -0
- package/src/components/Header/index.ts +1 -0
- package/src/components/IconText/IconText..stories.tsx +135 -0
- package/src/components/IconText/IconText.css +43 -0
- package/src/components/IconText/IconText.tsx +43 -0
- package/src/components/IconText/index.ts +1 -0
- package/src/components/LanguageSelector/LanguageSelector.css +31 -0
- package/src/components/LanguageSelector/LanguageSelector.stories.tsx +38 -0
- package/src/components/LanguageSelector/LanguageSelector.tsx +37 -0
- package/src/components/LanguageSelector/index.ts +1 -0
- package/src/components/Logo/Logo.css +89 -0
- package/src/components/Logo/Logo.stories.tsx +79 -0
- package/src/components/Logo/Logo.tsx +22 -0
- package/src/components/Logo/index.ts +2 -0
- package/src/components/MetricsPanel/MetricsItem.tsx +128 -0
- package/src/components/MetricsPanel/MetricsPanel.module.css +636 -0
- package/src/components/MetricsPanel/MetricsPanel.stories.tsx +692 -0
- package/src/components/MetricsPanel/MetricsPanel.tsx +282 -0
- package/src/components/MetricsPanel/PanelHeader.tsx +19 -0
- package/src/components/MetricsPanel/SummaryCard.tsx +61 -0
- package/src/components/MetricsPanel/index.ts +4 -0
- package/src/components/MetricsPanel/renderers/CompactRenderer.tsx +125 -0
- package/src/components/MetricsPanel/renderers/ImageCard.tsx +62 -0
- package/src/components/MetricsPanel/renderers/PertinenceCard.tsx +55 -0
- package/src/components/MetricsPanel/tools/MetricsPanelTypes.ts +62 -0
- package/src/components/MetricsPanel/tools/chooseDefaultRender.ts +50 -0
- package/src/components/MetricsPanel/tools/colorUtils.ts +39 -0
- package/src/components/MetricsPanel/tools/index.ts +2 -0
- package/src/components/ModuleHeader/ModuleHeader.css +37 -0
- package/src/components/ModuleHeader/ModuleHeader.stories.tsx +37 -0
- package/src/components/ModuleHeader/ModuleHeader.tsx +42 -0
- package/src/components/ModuleHeader/index.ts +1 -0
- package/src/components/ModuleSideBar/ModuleSideBar.css +227 -0
- package/src/components/ModuleSideBar/ModuleSideBar.stories.tsx +40 -0
- package/src/components/ModuleSideBar/ModuleSideBar.tsx +155 -0
- package/src/components/ModuleSideBar/index.ts +1 -0
- package/src/components/NavBar/NavBar.css +58 -0
- package/src/components/NavBar/NavBar.stories.tsx +169 -0
- package/src/components/NavBar/NavBar.tsx +100 -0
- package/src/components/NavBar/NavContext.tsx +30 -0
- package/src/components/NavBar/index.ts +2 -0
- package/src/components/NavItem/NavItem.css +29 -0
- package/src/components/NavItem/NavItem.tsx +58 -0
- package/src/components/NavItem/index.ts +1 -0
- package/src/components/Page/Dashboard.tsx +93 -0
- package/src/components/Page/Page.stories.ts +33 -0
- package/src/components/Page/Page.tsx +73 -0
- package/src/components/Page/page.css +81 -0
- package/src/components/PerformanceCard/PerformanceCard.module.css +232 -0
- package/src/components/PerformanceCard/PerformanceCard.stories.tsx +441 -0
- package/src/components/PerformanceCard/PerformanceCard.tsx +198 -0
- package/src/components/PerformanceCard/defaultHistogramRenderer.tsx +32 -0
- package/src/components/PerformanceCard/tools/types.ts +50 -0
- package/src/components/PerformanceCard/tools/usePerformanceCard.ts +93 -0
- package/src/components/PeriodRange/PeriodRange.module.css +158 -0
- package/src/components/PeriodRange/PeriodRange.stories.tsx +66 -0
- package/src/components/PeriodRange/PeriodRange.tsx +130 -0
- package/src/components/PeriodSelect/PeriodSelect.module.css +65 -0
- package/src/components/PeriodSelect/PeriodSelect.stories.tsx +40 -0
- package/src/components/PeriodSelect/PeriodSelect.tsx +42 -0
- package/src/components/PeriodSelect/index.ts +1 -0
- package/src/components/ScrollableHorizontale/ScrollableHorizontale.css +40 -0
- package/src/components/ScrollableHorizontale/ScrollableHorizontale.stories.tsx +133 -0
- package/src/components/ScrollableHorizontale/ScrollableHorizontale.tsx +29 -0
- package/src/components/ScrollableHorizontale/index.ts +1 -0
- package/src/components/SearchBar/SearchBar.css +40 -0
- package/src/components/SearchBar/SearchBar.stories.tsx +36 -0
- package/src/components/SearchBar/SearchBar.tsx +30 -0
- package/src/components/SearchBar/index.ts +1 -0
- package/src/components/SectionTitle/SectionTitle.css +21 -0
- package/src/components/SectionTitle/SectionTitle.stories.tsx +39 -0
- package/src/components/SectionTitle/SectionTitle.tsx +18 -0
- package/src/components/SideComponent/PatientEditor.tsx +64 -0
- package/src/components/SideComponent/SideComponent.css +179 -0
- package/src/components/SideComponent/SideComponent.stories.tsx +547 -0
- package/src/components/SideComponent/SideComponent.tsx +243 -0
- package/src/components/SideComponent/hooks/useBodyScrollLock.ts +15 -0
- package/src/components/SideComponent/index.ts +2 -0
- package/src/components/SideComponent/portal.ts +11 -0
- package/src/components/SubNavBar/SubNavBar.tsx +41 -0
- package/src/components/SubNavBar/index.ts +1 -0
- package/src/components/Switcher/Switcher.css +65 -0
- package/src/components/Switcher/Switcher.stories.tsx +153 -0
- package/src/components/Switcher/Switcher.tsx +83 -0
- package/src/components/Switcher/index.ts +1 -0
- package/src/components/Title/Title.stories.tsx +18 -0
- package/src/components/Title/Title.tsx +26 -0
- package/src/components/Title/index.ts +1 -0
- package/src/components/TranslationKey/TranslationKey.css +272 -0
- package/src/components/TranslationKey/TranslationKey.stories.tsx +50 -0
- package/src/components/TranslationKey/TranslationKey.tsx +245 -0
- package/src/components/TranslationKey/index.ts +1 -0
- package/src/components/TrendItem/TrendItem.css +36 -0
- package/src/components/TrendItem/TrendItem.stories.tsx +276 -0
- package/src/components/TrendItem/TrendItem.tsx +46 -0
- package/src/components/TrendItem/index.ts +1 -0
- package/src/components/TrendList/TrendList.css +16 -0
- package/src/components/TrendList/TrendList.stories.tsx +337 -0
- package/src/components/TrendList/TrendList.tsx +45 -0
- package/src/components/TrendList/index.ts +1 -0
- package/src/components/theme/ThemeSwitcherButton.tsx +64 -0
- package/src/components/theme/context/ThemeContext.tsx +61 -0
- package/src/components/theme/context/index.ts +2 -0
- package/src/components/theme/context/useThemeSwitcher.ts +18 -0
- package/src/components/theme/index.ts +1 -0
- package/src/index.css +68 -0
- package/src/main.tsx +10 -0
- package/src/vite-env.d.ts +1 -0
- package/tsconfig.app.json +27 -0
- package/tsconfig.json +4 -0
- package/tsconfig.node.json +25 -0
- package/vite.config.ts +43 -0
- package/vitest.shims.d.ts +1 -0
|
@@ -0,0 +1,69 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import type { CSSProperties } from 'react';
|
|
3
|
+
import './DayStatCard.css';
|
|
4
|
+
import { CircularProgress } from '../CircularProgress/CircularProgress';
|
|
5
|
+
import type { CircularProgressProps } from '../CircularProgress/CircularProgress';
|
|
6
|
+
|
|
7
|
+
export type DayStatCardProps = {
|
|
8
|
+
background?: string;
|
|
9
|
+
headerTop: string;
|
|
10
|
+
headerBottom?: string;
|
|
11
|
+
headerTopStyle?: CSSProperties;
|
|
12
|
+
headerBottomStyle?: CSSProperties;
|
|
13
|
+
progress1: CircularProgressProps;
|
|
14
|
+
progress2: CircularProgressProps;
|
|
15
|
+
progress3: CircularProgressProps;
|
|
16
|
+
style?: CSSProperties;
|
|
17
|
+
size?: number;
|
|
18
|
+
className?: string;
|
|
19
|
+
};
|
|
20
|
+
|
|
21
|
+
export const DayStatCard: React.FC<DayStatCardProps> = ({
|
|
22
|
+
size = 200,
|
|
23
|
+
background = '#fff',
|
|
24
|
+
headerTop,
|
|
25
|
+
headerBottom,
|
|
26
|
+
headerTopStyle,
|
|
27
|
+
headerBottomStyle,
|
|
28
|
+
progress1,
|
|
29
|
+
progress2,
|
|
30
|
+
progress3,
|
|
31
|
+
style,
|
|
32
|
+
className = '',
|
|
33
|
+
}) => {
|
|
34
|
+
const progress1WithDefaults = { size: size * 0.5, ...progress1 };
|
|
35
|
+
const progress2WithDefaults = { size: size * 0.4, ...progress2 };
|
|
36
|
+
const progress3WithDefaults = { size: size * 0.4, ...progress3 };
|
|
37
|
+
|
|
38
|
+
return (
|
|
39
|
+
<div style={{ width: size, background, ...style }} className={`stat-card ${className}`}>
|
|
40
|
+
<div className='stat-card-header'>
|
|
41
|
+
<div className='stat-card-header-top' style={headerTopStyle}>
|
|
42
|
+
{headerTop}
|
|
43
|
+
</div>
|
|
44
|
+
{headerBottom && (
|
|
45
|
+
<div className='stat-card-header-bottom' style={headerBottomStyle}>
|
|
46
|
+
{headerBottom}
|
|
47
|
+
</div>
|
|
48
|
+
)}
|
|
49
|
+
</div>
|
|
50
|
+
|
|
51
|
+
<div className='stat-card-body'>
|
|
52
|
+
{/* Première ligne - Progress Centré */}
|
|
53
|
+
<div className='progress-row-single'>
|
|
54
|
+
<CircularProgress {...progress1WithDefaults} />
|
|
55
|
+
</div>
|
|
56
|
+
|
|
57
|
+
{/* Deuxième ligne - Deux Progress côte à côte */}
|
|
58
|
+
<div className='progress-row-double'>
|
|
59
|
+
<div className='progress-item'>
|
|
60
|
+
<CircularProgress {...progress2WithDefaults} />
|
|
61
|
+
</div>
|
|
62
|
+
<div className='progress-item'>
|
|
63
|
+
<CircularProgress {...progress3WithDefaults} />
|
|
64
|
+
</div>
|
|
65
|
+
</div>
|
|
66
|
+
</div>
|
|
67
|
+
</div>
|
|
68
|
+
);
|
|
69
|
+
};
|
|
@@ -0,0 +1,58 @@
|
|
|
1
|
+
'use client';
|
|
2
|
+
import { useEffect, useState } from 'react';
|
|
3
|
+
import { useDraggableSwitcher } from './context/useDraggableSwitcher';
|
|
4
|
+
import { Switcher } from '../Switcher/Switcher';
|
|
5
|
+
|
|
6
|
+
export interface DraggableSwitcherButtonProps {
|
|
7
|
+
leftIcon?: string;
|
|
8
|
+
rightIcon?: string;
|
|
9
|
+
colors?: {
|
|
10
|
+
bg?: string;
|
|
11
|
+
activeBg?: string;
|
|
12
|
+
border?: string;
|
|
13
|
+
circle?: string;
|
|
14
|
+
icon?: string;
|
|
15
|
+
icon2?: string;
|
|
16
|
+
};
|
|
17
|
+
size?: number;
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
export const DraggableSwitcherButton = ({
|
|
21
|
+
leftIcon = 'Move',
|
|
22
|
+
rightIcon = 'MoveDiagonal',
|
|
23
|
+
colors = {
|
|
24
|
+
bg: '#e5e7eb',
|
|
25
|
+
activeBg: '#10b981',
|
|
26
|
+
border: '#ffffff',
|
|
27
|
+
circle: '#ffffff',
|
|
28
|
+
icon: '#10b981',
|
|
29
|
+
icon2: '#ffffff',
|
|
30
|
+
},
|
|
31
|
+
size = 24,
|
|
32
|
+
}: DraggableSwitcherButtonProps) => {
|
|
33
|
+
const { isDraggable, switchDraggable } = useDraggableSwitcher();
|
|
34
|
+
const [mounted, setMounted] = useState(false);
|
|
35
|
+
|
|
36
|
+
useEffect(() => {
|
|
37
|
+
setMounted(true);
|
|
38
|
+
}, []);
|
|
39
|
+
|
|
40
|
+
if (!mounted) return null;
|
|
41
|
+
|
|
42
|
+
const handleToggle = (checked: boolean) => {
|
|
43
|
+
switchDraggable(checked);
|
|
44
|
+
};
|
|
45
|
+
|
|
46
|
+
return (
|
|
47
|
+
<Switcher
|
|
48
|
+
leftIcon={leftIcon}
|
|
49
|
+
rightIcon={rightIcon}
|
|
50
|
+
checked={isDraggable}
|
|
51
|
+
onToggle={handleToggle}
|
|
52
|
+
colors={colors}
|
|
53
|
+
size={size}
|
|
54
|
+
/>
|
|
55
|
+
);
|
|
56
|
+
};
|
|
57
|
+
|
|
58
|
+
export default DraggableSwitcherButton;
|
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
'use client';
|
|
2
|
+
import { createContext, useContext, useState, useEffect } from 'react';
|
|
3
|
+
import type { ReactNode } from 'react';
|
|
4
|
+
|
|
5
|
+
interface DraggableContextType {
|
|
6
|
+
isDraggable: boolean;
|
|
7
|
+
switchDraggable: (value: boolean) => void;
|
|
8
|
+
}
|
|
9
|
+
|
|
10
|
+
const DraggableContext = createContext<DraggableContextType | undefined>(undefined);
|
|
11
|
+
|
|
12
|
+
export const DraggableProvider = ({ children }: { children: ReactNode }) => {
|
|
13
|
+
const [isDraggable, setIsDraggable] = useState(false);
|
|
14
|
+
|
|
15
|
+
// Charger depuis localStorage au premier rendu
|
|
16
|
+
useEffect(() => {
|
|
17
|
+
const stored = localStorage.getItem('isDraggable');
|
|
18
|
+
if (stored !== null) {
|
|
19
|
+
setIsDraggable(stored === 'true'); // localStorage stocke toujours des strings
|
|
20
|
+
}
|
|
21
|
+
}, []);
|
|
22
|
+
|
|
23
|
+
// Sauvegarder dans localStorage quand ça change
|
|
24
|
+
useEffect(() => {
|
|
25
|
+
localStorage.setItem('isDraggable', String(isDraggable));
|
|
26
|
+
}, [isDraggable]);
|
|
27
|
+
|
|
28
|
+
const switchDraggable = (value: boolean) => {
|
|
29
|
+
setIsDraggable(value);
|
|
30
|
+
};
|
|
31
|
+
|
|
32
|
+
return (
|
|
33
|
+
<DraggableContext.Provider value={{ isDraggable, switchDraggable }}>
|
|
34
|
+
{children}
|
|
35
|
+
</DraggableContext.Provider>
|
|
36
|
+
);
|
|
37
|
+
};
|
|
38
|
+
|
|
39
|
+
export const useDraggableSwitcher = () => {
|
|
40
|
+
const context = useContext(DraggableContext);
|
|
41
|
+
if (!context) {
|
|
42
|
+
throw new Error('useDraggableSwitcher must be used inside a DraggableProvider');
|
|
43
|
+
}
|
|
44
|
+
return context;
|
|
45
|
+
};
|
|
@@ -0,0 +1,100 @@
|
|
|
1
|
+
.dropdown {
|
|
2
|
+
position: relative;
|
|
3
|
+
display: inline-block;
|
|
4
|
+
}
|
|
5
|
+
|
|
6
|
+
.dropdown-button {
|
|
7
|
+
display: flex;
|
|
8
|
+
align-items: center;
|
|
9
|
+
gap: 8px;
|
|
10
|
+
border: 1px solid #ccc;
|
|
11
|
+
padding: 8px 16px;
|
|
12
|
+
border-radius: 6px;
|
|
13
|
+
background: #fff;
|
|
14
|
+
cursor: pointer;
|
|
15
|
+
font-size: var(--text-paragraph, 1rem);
|
|
16
|
+
font-weight: var(--font-medium, 500);
|
|
17
|
+
transition: all 0.2s ease;
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
.dropdown-button:hover {
|
|
21
|
+
background-color: #f5f5f5;
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
.dropdown-content {
|
|
25
|
+
position: absolute;
|
|
26
|
+
top: 100%;
|
|
27
|
+
margin-top: 4px;
|
|
28
|
+
background: #fff;
|
|
29
|
+
border: 1px solid #ddd;
|
|
30
|
+
border-radius: 8px;
|
|
31
|
+
box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
|
|
32
|
+
min-width: 200px;
|
|
33
|
+
z-index: 1000;
|
|
34
|
+
overflow: hidden;
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
.dropdown-content.left {
|
|
38
|
+
left: 0;
|
|
39
|
+
right: auto;
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
.dropdown-content.right {
|
|
43
|
+
right: 0;
|
|
44
|
+
left: auto;
|
|
45
|
+
}
|
|
46
|
+
|
|
47
|
+
.dropdown-category {
|
|
48
|
+
padding: 8px 0;
|
|
49
|
+
}
|
|
50
|
+
|
|
51
|
+
.dropdown-category:not(:last-child) {
|
|
52
|
+
border-bottom: 1px solid #eee;
|
|
53
|
+
}
|
|
54
|
+
|
|
55
|
+
.category-title {
|
|
56
|
+
padding: 8px 16px;
|
|
57
|
+
color: #666;
|
|
58
|
+
text-transform: uppercase;
|
|
59
|
+
letter-spacing: 0.5px;
|
|
60
|
+
font-size: var(--text-small, 0.875rem);
|
|
61
|
+
font-weight: var(--font-medium, 500);
|
|
62
|
+
}
|
|
63
|
+
|
|
64
|
+
.category-items {
|
|
65
|
+
display: flex;
|
|
66
|
+
flex-direction: column;
|
|
67
|
+
}
|
|
68
|
+
|
|
69
|
+
.dropdown-item {
|
|
70
|
+
padding: 10px 16px;
|
|
71
|
+
text-decoration: none;
|
|
72
|
+
color: #333;
|
|
73
|
+
background: none;
|
|
74
|
+
border: none;
|
|
75
|
+
text-align: left;
|
|
76
|
+
cursor: pointer;
|
|
77
|
+
font-size: var(--text-paragraph, 1rem);
|
|
78
|
+
font-weight: var(--font-normal, 400);
|
|
79
|
+
transition:
|
|
80
|
+
background-color 0.2s ease,
|
|
81
|
+
color 0.2s ease;
|
|
82
|
+
display: block;
|
|
83
|
+
}
|
|
84
|
+
|
|
85
|
+
.dropdown-item:hover {
|
|
86
|
+
background: #f0f0f0;
|
|
87
|
+
}
|
|
88
|
+
|
|
89
|
+
.dropdown-item.active {
|
|
90
|
+
color: var(--color-primary, #008fbb); /* couleur mise en avant */
|
|
91
|
+
font-weight: var(--font-medium, 600);
|
|
92
|
+
text-decoration: underline;
|
|
93
|
+
}
|
|
94
|
+
|
|
95
|
+
/* Masquer le texte du bouton sur les petits écrans */
|
|
96
|
+
@media (max-width: 768px) {
|
|
97
|
+
.button-text {
|
|
98
|
+
display: none;
|
|
99
|
+
}
|
|
100
|
+
}
|
|
@@ -0,0 +1,174 @@
|
|
|
1
|
+
import type { Meta, StoryObj } from '@storybook/react';
|
|
2
|
+
import DropdownMenu from './DropdownMenu';
|
|
3
|
+
import type { MenuCategory } from './DropdownMenu';
|
|
4
|
+
// Données mock pour les catégories de menu
|
|
5
|
+
const mockCategories: MenuCategory[] = [
|
|
6
|
+
{
|
|
7
|
+
title: 'Account',
|
|
8
|
+
items: [
|
|
9
|
+
{ label: 'Profile', href: '/profile', type: 'link' },
|
|
10
|
+
{ label: 'Settings', href: '/settings', type: 'link' },
|
|
11
|
+
{ label: 'Logout', type: 'button' },
|
|
12
|
+
],
|
|
13
|
+
},
|
|
14
|
+
{
|
|
15
|
+
title: 'Support',
|
|
16
|
+
items: [
|
|
17
|
+
{ label: 'Help Center', href: '/help', type: 'link' },
|
|
18
|
+
{ label: 'Contact Us', href: '/contact', type: 'link' },
|
|
19
|
+
{ label: 'Feedback', type: 'button' },
|
|
20
|
+
],
|
|
21
|
+
},
|
|
22
|
+
];
|
|
23
|
+
|
|
24
|
+
const meta = {
|
|
25
|
+
title: 'Components/DropdownMenu',
|
|
26
|
+
component: DropdownMenu,
|
|
27
|
+
parameters: {
|
|
28
|
+
layout: 'centered',
|
|
29
|
+
},
|
|
30
|
+
tags: ['autodocs'],
|
|
31
|
+
argTypes: {
|
|
32
|
+
categories: {
|
|
33
|
+
control: 'object',
|
|
34
|
+
description: 'Categories and items for the dropdown menu',
|
|
35
|
+
table: {
|
|
36
|
+
category: 'Content',
|
|
37
|
+
},
|
|
38
|
+
},
|
|
39
|
+
buttonContent: {
|
|
40
|
+
control: 'text',
|
|
41
|
+
description: 'Content of the dropdown toggle button',
|
|
42
|
+
table: {
|
|
43
|
+
category: 'Content',
|
|
44
|
+
},
|
|
45
|
+
},
|
|
46
|
+
position: {
|
|
47
|
+
control: 'select',
|
|
48
|
+
options: ['left', 'right'],
|
|
49
|
+
description: 'Position of the dropdown relative to the button',
|
|
50
|
+
table: {
|
|
51
|
+
category: 'Appearance',
|
|
52
|
+
},
|
|
53
|
+
},
|
|
54
|
+
closeOnClickOutside: {
|
|
55
|
+
control: 'boolean',
|
|
56
|
+
description: 'Whether to close the dropdown when clicking outside',
|
|
57
|
+
table: {
|
|
58
|
+
category: 'Behavior',
|
|
59
|
+
},
|
|
60
|
+
},
|
|
61
|
+
},
|
|
62
|
+
args: {
|
|
63
|
+
buttonContent: '☰ Menu',
|
|
64
|
+
position: 'right',
|
|
65
|
+
closeOnClickOutside: true,
|
|
66
|
+
},
|
|
67
|
+
} satisfies Meta<typeof DropdownMenu>;
|
|
68
|
+
|
|
69
|
+
export default meta;
|
|
70
|
+
type Story = StoryObj<typeof meta>;
|
|
71
|
+
|
|
72
|
+
export const Default: Story = {
|
|
73
|
+
args: {
|
|
74
|
+
categories: mockCategories,
|
|
75
|
+
},
|
|
76
|
+
parameters: {
|
|
77
|
+
docs: {
|
|
78
|
+
description: {
|
|
79
|
+
story: 'Default dropdown menu with account and support categories',
|
|
80
|
+
},
|
|
81
|
+
},
|
|
82
|
+
},
|
|
83
|
+
};
|
|
84
|
+
|
|
85
|
+
export const LeftPositioned: Story = {
|
|
86
|
+
args: {
|
|
87
|
+
categories: mockCategories,
|
|
88
|
+
position: 'left',
|
|
89
|
+
},
|
|
90
|
+
parameters: {
|
|
91
|
+
docs: {
|
|
92
|
+
description: {
|
|
93
|
+
story: 'Dropdown menu positioned to the left of the button',
|
|
94
|
+
},
|
|
95
|
+
},
|
|
96
|
+
},
|
|
97
|
+
};
|
|
98
|
+
|
|
99
|
+
export const CustomButtonContent: Story = {
|
|
100
|
+
args: {
|
|
101
|
+
categories: mockCategories,
|
|
102
|
+
buttonContent: 'Options',
|
|
103
|
+
},
|
|
104
|
+
parameters: {
|
|
105
|
+
docs: {
|
|
106
|
+
description: {
|
|
107
|
+
story: 'Dropdown menu with custom button content',
|
|
108
|
+
},
|
|
109
|
+
},
|
|
110
|
+
},
|
|
111
|
+
};
|
|
112
|
+
|
|
113
|
+
export const WithoutClickOutsideClose: Story = {
|
|
114
|
+
args: {
|
|
115
|
+
categories: mockCategories,
|
|
116
|
+
closeOnClickOutside: false,
|
|
117
|
+
},
|
|
118
|
+
parameters: {
|
|
119
|
+
docs: {
|
|
120
|
+
description: {
|
|
121
|
+
story: "Dropdown menu that doesn't close when clicking outside",
|
|
122
|
+
},
|
|
123
|
+
},
|
|
124
|
+
},
|
|
125
|
+
};
|
|
126
|
+
|
|
127
|
+
export const SingleCategory: Story = {
|
|
128
|
+
args: {
|
|
129
|
+
categories: [mockCategories[0]],
|
|
130
|
+
},
|
|
131
|
+
parameters: {
|
|
132
|
+
docs: {
|
|
133
|
+
description: {
|
|
134
|
+
story: 'Dropdown menu with only one category',
|
|
135
|
+
},
|
|
136
|
+
},
|
|
137
|
+
},
|
|
138
|
+
};
|
|
139
|
+
|
|
140
|
+
export const WithMixedItems: Story = {
|
|
141
|
+
args: {
|
|
142
|
+
categories: [
|
|
143
|
+
{
|
|
144
|
+
title: 'Actions',
|
|
145
|
+
items: [
|
|
146
|
+
{ label: 'View Details', href: '/details', type: 'link' },
|
|
147
|
+
{ label: 'Edit', type: 'button' },
|
|
148
|
+
{ label: 'Delete', type: 'button' },
|
|
149
|
+
{ label: 'Download', href: '/download', type: 'link' },
|
|
150
|
+
],
|
|
151
|
+
},
|
|
152
|
+
],
|
|
153
|
+
},
|
|
154
|
+
parameters: {
|
|
155
|
+
docs: {
|
|
156
|
+
description: {
|
|
157
|
+
story: 'Dropdown menu with a mix of link and button items',
|
|
158
|
+
},
|
|
159
|
+
},
|
|
160
|
+
},
|
|
161
|
+
};
|
|
162
|
+
|
|
163
|
+
export const EmptyMenu: Story = {
|
|
164
|
+
args: {
|
|
165
|
+
categories: [],
|
|
166
|
+
},
|
|
167
|
+
parameters: {
|
|
168
|
+
docs: {
|
|
169
|
+
description: {
|
|
170
|
+
story: 'Dropdown menu without any categories (empty state)',
|
|
171
|
+
},
|
|
172
|
+
},
|
|
173
|
+
},
|
|
174
|
+
};
|
|
@@ -0,0 +1,106 @@
|
|
|
1
|
+
import React, { useState, useRef, useEffect } from 'react';
|
|
2
|
+
import './DropdownMenu.css';
|
|
3
|
+
import type { LucideProps } from 'lucide-react';
|
|
4
|
+
import * as Icons from 'lucide-react';
|
|
5
|
+
import { useNavigation } from '../NavBar/NavContext';
|
|
6
|
+
|
|
7
|
+
export interface MenuItem {
|
|
8
|
+
id?: string;
|
|
9
|
+
label: string;
|
|
10
|
+
href?: string;
|
|
11
|
+
onClick?: () => void;
|
|
12
|
+
type?: 'link' | 'button';
|
|
13
|
+
}
|
|
14
|
+
|
|
15
|
+
export interface MenuCategory {
|
|
16
|
+
title?: string;
|
|
17
|
+
items: MenuItem[];
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
export interface DropdownMenuProps {
|
|
21
|
+
categories?: MenuCategory[];
|
|
22
|
+
buttonContent?: React.ReactNode;
|
|
23
|
+
position?: 'left' | 'right';
|
|
24
|
+
closeOnClickOutside?: boolean;
|
|
25
|
+
logo?: string;
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
const DropdownMenu: React.FC<DropdownMenuProps> = ({
|
|
29
|
+
categories,
|
|
30
|
+
logo = 'Menu',
|
|
31
|
+
buttonContent,
|
|
32
|
+
position = 'right',
|
|
33
|
+
closeOnClickOutside = true,
|
|
34
|
+
}) => {
|
|
35
|
+
const [open, setOpen] = useState(false);
|
|
36
|
+
const dropdownRef = useRef<HTMLDivElement>(null);
|
|
37
|
+
|
|
38
|
+
const { activeNav, activeSubNav } = useNavigation();
|
|
39
|
+
|
|
40
|
+
useEffect(() => {
|
|
41
|
+
if (!closeOnClickOutside) return;
|
|
42
|
+
|
|
43
|
+
const handleClickOutside = (event: MouseEvent) => {
|
|
44
|
+
if (dropdownRef.current && !dropdownRef.current.contains(event.target as Node)) {
|
|
45
|
+
setOpen(false);
|
|
46
|
+
}
|
|
47
|
+
};
|
|
48
|
+
|
|
49
|
+
document.addEventListener('mousedown', handleClickOutside);
|
|
50
|
+
return () => {
|
|
51
|
+
document.removeEventListener('mousedown', handleClickOutside);
|
|
52
|
+
};
|
|
53
|
+
}, [closeOnClickOutside]);
|
|
54
|
+
|
|
55
|
+
const LucideIcon = logo
|
|
56
|
+
? (Icons[logo as keyof typeof Icons] as React.ComponentType<LucideProps>)
|
|
57
|
+
: null;
|
|
58
|
+
|
|
59
|
+
return (
|
|
60
|
+
<div className='dropdown' ref={dropdownRef}>
|
|
61
|
+
<button className='dropdown-button' onClick={() => setOpen(!open)}>
|
|
62
|
+
{LucideIcon && <LucideIcon size={20} />}
|
|
63
|
+
{buttonContent && <span className='button-text'>{buttonContent}</span>}
|
|
64
|
+
</button>
|
|
65
|
+
{open && (
|
|
66
|
+
<div className={`dropdown-content ${position}`}>
|
|
67
|
+
{categories?.map((category, categoryIndex) => (
|
|
68
|
+
<div key={categoryIndex} className='dropdown-category'>
|
|
69
|
+
{category.title && <div className='category-title'>{category.title}</div>}
|
|
70
|
+
<div className='category-items'>
|
|
71
|
+
{category.items.map((item, itemIndex) => {
|
|
72
|
+
const itemId = item.id ?? item.label;
|
|
73
|
+
const isActive = activeNav === itemId || activeSubNav === itemId;
|
|
74
|
+
|
|
75
|
+
const commonProps = {
|
|
76
|
+
className: `dropdown-item ${isActive ? 'active' : ''}`,
|
|
77
|
+
onClick: () => {
|
|
78
|
+
item.onClick?.();
|
|
79
|
+
setOpen(false);
|
|
80
|
+
},
|
|
81
|
+
};
|
|
82
|
+
|
|
83
|
+
if (item.type === 'button' || !item.href) {
|
|
84
|
+
return (
|
|
85
|
+
<button key={itemIndex} {...commonProps}>
|
|
86
|
+
{item.label}
|
|
87
|
+
</button>
|
|
88
|
+
);
|
|
89
|
+
}
|
|
90
|
+
|
|
91
|
+
return (
|
|
92
|
+
<a key={itemIndex} {...commonProps} href={item.href}>
|
|
93
|
+
{item.label}
|
|
94
|
+
</a>
|
|
95
|
+
);
|
|
96
|
+
})}
|
|
97
|
+
</div>
|
|
98
|
+
</div>
|
|
99
|
+
))}
|
|
100
|
+
</div>
|
|
101
|
+
)}
|
|
102
|
+
</div>
|
|
103
|
+
);
|
|
104
|
+
};
|
|
105
|
+
|
|
106
|
+
export default DropdownMenu;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from './DropdownMenu';
|