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.
- package/.github/workflows/publish.yml +31 -0
- package/dist/_core/type/generiqueType.d.ts +4 -0
- package/dist/badge/Badge.d.ts +3 -1
- package/dist/button/button.interface.d.ts +1 -1
- package/dist/dataTable/DataTable.d.ts +17 -3
- package/dist/dataTable/dataTable.interface.d.ts +21 -3
- package/dist/dataTable/dataTableActions/DataTableAction.d.ts +2 -2
- package/dist/dataTable/dataTableColumn/DataTableColumn.d.ts +13 -7
- package/dist/dataTable/dataTableColumn/dataTableColumnFilter/DataTableColumnFilter.d.ts +10 -0
- package/dist/dataTable/dataTableColumn/dataTableColumnFilter/dataTableColumnFilterDate/DataTableColumnFilterDate.d.ts +9 -0
- package/dist/dataTable/dataTableColumn/dataTableColumnFilter/dataTableColumnFilterDateRange/dataTableColumnFilterDateRange.d.ts +9 -0
- package/dist/dataTable/dataTableColumn/dataTableColumnFilter/dataTableColumnFilterEnum/DataTableColumnFilterEnum.d.ts +13 -0
- package/dist/dataTable/dataTableColumn/dataTableColumnFilter/dataTableColumnFilterString/DataTableColumnFilterString.d.ts +9 -0
- package/dist/dataTable/dataTableColumn/dataTableColumnSort/DataTableColumnSort.d.ts +11 -0
- package/dist/dataTable/dataTableFilters/DataTableFilters.d.ts +7 -0
- package/dist/dataTable/dataTableLoading/DataTableLoading.d.ts +1 -3
- package/dist/dataTable/dataTableRow/DataTableRow.d.ts +5 -3
- package/dist/dataTable/dataTableRow/dataTableRowOverlay/DataTableRowOverlay.d.ts +12 -0
- package/dist/dataTable/dataTableRow/dataTableRowValue/DataTableRowValue.d.ts +11 -0
- package/dist/expands/expand/expand.d.ts +1 -1
- package/dist/form/form.enum.d.ts +1 -0
- package/dist/form/input/Input.d.ts +3 -0
- package/dist/form/inputNumber/InputNumber.d.ts +0 -2
- package/dist/icon/Icon.d.ts +1 -1
- package/dist/icon/icon.interface.d.ts +1 -0
- package/dist/index.d.ts +1 -0
- package/dist/index.js +3652 -2836
- package/dist/overlayPanel/OverlayPanel.d.ts +3 -1
- package/dist/select/Select.d.ts +4 -1
- package/dist/select/selectOption.interface.d.ts +1 -0
- package/dist/style.css +1 -1
- package/dist/tabs/Tabs.d.ts +2 -1
- package/kelt-ui-kit-react-1.6.9.tgz +0 -0
- package/package/README.md +46 -0
- package/package/index.html +20 -0
- package/package/package.json +56 -0
- package/package/public/favicon.ico +0 -0
- package/package/public/index.html +18 -0
- package/package/public/logo192.png +0 -0
- package/package/public/logo512.png +0 -0
- package/package/public/manifest.json +25 -0
- package/package/public/robots.txt +3 -0
- package/package/src/App.css +11 -0
- package/package/src/App.menu.tsx +249 -0
- package/package/src/App.routes.tsx +16 -0
- package/package/src/App.tsx +30 -0
- package/package/src/_core/hooks/HistoryProvider.tsx +25 -0
- package/package/src/_core/hooks/ImageChecker.tsx +26 -0
- package/package/src/_core/hooks/imageExist.tsx +9 -0
- package/package/src/_core/hooks/isEAN13.tsx +16 -0
- package/package/src/_core/hooks/objectToQueryParams.tsx +32 -0
- package/package/src/_core/hooks/useCurrency.tsx +18 -0
- package/package/src/_core/hooks/useDateutils.ts +64 -0
- package/package/src/_core/hooks/useIsMobile.ts +18 -0
- package/package/src/_core/hooks/useToken.tsx +19 -0
- package/package/src/_core/hooks/useValidate.tsx +18 -0
- package/package/src/_core/hooks/widgetSupport.tsx +39 -0
- package/package/src/action/Action.view.tsx +21 -0
- package/package/src/action/ButtonAction.tsx +32 -0
- package/package/src/action/action.css +20 -0
- package/package/src/badge/Badge.tsx +34 -0
- package/package/src/badge/Badge.view.tsx +15 -0
- package/package/src/badge/badge.css +55 -0
- package/package/src/button/Button.tsx +46 -0
- package/package/src/button/Button.view.tsx +85 -0
- package/package/src/button/button.css +53 -0
- package/package/src/button/button.interface.tsx +21 -0
- package/package/src/button/buttonActions/ButtonActions.tsx +104 -0
- package/package/src/button/buttonFile/ButtonFile.tsx +59 -0
- package/package/src/button/buttonFile/ButtonFile.view.tsx +70 -0
- package/package/src/button/buttonFilters/ButtonFilters.tsx +102 -0
- package/package/src/button/buttonFilters/buttonFilters.css +22 -0
- package/package/src/card/Card.tsx +125 -0
- package/package/src/card/Card.view.tsx +73 -0
- package/package/src/card/card.css +145 -0
- package/package/src/card/card.interface.tsx +9 -0
- package/package/src/card/cardAction/CardAction.tsx +135 -0
- package/package/src/card/cardAction/cardAction.css +10 -0
- package/package/src/card/cardAction.interface.tsx +10 -0
- package/package/src/card/hook/useCardInteractions.tsx +30 -0
- package/package/src/carousel/Carousel.css +44 -0
- package/package/src/carousel/Carousel.tsx +115 -0
- package/package/src/carousel/Carousel.view.tsx +13 -0
- package/package/src/damier/Damier.tsx +64 -0
- package/package/src/damier/Damier.view.tsx +31 -0
- package/package/src/damier/damier.css +50 -0
- package/package/src/damier/damierCell/DamierCell.tsx +18 -0
- package/package/src/damier/damierCell/damierCell.interface.tsx +5 -0
- package/package/src/dataTable/DataTable.tsx +259 -0
- package/package/src/dataTable/DataTable.view.tsx +62 -0
- package/package/src/dataTable/dataTable.css +30 -0
- package/package/src/dataTable/dataTable.interface.ts +30 -0
- package/package/src/dataTable/dataTableActions/DataTableAction.tsx +44 -0
- package/package/src/dataTable/dataTableColumn/DataTableColumn.tsx +27 -0
- package/package/src/dataTable/dataTableLoading/DataTableLoading.tsx +21 -0
- package/package/src/dataTable/dataTableRow/DataTableRow.tsx +54 -0
- package/package/src/datePicker/DatePicker.tsx +110 -0
- package/package/src/datePicker/DatePicker.view.tsx +9 -0
- package/package/src/datePicker/datePicker.css +77 -0
- package/package/src/expands/Expands.tsx +42 -0
- package/package/src/expands/Expands.view.tsx +90 -0
- package/package/src/expands/expand/expand.interface.tsx +8 -0
- package/package/src/expands/expand/expand.tsx +75 -0
- package/package/src/expands/expands.css +97 -0
- package/package/src/filAriane/FilAriane.tsx +57 -0
- package/package/src/filAriane/FilAriane.view.tsx +28 -0
- package/package/src/filAriane/filAriane.css +23 -0
- package/package/src/filAriane/filAriane.interface.tsx +6 -0
- package/package/src/form/Form.tsx +279 -0
- package/package/src/form/Form.view.tsx +59 -0
- package/package/src/form/form.css +62 -0
- package/package/src/form/form.enum.ts +13 -0
- package/package/src/form/form.interface.tsx +37 -0
- package/package/src/form/input/Input.tsx +106 -0
- package/package/src/form/input/input.css +26 -0
- package/package/src/form/inputNumber/InputNumber.tsx +132 -0
- package/package/src/form/inputNumber/InputNumber.view.tsx +15 -0
- package/package/src/form/inputPrice/InputPrice.tsx +42 -0
- package/package/src/form/inputPrice/InputPrice.view.tsx +15 -0
- package/package/src/form/textArea/TextArea.tsx +59 -0
- package/package/src/form/textArea/TextArea.view.tsx +34 -0
- package/package/src/form/textArea/textArea.css +9 -0
- package/package/src/grid/Grid.tsx +21 -0
- package/package/src/grid/Grid.view.tsx +24 -0
- package/package/src/grid/col/Col.tsx +15 -0
- package/package/src/grid/col/colStyled/ColStyled.tsx +41 -0
- package/package/src/grid/container/Container.tsx +8 -0
- package/package/src/grid/container/container.css +5 -0
- package/package/src/grid/grid.interface.tsx +7 -0
- package/package/src/grid/row/Row.tsx +12 -0
- package/package/src/grid/row/row.css +18 -0
- package/package/src/header/Header.tsx +62 -0
- package/package/src/header/Header.view.tsx +5 -0
- package/package/src/header/header.css +26 -0
- package/package/src/header/header.interface.tsx +10 -0
- package/package/src/home/Home.tsx +3 -0
- package/package/src/icon/Icon.tsx +6 -0
- package/package/src/icon/Icons.view.tsx +29 -0
- package/package/src/icon/icon.css +20 -0
- package/package/src/icon/icon.interface.tsx +6 -0
- package/package/src/icon/iconSize.enum.ts +7 -0
- package/package/src/index.css +502 -0
- package/package/src/index.ts +58 -0
- package/package/src/loader/Loader.tsx +37 -0
- package/package/src/loader/Loader.view.tsx +20 -0
- package/package/src/loader/loader.css +30 -0
- package/package/src/logo.svg +1 -0
- package/package/src/main.tsx +10 -0
- package/package/src/menus/Menus.tsx +42 -0
- package/package/src/menus/Menus.view.tsx +39 -0
- package/package/src/menus/menu/Menu.tsx +17 -0
- package/package/src/menus/menu/menu.interface.tsx +9 -0
- package/package/src/menus/menus.css +47 -0
- package/package/src/message/Message.tsx +30 -0
- package/package/src/message/Message.view.tsx +22 -0
- package/package/src/message/message.css +29 -0
- package/package/src/modal/Modal.tsx +59 -0
- package/package/src/modal/Modal.view.tsx +26 -0
- package/package/src/modal/modal.css +71 -0
- package/package/src/notFound/NotFound.tsx +3 -0
- package/package/src/overlayPanel/OverlayPanel.tsx +195 -0
- package/package/src/overlayPanel/OverlayPanel.view.tsx +25 -0
- package/package/src/overlayPanel/overlay.context.tsx +28 -0
- package/package/src/overlayPanel/overlayPanel.css +35 -0
- package/package/src/overlayPanel/overlayPanelStyled/OverlayPanelStyled.tsx +18 -0
- package/package/src/pdfViewer/PdfViewer.tsx +73 -0
- package/package/src/pdfViewer/PdfViewer.view.tsx +5 -0
- package/package/src/quantity/Quantity.tsx +103 -0
- package/package/src/quantity/Quantity.view.tsx +0 -0
- package/package/src/quantity/quantity.css +26 -0
- package/package/src/search/Search.tsx +161 -0
- package/package/src/search/Search.view.tsx +14 -0
- package/package/src/search/search.css +59 -0
- package/package/src/select/Select.tsx +103 -0
- package/package/src/select/Select.view.tsx +71 -0
- package/package/src/select/select.css +69 -0
- package/package/src/select/selectOption.interface.ts +4 -0
- package/package/src/sidebar/Sidebar.tsx +208 -0
- package/package/src/sidebar/Sidebar.view.tsx +17 -0
- package/package/src/sidebar/sidebar.css +104 -0
- package/package/src/sidebarData/SidebarData.tsx +19 -0
- package/package/src/sidebarData/SidebarData.view.tsx +19 -0
- package/package/src/sidebarData/sidebarData.css +27 -0
- package/package/src/tabs/Tabs.tsx +90 -0
- package/package/src/tabs/Tabs.view.tsx +20 -0
- package/package/src/tabs/tabs.css +24 -0
- package/package/src/toaster/Toaster.tsx +55 -0
- package/package/src/toaster/Toaster.view.tsx +24 -0
- package/package/src/toaster/store/useToasterStore.tsx +41 -0
- package/package/src/toaster/toaster.css +87 -0
- package/package/tsconfig.json +28 -0
- package/package/vite.config.ts +20 -0
- package/package/vite.config.ts.timestamp-1733262892554-a13dfef6e8a29.mjs +24 -0
- package/package/vite.config.ts.timestamp-1757847121745-e5a5bf54b81b.mjs +28 -0
- package/package/vite.config.ts.timestamp-1759742478362-4ac5c5a7db34b.mjs +28 -0
- package/package.json +1 -1
- package/src/_core/type/generiqueType.tsx +4 -0
- package/src/badge/Badge.tsx +9 -1
- package/src/badge/badge.css +4 -0
- package/src/button/Button.tsx +1 -1
- package/src/button/button.interface.tsx +1 -1
- package/src/card/card.css +23 -3
- package/src/card/cardAction/CardAction.tsx +4 -4
- package/src/dataTable/DataTable.tsx +670 -45
- package/src/dataTable/DataTable.view.tsx +47 -14
- package/src/dataTable/dataTable.css +153 -5
- package/src/dataTable/dataTable.interface.ts +21 -3
- package/src/dataTable/dataTableActions/DataTableAction.tsx +2 -2
- package/src/dataTable/dataTableColumn/DataTableColumn.tsx +64 -14
- package/src/dataTable/dataTableColumn/dataTableColumnFilter/DataTableColumnFilter.tsx +36 -0
- package/src/dataTable/dataTableColumn/dataTableColumnFilter/dataTableColumnFilter.css +0 -0
- package/src/dataTable/dataTableColumn/dataTableColumnFilter/dataTableColumnFilterDate/DataTableColumnFilterDate.tsx +39 -0
- package/src/dataTable/dataTableColumn/dataTableColumnFilter/dataTableColumnFilterDateRange/dataTableColumnFilterDateRange.tsx +80 -0
- package/src/dataTable/dataTableColumn/dataTableColumnFilter/dataTableColumnFilterEnum/DataTableColumnFilterEnum.tsx +89 -0
- package/src/dataTable/dataTableColumn/dataTableColumnFilter/dataTableColumnFilterString/DataTableColumnFilterString.tsx +37 -0
- package/src/dataTable/dataTableColumn/dataTableColumnSort/DataTableColumnSort.tsx +42 -0
- package/src/dataTable/dataTableFilters/DataTableFilters.tsx +91 -0
- package/src/dataTable/dataTableFilters/dataTableFilters.css +16 -0
- package/src/dataTable/dataTableLoading/DataTableLoading.tsx +4 -15
- package/src/dataTable/dataTableRow/DataTableRow.tsx +60 -33
- package/src/dataTable/dataTableRow/dataTableRowOverlay/DataTableRowOverlay.tsx +80 -0
- package/src/dataTable/dataTableRow/dataTableRowValue/DataTableRowValue.tsx +123 -0
- package/src/expands/Expands.tsx +2 -16
- package/src/expands/expand/expand.tsx +6 -18
- package/src/form/Form.tsx +13 -12
- package/src/form/form.css +13 -2
- package/src/form/form.enum.ts +1 -0
- package/src/form/input/Input.tsx +61 -7
- package/src/form/input/input.css +23 -1
- package/src/form/inputNumber/InputNumber.tsx +6 -11
- package/src/form/inputPrice/InputPrice.tsx +2 -4
- package/src/icon/Icon.tsx +6 -2
- package/src/icon/icon.interface.tsx +1 -0
- package/src/index.ts +2 -0
- package/src/overlayPanel/OverlayPanel.tsx +23 -10
- package/src/overlayPanel/overlay.context.tsx +6 -4
- package/src/overlayPanel/overlayPanel.css +10 -1
- package/src/select/Select.tsx +134 -38
- package/src/select/select.css +65 -14
- package/src/select/selectOption.interface.ts +1 -0
- package/src/sidebar/Sidebar.tsx +9 -80
- package/src/sidebar/sidebar.css +1 -18
- package/src/tabs/Tabs.tsx +19 -1
- package/vite.config.ts.timestamp-1757847121745-e5a5bf54b81b.mjs +28 -28
- package/vite.config.ts.timestamp-1759742478362-4ac5c5a7db34b.mjs +28 -28
|
@@ -0,0 +1,59 @@
|
|
|
1
|
+
import { ChangeEvent, useRef } from "react";
|
|
2
|
+
import { Button } from "../Button";
|
|
3
|
+
|
|
4
|
+
interface ButtonFileProps {
|
|
5
|
+
onFileSelected?: (file: File, buffer: ArrayBuffer) => void;
|
|
6
|
+
accept?: string;
|
|
7
|
+
buttonText?: string;
|
|
8
|
+
buttonClassName?: string;
|
|
9
|
+
containerClassName?: string;
|
|
10
|
+
}
|
|
11
|
+
|
|
12
|
+
export const ButtonFile = ({
|
|
13
|
+
onFileSelected,
|
|
14
|
+
accept = "*",
|
|
15
|
+
buttonText = "Choisir un fichier",
|
|
16
|
+
buttonClassName,
|
|
17
|
+
containerClassName,
|
|
18
|
+
}: ButtonFileProps) => {
|
|
19
|
+
const fileInputRef = useRef<HTMLInputElement>(null);
|
|
20
|
+
|
|
21
|
+
const handleFileChange = (e: ChangeEvent<HTMLInputElement>) => {
|
|
22
|
+
const file = e.target.files?.[0];
|
|
23
|
+
|
|
24
|
+
if (file && onFileSelected) {
|
|
25
|
+
const reader = new FileReader();
|
|
26
|
+
|
|
27
|
+
reader.onload = (event: ProgressEvent<FileReader>) => {
|
|
28
|
+
const buffer = event.target?.result as ArrayBuffer;
|
|
29
|
+
onFileSelected(file, buffer);
|
|
30
|
+
};
|
|
31
|
+
|
|
32
|
+
reader.readAsArrayBuffer(file);
|
|
33
|
+
}
|
|
34
|
+
};
|
|
35
|
+
|
|
36
|
+
const handleButtonClick = () => {
|
|
37
|
+
fileInputRef.current?.click();
|
|
38
|
+
};
|
|
39
|
+
|
|
40
|
+
return (
|
|
41
|
+
<div className={containerClassName}>
|
|
42
|
+
<input
|
|
43
|
+
type="file"
|
|
44
|
+
ref={fileInputRef}
|
|
45
|
+
onChange={handleFileChange}
|
|
46
|
+
className="hidden"
|
|
47
|
+
accept={accept}
|
|
48
|
+
/>
|
|
49
|
+
<Button
|
|
50
|
+
onClick={handleButtonClick}
|
|
51
|
+
className={
|
|
52
|
+
buttonClassName ||
|
|
53
|
+
"bg-green-500 hover:bg-green-600 text-white font-medium py-3 px-6 rounded-lg transition-colors duration-200"
|
|
54
|
+
}
|
|
55
|
+
title={buttonText || "Choisir un fichier"}
|
|
56
|
+
/>
|
|
57
|
+
</div>
|
|
58
|
+
);
|
|
59
|
+
};
|
|
@@ -0,0 +1,70 @@
|
|
|
1
|
+
import { ButtonFile } from "./ButtonFile";
|
|
2
|
+
|
|
3
|
+
export const ButtonFileView = () => {
|
|
4
|
+
const handleZipFile = (file: File, buffer: ArrayBuffer) => {
|
|
5
|
+
console.log("Fichier sélectionné:", file.name);
|
|
6
|
+
console.log("Type:", file.type);
|
|
7
|
+
console.log("Taille:", file.size);
|
|
8
|
+
console.log("Buffer:", buffer);
|
|
9
|
+
console.log("Taille du buffer:", buffer.byteLength);
|
|
10
|
+
|
|
11
|
+
// Convertir en Uint8Array si nécessaire
|
|
12
|
+
const uint8Array = new Uint8Array(buffer);
|
|
13
|
+
console.log("Uint8Array:", uint8Array);
|
|
14
|
+
|
|
15
|
+
// Faites ce que vous voulez avec le buffer ici
|
|
16
|
+
};
|
|
17
|
+
|
|
18
|
+
return (
|
|
19
|
+
<div className="min-h-screen bg-gray-50 p-8">
|
|
20
|
+
<div className="max-w-2xl mx-auto space-y-6">
|
|
21
|
+
<div className="border-2 border-dashed border-gray-300 rounded-lg p-8 text-center bg-white">
|
|
22
|
+
<h2 className="text-2xl font-semibold mb-6 text-gray-800">
|
|
23
|
+
Exemple 1 : Fichier ZIP
|
|
24
|
+
</h2>
|
|
25
|
+
<ButtonFile
|
|
26
|
+
onFileSelected={handleZipFile}
|
|
27
|
+
accept=".zip"
|
|
28
|
+
buttonText="Sélectionner un ZIP"
|
|
29
|
+
/>
|
|
30
|
+
</div>
|
|
31
|
+
|
|
32
|
+
<div className="border-2 border-dashed border-gray-300 rounded-lg p-8 text-center bg-white">
|
|
33
|
+
<h2 className="text-2xl font-semibold mb-6 text-gray-800">
|
|
34
|
+
Exemple 2 : Tout type de fichier
|
|
35
|
+
</h2>
|
|
36
|
+
<ButtonFile
|
|
37
|
+
onFileSelected={(file: File, buffer: ArrayBuffer) => {
|
|
38
|
+
console.log(
|
|
39
|
+
"Fichier:",
|
|
40
|
+
file.name,
|
|
41
|
+
"Buffer size:",
|
|
42
|
+
buffer.byteLength,
|
|
43
|
+
);
|
|
44
|
+
}}
|
|
45
|
+
buttonText="Sélectionner n'importe quel fichier"
|
|
46
|
+
buttonClassName="bg-blue-500 hover:bg-blue-600 text-white font-medium py-2 px-4 rounded"
|
|
47
|
+
/>
|
|
48
|
+
</div>
|
|
49
|
+
|
|
50
|
+
<div className="border-2 border-dashed border-gray-300 rounded-lg p-8 text-center bg-white">
|
|
51
|
+
<h2 className="text-2xl font-semibold mb-6 text-gray-800">
|
|
52
|
+
Exemple 3 : Images uniquement
|
|
53
|
+
</h2>
|
|
54
|
+
<ButtonFile
|
|
55
|
+
onFileSelected={(file: File, buffer: ArrayBuffer) => {
|
|
56
|
+
console.log("Image:", file.name);
|
|
57
|
+
// Créer une URL pour prévisualiser l'image
|
|
58
|
+
const blob = new Blob([buffer], { type: file.type });
|
|
59
|
+
const url = URL.createObjectURL(blob);
|
|
60
|
+
console.log("URL de prévisualisation:", url);
|
|
61
|
+
}}
|
|
62
|
+
accept="image/*"
|
|
63
|
+
buttonText="Sélectionner une image"
|
|
64
|
+
buttonClassName="bg-purple-500 hover:bg-purple-600 text-white font-medium py-3 px-6 rounded-lg"
|
|
65
|
+
/>
|
|
66
|
+
</div>
|
|
67
|
+
</div>
|
|
68
|
+
</div>
|
|
69
|
+
);
|
|
70
|
+
};
|
|
@@ -0,0 +1,102 @@
|
|
|
1
|
+
import { useCallback, useEffect, useRef, useState } from "react";
|
|
2
|
+
import { DynamicForm } from "../../form/Form";
|
|
3
|
+
import { FormInterface, FormValuesInterface } from "../../form/form.interface";
|
|
4
|
+
import { Icon } from "../../icon/Icon";
|
|
5
|
+
import { IconSizeEnum } from "../../icon/iconSize.enum";
|
|
6
|
+
import "./buttonFilters.css";
|
|
7
|
+
export type ButtonActionsProps<
|
|
8
|
+
T extends { [key: string]: string | number | boolean | Date | string[] },
|
|
9
|
+
> = {
|
|
10
|
+
className?: string;
|
|
11
|
+
onClick?: (e: React.MouseEvent) => void;
|
|
12
|
+
title: string;
|
|
13
|
+
classIcon?: string;
|
|
14
|
+
sizeIcon?: IconSizeEnum;
|
|
15
|
+
dataForm: FormInterface[];
|
|
16
|
+
onChange?: (values: FormValuesInterface<T>) => void;
|
|
17
|
+
disabled?: boolean;
|
|
18
|
+
id?: string;
|
|
19
|
+
};
|
|
20
|
+
export const ButtonFilters = <
|
|
21
|
+
T extends { [key: string]: string | number | boolean | Date | string[] },
|
|
22
|
+
>({
|
|
23
|
+
className,
|
|
24
|
+
onClick,
|
|
25
|
+
title,
|
|
26
|
+
classIcon,
|
|
27
|
+
sizeIcon,
|
|
28
|
+
disabled = false,
|
|
29
|
+
id,
|
|
30
|
+
dataForm,
|
|
31
|
+
onChange,
|
|
32
|
+
}: ButtonActionsProps<T>) => {
|
|
33
|
+
const buttonRef = useRef<HTMLButtonElement | null>(null);
|
|
34
|
+
const [openFilters, setOpenFilters] = useState(false);
|
|
35
|
+
const handleClick = (e: React.MouseEvent) => {
|
|
36
|
+
e.preventDefault();
|
|
37
|
+
setOpenFilters(!openFilters);
|
|
38
|
+
if (onClick) {
|
|
39
|
+
onClick(e);
|
|
40
|
+
}
|
|
41
|
+
};
|
|
42
|
+
const handleClickOutside = useCallback(
|
|
43
|
+
(event: MouseEvent) => {
|
|
44
|
+
if (
|
|
45
|
+
buttonRef.current &&
|
|
46
|
+
!buttonRef.current.contains(event.target as Node)
|
|
47
|
+
) {
|
|
48
|
+
setOpenFilters(false);
|
|
49
|
+
}
|
|
50
|
+
},
|
|
51
|
+
[setOpenFilters],
|
|
52
|
+
);
|
|
53
|
+
|
|
54
|
+
useEffect(() => {
|
|
55
|
+
if (openFilters) {
|
|
56
|
+
document.addEventListener("mousedown", handleClickOutside);
|
|
57
|
+
} else {
|
|
58
|
+
document.removeEventListener("mousedown", handleClickOutside);
|
|
59
|
+
}
|
|
60
|
+
|
|
61
|
+
return () => {
|
|
62
|
+
document.removeEventListener("mousedown", handleClickOutside);
|
|
63
|
+
};
|
|
64
|
+
}, [openFilters, handleClickOutside]);
|
|
65
|
+
|
|
66
|
+
return (
|
|
67
|
+
<>
|
|
68
|
+
<button
|
|
69
|
+
ref={buttonRef}
|
|
70
|
+
id={id ?? ""}
|
|
71
|
+
disabled={disabled}
|
|
72
|
+
type="button"
|
|
73
|
+
onClick={(e) => handleClick(e)}
|
|
74
|
+
className={` ${className} button--filters button--transparent `}
|
|
75
|
+
>
|
|
76
|
+
{classIcon && (
|
|
77
|
+
<span>
|
|
78
|
+
<Icon
|
|
79
|
+
classIcon={classIcon}
|
|
80
|
+
size={sizeIcon || IconSizeEnum.EXTRA_SMALL}
|
|
81
|
+
/>
|
|
82
|
+
</span>
|
|
83
|
+
)}
|
|
84
|
+
<span className=" flex-1">{title}</span>
|
|
85
|
+
{openFilters && (
|
|
86
|
+
<div
|
|
87
|
+
className="button--filters-overlay"
|
|
88
|
+
onClick={(e) => e.stopPropagation()}
|
|
89
|
+
>
|
|
90
|
+
<div className="button--filters-overlay-content">
|
|
91
|
+
<DynamicForm
|
|
92
|
+
onChange={onChange as any}
|
|
93
|
+
initialForm={dataForm}
|
|
94
|
+
hideSubmit
|
|
95
|
+
/>
|
|
96
|
+
</div>
|
|
97
|
+
</div>
|
|
98
|
+
)}
|
|
99
|
+
</button>
|
|
100
|
+
</>
|
|
101
|
+
);
|
|
102
|
+
};
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
.button--filters {
|
|
2
|
+
position: relative;
|
|
3
|
+
.button--filters-overlay {
|
|
4
|
+
position: absolute;
|
|
5
|
+
margin-top: 0.25rem;
|
|
6
|
+
top: 100%;
|
|
7
|
+
left: 0;
|
|
8
|
+
background-color: white;
|
|
9
|
+
border: 1px solid #ccc;
|
|
10
|
+
padding: 10px;
|
|
11
|
+
z-index: 1000;
|
|
12
|
+
border-radius: 4px;
|
|
13
|
+
width: 100%;
|
|
14
|
+
.button--filters-overlay-content {
|
|
15
|
+
display: flex;
|
|
16
|
+
gap: 0.5rem;
|
|
17
|
+
label {
|
|
18
|
+
color: #333;
|
|
19
|
+
}
|
|
20
|
+
}
|
|
21
|
+
}
|
|
22
|
+
}
|
|
@@ -0,0 +1,125 @@
|
|
|
1
|
+
import { useCallback, useState } from "react";
|
|
2
|
+
import { Icon } from "../icon/Icon";
|
|
3
|
+
import { PositionOverlay } from "../overlayPanel/OverlayPanel";
|
|
4
|
+
import "./card.css";
|
|
5
|
+
import { CardInterface } from "./card.interface";
|
|
6
|
+
import { CardActionInterface } from "./cardAction.interface";
|
|
7
|
+
import { CardAction } from "./cardAction/CardAction";
|
|
8
|
+
type CardProps = {
|
|
9
|
+
item: CardInterface;
|
|
10
|
+
actions?: CardActionInterface[];
|
|
11
|
+
className?: string;
|
|
12
|
+
handleClick?: (item: CardInterface) => void;
|
|
13
|
+
onClose?: (item: CardInterface) => void;
|
|
14
|
+
children?: JSX.Element;
|
|
15
|
+
customAction?: JSX.Element;
|
|
16
|
+
positionOverlay?: PositionOverlay;
|
|
17
|
+
};
|
|
18
|
+
|
|
19
|
+
// Composant Card modifié
|
|
20
|
+
export const Card = ({
|
|
21
|
+
item,
|
|
22
|
+
actions,
|
|
23
|
+
className,
|
|
24
|
+
handleClick,
|
|
25
|
+
onClose,
|
|
26
|
+
customAction,
|
|
27
|
+
positionOverlay,
|
|
28
|
+
children,
|
|
29
|
+
}: CardProps): JSX.Element => {
|
|
30
|
+
const [cliqueAction, setCliqueAction] = useState(false);
|
|
31
|
+
const [openActions, setOpenActions] = useState(false);
|
|
32
|
+
const [positions, setPositions] = useState<{ top: number; left: number }>();
|
|
33
|
+
const onClickClose = (e: React.MouseEvent, item: CardInterface) => {
|
|
34
|
+
e.stopPropagation();
|
|
35
|
+
if (onClose) {
|
|
36
|
+
onClose(item);
|
|
37
|
+
}
|
|
38
|
+
};
|
|
39
|
+
const onClickCard = useCallback(
|
|
40
|
+
(e: React.MouseEvent, item: CardInterface) => {
|
|
41
|
+
e.stopPropagation();
|
|
42
|
+
if (openActions) {
|
|
43
|
+
setPositions(undefined);
|
|
44
|
+
return setOpenActions(false);
|
|
45
|
+
}
|
|
46
|
+
if (
|
|
47
|
+
(e.target as HTMLElement).closest(".qte") ||
|
|
48
|
+
(e.target as HTMLElement).closest(".card-action-menu button") ||
|
|
49
|
+
(e.target as HTMLElement).closest(".card-actions")
|
|
50
|
+
) {
|
|
51
|
+
return; // Ne propage pas l'événement si le clic est dans Quantity
|
|
52
|
+
}
|
|
53
|
+
|
|
54
|
+
setCliqueAction(!cliqueAction);
|
|
55
|
+
|
|
56
|
+
if (handleClick && e.button !== 2) {
|
|
57
|
+
handleClick(item);
|
|
58
|
+
} else {
|
|
59
|
+
setPositions({ top: e.clientY, left: e.clientX });
|
|
60
|
+
setOpenActions(true);
|
|
61
|
+
}
|
|
62
|
+
},
|
|
63
|
+
[
|
|
64
|
+
setCliqueAction,
|
|
65
|
+
setPositions,
|
|
66
|
+
handleClick,
|
|
67
|
+
openActions,
|
|
68
|
+
setOpenActions,
|
|
69
|
+
cliqueAction,
|
|
70
|
+
]
|
|
71
|
+
);
|
|
72
|
+
|
|
73
|
+
return (
|
|
74
|
+
<div
|
|
75
|
+
onContextMenu={(e) => e.preventDefault()}
|
|
76
|
+
onMouseDown={(e) => onClickCard(e, item)}
|
|
77
|
+
className={`card ${className ?? ""} ${
|
|
78
|
+
cliqueAction ? "card--active" : ""
|
|
79
|
+
} `}
|
|
80
|
+
>
|
|
81
|
+
{children}
|
|
82
|
+
{!children && (
|
|
83
|
+
<>
|
|
84
|
+
<div className="card-text d-flex">
|
|
85
|
+
{item.image && (
|
|
86
|
+
<div className="card-img">
|
|
87
|
+
<img src={item.image} alt={"card-image"} />
|
|
88
|
+
</div>
|
|
89
|
+
)}
|
|
90
|
+
{item.title && <div className="card-title">{item.title}</div>}
|
|
91
|
+
{item.description && (
|
|
92
|
+
<div className="card-content">{item.description}</div>
|
|
93
|
+
)}
|
|
94
|
+
</div>
|
|
95
|
+
<div className="card-footer">
|
|
96
|
+
{customAction && (
|
|
97
|
+
<div className="card-custom-action">{customAction}</div>
|
|
98
|
+
)}
|
|
99
|
+
<div className="d-flex flex-1 align-items-center">
|
|
100
|
+
{item.prix && <div className="card-prix">{item.prix}</div>}
|
|
101
|
+
</div>
|
|
102
|
+
</div>
|
|
103
|
+
{onClose && (
|
|
104
|
+
<div
|
|
105
|
+
className="ml-2 cursor-pointer"
|
|
106
|
+
onClick={(e) => onClickClose(e, item)}
|
|
107
|
+
>
|
|
108
|
+
<Icon classIcon="bi-trash3" />
|
|
109
|
+
</div>
|
|
110
|
+
)}
|
|
111
|
+
{actions && (
|
|
112
|
+
<CardAction
|
|
113
|
+
openActions={openActions}
|
|
114
|
+
setOpenActions={setOpenActions}
|
|
115
|
+
actions={actions}
|
|
116
|
+
item={item}
|
|
117
|
+
positions={positions}
|
|
118
|
+
positionOverlay={positionOverlay}
|
|
119
|
+
/>
|
|
120
|
+
)}
|
|
121
|
+
</>
|
|
122
|
+
)}
|
|
123
|
+
</div>
|
|
124
|
+
);
|
|
125
|
+
};
|
|
@@ -0,0 +1,73 @@
|
|
|
1
|
+
import { useCallback, useEffect, useMemo, useState } from "react";
|
|
2
|
+
import { Grid } from "../grid/Grid";
|
|
3
|
+
import { GridInterface } from "../grid/grid.interface";
|
|
4
|
+
import { Quantity } from "../quantity/Quantity";
|
|
5
|
+
import { Card } from "./Card";
|
|
6
|
+
import { CardInterface } from "./card.interface";
|
|
7
|
+
import { CardActionInterface } from "./cardAction.interface";
|
|
8
|
+
export const CardView = (): JSX.Element => {
|
|
9
|
+
const [actions, setActions] = useState<GridInterface[]>([]);
|
|
10
|
+
const mockItems: CardInterface[] = [
|
|
11
|
+
{
|
|
12
|
+
title: "Client",
|
|
13
|
+
image:
|
|
14
|
+
"https://www.papapiqueetmamancoud.fr/media/cache/app_product_small_thumbnail_listing_cropped/41/a2/e90184ab12b765859580b529d2ec.jpg",
|
|
15
|
+
description: "Description 1",
|
|
16
|
+
prix: "59.18 €",
|
|
17
|
+
quantity: 12,
|
|
18
|
+
},
|
|
19
|
+
{
|
|
20
|
+
title: "Produits",
|
|
21
|
+
prix: "59.18 €",
|
|
22
|
+
quantity: 1,
|
|
23
|
+
},
|
|
24
|
+
{
|
|
25
|
+
title: "Total",
|
|
26
|
+
description: "Description 3",
|
|
27
|
+
quantity: 1,
|
|
28
|
+
},
|
|
29
|
+
];
|
|
30
|
+
const actionsCard: CardActionInterface[] = useMemo(() => {
|
|
31
|
+
return [
|
|
32
|
+
{
|
|
33
|
+
icon: "bi-trash3",
|
|
34
|
+
label: "Supprimer la transaction",
|
|
35
|
+
type: "menu",
|
|
36
|
+
onClick: (item: CardInterface) => console.log(item),
|
|
37
|
+
},
|
|
38
|
+
{
|
|
39
|
+
icon: "bi-trash3",
|
|
40
|
+
label: "Editer la transaction",
|
|
41
|
+
type: "menu",
|
|
42
|
+
onClick: (item: CardInterface) => console.log(item),
|
|
43
|
+
},
|
|
44
|
+
{
|
|
45
|
+
icon: "bi-pencil",
|
|
46
|
+
label: "Editer",
|
|
47
|
+
onClick: (item: CardInterface) => console.log(item),
|
|
48
|
+
},
|
|
49
|
+
];
|
|
50
|
+
}, []);
|
|
51
|
+
|
|
52
|
+
const setQuantity = useCallback((item: CardInterface, qte: number) => {
|
|
53
|
+
console.log(qte, item);
|
|
54
|
+
}, []);
|
|
55
|
+
useEffect(() => {
|
|
56
|
+
const initActions: GridInterface[] = mockItems.map((item) => {
|
|
57
|
+
return {
|
|
58
|
+
children: (
|
|
59
|
+
<Card
|
|
60
|
+
className="card--horizontal"
|
|
61
|
+
item={item}
|
|
62
|
+
actions={actionsCard}
|
|
63
|
+
customAction={
|
|
64
|
+
<Quantity pas={1} item={item} setQuantity={setQuantity} />
|
|
65
|
+
}
|
|
66
|
+
/>
|
|
67
|
+
),
|
|
68
|
+
};
|
|
69
|
+
});
|
|
70
|
+
setActions(initActions);
|
|
71
|
+
}, [setActions, setQuantity]);
|
|
72
|
+
return <Grid items={actions} />;
|
|
73
|
+
};
|
|
@@ -0,0 +1,145 @@
|
|
|
1
|
+
.card {
|
|
2
|
+
border: 1px solid #cfbdbd;
|
|
3
|
+
border-radius: 10px;
|
|
4
|
+
padding: 1rem;
|
|
5
|
+
max-width: 200px;
|
|
6
|
+
height: 100%;
|
|
7
|
+
overflow: hidden;
|
|
8
|
+
position: relative;
|
|
9
|
+
flex-wrap: wrap;
|
|
10
|
+
|
|
11
|
+
.card-overlay {
|
|
12
|
+
display: none;
|
|
13
|
+
position: absolute;
|
|
14
|
+
background-color: rgba(0, 0, 0, 0.1);
|
|
15
|
+
width: 100%;
|
|
16
|
+
left: 0;
|
|
17
|
+
right: 0;
|
|
18
|
+
top: 0;
|
|
19
|
+
bottom: 0;
|
|
20
|
+
pointer-events: none;
|
|
21
|
+
}
|
|
22
|
+
.bi-three-dots-vertical {
|
|
23
|
+
display: none;
|
|
24
|
+
}
|
|
25
|
+
.card-custom-action {
|
|
26
|
+
display: flex;
|
|
27
|
+
flex: 1;
|
|
28
|
+
justify-content: start;
|
|
29
|
+
align-items: center;
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
.bi-trash3 {
|
|
33
|
+
font-size: 1rem;
|
|
34
|
+
}
|
|
35
|
+
.card-text {
|
|
36
|
+
width: 100%;
|
|
37
|
+
}
|
|
38
|
+
.card-footer {
|
|
39
|
+
display: flex;
|
|
40
|
+
flex: 1;
|
|
41
|
+
align-items: center;
|
|
42
|
+
justify-content: space-between;
|
|
43
|
+
}
|
|
44
|
+
&.card--horizontal {
|
|
45
|
+
display: flex;
|
|
46
|
+
flex-direction: row;
|
|
47
|
+
align-items: center;
|
|
48
|
+
min-height: 56px;
|
|
49
|
+
max-width: initial;
|
|
50
|
+
.card-img {
|
|
51
|
+
margin-right: 0.5rem;
|
|
52
|
+
}
|
|
53
|
+
|
|
54
|
+
.card-content {
|
|
55
|
+
flex: 1;
|
|
56
|
+
min-width: 200px;
|
|
57
|
+
}
|
|
58
|
+
|
|
59
|
+
.card-title {
|
|
60
|
+
width: calc(100% - 20px);
|
|
61
|
+
margin-bottom: 1rem;
|
|
62
|
+
}
|
|
63
|
+
.card-action {
|
|
64
|
+
position: absolute;
|
|
65
|
+
right: 10px;
|
|
66
|
+
top: 10px;
|
|
67
|
+
}
|
|
68
|
+
.card-prix {
|
|
69
|
+
flex: 1;
|
|
70
|
+
display: flex;
|
|
71
|
+
justify-content: flex-end;
|
|
72
|
+
}
|
|
73
|
+
}
|
|
74
|
+
|
|
75
|
+
&:not(.card--horizontal) {
|
|
76
|
+
.card-title {
|
|
77
|
+
margin-bottom: 1rem;
|
|
78
|
+
}
|
|
79
|
+
}
|
|
80
|
+
|
|
81
|
+
.card-img {
|
|
82
|
+
width: 30px;
|
|
83
|
+
|
|
84
|
+
img {
|
|
85
|
+
width: 100%;
|
|
86
|
+
}
|
|
87
|
+
}
|
|
88
|
+
|
|
89
|
+
.card-title {
|
|
90
|
+
font-size: 14px;
|
|
91
|
+
font-weight: 600;
|
|
92
|
+
}
|
|
93
|
+
|
|
94
|
+
.card-content {
|
|
95
|
+
font-size: 14px;
|
|
96
|
+
font-weight: 400;
|
|
97
|
+
display: none;
|
|
98
|
+
}
|
|
99
|
+
}
|
|
100
|
+
@container (min-width: 992px) {
|
|
101
|
+
.card {
|
|
102
|
+
.card-custom-action {
|
|
103
|
+
justify-content: end;
|
|
104
|
+
}
|
|
105
|
+
.bi-three-dots-vertical {
|
|
106
|
+
display: block;
|
|
107
|
+
}
|
|
108
|
+
.bi-three-dots {
|
|
109
|
+
display: none;
|
|
110
|
+
}
|
|
111
|
+
&.card--horizontal {
|
|
112
|
+
.card-actions {
|
|
113
|
+
margin-left: 0.5rem;
|
|
114
|
+
}
|
|
115
|
+
.card-footer {
|
|
116
|
+
display: flex;
|
|
117
|
+
flex: 1;
|
|
118
|
+
justify-content: space-between;
|
|
119
|
+
}
|
|
120
|
+
.card-text {
|
|
121
|
+
width: 300px;
|
|
122
|
+
display: flex;
|
|
123
|
+
align-items: center;
|
|
124
|
+
}
|
|
125
|
+
.card-content {
|
|
126
|
+
display: flex;
|
|
127
|
+
}
|
|
128
|
+
.card-title {
|
|
129
|
+
min-width: auto;
|
|
130
|
+
width: auto;
|
|
131
|
+
margin-right: 1rem;
|
|
132
|
+
margin-bottom: 0;
|
|
133
|
+
}
|
|
134
|
+
.card-prix {
|
|
135
|
+
flex: inherit;
|
|
136
|
+
min-width: auto;
|
|
137
|
+
}
|
|
138
|
+
.card-action {
|
|
139
|
+
position: relative;
|
|
140
|
+
right: initial;
|
|
141
|
+
top: initial;
|
|
142
|
+
}
|
|
143
|
+
}
|
|
144
|
+
}
|
|
145
|
+
}
|