@tsiky/components-r19 1.0.0 → 1.1.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 (32) hide show
  1. package/index.ts +35 -33
  2. package/package.json +1 -1
  3. package/src/components/Charts/area-chart-admission/AreaChartAdmission.tsx +123 -89
  4. package/src/components/Charts/bar-chart/BarChart.tsx +167 -132
  5. package/src/components/Charts/mixed-chart/MixedChart.tsx +65 -9
  6. package/src/components/Charts/sankey-chart/SankeyChart.tsx +183 -155
  7. package/src/components/Confirmationpopup/ConfirmationPopup.module.css +88 -0
  8. package/src/components/Confirmationpopup/ConfirmationPopup.stories.tsx +94 -0
  9. package/src/components/Confirmationpopup/ConfirmationPopup.tsx +47 -0
  10. package/src/components/Confirmationpopup/index.ts +6 -0
  11. package/src/components/Confirmationpopup/useConfirmationPopup.ts +48 -0
  12. package/src/components/DayStatCard/DayStatCard.tsx +96 -69
  13. package/src/components/DynamicTable/AdvancedFilters.tsx +196 -196
  14. package/src/components/DynamicTable/ColumnSorter.tsx +185 -185
  15. package/src/components/DynamicTable/Pagination.tsx +115 -115
  16. package/src/components/DynamicTable/TableauDynamique.module.css +1287 -1287
  17. package/src/components/DynamicTable/filters/SelectFilter.tsx +69 -69
  18. package/src/components/EntryControl/EntryControl.tsx +117 -117
  19. package/src/components/Grid/Grid.tsx +5 -0
  20. package/src/components/Header/Header.tsx +4 -2
  21. package/src/components/Header/header.css +61 -31
  22. package/src/components/MetricsPanel/MetricsPanel.module.css +688 -636
  23. package/src/components/MetricsPanel/MetricsPanel.tsx +220 -282
  24. package/src/components/MetricsPanel/renderers/CompactRenderer.tsx +148 -125
  25. package/src/components/NavBar/NavBar.tsx +1 -1
  26. package/src/components/SelectFilter/SelectFilter.module.css +249 -0
  27. package/src/components/SelectFilter/SelectFilter.stories.tsx +321 -0
  28. package/src/components/SelectFilter/SelectFilter.tsx +219 -0
  29. package/src/components/SelectFilter/index.ts +2 -0
  30. package/src/components/SelectFilter/types.ts +19 -0
  31. package/src/components/TranslationKey/TranslationKey.tsx +265 -245
  32. package/src/components/TrendList/TrendList.tsx +72 -45
@@ -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,117 +1,117 @@
1
- 'use client';
2
- import React, { useEffect, useRef, useState } from 'react';
3
- import styles from './EntryControl.module.css';
4
-
5
- export interface EntryControlProps {
6
- onDateChange?: (isoString: string) => void;
7
- onSearch?: (query: string) => void;
8
- initialDate?: string;
9
- }
10
-
11
- export default function EntryControl({ onDateChange, onSearch, initialDate }: EntryControlProps) {
12
- const [showPicker, setShowPicker] = useState<boolean>(false);
13
- const [datetime, setDatetime] = useState<string>(initialDate ?? '');
14
- const containerRef = useRef<HTMLDivElement | null>(null);
15
-
16
- useEffect(() => {
17
- function handleClickOutside(e: MouseEvent) {
18
- const target = e.target as Node | null;
19
- if (containerRef.current && target && !containerRef.current.contains(target)) {
20
- setShowPicker(false);
21
- }
22
- }
23
-
24
- document.addEventListener('mousedown', handleClickOutside);
25
- return () => document.removeEventListener('mousedown', handleClickOutside);
26
- }, []);
27
-
28
- useEffect(() => {
29
- if (initialDate) setDatetime(initialDate);
30
- }, [initialDate]);
31
-
32
- const handleToggle = () => setShowPicker((v) => !v);
33
-
34
- const handleDateChange = (e: React.ChangeEvent<HTMLInputElement>) => {
35
- const v = e.target.value;
36
- setDatetime(v);
37
- onDateChange?.(v);
38
- };
39
-
40
- const handleSearch = (e: React.ChangeEvent<HTMLInputElement>) => {
41
- onSearch?.(e.target.value);
42
- };
43
-
44
- return (
45
- <div className={styles.wrapper} ref={containerRef}>
46
- <div className={styles.leftGroup}>
47
- <button
48
- type='button'
49
- className={`${styles.filterButton} ${showPicker ? styles.open : ''}`}
50
- onClick={handleToggle}
51
- aria-expanded={showPicker}
52
- aria-haspopup='dialog'
53
- aria-controls='entry-datetime'
54
- >
55
- <span>Entry time</span>
56
- <svg
57
- className={styles.filterIcon}
58
- xmlns='http://www.w3.org/2000/svg'
59
- viewBox='0 0 24 24'
60
- width='14'
61
- height='14'
62
- aria-hidden
63
- >
64
- <path fill='currentColor' d='M10 18h4v-2h-4v2zm-7-8v2h18V10H3zm3-6v2h12V4H6z' />
65
- </svg>
66
- </button>
67
-
68
- <div className={styles.infoText}>Confidence interval: step ± 15' / exit ± 30'</div>
69
-
70
- {/* pickerContainer est maintenant inline sur grands écrans, absolute sur petits */}
71
- {showPicker && (
72
- <div
73
- className={styles.pickerContainer}
74
- role='dialog'
75
- aria-label='Choisir la date et l’heure'
76
- >
77
- <label className={styles.pickerLabel} htmlFor='entry-datetime'>
78
- <span className={styles.srOnly}>Choisir la date et l’heure</span>
79
- </label>
80
- <input
81
- id='entry-datetime'
82
- className={styles.datetime}
83
- type='datetime-local'
84
- value={datetime}
85
- onChange={handleDateChange}
86
- aria-label='Date et heure d’entrée'
87
- />
88
- </div>
89
- )}
90
- </div>
91
-
92
- <div className={styles.rightGroup}>
93
- <div className={styles.searchInputWrap}>
94
- <input
95
- className={styles.searchInput}
96
- placeholder='Search...'
97
- onChange={handleSearch}
98
- aria-label='Search'
99
- />
100
- <svg
101
- className={styles.searchIcon}
102
- xmlns='http://www.w3.org/2000/svg'
103
- viewBox='0 0 24 24'
104
- width='16'
105
- height='16'
106
- aria-hidden
107
- >
108
- <path
109
- fill='currentColor'
110
- d='M15.5 14h-.79l-.28-.27A6.471 6.471 0 0016 9.5 6.5 6.5 0 109.5 16a6.471 6.471 0 004.23-1.57l.27.28v.79L20 20.49 21.49 19l-5.99-5zM10 15.5A5.5 5.5 0 1115.5 10 5.5 5.5 0 0110 15.5z'
111
- />
112
- </svg>
113
- </div>
114
- </div>
115
- </div>
116
- );
117
- }
1
+ 'use client';
2
+ import React, { useEffect, useRef, useState } from 'react';
3
+ import styles from './EntryControl.module.css';
4
+
5
+ export interface EntryControlProps {
6
+ onDateChange?: (isoString: string) => void;
7
+ onSearch?: (query: string) => void;
8
+ initialDate?: string;
9
+ }
10
+
11
+ export default function EntryControl({ onDateChange, onSearch, initialDate }: EntryControlProps) {
12
+ const [showPicker, setShowPicker] = useState<boolean>(false);
13
+ const [datetime, setDatetime] = useState<string>(initialDate ?? '');
14
+ const containerRef = useRef<HTMLDivElement | null>(null);
15
+
16
+ useEffect(() => {
17
+ function handleClickOutside(e: MouseEvent) {
18
+ const target = e.target as Node | null;
19
+ if (containerRef.current && target && !containerRef.current.contains(target)) {
20
+ setShowPicker(false);
21
+ }
22
+ }
23
+
24
+ document.addEventListener('mousedown', handleClickOutside);
25
+ return () => document.removeEventListener('mousedown', handleClickOutside);
26
+ }, []);
27
+
28
+ useEffect(() => {
29
+ if (initialDate) setDatetime(initialDate);
30
+ }, [initialDate]);
31
+
32
+ const handleToggle = () => setShowPicker((v) => !v);
33
+
34
+ const handleDateChange = (e: React.ChangeEvent<HTMLInputElement>) => {
35
+ const v = e.target.value;
36
+ setDatetime(v);
37
+ onDateChange?.(v);
38
+ };
39
+
40
+ const handleSearch = (e: React.ChangeEvent<HTMLInputElement>) => {
41
+ onSearch?.(e.target.value);
42
+ };
43
+
44
+ return (
45
+ <div className={styles.wrapper} ref={containerRef}>
46
+ <div className={styles.leftGroup}>
47
+ <button
48
+ type='button'
49
+ className={`${styles.filterButton} ${showPicker ? styles.open : ''}`}
50
+ onClick={handleToggle}
51
+ aria-expanded={showPicker}
52
+ aria-haspopup='dialog'
53
+ aria-controls='entry-datetime'
54
+ >
55
+ <span>Entry time</span>
56
+ <svg
57
+ className={styles.filterIcon}
58
+ xmlns='http://www.w3.org/2000/svg'
59
+ viewBox='0 0 24 24'
60
+ width='14'
61
+ height='14'
62
+ aria-hidden
63
+ >
64
+ <path fill='currentColor' d='M10 18h4v-2h-4v2zm-7-8v2h18V10H3zm3-6v2h12V4H6z' />
65
+ </svg>
66
+ </button>
67
+
68
+ <div className={styles.infoText}>Confidence interval: step ± 15' / exit ± 30'</div>
69
+
70
+ {/* pickerContainer est maintenant inline sur grands écrans, absolute sur petits */}
71
+ {showPicker && (
72
+ <div
73
+ className={styles.pickerContainer}
74
+ role='dialog'
75
+ aria-label='Choisir la date et l’heure'
76
+ >
77
+ <label className={styles.pickerLabel} htmlFor='entry-datetime'>
78
+ <span className={styles.srOnly}>Choisir la date et l’heure</span>
79
+ </label>
80
+ <input
81
+ id='entry-datetime'
82
+ className={styles.datetime}
83
+ type='datetime-local'
84
+ value={datetime}
85
+ onChange={handleDateChange}
86
+ aria-label='Date et heure d’entrée'
87
+ />
88
+ </div>
89
+ )}
90
+ </div>
91
+
92
+ <div className={styles.rightGroup}>
93
+ <div className={styles.searchInputWrap}>
94
+ <input
95
+ className={styles.searchInput}
96
+ placeholder='Search...'
97
+ onChange={handleSearch}
98
+ aria-label='Search'
99
+ />
100
+ <svg
101
+ className={styles.searchIcon}
102
+ xmlns='http://www.w3.org/2000/svg'
103
+ viewBox='0 0 24 24'
104
+ width='16'
105
+ height='16'
106
+ aria-hidden
107
+ >
108
+ <path
109
+ fill='currentColor'
110
+ d='M15.5 14h-.79l-.28-.27A6.471 6.471 0 0016 9.5 6.5 6.5 0 109.5 16a6.471 6.471 0 004.23-1.57l.27.28v.79L20 20.49 21.49 19l-5.99-5zM10 15.5A5.5 5.5 0 1115.5 10 5.5 5.5 0 0110 15.5z'
111
+ />
112
+ </svg>
113
+ </div>
114
+ </div>
115
+ </div>
116
+ );
117
+ }
@@ -94,6 +94,7 @@ const Grid: React.FC<GridProps> = ({
94
94
  const handleDragStart = (e: React.DragEvent<HTMLDivElement>, index: number) => {
95
95
  e.stopPropagation();
96
96
  e.dataTransfer.setData('dragIndex', index.toString());
97
+ e.dataTransfer.setData('parentKey', uniqueKey.toString());
97
98
  };
98
99
 
99
100
  const handleDragOver = (e: React.DragEvent<HTMLDivElement>) => {
@@ -104,6 +105,10 @@ const Grid: React.FC<GridProps> = ({
104
105
  const handleDrop = (e: React.DragEvent<HTMLDivElement>, dropIndex: number) => {
105
106
  e.preventDefault();
106
107
  const dragIndex = Number(e.dataTransfer.getData('dragIndex'));
108
+ const dragParent = Number(e.dataTransfer.getData('parentKey'));
109
+ if (container && dragParent !== uniqueKey) {
110
+ return;
111
+ }
107
112
  const updatedItems = [...items];
108
113
 
109
114
  let dropInd = -1;
@@ -46,8 +46,10 @@ export const Header: React.FC<HeaderProps> = ({
46
46
 
47
47
  {/* Droite : menu */}
48
48
  <div className='header-right'>
49
- <DraggableSwitcherButton />
50
- <ThemeSwitcherButton />
49
+ <div className='switcher'>
50
+ <DraggableSwitcherButton />
51
+ <ThemeSwitcherButton />
52
+ </div>
51
53
  <DropdownMenu
52
54
  categories={dropdownItems?.categories}
53
55
  buttonContent={dropdownItems?.buttonContent}
@@ -1,31 +1,61 @@
1
- .header {
2
- background: var(--headerBg);
3
- border-bottom: 1px solid rgba(0, 0, 0, 0.06);
4
- box-shadow: 0 1px 0 rgba(0, 0, 0, 0.04);
5
- max-width: 100vw;
6
- font-size: var(--text-small);
7
- }
8
-
9
- /* container centré */
10
- .header-container {
11
- margin: 0 auto;
12
- display: flex;
13
- align-items: center;
14
- justify-content: space-between;
15
- padding: 15px 17px;
16
- gap: 20px;
17
- }
18
-
19
- /* gauche : logo + nav */
20
- .header-left {
21
- display: flex;
22
- align-items: center;
23
- gap: 22px;
24
- }
25
-
26
- /* droite : menu bouton */
27
- .header-right {
28
- display: flex;
29
- align-items: center;
30
- gap: 12px;
31
- }
1
+ .header {
2
+ background: var(--headerBg);
3
+ border-bottom: 1px solid rgba(0, 0, 0, 0.06);
4
+ box-shadow: 0 1px 0 rgba(0, 0, 0, 0.04);
5
+ max-width: 100vw;
6
+ font-size: var(--text-small);
7
+ }
8
+
9
+ /* container centré */
10
+ .header-container {
11
+ margin: 0 auto;
12
+ display: flex;
13
+ align-items: center;
14
+ justify-content: space-between;
15
+ padding: 15px 17px;
16
+ gap: 20px;
17
+ }
18
+
19
+ /* gauche : logo + nav */
20
+ .header-left {
21
+ display: flex;
22
+ align-items: center;
23
+ gap: 22px;
24
+ }
25
+
26
+ /* droite : menu bouton */
27
+ .header-right {
28
+ display: flex;
29
+ align-items: center;
30
+ gap: 12px;
31
+ }
32
+
33
+ .switcher {
34
+ display: flex;
35
+ align-items: center;
36
+ }
37
+
38
+ @media (max-width: 500px) {
39
+ .switcher {
40
+ display: flex;
41
+ flex-direction: column;
42
+ align-items: center;
43
+ justify-content: center;
44
+ gap: 0.2025rem;
45
+ }
46
+
47
+ .switcher {
48
+ animation: slideDown 0.4s ease;
49
+ }
50
+
51
+ @keyframes slideDown {
52
+ from {
53
+ transform: translateY(-15px);
54
+ opacity: 0;
55
+ }
56
+ to {
57
+ transform: translateY(0);
58
+ opacity: 1;
59
+ }
60
+ }
61
+ }