@tsiky/components-r19 1.1.0 → 1.3.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/package.json +1 -1
- package/src/components/AnnouncementPanel/FlexRowContainer.css +17 -17
- package/src/components/AnnouncementPanel/FlexRowContainer.stories.tsx +329 -329
- package/src/components/AnnouncementPanel/FlexRowContainer.tsx +24 -24
- package/src/components/AnnouncementPanel/ListBox/CounterListBox.css +56 -56
- package/src/components/AnnouncementPanel/ListBox/CounterListBox.stories.tsx +292 -292
- package/src/components/AnnouncementPanel/ListBox/CounterListBox.tsx +106 -106
- package/src/components/AnnouncementPanel/ListBox/SimpleListBox.css +57 -57
- package/src/components/AnnouncementPanel/ListBox/SimpleListBox.stories.tsx +189 -189
- package/src/components/AnnouncementPanel/ListBox/SimpleListBox.tsx +138 -138
- package/src/components/AnnouncementPanel/ListBox/TrendListBox.css +61 -61
- package/src/components/AnnouncementPanel/ListBox/TrendListBox.stories.tsx +257 -257
- package/src/components/AnnouncementPanel/ListBox/TrendListBox.tsx +90 -90
- package/src/components/AnnouncementPanel/ListBox/index.ts +3 -3
- package/src/components/AnnouncementPanel/ListContentContainer.css +23 -23
- package/src/components/AnnouncementPanel/ListContentContainer.stories.tsx +212 -212
- package/src/components/AnnouncementPanel/ListContentContainer.tsx +33 -33
- package/src/components/AnnouncementPanel/index.ts +3 -3
- package/src/components/Charts/area-chart-admission/AreaChartAdmission.tsx +7 -1
- package/src/components/Charts/bar-chart/BarChart.tsx +6 -2
- package/src/components/Charts/boxplot-chart/BoxPlotChart.tsx +114 -114
- package/src/components/Charts/mixed-chart/MixedChart.tsx +1 -1
- package/src/components/Charts/sankey-adaptation/sankey.tsx +70 -70
- package/src/components/DraggableSwitcher/DraggableSwitcherButton.tsx +58 -58
- package/src/components/DraggableSwitcher/context/useDraggableSwitcher.tsx +45 -45
- package/src/components/DraggableSwitcher/index.ts +2 -2
- package/src/components/DynamicInput/DynamicInput.module.css +125 -126
- package/src/components/DynamicInput/input/SelectInput.tsx +75 -75
- package/src/components/DynamicInput/input/assets/SelectInput.module.css +95 -95
- package/src/components/DynamicTable/AdvancedFilters.tsx +196 -196
- package/src/components/DynamicTable/ColumnSorter.tsx +185 -185
- package/src/components/DynamicTable/Pagination.tsx +115 -115
- package/src/components/DynamicTable/TableCell.tsx +38 -30
- package/src/components/DynamicTable/TableHeader.tsx +39 -34
- package/src/components/DynamicTable/TableauDynamique.module.css +77 -70
- package/src/components/DynamicTable/TableauDynamique.tsx +154 -154
- package/src/components/DynamicTable/filters/SelectFilter.tsx +69 -69
- package/src/components/DynamicTable/tools/tableTypes.ts +63 -63
- package/src/components/EntryControl/EntryControl.tsx +117 -117
- package/src/components/Grid/grid.css +285 -285
- package/src/components/MetricsPanel/MetricsPanel.tsx +37 -37
- package/src/components/MetricsPanel/renderers/CompactRenderer.tsx +1 -1
- package/src/components/NavItem/NavItem.tsx +58 -58
- package/src/components/PeriodRange/PeriodRange.module.css +158 -158
- package/src/components/PeriodRange/PeriodRange.tsx +130 -130
- package/src/components/PeriodSelect/PeriodSelect.module.css +64 -65
- package/src/components/PeriodSelect/PeriodSelect.tsx +48 -42
- package/src/components/SearchBar/SearchBar.css +40 -40
- package/src/components/TranslationKey/TranslationKey.css +272 -272
- package/src/components/TranslationKey/TranslationKey.tsx +8 -7
|
@@ -1,154 +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;
|
|
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;
|
|
@@ -1,69 +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;
|
|
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;
|
|
@@ -1,63 +1,63 @@
|
|
|
1
|
-
/* eslint-disable @typescript-eslint/no-explicit-any */
|
|
2
|
-
import type { ComponentType } from 'react';
|
|
3
|
-
|
|
4
|
-
export interface TableColumn<T = any> {
|
|
5
|
-
id: string;
|
|
6
|
-
label: string;
|
|
7
|
-
width?: string | number;
|
|
8
|
-
align?: 'left' | 'center' | 'right';
|
|
9
|
-
sortable?: boolean; // Rendre optionnel
|
|
10
|
-
render?: (value: any, row: T, column: TableColumn<T>) => React.ReactNode;
|
|
11
|
-
component?: ComponentType<{ value: any; row: T; column: TableColumn<T> }>;
|
|
12
|
-
type?: string;
|
|
13
|
-
options?: { value: string; label: string }[];
|
|
14
|
-
}
|
|
15
|
-
|
|
16
|
-
export interface TableRowData<T = any> {
|
|
17
|
-
id: string;
|
|
18
|
-
data: T;
|
|
19
|
-
}
|
|
20
|
-
|
|
21
|
-
export interface RendererProps<T = any> {
|
|
22
|
-
value: any;
|
|
23
|
-
row: T;
|
|
24
|
-
column: TableColumn<T>;
|
|
25
|
-
}
|
|
26
|
-
|
|
27
|
-
export interface TableConfigType {
|
|
28
|
-
renderers: Record<string, ComponentType<RendererProps>>;
|
|
29
|
-
icons: {
|
|
30
|
-
sortAsc: React.ReactElement;
|
|
31
|
-
sortDesc: React.ReactElement;
|
|
32
|
-
sortDefault: React.ReactElement;
|
|
33
|
-
};
|
|
34
|
-
}
|
|
35
|
-
|
|
36
|
-
export interface SortConfig {
|
|
37
|
-
key: string | null;
|
|
38
|
-
direction: 'asc' | 'desc';
|
|
39
|
-
}
|
|
40
|
-
|
|
41
|
-
export interface TableauDynamiqueProps<T = any> {
|
|
42
|
-
columns?: TableColumn<T>[];
|
|
43
|
-
data?: TableRowData<T>[];
|
|
44
|
-
pagination?: { pageSize: number; currentPage: number };
|
|
45
|
-
onSort?: (sortConfig: SortConfig) => void;
|
|
46
|
-
onPageChange?: (page: number) => void;
|
|
47
|
-
onPageSizeChange?: (size: number) => void;
|
|
48
|
-
onRowClick?: (row: T, index: number) => void;
|
|
49
|
-
filterable?: boolean;
|
|
50
|
-
searchTerm?: string;
|
|
51
|
-
onSearch?: (term: string) => void;
|
|
52
|
-
className?: string;
|
|
53
|
-
onNewPage?: (page: number) => void;
|
|
54
|
-
}
|
|
55
|
-
|
|
56
|
-
export interface TableBodyProps<T> {
|
|
57
|
-
data: TableRowData<T>[];
|
|
58
|
-
columns: TableColumn<T>[];
|
|
59
|
-
onRowClick?: (row: T, index: number) => void;
|
|
60
|
-
startIndex: number;
|
|
61
|
-
searchTerm?: string;
|
|
62
|
-
getRowStyle?: (row: T) => React.CSSProperties;
|
|
63
|
-
}
|
|
1
|
+
/* eslint-disable @typescript-eslint/no-explicit-any */
|
|
2
|
+
import type { ComponentType } from 'react';
|
|
3
|
+
|
|
4
|
+
export interface TableColumn<T = any> {
|
|
5
|
+
id: string;
|
|
6
|
+
label: string;
|
|
7
|
+
width?: string | number;
|
|
8
|
+
align?: 'left' | 'center' | 'right';
|
|
9
|
+
sortable?: boolean; // Rendre optionnel
|
|
10
|
+
render?: (value: any, row: T, column: TableColumn<T>) => React.ReactNode;
|
|
11
|
+
component?: ComponentType<{ value: any; row: T; column: TableColumn<T> }>;
|
|
12
|
+
type?: string;
|
|
13
|
+
options?: { value: string; label: string }[];
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
export interface TableRowData<T = any> {
|
|
17
|
+
id: string;
|
|
18
|
+
data: T;
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
export interface RendererProps<T = any> {
|
|
22
|
+
value: any;
|
|
23
|
+
row: T;
|
|
24
|
+
column: TableColumn<T>;
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
export interface TableConfigType {
|
|
28
|
+
renderers: Record<string, ComponentType<RendererProps>>;
|
|
29
|
+
icons: {
|
|
30
|
+
sortAsc: React.ReactElement;
|
|
31
|
+
sortDesc: React.ReactElement;
|
|
32
|
+
sortDefault: React.ReactElement;
|
|
33
|
+
};
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
export interface SortConfig {
|
|
37
|
+
key: string | null;
|
|
38
|
+
direction: 'asc' | 'desc';
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
export interface TableauDynamiqueProps<T = any> {
|
|
42
|
+
columns?: TableColumn<T>[];
|
|
43
|
+
data?: TableRowData<T>[];
|
|
44
|
+
pagination?: { pageSize: number; currentPage: number };
|
|
45
|
+
onSort?: (sortConfig: SortConfig) => void;
|
|
46
|
+
onPageChange?: (page: number) => void;
|
|
47
|
+
onPageSizeChange?: (size: number) => void;
|
|
48
|
+
onRowClick?: (row: T, index: number) => void;
|
|
49
|
+
filterable?: boolean;
|
|
50
|
+
searchTerm?: string;
|
|
51
|
+
onSearch?: (term: string) => void;
|
|
52
|
+
className?: string;
|
|
53
|
+
onNewPage?: (page: number) => void;
|
|
54
|
+
}
|
|
55
|
+
|
|
56
|
+
export interface TableBodyProps<T> {
|
|
57
|
+
data: TableRowData<T>[];
|
|
58
|
+
columns: TableColumn<T>[];
|
|
59
|
+
onRowClick?: (row: T, index: number) => void;
|
|
60
|
+
startIndex: number;
|
|
61
|
+
searchTerm?: string;
|
|
62
|
+
getRowStyle?: (row: T) => React.CSSProperties;
|
|
63
|
+
}
|