@tsiky/components-r19 1.1.0 → 1.2.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (47) hide show
  1. package/package.json +1 -1
  2. package/src/components/AnnouncementPanel/FlexRowContainer.css +17 -17
  3. package/src/components/AnnouncementPanel/FlexRowContainer.stories.tsx +329 -329
  4. package/src/components/AnnouncementPanel/FlexRowContainer.tsx +24 -24
  5. package/src/components/AnnouncementPanel/ListBox/CounterListBox.css +56 -56
  6. package/src/components/AnnouncementPanel/ListBox/CounterListBox.stories.tsx +292 -292
  7. package/src/components/AnnouncementPanel/ListBox/CounterListBox.tsx +106 -106
  8. package/src/components/AnnouncementPanel/ListBox/SimpleListBox.css +57 -57
  9. package/src/components/AnnouncementPanel/ListBox/SimpleListBox.stories.tsx +189 -189
  10. package/src/components/AnnouncementPanel/ListBox/SimpleListBox.tsx +138 -138
  11. package/src/components/AnnouncementPanel/ListBox/TrendListBox.css +61 -61
  12. package/src/components/AnnouncementPanel/ListBox/TrendListBox.stories.tsx +257 -257
  13. package/src/components/AnnouncementPanel/ListBox/TrendListBox.tsx +90 -90
  14. package/src/components/AnnouncementPanel/ListBox/index.ts +3 -3
  15. package/src/components/AnnouncementPanel/ListContentContainer.css +23 -23
  16. package/src/components/AnnouncementPanel/ListContentContainer.stories.tsx +212 -212
  17. package/src/components/AnnouncementPanel/ListContentContainer.tsx +33 -33
  18. package/src/components/AnnouncementPanel/index.ts +3 -3
  19. package/src/components/Charts/area-chart-admission/AreaChartAdmission.tsx +7 -1
  20. package/src/components/Charts/bar-chart/BarChart.tsx +6 -2
  21. package/src/components/Charts/boxplot-chart/BoxPlotChart.tsx +114 -114
  22. package/src/components/Charts/mixed-chart/MixedChart.tsx +1 -1
  23. package/src/components/Charts/sankey-adaptation/sankey.tsx +70 -70
  24. package/src/components/DraggableSwitcher/DraggableSwitcherButton.tsx +58 -58
  25. package/src/components/DraggableSwitcher/context/useDraggableSwitcher.tsx +45 -45
  26. package/src/components/DraggableSwitcher/index.ts +2 -2
  27. package/src/components/DynamicInput/input/SelectInput.tsx +75 -75
  28. package/src/components/DynamicInput/input/assets/SelectInput.module.css +95 -95
  29. package/src/components/DynamicTable/AdvancedFilters.tsx +196 -196
  30. package/src/components/DynamicTable/ColumnSorter.tsx +185 -185
  31. package/src/components/DynamicTable/Pagination.tsx +115 -115
  32. package/src/components/DynamicTable/TableCell.tsx +38 -30
  33. package/src/components/DynamicTable/TableHeader.tsx +39 -34
  34. package/src/components/DynamicTable/TableauDynamique.module.css +79 -33
  35. package/src/components/DynamicTable/TableauDynamique.tsx +154 -154
  36. package/src/components/DynamicTable/filters/SelectFilter.tsx +69 -69
  37. package/src/components/DynamicTable/tools/tableTypes.ts +63 -63
  38. package/src/components/EntryControl/EntryControl.tsx +117 -117
  39. package/src/components/Grid/grid.css +285 -285
  40. package/src/components/MetricsPanel/MetricsPanel.tsx +37 -37
  41. package/src/components/MetricsPanel/renderers/CompactRenderer.tsx +1 -1
  42. package/src/components/NavItem/NavItem.tsx +58 -58
  43. package/src/components/PeriodRange/PeriodRange.module.css +158 -158
  44. package/src/components/PeriodRange/PeriodRange.tsx +130 -130
  45. package/src/components/SearchBar/SearchBar.css +40 -40
  46. package/src/components/TranslationKey/TranslationKey.css +272 -272
  47. package/src/components/TranslationKey/TranslationKey.tsx +8 -7
@@ -1,196 +1,196 @@
1
- 'use client';
2
-
3
- import React, { useEffect, useRef, useState } from 'react';
4
- import { X, Filter } from 'lucide-react';
5
- import type { FilterConfig, AppliedFilter } from './tools/filterTypes';
6
- import { useFilters } from './hooks/useFilters';
7
- import FilterRenderer from './filters/FilterRenderer';
8
- import styles from './TableauDynamique.module.css';
9
-
10
- interface AdvancedFiltersProps {
11
- filters: FilterConfig[];
12
- externalFilters?: AppliedFilter[];
13
- onFiltersChange?: (filters: AppliedFilter[]) => void;
14
- onApply?: (filters: AppliedFilter[]) => void;
15
- isControlled?: boolean;
16
- debounceTimeout?: number;
17
- resultsCount?: number;
18
- expanded?: boolean;
19
- onToggle?: (expanded: boolean) => void;
20
- panelPlacement?: 'overlay' | 'top';
21
- onPanelHeightChange?: (height: number) => void;
22
- }
23
-
24
- const AdvancedFilters: React.FC<AdvancedFiltersProps> = ({
25
- filters,
26
- externalFilters = [],
27
- onFiltersChange,
28
- onApply,
29
- isControlled = false,
30
- debounceTimeout = 300,
31
- resultsCount = 0,
32
- expanded,
33
- onToggle,
34
- panelPlacement = 'top',
35
- onPanelHeightChange,
36
- }) => {
37
- const [localExpanded, setLocalExpanded] = useState(false);
38
- const isExpanded = typeof expanded === 'boolean' ? expanded : localExpanded;
39
-
40
- const { appliedFilters, tempFilters, updateFilter, applyFilters, clearAllFilters } = useFilters({
41
- filters,
42
- externalFilters,
43
- onFiltersChange,
44
- onApply,
45
- debounceTimeout,
46
- isControlled,
47
- });
48
-
49
- const panelRef = useRef<HTMLDivElement | null>(null);
50
- const wrapperRef = useRef<HTMLDivElement | null>(null);
51
-
52
- useEffect(() => {
53
- if (isExpanded && panelRef.current) {
54
- const h = panelRef.current.getBoundingClientRect().height;
55
- onPanelHeightChange?.(h);
56
- } else {
57
- onPanelHeightChange?.(0);
58
- }
59
- }, [isExpanded, filters, tempFilters, onPanelHeightChange]);
60
-
61
- const toggle = () => {
62
- if (typeof expanded === 'boolean') {
63
- onToggle?.(!expanded);
64
- } else {
65
- setLocalExpanded((s) => {
66
- const next = !s;
67
- onToggle?.(next);
68
- return next;
69
- });
70
- }
71
- };
72
-
73
- const handleApply = async () => {
74
- await applyFilters();
75
- onToggle?.(false);
76
- if (typeof expanded !== 'boolean') setLocalExpanded(false);
77
- };
78
-
79
- useEffect(() => {
80
- const onPointerDown = (e: PointerEvent) => {
81
- if (!isExpanded) return;
82
- if (!wrapperRef.current) return;
83
- if (!wrapperRef.current.contains(e.target as Node)) {
84
- onToggle?.(false);
85
- if (typeof expanded !== 'boolean') setLocalExpanded(false);
86
- }
87
- };
88
-
89
- const onKey = (e: KeyboardEvent) => {
90
- if (e.key === 'Escape' && isExpanded) {
91
- onToggle?.(false);
92
- if (typeof expanded !== 'boolean') setLocalExpanded(false);
93
- }
94
- };
95
-
96
- if (isExpanded) {
97
- document.addEventListener('pointerdown', onPointerDown);
98
- document.addEventListener('keydown', onKey);
99
- }
100
-
101
- return () => {
102
- document.removeEventListener('pointerdown', onPointerDown);
103
- document.removeEventListener('keydown', onKey);
104
- };
105
- }, [isExpanded, expanded, onToggle]);
106
-
107
- return (
108
- <div className={styles.advancedFiltersContainer} ref={wrapperRef}>
109
- <div className={styles.filtersHeader}>
110
- <button
111
- className={styles.toggleFiltersButton}
112
- onClick={toggle}
113
- aria-expanded={isExpanded}
114
- aria-controls='advanced-filters-panel'
115
- >
116
- <Filter size={14} />
117
- <span className={styles.buttonTextCompact}>Advanced-Filters</span>
118
- </button>
119
-
120
- {appliedFilters.length > 0 && (
121
- <button className={styles.clearFiltersButton} onClick={clearAllFilters}>
122
- <X size={14} /> <span className={styles.buttonTextCompact}>Effacer</span>
123
- </button>
124
- )}
125
- </div>
126
-
127
- {isExpanded && (
128
- <div
129
- id='advanced-filters-panel'
130
- ref={panelRef}
131
- className={`${styles.filtersPanel} ${
132
- panelPlacement === 'top'
133
- ? `${styles.filtersPanelInline} ${styles.filtersPanelHorizontal}`
134
- : ''
135
- }`}
136
- role='region'
137
- aria-label='Panneau de filtres avancés'
138
- >
139
- <div className={styles.filtersRow}>
140
- {filters.map((filter) => (
141
- <div key={filter.id} className={`${styles.filterItem} ${styles.filterItemInline}`}>
142
- <label className={styles.filterLabel}>
143
- {filter.label}
144
- {filter.required && <span className={styles.required}>*</span>}
145
- </label>
146
- <FilterRenderer
147
- config={filter}
148
- value={tempFilters[filter.id]}
149
- onChange={(value) => updateFilter(filter.id, value)}
150
- disabled={filter.disabled}
151
- />
152
- </div>
153
- ))}
154
- </div>
155
-
156
- <div className={styles.filtersActionsHorizontal}>
157
- <div className={styles.activeFiltersWrap}>
158
- {appliedFilters.length > 0 && (
159
- <div className={styles.activeFilters}>
160
- <span className={styles.activeLabelCompact}>Actifs :</span>
161
- {appliedFilters.map((f) => (
162
- <div key={f.id} className={styles.activeFilterTag}>
163
- {f.label ?? f.id}
164
- <button
165
- onClick={() => updateFilter(f.id, undefined)}
166
- aria-label={`Supprimer ${f.id}`}
167
- >
168
- ×
169
- </button>
170
- </div>
171
- ))}
172
- </div>
173
- )}
174
- </div>
175
-
176
- <div className={styles.actionsGroup}>
177
- <button
178
- className={styles.cancelButton}
179
- onClick={() => {
180
- onToggle?.(false);
181
- }}
182
- >
183
- Cancel
184
- </button>
185
- <button className={styles.applyButton} onClick={handleApply}>
186
- Apply
187
- </button>
188
- </div>
189
- </div>
190
- </div>
191
- )}
192
- </div>
193
- );
194
- };
195
-
196
- export default AdvancedFilters;
1
+ 'use client';
2
+
3
+ import React, { useEffect, useRef, useState } from 'react';
4
+ import { X, Filter } from 'lucide-react';
5
+ import type { FilterConfig, AppliedFilter } from './tools/filterTypes';
6
+ import { useFilters } from './hooks/useFilters';
7
+ import FilterRenderer from './filters/FilterRenderer';
8
+ import styles from './TableauDynamique.module.css';
9
+
10
+ interface AdvancedFiltersProps {
11
+ filters: FilterConfig[];
12
+ externalFilters?: AppliedFilter[];
13
+ onFiltersChange?: (filters: AppliedFilter[]) => void;
14
+ onApply?: (filters: AppliedFilter[]) => void;
15
+ isControlled?: boolean;
16
+ debounceTimeout?: number;
17
+ resultsCount?: number;
18
+ expanded?: boolean;
19
+ onToggle?: (expanded: boolean) => void;
20
+ panelPlacement?: 'overlay' | 'top';
21
+ onPanelHeightChange?: (height: number) => void;
22
+ }
23
+
24
+ const AdvancedFilters: React.FC<AdvancedFiltersProps> = ({
25
+ filters,
26
+ externalFilters = [],
27
+ onFiltersChange,
28
+ onApply,
29
+ isControlled = false,
30
+ debounceTimeout = 300,
31
+ resultsCount = 0,
32
+ expanded,
33
+ onToggle,
34
+ panelPlacement = 'top',
35
+ onPanelHeightChange,
36
+ }) => {
37
+ const [localExpanded, setLocalExpanded] = useState(false);
38
+ const isExpanded = typeof expanded === 'boolean' ? expanded : localExpanded;
39
+
40
+ const { appliedFilters, tempFilters, updateFilter, applyFilters, clearAllFilters } = useFilters({
41
+ filters,
42
+ externalFilters,
43
+ onFiltersChange,
44
+ onApply,
45
+ debounceTimeout,
46
+ isControlled,
47
+ });
48
+
49
+ const panelRef = useRef<HTMLDivElement | null>(null);
50
+ const wrapperRef = useRef<HTMLDivElement | null>(null);
51
+
52
+ useEffect(() => {
53
+ if (isExpanded && panelRef.current) {
54
+ const h = panelRef.current.getBoundingClientRect().height;
55
+ onPanelHeightChange?.(h);
56
+ } else {
57
+ onPanelHeightChange?.(0);
58
+ }
59
+ }, [isExpanded, filters, tempFilters, onPanelHeightChange]);
60
+
61
+ const toggle = () => {
62
+ if (typeof expanded === 'boolean') {
63
+ onToggle?.(!expanded);
64
+ } else {
65
+ setLocalExpanded((s) => {
66
+ const next = !s;
67
+ onToggle?.(next);
68
+ return next;
69
+ });
70
+ }
71
+ };
72
+
73
+ const handleApply = async () => {
74
+ await applyFilters();
75
+ onToggle?.(false);
76
+ if (typeof expanded !== 'boolean') setLocalExpanded(false);
77
+ };
78
+
79
+ useEffect(() => {
80
+ const onPointerDown = (e: PointerEvent) => {
81
+ if (!isExpanded) return;
82
+ if (!wrapperRef.current) return;
83
+ if (!wrapperRef.current.contains(e.target as Node)) {
84
+ onToggle?.(false);
85
+ if (typeof expanded !== 'boolean') setLocalExpanded(false);
86
+ }
87
+ };
88
+
89
+ const onKey = (e: KeyboardEvent) => {
90
+ if (e.key === 'Escape' && isExpanded) {
91
+ onToggle?.(false);
92
+ if (typeof expanded !== 'boolean') setLocalExpanded(false);
93
+ }
94
+ };
95
+
96
+ if (isExpanded) {
97
+ document.addEventListener('pointerdown', onPointerDown);
98
+ document.addEventListener('keydown', onKey);
99
+ }
100
+
101
+ return () => {
102
+ document.removeEventListener('pointerdown', onPointerDown);
103
+ document.removeEventListener('keydown', onKey);
104
+ };
105
+ }, [isExpanded, expanded, onToggle]);
106
+
107
+ return (
108
+ <div className={styles.advancedFiltersContainer} ref={wrapperRef}>
109
+ <div className={styles.filtersHeader}>
110
+ <button
111
+ className={styles.toggleFiltersButton}
112
+ onClick={toggle}
113
+ aria-expanded={isExpanded}
114
+ aria-controls='advanced-filters-panel'
115
+ >
116
+ <Filter size={14} />
117
+ <span className={styles.buttonTextCompact}>Advanced-Filters</span>
118
+ </button>
119
+
120
+ {appliedFilters.length > 0 && (
121
+ <button className={styles.clearFiltersButton} onClick={clearAllFilters}>
122
+ <X size={14} /> <span className={styles.buttonTextCompact}>Effacer</span>
123
+ </button>
124
+ )}
125
+ </div>
126
+
127
+ {isExpanded && (
128
+ <div
129
+ id='advanced-filters-panel'
130
+ ref={panelRef}
131
+ className={`${styles.filtersPanel} ${
132
+ panelPlacement === 'top'
133
+ ? `${styles.filtersPanelInline} ${styles.filtersPanelHorizontal}`
134
+ : ''
135
+ }`}
136
+ role='region'
137
+ aria-label='Panneau de filtres avancés'
138
+ >
139
+ <div className={styles.filtersRow}>
140
+ {filters.map((filter) => (
141
+ <div key={filter.id} className={`${styles.filterItem} ${styles.filterItemInline}`}>
142
+ <label className={styles.filterLabel}>
143
+ {filter.label}
144
+ {filter.required && <span className={styles.required}>*</span>}
145
+ </label>
146
+ <FilterRenderer
147
+ config={filter}
148
+ value={tempFilters[filter.id]}
149
+ onChange={(value) => updateFilter(filter.id, value)}
150
+ disabled={filter.disabled}
151
+ />
152
+ </div>
153
+ ))}
154
+ </div>
155
+
156
+ <div className={styles.filtersActionsHorizontal}>
157
+ <div className={styles.activeFiltersWrap}>
158
+ {appliedFilters.length > 0 && (
159
+ <div className={styles.activeFilters}>
160
+ <span className={styles.activeLabelCompact}>Actifs :</span>
161
+ {appliedFilters.map((f) => (
162
+ <div key={f.id} className={styles.activeFilterTag}>
163
+ {f.label ?? f.id}
164
+ <button
165
+ onClick={() => updateFilter(f.id, undefined)}
166
+ aria-label={`Supprimer ${f.id}`}
167
+ >
168
+ ×
169
+ </button>
170
+ </div>
171
+ ))}
172
+ </div>
173
+ )}
174
+ </div>
175
+
176
+ <div className={styles.actionsGroup}>
177
+ <button
178
+ className={styles.cancelButton}
179
+ onClick={() => {
180
+ onToggle?.(false);
181
+ }}
182
+ >
183
+ Cancel
184
+ </button>
185
+ <button className={styles.applyButton} onClick={handleApply}>
186
+ Apply
187
+ </button>
188
+ </div>
189
+ </div>
190
+ </div>
191
+ )}
192
+ </div>
193
+ );
194
+ };
195
+
196
+ export default AdvancedFilters;