kelt-ui-kit-react 1.2.0 → 1.2.2
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 +2 -3
- package/dist/App.menu.d.ts +10 -10
- package/dist/App.routes.d.ts +1 -1
- package/dist/_core/hooks/ImageChecker.d.ts +5 -6
- package/dist/_core/hooks/useIsMobile.d.ts +1 -1
- package/dist/action/Action.view.d.ts +1 -1
- package/dist/action/ButtonAction.d.ts +8 -9
- package/dist/badge/Badge.d.ts +8 -9
- package/dist/badge/Badge.view.d.ts +1 -1
- package/dist/button/Button.d.ts +1 -2
- package/dist/button/Button.view.d.ts +1 -1
- package/dist/button/button.interface.d.ts +17 -18
- package/dist/button/buttonActions/ButtonActions.d.ts +10 -11
- package/dist/card/Card.d.ts +12 -13
- 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 +13 -14
- package/dist/card/cardAction.interface.d.ts +8 -9
- package/dist/card/hook/useCardInteractions.d.ts +8 -8
- package/dist/carousel/Carousel.d.ts +14 -15
- package/dist/carousel/Carousel.view.d.ts +1 -1
- package/dist/damier/Damier.d.ts +9 -10
- package/dist/damier/Damier.view.d.ts +1 -1
- package/dist/damier/damierCell/DamierCell.d.ts +6 -7
- package/dist/damier/damierCell/damierCell.interface.d.ts +6 -6
- package/dist/dataTable/DataTable.d.ts +17 -16
- package/dist/dataTable/DataTable.view.d.ts +1 -1
- package/dist/dataTable/dataTable.interface.d.ts +30 -31
- package/dist/datePicker/DatePicker.d.ts +7 -8
- package/dist/datePicker/DatePicker.view.d.ts +1 -1
- package/dist/expands/Expands.d.ts +9 -10
- package/dist/expands/Expands.view.d.ts +1 -1
- package/dist/expands/expand/expand.d.ts +8 -9
- package/dist/expands/expand/expand.interface.d.ts +9 -9
- package/dist/filAriane/FilAriane.d.ts +8 -9
- package/dist/filAriane/FilAriane.view.d.ts +1 -1
- package/dist/filAriane/filAriane.interface.d.ts +6 -6
- package/dist/form/Form.d.ts +23 -24
- 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 +29 -30
- package/dist/form/textArea/TextArea.d.ts +12 -13
- package/dist/form/textArea/TextArea.view.d.ts +1 -1
- package/dist/grid/Grid.d.ts +7 -8
- 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 +5 -6
- package/dist/grid/grid.interface.d.ts +8 -8
- package/dist/grid/row/Row.d.ts +7 -8
- package/dist/header/Header.d.ts +1 -2
- 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 +1 -2
- package/dist/icon/Icons.view.d.ts +1 -1
- package/dist/icon/icon.interface.d.ts +4 -5
- package/dist/icon/iconSize.enum.d.ts +7 -7
- package/dist/index.d.ts +31 -32
- package/dist/index.html +18 -18
- package/dist/index.js +902 -885
- package/dist/loader/Loader.d.ts +7 -8
- package/dist/loader/Loader.view.d.ts +1 -1
- package/dist/main.d.ts +0 -1
- package/dist/manifest.json +25 -25
- package/dist/menus/Menus.d.ts +5 -6
- package/dist/menus/Menus.view.d.ts +1 -1
- package/dist/menus/menu/Menu.d.ts +6 -7
- package/dist/menus/menu/menu.interface.d.ts +10 -10
- package/dist/modal/Modal.d.ts +12 -13
- package/dist/modal/Modal.view.d.ts +1 -1
- package/dist/notFound/NotFound.d.ts +1 -1
- package/dist/overlayPanel/OverlayPanel.d.ts +18 -19
- package/dist/overlayPanel/OverlayPanel.view.d.ts +1 -1
- package/dist/overlayPanel/overlay.context.d.ts +9 -10
- package/dist/overlayPanel/overlayPanelStyled/OverlayPanelStyled.d.ts +7 -7
- package/dist/quantity/Quantity.d.ts +10 -11
- package/dist/robots.txt +3 -3
- package/dist/search/Search.d.ts +21 -22
- package/dist/search/Search.view.d.ts +1 -1
- package/dist/select/Select.d.ts +13 -14
- package/dist/select/Select.view.d.ts +1 -1
- package/dist/select/selectOption.interface.d.ts +4 -4
- package/dist/sidebar/Sidebar.d.ts +12 -13
- package/dist/sidebar/Sidebar.view.d.ts +1 -1
- package/dist/sidebarData/SidebarData.d.ts +6 -7
- package/dist/sidebarData/SidebarData.view.d.ts +1 -1
- package/dist/style.css +1 -1
- package/dist/toaster/Toaster.d.ts +1 -2
- 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 +236 -202
- package/src/dataTable/DataTable.view.tsx +59 -59
- package/src/dataTable/dataTable.css +16 -14
- package/src/dataTable/dataTable.interface.ts +29 -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 +69 -65
- 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
package/src/modal/Modal.tsx
CHANGED
|
@@ -1,53 +1,53 @@
|
|
|
1
|
-
import React, { ReactNode } from "react";
|
|
2
|
-
import { createPortal } from "react-dom";
|
|
3
|
-
import { Button } from "../button/Button";
|
|
4
|
-
import { Icon } from "../icon/Icon";
|
|
5
|
-
import "./modal.css";
|
|
6
|
-
|
|
7
|
-
interface ModalProps {
|
|
8
|
-
isOpen: boolean;
|
|
9
|
-
onClose: () => void;
|
|
10
|
-
onSubmit?: () => void;
|
|
11
|
-
titleButton?: string;
|
|
12
|
-
children: ReactNode;
|
|
13
|
-
title?: string;
|
|
14
|
-
styleContainer?: React.CSSProperties;
|
|
15
|
-
classNameContainer?: string;
|
|
16
|
-
}
|
|
17
|
-
|
|
18
|
-
export const Modal: React.FC<ModalProps> = ({
|
|
19
|
-
isOpen,
|
|
20
|
-
onClose,
|
|
21
|
-
children,
|
|
22
|
-
onSubmit,
|
|
23
|
-
titleButton,
|
|
24
|
-
title,
|
|
25
|
-
styleContainer = {},
|
|
26
|
-
classNameContainer = "",
|
|
27
|
-
}) => {
|
|
28
|
-
if (!isOpen) return null;
|
|
29
|
-
|
|
30
|
-
return createPortal(
|
|
31
|
-
<div className="modal-overlay" onMouseDown={onClose}>
|
|
32
|
-
<div
|
|
33
|
-
className={`modal-container ${classNameContainer}`}
|
|
34
|
-
style={styleContainer}
|
|
35
|
-
onMouseDown={(e) => e.stopPropagation()}
|
|
36
|
-
>
|
|
37
|
-
<div className="modal-header">
|
|
38
|
-
{title && <h2 className="modal-title">{title}</h2>}
|
|
39
|
-
<div className="modal-close-button" onClick={onClose}>
|
|
40
|
-
<Icon classIcon="bi-x-lg" />
|
|
41
|
-
</div>
|
|
42
|
-
</div>
|
|
43
|
-
<div className="modal-content">{children}</div>
|
|
44
|
-
{onSubmit && (
|
|
45
|
-
<div className="d-flex justify-content-end">
|
|
46
|
-
<Button onClick={onSubmit} title={titleButton ?? ""} />
|
|
47
|
-
</div>
|
|
48
|
-
)}
|
|
49
|
-
</div>
|
|
50
|
-
</div>,
|
|
51
|
-
document.body
|
|
52
|
-
);
|
|
53
|
-
};
|
|
1
|
+
import React, { ReactNode } from "react";
|
|
2
|
+
import { createPortal } from "react-dom";
|
|
3
|
+
import { Button } from "../button/Button";
|
|
4
|
+
import { Icon } from "../icon/Icon";
|
|
5
|
+
import "./modal.css";
|
|
6
|
+
|
|
7
|
+
interface ModalProps {
|
|
8
|
+
isOpen: boolean;
|
|
9
|
+
onClose: () => void;
|
|
10
|
+
onSubmit?: () => void;
|
|
11
|
+
titleButton?: string;
|
|
12
|
+
children: ReactNode;
|
|
13
|
+
title?: string;
|
|
14
|
+
styleContainer?: React.CSSProperties;
|
|
15
|
+
classNameContainer?: string;
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
export const Modal: React.FC<ModalProps> = ({
|
|
19
|
+
isOpen,
|
|
20
|
+
onClose,
|
|
21
|
+
children,
|
|
22
|
+
onSubmit,
|
|
23
|
+
titleButton,
|
|
24
|
+
title,
|
|
25
|
+
styleContainer = {},
|
|
26
|
+
classNameContainer = "",
|
|
27
|
+
}) => {
|
|
28
|
+
if (!isOpen) return null;
|
|
29
|
+
|
|
30
|
+
return createPortal(
|
|
31
|
+
<div className="modal-overlay" onMouseDown={onClose}>
|
|
32
|
+
<div
|
|
33
|
+
className={`modal-container ${classNameContainer}`}
|
|
34
|
+
style={styleContainer}
|
|
35
|
+
onMouseDown={(e) => e.stopPropagation()}
|
|
36
|
+
>
|
|
37
|
+
<div className="modal-header">
|
|
38
|
+
{title && <h2 className="modal-title">{title}</h2>}
|
|
39
|
+
<div className="modal-close-button" onClick={onClose}>
|
|
40
|
+
<Icon classIcon="bi-x-lg" />
|
|
41
|
+
</div>
|
|
42
|
+
</div>
|
|
43
|
+
<div className="modal-content">{children}</div>
|
|
44
|
+
{onSubmit && (
|
|
45
|
+
<div className="d-flex justify-content-end">
|
|
46
|
+
<Button onClick={onSubmit} title={titleButton ?? ""} />
|
|
47
|
+
</div>
|
|
48
|
+
)}
|
|
49
|
+
</div>
|
|
50
|
+
</div>,
|
|
51
|
+
document.body
|
|
52
|
+
);
|
|
53
|
+
};
|
package/src/modal/Modal.view.tsx
CHANGED
|
@@ -1,25 +1,25 @@
|
|
|
1
|
-
import { useCallback, useState } from "react";
|
|
2
|
-
import { Button } from "../button/Button";
|
|
3
|
-
import { Modal } from "./Modal";
|
|
4
|
-
|
|
5
|
-
export const ModalView = (): JSX.Element => {
|
|
6
|
-
const [isOpen, setIsOpen] = useState(false);
|
|
7
|
-
const openModal = useCallback(() => {
|
|
8
|
-
setIsOpen(true);
|
|
9
|
-
}, [setIsOpen, true]);
|
|
10
|
-
|
|
11
|
-
return (
|
|
12
|
-
<div>
|
|
13
|
-
<Button onClick={openModal} title="Open Modal" />
|
|
14
|
-
<Modal
|
|
15
|
-
onSubmit={() => setIsOpen(false)}
|
|
16
|
-
title={"test"}
|
|
17
|
-
titleButton="Submit"
|
|
18
|
-
onClose={() => setIsOpen(false)}
|
|
19
|
-
isOpen={isOpen}
|
|
20
|
-
>
|
|
21
|
-
test
|
|
22
|
-
</Modal>
|
|
23
|
-
</div>
|
|
24
|
-
);
|
|
25
|
-
};
|
|
1
|
+
import { useCallback, useState } from "react";
|
|
2
|
+
import { Button } from "../button/Button";
|
|
3
|
+
import { Modal } from "./Modal";
|
|
4
|
+
|
|
5
|
+
export const ModalView = (): JSX.Element => {
|
|
6
|
+
const [isOpen, setIsOpen] = useState(false);
|
|
7
|
+
const openModal = useCallback(() => {
|
|
8
|
+
setIsOpen(true);
|
|
9
|
+
}, [setIsOpen, true]);
|
|
10
|
+
|
|
11
|
+
return (
|
|
12
|
+
<div>
|
|
13
|
+
<Button onClick={openModal} title="Open Modal" />
|
|
14
|
+
<Modal
|
|
15
|
+
onSubmit={() => setIsOpen(false)}
|
|
16
|
+
title={"test"}
|
|
17
|
+
titleButton="Submit"
|
|
18
|
+
onClose={() => setIsOpen(false)}
|
|
19
|
+
isOpen={isOpen}
|
|
20
|
+
>
|
|
21
|
+
test
|
|
22
|
+
</Modal>
|
|
23
|
+
</div>
|
|
24
|
+
);
|
|
25
|
+
};
|
package/src/modal/modal.css
CHANGED
|
@@ -1,65 +1,69 @@
|
|
|
1
|
-
/* Modal.css */
|
|
2
|
-
|
|
3
|
-
.modal-overlay {
|
|
4
|
-
position: fixed;
|
|
5
|
-
top: 0;
|
|
6
|
-
left: 0;
|
|
7
|
-
right: 0;
|
|
8
|
-
bottom: 0;
|
|
9
|
-
background-color: rgba(0, 0, 0, 0.5);
|
|
10
|
-
display: flex;
|
|
11
|
-
justify-content: center;
|
|
12
|
-
align-items: center;
|
|
13
|
-
z-index: 2;
|
|
14
|
-
}
|
|
15
|
-
|
|
16
|
-
.modal-container {
|
|
17
|
-
background: white;
|
|
18
|
-
border-radius: 8px;
|
|
19
|
-
max-width: 500px;
|
|
20
|
-
width: 90%;
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
.
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
opacity:
|
|
63
|
-
transform: scale(
|
|
64
|
-
}
|
|
65
|
-
|
|
1
|
+
/* Modal.css */
|
|
2
|
+
|
|
3
|
+
.modal-overlay {
|
|
4
|
+
position: fixed;
|
|
5
|
+
top: 0;
|
|
6
|
+
left: 0;
|
|
7
|
+
right: 0;
|
|
8
|
+
bottom: 0;
|
|
9
|
+
background-color: rgba(0, 0, 0, 0.5);
|
|
10
|
+
display: flex;
|
|
11
|
+
justify-content: center;
|
|
12
|
+
align-items: center;
|
|
13
|
+
z-index: 2;
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
.modal-container {
|
|
17
|
+
background: white;
|
|
18
|
+
border-radius: 8px;
|
|
19
|
+
max-width: 500px;
|
|
20
|
+
width: 90%;
|
|
21
|
+
max-height: 90%;
|
|
22
|
+
display : flex;
|
|
23
|
+
overflow : hidden;
|
|
24
|
+
box-shadow: 0 4px 6px rgba(0, 0, 0, 0.1);
|
|
25
|
+
padding: 20px;
|
|
26
|
+
position: relative;
|
|
27
|
+
animation: fadeIn 0.3s ease;
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
.modal-header {
|
|
31
|
+
display: flex;
|
|
32
|
+
justify-content: space-between;
|
|
33
|
+
align-items: center;
|
|
34
|
+
margin-bottom: 10px;
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
.modal-title {
|
|
38
|
+
font-size: 1.25rem;
|
|
39
|
+
margin: 0;
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
.modal-close-button {
|
|
43
|
+
background: transparent;
|
|
44
|
+
border: none;
|
|
45
|
+
position: absolute;
|
|
46
|
+
right: 10px;
|
|
47
|
+
top: 10px;
|
|
48
|
+
cursor: pointer;
|
|
49
|
+
}
|
|
50
|
+
|
|
51
|
+
.modal-close-button:hover {
|
|
52
|
+
color: red;
|
|
53
|
+
}
|
|
54
|
+
|
|
55
|
+
.modal-content {
|
|
56
|
+
margin-top: 10px;
|
|
57
|
+
flex : 1;
|
|
58
|
+
}
|
|
59
|
+
|
|
60
|
+
@keyframes fadeIn {
|
|
61
|
+
from {
|
|
62
|
+
opacity: 0;
|
|
63
|
+
transform: scale(0.9);
|
|
64
|
+
}
|
|
65
|
+
to {
|
|
66
|
+
opacity: 1;
|
|
67
|
+
transform: scale(1);
|
|
68
|
+
}
|
|
69
|
+
}
|
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
export const NotFound = (): JSX.Element => {
|
|
2
|
-
return <h1>404 - Page Not Found</h1>;
|
|
3
|
-
};
|
|
1
|
+
export const NotFound = (): JSX.Element => {
|
|
2
|
+
return <h1>404 - Page Not Found</h1>;
|
|
3
|
+
};
|
|
@@ -1,189 +1,189 @@
|
|
|
1
|
-
import React, {
|
|
2
|
-
forwardRef,
|
|
3
|
-
useCallback,
|
|
4
|
-
useEffect,
|
|
5
|
-
useId,
|
|
6
|
-
useImperativeHandle,
|
|
7
|
-
useRef,
|
|
8
|
-
useState,
|
|
9
|
-
} from "react";
|
|
10
|
-
import ReactDOM from "react-dom";
|
|
11
|
-
|
|
12
|
-
import { Icon } from "../icon/Icon";
|
|
13
|
-
import { useOverlayContext } from "./overlay.context";
|
|
14
|
-
import "./overlayPanel.css";
|
|
15
|
-
import { OverlayPanelStyled } from "./overlayPanelStyled/OverlayPanelStyled";
|
|
16
|
-
|
|
17
|
-
export type PositionOverlay =
|
|
18
|
-
| "left"
|
|
19
|
-
| "right"
|
|
20
|
-
| "topLeft"
|
|
21
|
-
| "topRight"
|
|
22
|
-
| "bottomLeft"
|
|
23
|
-
| "bottomRight";
|
|
24
|
-
|
|
25
|
-
export type OverlayPanelProps = {
|
|
26
|
-
referenceElement?: HTMLElement;
|
|
27
|
-
coordonnees?: { top: number; left: number };
|
|
28
|
-
position?: PositionOverlay;
|
|
29
|
-
children: React.ReactNode;
|
|
30
|
-
show?: boolean;
|
|
31
|
-
closeOverlay?: (close: boolean) => void;
|
|
32
|
-
};
|
|
33
|
-
|
|
34
|
-
export const OverlayPanel = forwardRef(
|
|
35
|
-
(
|
|
36
|
-
{
|
|
37
|
-
referenceElement,
|
|
38
|
-
position,
|
|
39
|
-
coordonnees,
|
|
40
|
-
children,
|
|
41
|
-
show,
|
|
42
|
-
closeOverlay,
|
|
43
|
-
}: OverlayPanelProps,
|
|
44
|
-
ref: React.Ref<{
|
|
45
|
-
setCoords?: (coords: { top: number; left: number }) => void;
|
|
46
|
-
}>
|
|
47
|
-
) => {
|
|
48
|
-
const { activeOverlayId, setActiveOverlay } = useOverlayContext();
|
|
49
|
-
const [isShow, setIsShow] = useState(show || false);
|
|
50
|
-
const [coords, setCoords] = useState<{ top: number; left: number }>(
|
|
51
|
-
coordonnees ?? { top: 0, left: 0 }
|
|
52
|
-
);
|
|
53
|
-
const boxRef = useRef<HTMLDivElement>(null);
|
|
54
|
-
const overlayId = useId();
|
|
55
|
-
useImperativeHandle(ref, () => ({
|
|
56
|
-
setCoords,
|
|
57
|
-
}));
|
|
58
|
-
|
|
59
|
-
useEffect(() => {
|
|
60
|
-
if (activeOverlayId !== overlayId) {
|
|
61
|
-
setIsShow(false);
|
|
62
|
-
}
|
|
63
|
-
}, [activeOverlayId, overlayId]);
|
|
64
|
-
|
|
65
|
-
useEffect(() => {
|
|
66
|
-
const updatePosition = () => {
|
|
67
|
-
if (!position && coordonnees) {
|
|
68
|
-
setCoords(coordonnees);
|
|
69
|
-
} else if (referenceElement) {
|
|
70
|
-
const rect = referenceElement.getBoundingClientRect();
|
|
71
|
-
const boxRect = boxRef.current?.getBoundingClientRect();
|
|
72
|
-
const { innerWidth, innerHeight } = window;
|
|
73
|
-
|
|
74
|
-
if (boxRect) {
|
|
75
|
-
// Positions par défaut si définies
|
|
76
|
-
let top, left;
|
|
77
|
-
const positions = {
|
|
78
|
-
topRight: () => ({
|
|
79
|
-
top: rect.top - boxRect.height,
|
|
80
|
-
left: rect.right - boxRect.width,
|
|
81
|
-
}),
|
|
82
|
-
topLeft: () => ({
|
|
83
|
-
top: rect.top - boxRect.height,
|
|
84
|
-
left: rect.left,
|
|
85
|
-
}),
|
|
86
|
-
bottomRight: () => ({
|
|
87
|
-
top: rect.bottom,
|
|
88
|
-
left: rect.right - boxRect.width,
|
|
89
|
-
}),
|
|
90
|
-
bottomLeft: () => ({
|
|
91
|
-
top: rect.bottom,
|
|
92
|
-
left: rect.left,
|
|
93
|
-
}),
|
|
94
|
-
left: () => ({
|
|
95
|
-
top: rect.top + rect.height / 2 - boxRect.height / 2,
|
|
96
|
-
left: rect.left - boxRect.width,
|
|
97
|
-
}),
|
|
98
|
-
right: () => ({
|
|
99
|
-
top: rect.top + rect.height / 2 - boxRect.height / 2,
|
|
100
|
-
left: rect.right,
|
|
101
|
-
}),
|
|
102
|
-
};
|
|
103
|
-
|
|
104
|
-
if (position && positions[position]) {
|
|
105
|
-
// Si une position est définie, on tente de l'appliquer
|
|
106
|
-
({ top, left } = positions[position]());
|
|
107
|
-
} else {
|
|
108
|
-
// Sinon, on adapte dynamiquement
|
|
109
|
-
left = rect.right;
|
|
110
|
-
top = rect.bottom;
|
|
111
|
-
|
|
112
|
-
if (rect.right + boxRect.width > innerWidth) {
|
|
113
|
-
left = rect.left - boxRect.width; // Manque d'espace à droite → afficher à gauche
|
|
114
|
-
}
|
|
115
|
-
|
|
116
|
-
if (rect.bottom + boxRect.height > innerHeight) {
|
|
117
|
-
top = rect.top - boxRect.height; // Manque d'espace en bas → afficher en haut
|
|
118
|
-
}
|
|
119
|
-
}
|
|
120
|
-
|
|
121
|
-
setCoords({ top, left: left < 0 ? 0 : left });
|
|
122
|
-
}
|
|
123
|
-
}
|
|
124
|
-
};
|
|
125
|
-
|
|
126
|
-
if (isShow) {
|
|
127
|
-
updatePosition();
|
|
128
|
-
window.addEventListener("resize", updatePosition);
|
|
129
|
-
}
|
|
130
|
-
|
|
131
|
-
return () => window.removeEventListener("resize", updatePosition);
|
|
132
|
-
}, [referenceElement, isShow, position]);
|
|
133
|
-
|
|
134
|
-
const openOverlay = () => {
|
|
135
|
-
setIsShow(true);
|
|
136
|
-
setActiveOverlay(overlayId);
|
|
137
|
-
};
|
|
138
|
-
|
|
139
|
-
const closeOverlayHandler = useCallback(
|
|
140
|
-
(e: any) => {
|
|
141
|
-
e.stopPropagation();
|
|
142
|
-
setIsShow(false);
|
|
143
|
-
setActiveOverlay(null);
|
|
144
|
-
if (closeOverlay) {
|
|
145
|
-
closeOverlay(false);
|
|
146
|
-
}
|
|
147
|
-
},
|
|
148
|
-
[closeOverlay, setActiveOverlay]
|
|
149
|
-
);
|
|
150
|
-
useEffect(() => {
|
|
151
|
-
const handleClickOutside = (event: MouseEvent) => {
|
|
152
|
-
if (boxRef.current && !boxRef.current.contains(event.target as Node)) {
|
|
153
|
-
closeOverlayHandler(event);
|
|
154
|
-
}
|
|
155
|
-
};
|
|
156
|
-
|
|
157
|
-
if (isShow) {
|
|
158
|
-
document.addEventListener("mousedown", handleClickOutside);
|
|
159
|
-
}
|
|
160
|
-
|
|
161
|
-
return () => {
|
|
162
|
-
document.removeEventListener("mousedown", handleClickOutside);
|
|
163
|
-
};
|
|
164
|
-
}, [isShow, closeOverlayHandler]);
|
|
165
|
-
useEffect(() => {
|
|
166
|
-
if (show) {
|
|
167
|
-
openOverlay();
|
|
168
|
-
}
|
|
169
|
-
}, [show]);
|
|
170
|
-
|
|
171
|
-
if (!isShow) return null;
|
|
172
|
-
|
|
173
|
-
return ReactDOM.createPortal(
|
|
174
|
-
<OverlayPanelStyled ref={boxRef} $top={coords.top} $left={coords.left}>
|
|
175
|
-
<div
|
|
176
|
-
className={`overlayPanel ${
|
|
177
|
-
coords.top > 0 || coords.left > 0 ? "visible" : "hide"
|
|
178
|
-
}`}
|
|
179
|
-
>
|
|
180
|
-
<button className="toggle-btn" onClick={closeOverlayHandler}>
|
|
181
|
-
<Icon classIcon="bi-x-lg" />
|
|
182
|
-
</button>
|
|
183
|
-
{children}
|
|
184
|
-
</div>
|
|
185
|
-
</OverlayPanelStyled>,
|
|
186
|
-
document.body
|
|
187
|
-
);
|
|
188
|
-
}
|
|
189
|
-
);
|
|
1
|
+
import React, {
|
|
2
|
+
forwardRef,
|
|
3
|
+
useCallback,
|
|
4
|
+
useEffect,
|
|
5
|
+
useId,
|
|
6
|
+
useImperativeHandle,
|
|
7
|
+
useRef,
|
|
8
|
+
useState,
|
|
9
|
+
} from "react";
|
|
10
|
+
import ReactDOM from "react-dom";
|
|
11
|
+
|
|
12
|
+
import { Icon } from "../icon/Icon";
|
|
13
|
+
import { useOverlayContext } from "./overlay.context";
|
|
14
|
+
import "./overlayPanel.css";
|
|
15
|
+
import { OverlayPanelStyled } from "./overlayPanelStyled/OverlayPanelStyled";
|
|
16
|
+
|
|
17
|
+
export type PositionOverlay =
|
|
18
|
+
| "left"
|
|
19
|
+
| "right"
|
|
20
|
+
| "topLeft"
|
|
21
|
+
| "topRight"
|
|
22
|
+
| "bottomLeft"
|
|
23
|
+
| "bottomRight";
|
|
24
|
+
|
|
25
|
+
export type OverlayPanelProps = {
|
|
26
|
+
referenceElement?: HTMLElement;
|
|
27
|
+
coordonnees?: { top: number; left: number };
|
|
28
|
+
position?: PositionOverlay;
|
|
29
|
+
children: React.ReactNode;
|
|
30
|
+
show?: boolean;
|
|
31
|
+
closeOverlay?: (close: boolean) => void;
|
|
32
|
+
};
|
|
33
|
+
|
|
34
|
+
export const OverlayPanel = forwardRef(
|
|
35
|
+
(
|
|
36
|
+
{
|
|
37
|
+
referenceElement,
|
|
38
|
+
position,
|
|
39
|
+
coordonnees,
|
|
40
|
+
children,
|
|
41
|
+
show,
|
|
42
|
+
closeOverlay,
|
|
43
|
+
}: OverlayPanelProps,
|
|
44
|
+
ref: React.Ref<{
|
|
45
|
+
setCoords?: (coords: { top: number; left: number }) => void;
|
|
46
|
+
}>
|
|
47
|
+
) => {
|
|
48
|
+
const { activeOverlayId, setActiveOverlay } = useOverlayContext();
|
|
49
|
+
const [isShow, setIsShow] = useState(show || false);
|
|
50
|
+
const [coords, setCoords] = useState<{ top: number; left: number }>(
|
|
51
|
+
coordonnees ?? { top: 0, left: 0 }
|
|
52
|
+
);
|
|
53
|
+
const boxRef = useRef<HTMLDivElement>(null);
|
|
54
|
+
const overlayId = useId();
|
|
55
|
+
useImperativeHandle(ref, () => ({
|
|
56
|
+
setCoords,
|
|
57
|
+
}));
|
|
58
|
+
|
|
59
|
+
useEffect(() => {
|
|
60
|
+
if (activeOverlayId !== overlayId) {
|
|
61
|
+
setIsShow(false);
|
|
62
|
+
}
|
|
63
|
+
}, [activeOverlayId, overlayId]);
|
|
64
|
+
|
|
65
|
+
useEffect(() => {
|
|
66
|
+
const updatePosition = () => {
|
|
67
|
+
if (!position && coordonnees) {
|
|
68
|
+
setCoords(coordonnees);
|
|
69
|
+
} else if (referenceElement) {
|
|
70
|
+
const rect = referenceElement.getBoundingClientRect();
|
|
71
|
+
const boxRect = boxRef.current?.getBoundingClientRect();
|
|
72
|
+
const { innerWidth, innerHeight } = window;
|
|
73
|
+
|
|
74
|
+
if (boxRect) {
|
|
75
|
+
// Positions par défaut si définies
|
|
76
|
+
let top, left;
|
|
77
|
+
const positions = {
|
|
78
|
+
topRight: () => ({
|
|
79
|
+
top: rect.top - boxRect.height,
|
|
80
|
+
left: rect.right - boxRect.width,
|
|
81
|
+
}),
|
|
82
|
+
topLeft: () => ({
|
|
83
|
+
top: rect.top - boxRect.height,
|
|
84
|
+
left: rect.left,
|
|
85
|
+
}),
|
|
86
|
+
bottomRight: () => ({
|
|
87
|
+
top: rect.bottom,
|
|
88
|
+
left: rect.right - boxRect.width,
|
|
89
|
+
}),
|
|
90
|
+
bottomLeft: () => ({
|
|
91
|
+
top: rect.bottom,
|
|
92
|
+
left: rect.left,
|
|
93
|
+
}),
|
|
94
|
+
left: () => ({
|
|
95
|
+
top: rect.top + rect.height / 2 - boxRect.height / 2,
|
|
96
|
+
left: rect.left - boxRect.width,
|
|
97
|
+
}),
|
|
98
|
+
right: () => ({
|
|
99
|
+
top: rect.top + rect.height / 2 - boxRect.height / 2,
|
|
100
|
+
left: rect.right,
|
|
101
|
+
}),
|
|
102
|
+
};
|
|
103
|
+
|
|
104
|
+
if (position && positions[position]) {
|
|
105
|
+
// Si une position est définie, on tente de l'appliquer
|
|
106
|
+
({ top, left } = positions[position]());
|
|
107
|
+
} else {
|
|
108
|
+
// Sinon, on adapte dynamiquement
|
|
109
|
+
left = rect.right;
|
|
110
|
+
top = rect.bottom;
|
|
111
|
+
|
|
112
|
+
if (rect.right + boxRect.width > innerWidth) {
|
|
113
|
+
left = rect.left - boxRect.width; // Manque d'espace à droite → afficher à gauche
|
|
114
|
+
}
|
|
115
|
+
|
|
116
|
+
if (rect.bottom + boxRect.height > innerHeight) {
|
|
117
|
+
top = rect.top - boxRect.height; // Manque d'espace en bas → afficher en haut
|
|
118
|
+
}
|
|
119
|
+
}
|
|
120
|
+
|
|
121
|
+
setCoords({ top, left: left < 0 ? 0 : left });
|
|
122
|
+
}
|
|
123
|
+
}
|
|
124
|
+
};
|
|
125
|
+
|
|
126
|
+
if (isShow) {
|
|
127
|
+
updatePosition();
|
|
128
|
+
window.addEventListener("resize", updatePosition);
|
|
129
|
+
}
|
|
130
|
+
|
|
131
|
+
return () => window.removeEventListener("resize", updatePosition);
|
|
132
|
+
}, [referenceElement, isShow, position]);
|
|
133
|
+
|
|
134
|
+
const openOverlay = () => {
|
|
135
|
+
setIsShow(true);
|
|
136
|
+
setActiveOverlay(overlayId);
|
|
137
|
+
};
|
|
138
|
+
|
|
139
|
+
const closeOverlayHandler = useCallback(
|
|
140
|
+
(e: any) => {
|
|
141
|
+
e.stopPropagation();
|
|
142
|
+
setIsShow(false);
|
|
143
|
+
setActiveOverlay(null);
|
|
144
|
+
if (closeOverlay) {
|
|
145
|
+
closeOverlay(false);
|
|
146
|
+
}
|
|
147
|
+
},
|
|
148
|
+
[closeOverlay, setActiveOverlay]
|
|
149
|
+
);
|
|
150
|
+
useEffect(() => {
|
|
151
|
+
const handleClickOutside = (event: MouseEvent) => {
|
|
152
|
+
if (boxRef.current && !boxRef.current.contains(event.target as Node)) {
|
|
153
|
+
closeOverlayHandler(event);
|
|
154
|
+
}
|
|
155
|
+
};
|
|
156
|
+
|
|
157
|
+
if (isShow) {
|
|
158
|
+
document.addEventListener("mousedown", handleClickOutside);
|
|
159
|
+
}
|
|
160
|
+
|
|
161
|
+
return () => {
|
|
162
|
+
document.removeEventListener("mousedown", handleClickOutside);
|
|
163
|
+
};
|
|
164
|
+
}, [isShow, closeOverlayHandler]);
|
|
165
|
+
useEffect(() => {
|
|
166
|
+
if (show) {
|
|
167
|
+
openOverlay();
|
|
168
|
+
}
|
|
169
|
+
}, [show]);
|
|
170
|
+
|
|
171
|
+
if (!isShow) return null;
|
|
172
|
+
|
|
173
|
+
return ReactDOM.createPortal(
|
|
174
|
+
<OverlayPanelStyled ref={boxRef} $top={coords.top} $left={coords.left}>
|
|
175
|
+
<div
|
|
176
|
+
className={`overlayPanel ${
|
|
177
|
+
coords.top > 0 || coords.left > 0 ? "visible" : "hide"
|
|
178
|
+
}`}
|
|
179
|
+
>
|
|
180
|
+
<button className="toggle-btn" onClick={closeOverlayHandler}>
|
|
181
|
+
<Icon classIcon="bi-x-lg" />
|
|
182
|
+
</button>
|
|
183
|
+
{children}
|
|
184
|
+
</div>
|
|
185
|
+
</OverlayPanelStyled>,
|
|
186
|
+
document.body
|
|
187
|
+
);
|
|
188
|
+
}
|
|
189
|
+
);
|