@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,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';
|