kelt-ui-kit-react 1.7.8 → 1.7.9

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 CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "kelt-ui-kit-react",
3
3
  "type": "module",
4
- "version": "1.7.8",
4
+ "version": "1.7.9",
5
5
  "private": false,
6
6
  "main": "dist/index.js",
7
7
  "types": "dist/index.d.ts",
@@ -29,6 +29,8 @@ export const Sidebar = ({
29
29
  const [isOpen, setIsOpen] = useState(open || false);
30
30
  const sidebarRef = useRef<HTMLDivElement | null>(null);
31
31
  const rootRef = useRef<HTMLDivElement | null>(null);
32
+ const touchStartX = useRef(0);
33
+ const touchStartY = useRef(0);
32
34
 
33
35
  // Créer le conteneur une seule fois
34
36
  useEffect(() => {
@@ -69,7 +71,29 @@ export const Sidebar = ({
69
71
  toggleSidebar();
70
72
  }
71
73
  },
72
- [toggleSidebar, closeOnClickOutside]
74
+ [toggleSidebar, closeOnClickOutside],
75
+ );
76
+
77
+ const handleTouchStart = useCallback((event: React.TouchEvent) => {
78
+ const touch = event.touches[0];
79
+ touchStartX.current = touch.clientX;
80
+ touchStartY.current = touch.clientY;
81
+ }, []);
82
+
83
+ const handleTouchEnd = useCallback(
84
+ (event: React.TouchEvent) => {
85
+ if (!isOpen) return;
86
+
87
+ const touch = event.changedTouches[0];
88
+ const deltaX = touch.clientX - touchStartX.current;
89
+ const deltaY = Math.abs(touch.clientY - touchStartY.current);
90
+
91
+ // Ferme seulement sur un vrai swipe horizontal gauche -> droite.
92
+ if (deltaX > 60 && deltaY < 40) {
93
+ toggleSidebar();
94
+ }
95
+ },
96
+ [isOpen, toggleSidebar],
73
97
  );
74
98
 
75
99
  useEffect(() => {
@@ -95,6 +119,8 @@ export const Sidebar = ({
95
119
  ref={sidebarRef}
96
120
  style={width ? { width: width } : {}}
97
121
  className={`sidebar ${isOpen ? "open" : "closed"} ${className ?? ""}`}
122
+ onTouchStart={handleTouchStart}
123
+ onTouchEnd={handleTouchEnd}
98
124
  >
99
125
  <div className="sidebar-header">
100
126
  {title && <h2 className="flex-1">{title}</h2>}
@@ -106,6 +132,6 @@ export const Sidebar = ({
106
132
  {children && children}
107
133
  </div>
108
134
  </>,
109
- rootRef.current
135
+ rootRef.current,
110
136
  );
111
137
  };