kelt-ui-kit-react 1.2.4 → 1.2.6
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/README.md +46 -46
- package/dist/App.d.ts +3 -2
- package/dist/App.menu.d.ts +10 -10
- package/dist/App.routes.d.ts +1 -1
- package/dist/_core/hooks/ImageChecker.d.ts +6 -5
- package/dist/_core/hooks/useIsMobile.d.ts +1 -1
- package/dist/action/Action.view.d.ts +1 -1
- package/dist/action/ButtonAction.d.ts +9 -8
- package/dist/badge/Badge.d.ts +9 -8
- package/dist/badge/Badge.view.d.ts +1 -1
- package/dist/button/Button.d.ts +2 -1
- package/dist/button/Button.view.d.ts +1 -1
- package/dist/button/button.interface.d.ts +18 -17
- package/dist/button/buttonActions/ButtonActions.d.ts +11 -10
- package/dist/card/Card.d.ts +13 -12
- package/dist/card/Card.view.d.ts +1 -1
- package/dist/card/card.interface.d.ts +10 -10
- package/dist/card/cardAction/CardAction.d.ts +14 -13
- package/dist/card/cardAction.interface.d.ts +9 -8
- package/dist/card/hook/useCardInteractions.d.ts +8 -8
- package/dist/carousel/Carousel.d.ts +15 -14
- package/dist/carousel/Carousel.view.d.ts +1 -1
- package/dist/damier/Damier.d.ts +10 -9
- package/dist/damier/Damier.view.d.ts +1 -1
- package/dist/damier/damierCell/DamierCell.d.ts +7 -6
- package/dist/damier/damierCell/damierCell.interface.d.ts +6 -6
- package/dist/dataTable/DataTable.d.ts +18 -17
- package/dist/dataTable/DataTable.view.d.ts +1 -1
- package/dist/dataTable/dataTable.interface.d.ts +32 -30
- package/dist/datePicker/DatePicker.d.ts +8 -7
- package/dist/datePicker/DatePicker.view.d.ts +1 -1
- package/dist/expands/Expands.d.ts +10 -9
- package/dist/expands/Expands.view.d.ts +1 -1
- package/dist/expands/expand/expand.d.ts +9 -8
- package/dist/expands/expand/expand.interface.d.ts +9 -9
- package/dist/filAriane/FilAriane.d.ts +9 -8
- package/dist/filAriane/FilAriane.view.d.ts +1 -1
- package/dist/filAriane/filAriane.interface.d.ts +6 -6
- package/dist/form/Form.d.ts +24 -23
- package/dist/form/Form.view.d.ts +1 -1
- package/dist/form/form.enum.d.ts +11 -11
- package/dist/form/form.interface.d.ts +30 -29
- package/dist/form/textArea/TextArea.d.ts +13 -12
- package/dist/form/textArea/TextArea.view.d.ts +1 -1
- package/dist/grid/Grid.d.ts +8 -7
- package/dist/grid/Grid.view.d.ts +1 -1
- package/dist/grid/col/Col.d.ts +10 -10
- package/dist/grid/col/colStyled/ColStyled.d.ts +9 -9
- package/dist/grid/container/Container.d.ts +6 -5
- package/dist/grid/grid.interface.d.ts +8 -8
- package/dist/grid/row/Row.d.ts +8 -7
- package/dist/header/Header.d.ts +2 -1
- package/dist/header/Header.view.d.ts +1 -1
- package/dist/header/header.interface.d.ts +9 -9
- package/dist/home/Home.d.ts +1 -1
- package/dist/icon/Icon.d.ts +2 -1
- package/dist/icon/Icons.view.d.ts +1 -1
- package/dist/icon/icon.interface.d.ts +5 -4
- package/dist/icon/iconSize.enum.d.ts +7 -7
- package/dist/index.d.ts +32 -31
- package/dist/index.html +18 -18
- package/dist/index.js +66 -65
- package/dist/loader/Loader.d.ts +8 -7
- package/dist/loader/Loader.view.d.ts +1 -1
- package/dist/main.d.ts +1 -0
- package/dist/manifest.json +25 -25
- package/dist/menus/Menus.d.ts +6 -5
- package/dist/menus/Menus.view.d.ts +1 -1
- package/dist/menus/menu/Menu.d.ts +7 -6
- package/dist/menus/menu/menu.interface.d.ts +10 -10
- package/dist/modal/Modal.d.ts +13 -12
- package/dist/modal/Modal.view.d.ts +1 -1
- package/dist/notFound/NotFound.d.ts +1 -1
- package/dist/overlayPanel/OverlayPanel.d.ts +19 -18
- package/dist/overlayPanel/OverlayPanel.view.d.ts +1 -1
- package/dist/overlayPanel/overlay.context.d.ts +10 -9
- package/dist/overlayPanel/overlayPanelStyled/OverlayPanelStyled.d.ts +7 -7
- package/dist/quantity/Quantity.d.ts +11 -10
- package/dist/robots.txt +3 -3
- package/dist/search/Search.d.ts +22 -21
- package/dist/search/Search.view.d.ts +1 -1
- package/dist/select/Select.d.ts +14 -13
- package/dist/select/Select.view.d.ts +1 -1
- package/dist/select/selectOption.interface.d.ts +4 -4
- package/dist/sidebar/Sidebar.d.ts +13 -12
- package/dist/sidebar/Sidebar.view.d.ts +1 -1
- package/dist/sidebarData/SidebarData.d.ts +7 -6
- package/dist/sidebarData/SidebarData.view.d.ts +1 -1
- package/dist/style.css +1 -1
- package/dist/toaster/Toaster.d.ts +2 -1
- package/dist/toaster/Toaster.view.d.ts +1 -1
- package/dist/toaster/store/useToasterStore.d.ts +18 -18
- package/index.html +19 -19
- package/package.json +55 -55
- package/public/index.html +18 -18
- package/public/manifest.json +25 -25
- package/public/robots.txt +3 -3
- package/src/App.css +11 -11
- package/src/App.menu.tsx +209 -209
- package/src/App.routes.tsx +16 -16
- package/src/App.tsx +28 -28
- package/src/_core/hooks/ImageChecker.tsx +26 -26
- package/src/_core/hooks/useIsMobile.ts +18 -18
- package/src/action/Action.view.tsx +21 -21
- package/src/action/ButtonAction.tsx +32 -32
- package/src/action/action.css +20 -20
- package/src/badge/Badge.tsx +34 -34
- package/src/badge/Badge.view.tsx +15 -15
- package/src/badge/badge.css +55 -55
- package/src/button/Button.tsx +44 -44
- package/src/button/Button.view.tsx +61 -61
- package/src/button/button.css +53 -53
- package/src/button/button.interface.tsx +20 -20
- package/src/button/buttonActions/ButtonActions.tsx +101 -101
- package/src/card/Card.tsx +125 -125
- package/src/card/Card.view.tsx +73 -73
- package/src/card/card.css +145 -145
- package/src/card/card.interface.tsx +9 -9
- package/src/card/cardAction/CardAction.tsx +135 -135
- package/src/card/cardAction/cardAction.css +10 -10
- package/src/card/cardAction.interface.tsx +10 -10
- package/src/card/hook/useCardInteractions.tsx +30 -30
- package/src/carousel/Carousel.css +44 -44
- package/src/carousel/Carousel.tsx +115 -115
- package/src/carousel/Carousel.view.tsx +13 -13
- package/src/damier/Damier.tsx +55 -55
- package/src/damier/Damier.view.tsx +31 -31
- package/src/damier/damier.css +44 -44
- package/src/damier/damierCell/DamierCell.tsx +18 -18
- package/src/damier/damierCell/damierCell.interface.tsx +5 -5
- package/src/dataTable/DataTable.tsx +242 -241
- package/src/dataTable/DataTable.view.tsx +59 -59
- package/src/dataTable/dataTable.css +17 -17
- package/src/dataTable/dataTable.interface.ts +30 -29
- package/src/datePicker/DatePicker.tsx +110 -110
- package/src/datePicker/DatePicker.view.tsx +9 -9
- package/src/datePicker/datePicker.css +77 -77
- package/src/expands/Expands.tsx +42 -42
- package/src/expands/Expands.view.tsx +90 -90
- package/src/expands/expand/expand.interface.tsx +8 -8
- package/src/expands/expand/expand.tsx +75 -75
- package/src/expands/expands.css +97 -97
- package/src/filAriane/FilAriane.tsx +57 -57
- package/src/filAriane/FilAriane.view.tsx +28 -28
- package/src/filAriane/filAriane.css +22 -22
- package/src/filAriane/filAriane.interface.tsx +6 -6
- package/src/form/Form.tsx +175 -175
- package/src/form/Form.view.tsx +47 -47
- package/src/form/form.css +37 -37
- package/src/form/form.enum.ts +11 -11
- package/src/form/form.interface.tsx +31 -31
- package/src/form/textArea/TextArea.tsx +53 -53
- package/src/form/textArea/TextArea.view.tsx +34 -34
- package/src/form/textArea/textArea.css +9 -9
- package/src/grid/Grid.tsx +21 -21
- package/src/grid/Grid.view.tsx +24 -24
- package/src/grid/col/Col.tsx +15 -15
- package/src/grid/col/colStyled/ColStyled.tsx +41 -41
- package/src/grid/container/Container.tsx +8 -8
- package/src/grid/container/container.css +5 -5
- package/src/grid/grid.interface.tsx +7 -7
- package/src/grid/row/Row.tsx +12 -12
- package/src/grid/row/row.css +18 -18
- package/src/header/Header.tsx +51 -51
- package/src/header/Header.view.tsx +5 -5
- package/src/header/header.css +26 -26
- package/src/header/header.interface.tsx +8 -8
- package/src/home/Home.tsx +3 -3
- package/src/icon/Icon.tsx +6 -6
- package/src/icon/Icons.view.tsx +29 -29
- package/src/icon/icon.css +20 -20
- package/src/icon/icon.interface.tsx +6 -6
- package/src/icon/iconSize.enum.ts +7 -7
- package/src/index.css +502 -502
- package/src/index.ts +33 -33
- package/src/loader/Loader.tsx +37 -37
- package/src/loader/Loader.view.tsx +20 -20
- package/src/loader/loader.css +30 -30
- package/src/main.tsx +10 -10
- package/src/menus/Menus.tsx +42 -42
- package/src/menus/Menus.view.tsx +39 -39
- package/src/menus/menu/Menu.tsx +17 -17
- package/src/menus/menu/menu.interface.tsx +9 -9
- package/src/menus/menus.css +47 -47
- package/src/modal/Modal.tsx +53 -53
- package/src/modal/Modal.view.tsx +25 -25
- package/src/modal/modal.css +71 -70
- package/src/notFound/NotFound.tsx +3 -3
- package/src/overlayPanel/OverlayPanel.tsx +189 -189
- package/src/overlayPanel/OverlayPanel.view.tsx +25 -25
- package/src/overlayPanel/overlay.context.tsx +28 -28
- package/src/overlayPanel/overlayPanel.css +35 -35
- package/src/overlayPanel/overlayPanelStyled/OverlayPanelStyled.tsx +18 -18
- package/src/quantity/Quantity.tsx +103 -103
- package/src/quantity/quantity.css +26 -26
- package/src/search/Search.tsx +161 -161
- package/src/search/Search.view.tsx +14 -14
- package/src/search/search.css +59 -59
- package/src/select/Select.tsx +53 -53
- package/src/select/Select.view.tsx +71 -71
- package/src/select/select.css +51 -51
- package/src/select/selectOption.interface.ts +4 -4
- package/src/sidebar/Sidebar.tsx +111 -111
- package/src/sidebar/Sidebar.view.tsx +17 -17
- package/src/sidebar/sidebar.css +87 -87
- package/src/sidebarData/SidebarData.tsx +19 -19
- package/src/sidebarData/SidebarData.view.tsx +19 -19
- package/src/sidebarData/sidebarData.css +27 -27
- package/src/toaster/Toaster.tsx +47 -47
- package/src/toaster/Toaster.view.tsx +3 -3
- package/src/toaster/store/useToasterStore.tsx +39 -39
- package/src/toaster/toaster.css +57 -57
- package/tsconfig.json +28 -28
- package/vite.config.ts +20 -20
- package/vite.config.ts.timestamp-1733262892554-a13dfef6e8a29.mjs +24 -24
|
@@ -1,101 +1,101 @@
|
|
|
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
|
-
};
|
|
19
|
-
export const ButtonActions = ({
|
|
20
|
-
className,
|
|
21
|
-
onClick,
|
|
22
|
-
title,
|
|
23
|
-
actions,
|
|
24
|
-
positionActions = "topRight",
|
|
25
|
-
disabled = false,
|
|
26
|
-
}: ButtonActionsProps) => {
|
|
27
|
-
const handleClick = (e: React.MouseEvent) => {
|
|
28
|
-
e.preventDefault();
|
|
29
|
-
if (onClick) {
|
|
30
|
-
onClick(e);
|
|
31
|
-
}
|
|
32
|
-
};
|
|
33
|
-
const refButton = useRef<HTMLDivElement>(null);
|
|
34
|
-
const [openOverlay, setOpenOverlay] = useState(false);
|
|
35
|
-
const onClickActions = useCallback(
|
|
36
|
-
(e: React.MouseEvent) => {
|
|
37
|
-
e.stopPropagation();
|
|
38
|
-
if (actions) setOpenOverlay(!openOverlay);
|
|
39
|
-
},
|
|
40
|
-
[openOverlay, setOpenOverlay]
|
|
41
|
-
);
|
|
42
|
-
const overlayMenu: MenuInterface[] = useMemo(() => {
|
|
43
|
-
if (!actions) return [];
|
|
44
|
-
return actions.map((a, index) => {
|
|
45
|
-
return {
|
|
46
|
-
id: a.id ?? index,
|
|
47
|
-
icon: a.icon,
|
|
48
|
-
name: a.label,
|
|
49
|
-
children: (
|
|
50
|
-
<Button
|
|
51
|
-
key={index}
|
|
52
|
-
classIcon={a.icon}
|
|
53
|
-
sizeIcon={IconSizeEnum.LARGE}
|
|
54
|
-
onClick={(e) => {
|
|
55
|
-
e.stopPropagation();
|
|
56
|
-
closeOverlay();
|
|
57
|
-
a.onClick && a.onClick(a);
|
|
58
|
-
}}
|
|
59
|
-
title={a.label || ""}
|
|
60
|
-
/>
|
|
61
|
-
),
|
|
62
|
-
};
|
|
63
|
-
}) as MenuInterface[];
|
|
64
|
-
}, [actions]);
|
|
65
|
-
const closeOverlay = useCallback(() => {
|
|
66
|
-
setOpenOverlay(false);
|
|
67
|
-
}, [setOpenOverlay]);
|
|
68
|
-
return (
|
|
69
|
-
<>
|
|
70
|
-
<button
|
|
71
|
-
disabled={disabled}
|
|
72
|
-
type="submit"
|
|
73
|
-
onClick={(e) => handleClick(e)}
|
|
74
|
-
className={` ${className} button-actions`}
|
|
75
|
-
>
|
|
76
|
-
<span className="mr-2 flex-1">{title}</span>
|
|
77
|
-
|
|
78
|
-
<span
|
|
79
|
-
className="ml-2"
|
|
80
|
-
ref={refButton}
|
|
81
|
-
onClick={(e) => onClickActions(e)}
|
|
82
|
-
>
|
|
83
|
-
<Icon classIcon="bi-chevron-up" />
|
|
84
|
-
</span>
|
|
85
|
-
</button>
|
|
86
|
-
{actions && openOverlay && refButton.current && (
|
|
87
|
-
<OverlayPanel
|
|
88
|
-
show={openOverlay}
|
|
89
|
-
position={positionActions}
|
|
90
|
-
closeOverlay={setOpenOverlay}
|
|
91
|
-
referenceElement={refButton.current}
|
|
92
|
-
children={
|
|
93
|
-
<div>
|
|
94
|
-
<Menus className="card-action-menu" items={overlayMenu} />
|
|
95
|
-
</div>
|
|
96
|
-
}
|
|
97
|
-
/>
|
|
98
|
-
)}
|
|
99
|
-
</>
|
|
100
|
-
);
|
|
101
|
-
};
|
|
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
|
+
};
|
|
19
|
+
export const ButtonActions = ({
|
|
20
|
+
className,
|
|
21
|
+
onClick,
|
|
22
|
+
title,
|
|
23
|
+
actions,
|
|
24
|
+
positionActions = "topRight",
|
|
25
|
+
disabled = false,
|
|
26
|
+
}: ButtonActionsProps) => {
|
|
27
|
+
const handleClick = (e: React.MouseEvent) => {
|
|
28
|
+
e.preventDefault();
|
|
29
|
+
if (onClick) {
|
|
30
|
+
onClick(e);
|
|
31
|
+
}
|
|
32
|
+
};
|
|
33
|
+
const refButton = useRef<HTMLDivElement>(null);
|
|
34
|
+
const [openOverlay, setOpenOverlay] = useState(false);
|
|
35
|
+
const onClickActions = useCallback(
|
|
36
|
+
(e: React.MouseEvent) => {
|
|
37
|
+
e.stopPropagation();
|
|
38
|
+
if (actions) setOpenOverlay(!openOverlay);
|
|
39
|
+
},
|
|
40
|
+
[openOverlay, setOpenOverlay]
|
|
41
|
+
);
|
|
42
|
+
const overlayMenu: MenuInterface[] = useMemo(() => {
|
|
43
|
+
if (!actions) return [];
|
|
44
|
+
return actions.map((a, index) => {
|
|
45
|
+
return {
|
|
46
|
+
id: a.id ?? index,
|
|
47
|
+
icon: a.icon,
|
|
48
|
+
name: a.label,
|
|
49
|
+
children: (
|
|
50
|
+
<Button
|
|
51
|
+
key={index}
|
|
52
|
+
classIcon={a.icon}
|
|
53
|
+
sizeIcon={IconSizeEnum.LARGE}
|
|
54
|
+
onClick={(e) => {
|
|
55
|
+
e.stopPropagation();
|
|
56
|
+
closeOverlay();
|
|
57
|
+
a.onClick && a.onClick(a);
|
|
58
|
+
}}
|
|
59
|
+
title={a.label || ""}
|
|
60
|
+
/>
|
|
61
|
+
),
|
|
62
|
+
};
|
|
63
|
+
}) as MenuInterface[];
|
|
64
|
+
}, [actions]);
|
|
65
|
+
const closeOverlay = useCallback(() => {
|
|
66
|
+
setOpenOverlay(false);
|
|
67
|
+
}, [setOpenOverlay]);
|
|
68
|
+
return (
|
|
69
|
+
<>
|
|
70
|
+
<button
|
|
71
|
+
disabled={disabled}
|
|
72
|
+
type="submit"
|
|
73
|
+
onClick={(e) => handleClick(e)}
|
|
74
|
+
className={` ${className} button-actions`}
|
|
75
|
+
>
|
|
76
|
+
<span className="mr-2 flex-1">{title}</span>
|
|
77
|
+
|
|
78
|
+
<span
|
|
79
|
+
className="ml-2"
|
|
80
|
+
ref={refButton}
|
|
81
|
+
onClick={(e) => onClickActions(e)}
|
|
82
|
+
>
|
|
83
|
+
<Icon classIcon="bi-chevron-up" />
|
|
84
|
+
</span>
|
|
85
|
+
</button>
|
|
86
|
+
{actions && openOverlay && refButton.current && (
|
|
87
|
+
<OverlayPanel
|
|
88
|
+
show={openOverlay}
|
|
89
|
+
position={positionActions}
|
|
90
|
+
closeOverlay={setOpenOverlay}
|
|
91
|
+
referenceElement={refButton.current}
|
|
92
|
+
children={
|
|
93
|
+
<div>
|
|
94
|
+
<Menus className="card-action-menu" items={overlayMenu} />
|
|
95
|
+
</div>
|
|
96
|
+
}
|
|
97
|
+
/>
|
|
98
|
+
)}
|
|
99
|
+
</>
|
|
100
|
+
);
|
|
101
|
+
};
|
package/src/card/Card.tsx
CHANGED
|
@@ -1,125 +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
|
-
};
|
|
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
|
+
};
|
package/src/card/Card.view.tsx
CHANGED
|
@@ -1,73 +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
|
-
};
|
|
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
|
+
};
|