kelt-ui-kit-react 1.8.2 → 1.8.3

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 (245) hide show
  1. package/.github/workflows/publish.yml +31 -0
  2. package/dist/_core/type/generiqueType.d.ts +4 -0
  3. package/dist/badge/Badge.d.ts +3 -1
  4. package/dist/button/button.interface.d.ts +1 -1
  5. package/dist/dataTable/DataTable.d.ts +17 -3
  6. package/dist/dataTable/dataTable.interface.d.ts +21 -3
  7. package/dist/dataTable/dataTableActions/DataTableAction.d.ts +2 -2
  8. package/dist/dataTable/dataTableColumn/DataTableColumn.d.ts +13 -7
  9. package/dist/dataTable/dataTableColumn/dataTableColumnFilter/DataTableColumnFilter.d.ts +10 -0
  10. package/dist/dataTable/dataTableColumn/dataTableColumnFilter/dataTableColumnFilterDate/DataTableColumnFilterDate.d.ts +9 -0
  11. package/dist/dataTable/dataTableColumn/dataTableColumnFilter/dataTableColumnFilterDateRange/dataTableColumnFilterDateRange.d.ts +9 -0
  12. package/dist/dataTable/dataTableColumn/dataTableColumnFilter/dataTableColumnFilterEnum/DataTableColumnFilterEnum.d.ts +13 -0
  13. package/dist/dataTable/dataTableColumn/dataTableColumnFilter/dataTableColumnFilterString/DataTableColumnFilterString.d.ts +9 -0
  14. package/dist/dataTable/dataTableColumn/dataTableColumnSort/DataTableColumnSort.d.ts +11 -0
  15. package/dist/dataTable/dataTableFilters/DataTableFilters.d.ts +7 -0
  16. package/dist/dataTable/dataTableLoading/DataTableLoading.d.ts +1 -3
  17. package/dist/dataTable/dataTableRow/DataTableRow.d.ts +5 -3
  18. package/dist/dataTable/dataTableRow/dataTableRowOverlay/DataTableRowOverlay.d.ts +12 -0
  19. package/dist/dataTable/dataTableRow/dataTableRowValue/DataTableRowValue.d.ts +11 -0
  20. package/dist/expands/expand/expand.d.ts +1 -1
  21. package/dist/form/form.enum.d.ts +1 -0
  22. package/dist/form/input/Input.d.ts +3 -0
  23. package/dist/form/inputNumber/InputNumber.d.ts +0 -2
  24. package/dist/icon/Icon.d.ts +1 -1
  25. package/dist/icon/icon.interface.d.ts +1 -0
  26. package/dist/index.d.ts +1 -0
  27. package/dist/index.js +3652 -2836
  28. package/dist/overlayPanel/OverlayPanel.d.ts +3 -1
  29. package/dist/select/Select.d.ts +4 -1
  30. package/dist/select/selectOption.interface.d.ts +1 -0
  31. package/dist/style.css +1 -1
  32. package/dist/tabs/Tabs.d.ts +2 -1
  33. package/kelt-ui-kit-react-1.6.9.tgz +0 -0
  34. package/package/README.md +46 -0
  35. package/package/index.html +20 -0
  36. package/package/package.json +56 -0
  37. package/package/public/favicon.ico +0 -0
  38. package/package/public/index.html +18 -0
  39. package/package/public/logo192.png +0 -0
  40. package/package/public/logo512.png +0 -0
  41. package/package/public/manifest.json +25 -0
  42. package/package/public/robots.txt +3 -0
  43. package/package/src/App.css +11 -0
  44. package/package/src/App.menu.tsx +249 -0
  45. package/package/src/App.routes.tsx +16 -0
  46. package/package/src/App.tsx +30 -0
  47. package/package/src/_core/hooks/HistoryProvider.tsx +25 -0
  48. package/package/src/_core/hooks/ImageChecker.tsx +26 -0
  49. package/package/src/_core/hooks/imageExist.tsx +9 -0
  50. package/package/src/_core/hooks/isEAN13.tsx +16 -0
  51. package/package/src/_core/hooks/objectToQueryParams.tsx +32 -0
  52. package/package/src/_core/hooks/useCurrency.tsx +18 -0
  53. package/package/src/_core/hooks/useDateutils.ts +64 -0
  54. package/package/src/_core/hooks/useIsMobile.ts +18 -0
  55. package/package/src/_core/hooks/useToken.tsx +19 -0
  56. package/package/src/_core/hooks/useValidate.tsx +18 -0
  57. package/package/src/_core/hooks/widgetSupport.tsx +39 -0
  58. package/package/src/action/Action.view.tsx +21 -0
  59. package/package/src/action/ButtonAction.tsx +32 -0
  60. package/package/src/action/action.css +20 -0
  61. package/package/src/badge/Badge.tsx +34 -0
  62. package/package/src/badge/Badge.view.tsx +15 -0
  63. package/package/src/badge/badge.css +55 -0
  64. package/package/src/button/Button.tsx +46 -0
  65. package/package/src/button/Button.view.tsx +85 -0
  66. package/package/src/button/button.css +53 -0
  67. package/package/src/button/button.interface.tsx +21 -0
  68. package/package/src/button/buttonActions/ButtonActions.tsx +104 -0
  69. package/package/src/button/buttonFile/ButtonFile.tsx +59 -0
  70. package/package/src/button/buttonFile/ButtonFile.view.tsx +70 -0
  71. package/package/src/button/buttonFilters/ButtonFilters.tsx +102 -0
  72. package/package/src/button/buttonFilters/buttonFilters.css +22 -0
  73. package/package/src/card/Card.tsx +125 -0
  74. package/package/src/card/Card.view.tsx +73 -0
  75. package/package/src/card/card.css +145 -0
  76. package/package/src/card/card.interface.tsx +9 -0
  77. package/package/src/card/cardAction/CardAction.tsx +135 -0
  78. package/package/src/card/cardAction/cardAction.css +10 -0
  79. package/package/src/card/cardAction.interface.tsx +10 -0
  80. package/package/src/card/hook/useCardInteractions.tsx +30 -0
  81. package/package/src/carousel/Carousel.css +44 -0
  82. package/package/src/carousel/Carousel.tsx +115 -0
  83. package/package/src/carousel/Carousel.view.tsx +13 -0
  84. package/package/src/damier/Damier.tsx +64 -0
  85. package/package/src/damier/Damier.view.tsx +31 -0
  86. package/package/src/damier/damier.css +50 -0
  87. package/package/src/damier/damierCell/DamierCell.tsx +18 -0
  88. package/package/src/damier/damierCell/damierCell.interface.tsx +5 -0
  89. package/package/src/dataTable/DataTable.tsx +259 -0
  90. package/package/src/dataTable/DataTable.view.tsx +62 -0
  91. package/package/src/dataTable/dataTable.css +30 -0
  92. package/package/src/dataTable/dataTable.interface.ts +30 -0
  93. package/package/src/dataTable/dataTableActions/DataTableAction.tsx +44 -0
  94. package/package/src/dataTable/dataTableColumn/DataTableColumn.tsx +27 -0
  95. package/package/src/dataTable/dataTableLoading/DataTableLoading.tsx +21 -0
  96. package/package/src/dataTable/dataTableRow/DataTableRow.tsx +54 -0
  97. package/package/src/datePicker/DatePicker.tsx +110 -0
  98. package/package/src/datePicker/DatePicker.view.tsx +9 -0
  99. package/package/src/datePicker/datePicker.css +77 -0
  100. package/package/src/expands/Expands.tsx +42 -0
  101. package/package/src/expands/Expands.view.tsx +90 -0
  102. package/package/src/expands/expand/expand.interface.tsx +8 -0
  103. package/package/src/expands/expand/expand.tsx +75 -0
  104. package/package/src/expands/expands.css +97 -0
  105. package/package/src/filAriane/FilAriane.tsx +57 -0
  106. package/package/src/filAriane/FilAriane.view.tsx +28 -0
  107. package/package/src/filAriane/filAriane.css +23 -0
  108. package/package/src/filAriane/filAriane.interface.tsx +6 -0
  109. package/package/src/form/Form.tsx +279 -0
  110. package/package/src/form/Form.view.tsx +59 -0
  111. package/package/src/form/form.css +62 -0
  112. package/package/src/form/form.enum.ts +13 -0
  113. package/package/src/form/form.interface.tsx +37 -0
  114. package/package/src/form/input/Input.tsx +106 -0
  115. package/package/src/form/input/input.css +26 -0
  116. package/package/src/form/inputNumber/InputNumber.tsx +132 -0
  117. package/package/src/form/inputNumber/InputNumber.view.tsx +15 -0
  118. package/package/src/form/inputPrice/InputPrice.tsx +42 -0
  119. package/package/src/form/inputPrice/InputPrice.view.tsx +15 -0
  120. package/package/src/form/textArea/TextArea.tsx +59 -0
  121. package/package/src/form/textArea/TextArea.view.tsx +34 -0
  122. package/package/src/form/textArea/textArea.css +9 -0
  123. package/package/src/grid/Grid.tsx +21 -0
  124. package/package/src/grid/Grid.view.tsx +24 -0
  125. package/package/src/grid/col/Col.tsx +15 -0
  126. package/package/src/grid/col/colStyled/ColStyled.tsx +41 -0
  127. package/package/src/grid/container/Container.tsx +8 -0
  128. package/package/src/grid/container/container.css +5 -0
  129. package/package/src/grid/grid.interface.tsx +7 -0
  130. package/package/src/grid/row/Row.tsx +12 -0
  131. package/package/src/grid/row/row.css +18 -0
  132. package/package/src/header/Header.tsx +62 -0
  133. package/package/src/header/Header.view.tsx +5 -0
  134. package/package/src/header/header.css +26 -0
  135. package/package/src/header/header.interface.tsx +10 -0
  136. package/package/src/home/Home.tsx +3 -0
  137. package/package/src/icon/Icon.tsx +6 -0
  138. package/package/src/icon/Icons.view.tsx +29 -0
  139. package/package/src/icon/icon.css +20 -0
  140. package/package/src/icon/icon.interface.tsx +6 -0
  141. package/package/src/icon/iconSize.enum.ts +7 -0
  142. package/package/src/index.css +502 -0
  143. package/package/src/index.ts +58 -0
  144. package/package/src/loader/Loader.tsx +37 -0
  145. package/package/src/loader/Loader.view.tsx +20 -0
  146. package/package/src/loader/loader.css +30 -0
  147. package/package/src/logo.svg +1 -0
  148. package/package/src/main.tsx +10 -0
  149. package/package/src/menus/Menus.tsx +42 -0
  150. package/package/src/menus/Menus.view.tsx +39 -0
  151. package/package/src/menus/menu/Menu.tsx +17 -0
  152. package/package/src/menus/menu/menu.interface.tsx +9 -0
  153. package/package/src/menus/menus.css +47 -0
  154. package/package/src/message/Message.tsx +30 -0
  155. package/package/src/message/Message.view.tsx +22 -0
  156. package/package/src/message/message.css +29 -0
  157. package/package/src/modal/Modal.tsx +59 -0
  158. package/package/src/modal/Modal.view.tsx +26 -0
  159. package/package/src/modal/modal.css +71 -0
  160. package/package/src/notFound/NotFound.tsx +3 -0
  161. package/package/src/overlayPanel/OverlayPanel.tsx +195 -0
  162. package/package/src/overlayPanel/OverlayPanel.view.tsx +25 -0
  163. package/package/src/overlayPanel/overlay.context.tsx +28 -0
  164. package/package/src/overlayPanel/overlayPanel.css +35 -0
  165. package/package/src/overlayPanel/overlayPanelStyled/OverlayPanelStyled.tsx +18 -0
  166. package/package/src/pdfViewer/PdfViewer.tsx +73 -0
  167. package/package/src/pdfViewer/PdfViewer.view.tsx +5 -0
  168. package/package/src/quantity/Quantity.tsx +103 -0
  169. package/package/src/quantity/Quantity.view.tsx +0 -0
  170. package/package/src/quantity/quantity.css +26 -0
  171. package/package/src/search/Search.tsx +161 -0
  172. package/package/src/search/Search.view.tsx +14 -0
  173. package/package/src/search/search.css +59 -0
  174. package/package/src/select/Select.tsx +103 -0
  175. package/package/src/select/Select.view.tsx +71 -0
  176. package/package/src/select/select.css +69 -0
  177. package/package/src/select/selectOption.interface.ts +4 -0
  178. package/package/src/sidebar/Sidebar.tsx +208 -0
  179. package/package/src/sidebar/Sidebar.view.tsx +17 -0
  180. package/package/src/sidebar/sidebar.css +104 -0
  181. package/package/src/sidebarData/SidebarData.tsx +19 -0
  182. package/package/src/sidebarData/SidebarData.view.tsx +19 -0
  183. package/package/src/sidebarData/sidebarData.css +27 -0
  184. package/package/src/tabs/Tabs.tsx +90 -0
  185. package/package/src/tabs/Tabs.view.tsx +20 -0
  186. package/package/src/tabs/tabs.css +24 -0
  187. package/package/src/toaster/Toaster.tsx +55 -0
  188. package/package/src/toaster/Toaster.view.tsx +24 -0
  189. package/package/src/toaster/store/useToasterStore.tsx +41 -0
  190. package/package/src/toaster/toaster.css +87 -0
  191. package/package/tsconfig.json +28 -0
  192. package/package/vite.config.ts +20 -0
  193. package/package/vite.config.ts.timestamp-1733262892554-a13dfef6e8a29.mjs +24 -0
  194. package/package/vite.config.ts.timestamp-1757847121745-e5a5bf54b81b.mjs +28 -0
  195. package/package/vite.config.ts.timestamp-1759742478362-4ac5c5a7db34b.mjs +28 -0
  196. package/package.json +1 -1
  197. package/src/_core/type/generiqueType.tsx +4 -0
  198. package/src/badge/Badge.tsx +9 -1
  199. package/src/badge/badge.css +4 -0
  200. package/src/button/Button.tsx +1 -1
  201. package/src/button/button.interface.tsx +1 -1
  202. package/src/card/card.css +23 -3
  203. package/src/card/cardAction/CardAction.tsx +4 -4
  204. package/src/dataTable/DataTable.tsx +670 -45
  205. package/src/dataTable/DataTable.view.tsx +47 -14
  206. package/src/dataTable/dataTable.css +153 -5
  207. package/src/dataTable/dataTable.interface.ts +21 -3
  208. package/src/dataTable/dataTableActions/DataTableAction.tsx +2 -2
  209. package/src/dataTable/dataTableColumn/DataTableColumn.tsx +64 -14
  210. package/src/dataTable/dataTableColumn/dataTableColumnFilter/DataTableColumnFilter.tsx +36 -0
  211. package/src/dataTable/dataTableColumn/dataTableColumnFilter/dataTableColumnFilter.css +0 -0
  212. package/src/dataTable/dataTableColumn/dataTableColumnFilter/dataTableColumnFilterDate/DataTableColumnFilterDate.tsx +39 -0
  213. package/src/dataTable/dataTableColumn/dataTableColumnFilter/dataTableColumnFilterDateRange/dataTableColumnFilterDateRange.tsx +80 -0
  214. package/src/dataTable/dataTableColumn/dataTableColumnFilter/dataTableColumnFilterEnum/DataTableColumnFilterEnum.tsx +89 -0
  215. package/src/dataTable/dataTableColumn/dataTableColumnFilter/dataTableColumnFilterString/DataTableColumnFilterString.tsx +37 -0
  216. package/src/dataTable/dataTableColumn/dataTableColumnSort/DataTableColumnSort.tsx +42 -0
  217. package/src/dataTable/dataTableFilters/DataTableFilters.tsx +91 -0
  218. package/src/dataTable/dataTableFilters/dataTableFilters.css +16 -0
  219. package/src/dataTable/dataTableLoading/DataTableLoading.tsx +4 -15
  220. package/src/dataTable/dataTableRow/DataTableRow.tsx +60 -33
  221. package/src/dataTable/dataTableRow/dataTableRowOverlay/DataTableRowOverlay.tsx +80 -0
  222. package/src/dataTable/dataTableRow/dataTableRowValue/DataTableRowValue.tsx +123 -0
  223. package/src/expands/Expands.tsx +2 -16
  224. package/src/expands/expand/expand.tsx +6 -18
  225. package/src/form/Form.tsx +13 -12
  226. package/src/form/form.css +13 -2
  227. package/src/form/form.enum.ts +1 -0
  228. package/src/form/input/Input.tsx +61 -7
  229. package/src/form/input/input.css +23 -1
  230. package/src/form/inputNumber/InputNumber.tsx +6 -11
  231. package/src/form/inputPrice/InputPrice.tsx +2 -4
  232. package/src/icon/Icon.tsx +6 -2
  233. package/src/icon/icon.interface.tsx +1 -0
  234. package/src/index.ts +2 -0
  235. package/src/overlayPanel/OverlayPanel.tsx +23 -10
  236. package/src/overlayPanel/overlay.context.tsx +6 -4
  237. package/src/overlayPanel/overlayPanel.css +10 -1
  238. package/src/select/Select.tsx +134 -38
  239. package/src/select/select.css +65 -14
  240. package/src/select/selectOption.interface.ts +1 -0
  241. package/src/sidebar/Sidebar.tsx +9 -80
  242. package/src/sidebar/sidebar.css +1 -18
  243. package/src/tabs/Tabs.tsx +19 -1
  244. package/vite.config.ts.timestamp-1757847121745-e5a5bf54b81b.mjs +28 -28
  245. package/vite.config.ts.timestamp-1759742478362-4ac5c5a7db34b.mjs +28 -28
@@ -0,0 +1,64 @@
1
+ export function FormatDate(date: Date, format: string): string {
2
+ const days = [
3
+ "Dimanche",
4
+ "Lundi",
5
+ "Mardi",
6
+ "Mercredi",
7
+ "Jeudi",
8
+ "Vendredi",
9
+ "Samedi",
10
+ ];
11
+ const months = [
12
+ "janvier",
13
+ "février",
14
+ "mars",
15
+ "avril",
16
+ "mai",
17
+ "juin",
18
+ "juillet",
19
+ "août",
20
+ "septembre",
21
+ "octobre",
22
+ "novembre",
23
+ "décembre",
24
+ ];
25
+
26
+ if (!date) return "";
27
+
28
+ const year = date.getFullYear().toString();
29
+ const month = String(date.getMonth() + 1).padStart(2, "0"); // Mois en chiffres
30
+ const day = String(date.getDate()).padStart(2, "0");
31
+ const hours = String(date.getHours()).padStart(2, "0");
32
+ const minutes = String(date.getMinutes()).padStart(2, "0");
33
+ const seconds = String(date.getSeconds()).padStart(2, "0");
34
+
35
+ const dayName = days[date.getDay()];
36
+ const monthName = months[date.getMonth()];
37
+
38
+ return format
39
+ .replace("dddd", dayName) // Remplace d'abord "dddd"
40
+ .replace("MMMM", monthName) // Puis "MMMM" pour éviter de modifier "MM"
41
+ .replace("YYYY", year)
42
+ .replace("MM", month) // Enfin, "MM" pour éviter d'écraser les valeurs de "MMMM"
43
+ .replace("DD", day)
44
+ .replace("HH", hours)
45
+ .replace("mm", minutes)
46
+ .replace("ss", seconds);
47
+ }
48
+ export function LocalDateStringToUTC(dateStr: string): string {
49
+ const [year, month, day] = dateStr.split("-").map(Number);
50
+
51
+ // Crée une date en heure locale
52
+ const localDate = new Date(year, month - 1, day, 0, 0, 0);
53
+
54
+ // Convertit en UTC ISO
55
+ return localDate.toISOString();
56
+ }
57
+ export function localDateStartToUTC(dateStr: string): Date {
58
+ const [y, m, d] = dateStr.split("-").map(Number);
59
+ return new Date(y, m - 1, d, 0, 0, 0, 0);
60
+ }
61
+ export function localDateEndToUTC(dateStr: string): Date {
62
+ const [y, m, d] = dateStr.split("-").map(Number);
63
+ return new Date(y, m - 1, d, 23, 59, 59, 999);
64
+ }
@@ -0,0 +1,18 @@
1
+ import { useEffect, useState } from "react";
2
+
3
+ export const useIsMobile = (maxWidth: number = 768) => {
4
+ const [isMobile, setIsMobile] = useState(
5
+ typeof window !== "undefined" ? window.innerWidth <= maxWidth : false
6
+ );
7
+
8
+ useEffect(() => {
9
+ const handleResize = () => {
10
+ setIsMobile(window.innerWidth <= maxWidth);
11
+ };
12
+
13
+ window.addEventListener("resize", handleResize);
14
+ return () => window.removeEventListener("resize", handleResize);
15
+ }, [maxWidth]);
16
+
17
+ return isMobile;
18
+ };
@@ -0,0 +1,19 @@
1
+ import { jwtDecode } from "jwt-decode";
2
+ import { useCallback } from "react";
3
+
4
+ export const useToken = () => {
5
+ const getTokenValidate = useCallback((): string | null => {
6
+ const token = localStorage.getItem("token");
7
+ if (!token) {
8
+ return null;
9
+ }
10
+ const decoded = jwtDecode(token);
11
+ const currentTime = Date.now() / 1000; // Convertir en secondes
12
+ if (!decoded.exp || decoded.exp < currentTime) {
13
+ return null;
14
+ }
15
+ return token;
16
+ }, []);
17
+
18
+ return { getTokenValidate };
19
+ };
@@ -0,0 +1,18 @@
1
+ export const useValidate = () => {
2
+ const isValidateEmail = (input: string): boolean => {
3
+ const emailRegex = /^[^\s@]+@[^\s@]+\.[^\s@]+$/;
4
+ return emailRegex.test(input);
5
+ };
6
+
7
+ const isValidateTel = (input: string): boolean => {
8
+ const emailRegex = /^\+?[0-9\s.-]{7,15}$/;
9
+ return emailRegex.test(input);
10
+ };
11
+
12
+ const isValidateCodePostal = (input: string): boolean => {
13
+ const emailRegex = /^[0-9]{5}$/;
14
+ return emailRegex.test(input);
15
+ };
16
+
17
+ return { isValidateEmail, isValidateTel, isValidateCodePostal };
18
+ };
@@ -0,0 +1,39 @@
1
+ import { useEffect, useRef } from "react";
2
+
3
+ export const WidgetSupport = () => {
4
+ const targetRef = useRef<HTMLDivElement>(null);
5
+ useEffect(() => {
6
+ if (!targetRef.current) return;
7
+ const script = document.createElement("script");
8
+ script.type = "text/javascript";
9
+ script.innerHTML = `
10
+ !function(e,t,n){
11
+ function a(){
12
+ var e = t.getElementsByTagName("script")[0],
13
+ n = t.createElement("script");
14
+ n.type = "text/javascript";
15
+ n.async = true;
16
+ n.src = "https://beacon-v2.helpscout.net";
17
+ e.parentNode.insertBefore(n,e);
18
+ }
19
+ if(e.Beacon = n = function(t,n,a){
20
+ e.Beacon.readyQueue.push({method: t, options: n, data: a});
21
+ }, n.readyQueue = [], t.readyState === "complete") return a();
22
+ e.attachEvent ? e.attachEvent("onload", a) : e.addEventListener("load", a, false);
23
+ }(window, document, window.Beacon || function(){});
24
+
25
+ window.Beacon('init', '5deebca7-9d32-4a66-abba-f94a05fa0522');
26
+ `;
27
+ targetRef.current.appendChild(script);
28
+
29
+ return () => {
30
+ targetRef?.current?.removeChild(script);
31
+ };
32
+ }, []);
33
+
34
+ return (
35
+ <div>
36
+ <div ref={targetRef} />
37
+ </div>
38
+ );
39
+ };
@@ -0,0 +1,21 @@
1
+ import { ButtonAction } from "./ButtonAction";
2
+
3
+ export const ActionView = (): JSX.Element => {
4
+ return (
5
+ <div className="d-flex">
6
+ <ButtonAction
7
+ className="mr-2"
8
+ onClick={() => console.log("Envoyer")}
9
+ title="Envoyer"
10
+ classIcon="bi-send"
11
+ badge={{
12
+ className: "badge--primary",
13
+ title: "Badge",
14
+ sizeIcon: undefined,
15
+ classIcon: "bi-check-circle",
16
+ onClick: () => console.log("Badge clicked"),
17
+ }}
18
+ />
19
+ </div>
20
+ );
21
+ };
@@ -0,0 +1,32 @@
1
+ import { Badge, BadgeInterface } from "../badge/Badge";
2
+ import { Icon } from "../icon/Icon";
3
+ import { IconSizeEnum } from "../icon/iconSize.enum";
4
+ import "./action.css";
5
+
6
+ export type ButtonActionProps = {
7
+ className?: string;
8
+ onClick?: (e: React.MouseEvent) => void;
9
+ title?: string;
10
+ classIcon?: string;
11
+ badge?: BadgeInterface;
12
+ };
13
+ export const ButtonAction = ({
14
+ className,
15
+ onClick,
16
+ title,
17
+ classIcon,
18
+ badge,
19
+ }: ButtonActionProps) => {
20
+ const handleClick = (e: React.MouseEvent) => {
21
+ if (onClick) {
22
+ onClick(e);
23
+ }
24
+ };
25
+ return (
26
+ <div className={`action ${className}`} onClick={handleClick}>
27
+ {badge && <Badge {...badge} />}
28
+ {classIcon && <Icon classIcon={classIcon} size={IconSizeEnum.LARGE} />}
29
+ <small>{title}</small>
30
+ </div>
31
+ );
32
+ };
@@ -0,0 +1,20 @@
1
+ .action {
2
+ background-color: var(--tertiary-color);
3
+ color: #fff;
4
+ position: relative;
5
+ display: flex;
6
+ align-items: center;
7
+ flex-direction: column;
8
+ justify-content: center;
9
+ padding: 0.5rem 0.5rem;
10
+ min-width: 120px;
11
+ text-align: center;
12
+ cursor: pointer;
13
+ border-radius: 4px;
14
+ height: 100%;
15
+ .badge {
16
+ position: absolute;
17
+ right: 10px;
18
+ top: -10px;
19
+ }
20
+ }
@@ -0,0 +1,34 @@
1
+ import { useCallback } from "react";
2
+ import { Icon } from "../icon/Icon";
3
+ import { IconSizeEnum } from "../icon/iconSize.enum";
4
+ import "./badge.css";
5
+ export type BadgeInterface = {
6
+ className?: string;
7
+ onClick?: (e: React.MouseEvent) => void;
8
+ title?: string;
9
+ sizeIcon?: IconSizeEnum;
10
+ classIcon?: string;
11
+ };
12
+ export const Badge = ({
13
+ className,
14
+ onClick,
15
+ title,
16
+ sizeIcon,
17
+ classIcon,
18
+ }: BadgeInterface) => {
19
+ const handleClick = useCallback((e: React.MouseEvent) => {
20
+ e.stopPropagation();
21
+ if (onClick) {
22
+ onClick(e);
23
+ }
24
+ }, []);
25
+ return (
26
+ <div
27
+ onClick={handleClick}
28
+ className={`badge ${className ? className : ""}`}
29
+ >
30
+ {classIcon && <Icon size={sizeIcon} classIcon={classIcon}></Icon>}
31
+ <span>{title}</span>
32
+ </div>
33
+ );
34
+ };
@@ -0,0 +1,15 @@
1
+ import { Badge } from "./Badge";
2
+
3
+ export const BadgeView = (): JSX.Element => {
4
+ return (
5
+ <>
6
+ <Badge
7
+ className="badge--primary"
8
+ title="Badge"
9
+ sizeIcon={undefined}
10
+ classIcon="bi-check-circle"
11
+ onClick={() => console.log("Badge clicked")}
12
+ />
13
+ </>
14
+ );
15
+ };
@@ -0,0 +1,55 @@
1
+ .badge {
2
+ display: flex;
3
+ align-items: center;
4
+ padding: 0.25em 0.4em;
5
+ font-size: 0.5rem;
6
+ font-weight: 700;
7
+ line-height: 1;
8
+ color: #fff;
9
+ width: fit-content;
10
+ text-transform: uppercase;
11
+ border-radius: 0.2rem;
12
+ background-color: #007bff;
13
+ border: 1px solid transparent;
14
+ .bi {
15
+ font-size: 0.8rem;
16
+ margin-right: 0.25rem;
17
+ }
18
+ &.badge-primary {
19
+ background-color: var(--primary-color);
20
+ border-color: var(--primary-color);
21
+ }
22
+ &.badge-secondary {
23
+ background-color: var(--secondary-color);
24
+ border-color: var(--secondary-color);
25
+ }
26
+ &.badge-success {
27
+ background-color: #28a745;
28
+ border-color: #28a745;
29
+ }
30
+ &.badge-danger {
31
+ background-color: #dc3545;
32
+ border-color: #dc3545;
33
+ }
34
+ &.badge-warning {
35
+ background-color: #ffc107;
36
+ border-color: #ffc107;
37
+ }
38
+ &.badge-info {
39
+ background-color: #17a2b8;
40
+ border-color: #17a2b8;
41
+ }
42
+ &.badge-light {
43
+ background-color: #f8f9fa;
44
+ border-color: #f8f9fa;
45
+ color: #212529;
46
+ }
47
+ &.badge-dark {
48
+ background-color: #343a40;
49
+ border-color: #343a40;
50
+ }
51
+ &.badge-link {
52
+ color: #007bff;
53
+ text-decoration: none;
54
+ }
55
+ }
@@ -0,0 +1,46 @@
1
+ import { Badge } from "../badge/Badge";
2
+ import { Icon } from "../icon/Icon";
3
+ import "./button.css";
4
+ import { ButtonInterface } from "./button.interface";
5
+
6
+ export const Button = ({
7
+ className,
8
+ onClick,
9
+ badge,
10
+ title,
11
+ sizeIcon,
12
+ id,
13
+ classIcon,
14
+ positionicon = 1,
15
+ disabled = false,
16
+ }: ButtonInterface) => {
17
+ const handleClick = (e: React.MouseEvent) => {
18
+ e.stopPropagation();
19
+ if (onClick) {
20
+ onClick(e);
21
+ }
22
+ };
23
+
24
+ return (
25
+ <button
26
+ id={id ?? ""}
27
+ disabled={disabled}
28
+ type="submit"
29
+ onClick={(e) => handleClick(e)}
30
+ className={className}
31
+ >
32
+ {badge && <Badge {...badge} />}
33
+ {classIcon && positionicon == 1 && (
34
+ <span className={`${title ? "mr-2" : ""}`}>
35
+ <Icon size={sizeIcon} classIcon={classIcon}></Icon>
36
+ </span>
37
+ )}
38
+ <span>{title}</span>
39
+ {classIcon && positionicon == 2 && (
40
+ <span className="ml-2">
41
+ <Icon classIcon={classIcon}></Icon>
42
+ </span>
43
+ )}
44
+ </button>
45
+ );
46
+ };
@@ -0,0 +1,85 @@
1
+ import { useMemo } from "react";
2
+ import { TypeInputEnum } from "../form/form.enum";
3
+ import { FormInterface } from "../form/form.interface";
4
+ import { Button } from "./Button";
5
+ import { ButtonInterface } from "./button.interface";
6
+ import {
7
+ ButtonActions,
8
+ ButtonActionsProps,
9
+ } from "./buttonActions/ButtonActions";
10
+ import { ButtonFilters } from "./buttonFilters/ButtonFilters";
11
+
12
+ export const ButtonView = (): JSX.Element => {
13
+ const initialValues: FormInterface[] = [
14
+ {
15
+ value: false,
16
+ name: "test1",
17
+ label: "test 1",
18
+ type: TypeInputEnum.CHECKBOX,
19
+ },
20
+ {
21
+ value: false,
22
+ name: "test2",
23
+ label: "test 2",
24
+ type: TypeInputEnum.CHECKBOX,
25
+ },
26
+ ];
27
+ const mockButtonItems: ButtonInterface[] = [
28
+ {
29
+ title: "Envoyer",
30
+ onClick: () => console.log("Envoyer"),
31
+ classIcon: "bi-send",
32
+ disabled: true,
33
+ positionicon: 1,
34
+ badge: {
35
+ className: "badge--primary",
36
+ title: "Badge",
37
+ sizeIcon: undefined,
38
+ classIcon: "bi-check-circle",
39
+ onClick: () => console.log("Badge clicked"),
40
+ },
41
+ },
42
+ {
43
+ title: "Annuler",
44
+ onClick: () => console.log("Envoyer"),
45
+ className: "button--secondary",
46
+ },
47
+ ];
48
+ const mockButtonAction: ButtonActionsProps = useMemo(() => {
49
+ return {
50
+ title: "Supprimer",
51
+ onClick: () => console.log("Supprimer"),
52
+ className: "button--secondary",
53
+
54
+ actions: [
55
+ {
56
+ id: "1",
57
+ label: "Supprimer",
58
+ onClick: () => console.log("Supprimer action"),
59
+ },
60
+ {
61
+ id: "2",
62
+ label: "Supprimer définitivement",
63
+ onClick: () => console.log("Supprimer définitivement"),
64
+ },
65
+ ],
66
+ };
67
+ }, []);
68
+ return (
69
+ <div className="d-flex">
70
+ {mockButtonItems.map((item, index) => (
71
+ <div className="mr-2" key={index}>
72
+ <Button {...item} />
73
+ </div>
74
+ ))}
75
+ <ButtonActions {...mockButtonAction} />
76
+ <div className="ml-2">
77
+ <ButtonFilters
78
+ classIcon="bi-send"
79
+ {...mockButtonAction}
80
+ dataForm={initialValues}
81
+ />
82
+ </div>
83
+ </div>
84
+ );
85
+ };
@@ -0,0 +1,53 @@
1
+ button {
2
+ background-color: var(--primary-color);
3
+ color: white;
4
+ border: none;
5
+ padding: 10px;
6
+ border-radius: 5px;
7
+ cursor: pointer;
8
+ font-size: 16px;
9
+ font-weight: 500;
10
+ transition: background-color 0.3s;
11
+ display: flex;
12
+ max-height: 40px;
13
+ min-width: 150px;
14
+ position: relative;
15
+ align-items: center;
16
+ justify-content: center;
17
+ font-family: "Raleway", sans-serif !important;
18
+ .badge {
19
+ position: absolute;
20
+ right: 10px;
21
+ top: -10px;
22
+ }
23
+ &:disabled {
24
+ opacity: 0.7;
25
+ cursor: not-allowed;
26
+ }
27
+ &.button--primary {
28
+ background-color: var(--primary-color);
29
+ }
30
+
31
+ &.button--secondary {
32
+ background-color: var(--secondary-color);
33
+ }
34
+ &.button--tertiary {
35
+ background-color: var(--tertiary-color);
36
+ }
37
+ &.button--transparent {
38
+ background-color: transparent;
39
+ color: var(--primary-color);
40
+ border: 1px solid;
41
+ }
42
+ &.button--success {
43
+ background-color: var(--success-color);
44
+ }
45
+
46
+ &.button--info {
47
+ background-color: var(--info-color);
48
+ }
49
+
50
+ &.button--warning {
51
+ background-color: var(--warning-color);
52
+ }
53
+ }
@@ -0,0 +1,21 @@
1
+ import { BadgeInterface } from "../badge/Badge";
2
+ import { IconSizeEnum } from "../icon/iconSize.enum";
3
+
4
+ export interface ButtonInterface {
5
+ className?: string;
6
+ badge?: BadgeInterface;
7
+ id?: string;
8
+ onClick?: (e: React.MouseEvent) => void;
9
+ title: string;
10
+ classIcon?: string;
11
+ positionicon?: number;
12
+ disabled?: boolean;
13
+ sizeIcon?: IconSizeEnum;
14
+ }
15
+ export interface buttonActionInterface {
16
+ icon?: string;
17
+ id?: number | string;
18
+ label: string;
19
+ disabled?: boolean;
20
+ onClick: (a: buttonActionInterface) => void;
21
+ }
@@ -0,0 +1,104 @@
1
+ import { useCallback, useMemo, useRef, useState } from "react";
2
+ import { Icon } from "../../icon/Icon";
3
+ import { IconSizeEnum } from "../../icon/iconSize.enum";
4
+ import { MenuInterface } from "../../menus/menu/menu.interface";
5
+ import { Menus } from "../../menus/Menus";
6
+ import { OverlayPanel, PositionOverlay } from "../../overlayPanel/OverlayPanel";
7
+ import { Button } from "../Button";
8
+ import { buttonActionInterface } from "../button.interface";
9
+
10
+ export type ButtonActionsProps = {
11
+ className?: string;
12
+ onClick?: (e: React.MouseEvent) => void;
13
+ title: string;
14
+ actions?: buttonActionInterface[];
15
+ classIcon?: string;
16
+ positionActions?: PositionOverlay;
17
+ disabled?: boolean;
18
+ id?: string;
19
+ };
20
+ export const ButtonActions = ({
21
+ className,
22
+ onClick,
23
+ title,
24
+ actions,
25
+ positionActions = "topRight",
26
+ disabled = false,
27
+ id,
28
+ }: ButtonActionsProps) => {
29
+ const handleClick = (e: React.MouseEvent) => {
30
+ e.preventDefault();
31
+ if (onClick) {
32
+ onClick(e);
33
+ }
34
+ };
35
+ const refButton = useRef<HTMLDivElement>(null);
36
+ const [openOverlay, setOpenOverlay] = useState(false);
37
+ const onClickActions = useCallback(
38
+ (e: React.MouseEvent) => {
39
+ e.stopPropagation();
40
+ if (actions) setOpenOverlay(!openOverlay);
41
+ },
42
+ [openOverlay, setOpenOverlay],
43
+ );
44
+ const overlayMenu: MenuInterface[] = useMemo(() => {
45
+ if (!actions) return [];
46
+ return actions.map((a, index) => {
47
+ return {
48
+ id: a.id ?? index,
49
+ icon: a.icon,
50
+ name: a.label,
51
+ children: (
52
+ <Button
53
+ key={index}
54
+ classIcon={a.icon}
55
+ sizeIcon={IconSizeEnum.LARGE}
56
+ onClick={(e) => {
57
+ e.stopPropagation();
58
+ closeOverlay();
59
+ a.onClick && a.onClick(a);
60
+ }}
61
+ title={a.label || ""}
62
+ />
63
+ ),
64
+ };
65
+ }) as MenuInterface[];
66
+ }, [actions]);
67
+ const closeOverlay = useCallback(() => {
68
+ setOpenOverlay(false);
69
+ }, [setOpenOverlay]);
70
+ return (
71
+ <>
72
+ <button
73
+ id={id ?? ""}
74
+ disabled={disabled}
75
+ type="submit"
76
+ onClick={(e) => handleClick(e)}
77
+ className={` ${className} button-actions`}
78
+ >
79
+ <span className="mr-2 flex-1">{title}</span>
80
+
81
+ <span
82
+ className="ml-2"
83
+ ref={refButton}
84
+ onClick={(e) => onClickActions(e)}
85
+ >
86
+ <Icon classIcon="bi-chevron-up" />
87
+ </span>
88
+ </button>
89
+ {actions && openOverlay && refButton.current && (
90
+ <OverlayPanel
91
+ show={openOverlay}
92
+ position={positionActions}
93
+ closeOverlay={setOpenOverlay}
94
+ referenceElement={refButton.current}
95
+ children={
96
+ <div>
97
+ <Menus className="card-action-menu" items={overlayMenu} />
98
+ </div>
99
+ }
100
+ />
101
+ )}
102
+ </>
103
+ );
104
+ };