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,39 @@
|
|
|
1
|
+
import { NavLink } from "react-router-dom";
|
|
2
|
+
import { MenuInterface } from "./menu/menu.interface";
|
|
3
|
+
import { Menus } from "./Menus";
|
|
4
|
+
import { Button } from "../button/Button";
|
|
5
|
+
import { useCallback } from "react";
|
|
6
|
+
|
|
7
|
+
export const MenusView = (): JSX.Element => {
|
|
8
|
+
const buttonAction = useCallback((e: React.MouseEvent) => {
|
|
9
|
+
console.log("Button clicked", e);
|
|
10
|
+
}, []);
|
|
11
|
+
const mockItems: MenuInterface[] = [
|
|
12
|
+
{
|
|
13
|
+
id: 1,
|
|
14
|
+
name: "Menu 1",
|
|
15
|
+
children: "Menu 1",
|
|
16
|
+
active: true,
|
|
17
|
+
subMenu : [{
|
|
18
|
+
id: 1,
|
|
19
|
+
name: "Menu 1",
|
|
20
|
+
children: <NavLink to="/expands">Menu 1</NavLink>,
|
|
21
|
+
active: true,
|
|
22
|
+
}]
|
|
23
|
+
},
|
|
24
|
+
{
|
|
25
|
+
id: 2,
|
|
26
|
+
name: "Menu 2",
|
|
27
|
+
children: <Button onClick={buttonAction} title={"deconnexion"} />,
|
|
28
|
+
active: false,
|
|
29
|
+
},
|
|
30
|
+
{
|
|
31
|
+
id: 3,
|
|
32
|
+
children: <NavLink to="/expands">Menu 1</NavLink>,
|
|
33
|
+
name: "Menu 3",
|
|
34
|
+
active: false,
|
|
35
|
+
},
|
|
36
|
+
];
|
|
37
|
+
|
|
38
|
+
return <Menus items={mockItems} />;
|
|
39
|
+
};
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import { MenuInterface } from "./menu.interface";
|
|
2
|
+
|
|
3
|
+
export type MenuProps = {
|
|
4
|
+
active: boolean;
|
|
5
|
+
item: MenuInterface;
|
|
6
|
+
onChange: (item: MenuInterface) => void;
|
|
7
|
+
};
|
|
8
|
+
export const Menu = (props: MenuProps): JSX.Element => {
|
|
9
|
+
return (
|
|
10
|
+
<div
|
|
11
|
+
onClick={() => props.onChange(props.item)}
|
|
12
|
+
className={props.active ? "expand expand--active" : "expand"}
|
|
13
|
+
>
|
|
14
|
+
{props.item.children}
|
|
15
|
+
</div>
|
|
16
|
+
);
|
|
17
|
+
};
|
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
.menu {
|
|
2
|
+
width: 200px;
|
|
3
|
+
padding: 2rem;
|
|
4
|
+
.submenu{
|
|
5
|
+
li{
|
|
6
|
+
a{
|
|
7
|
+
font-size : 0.9rem;
|
|
8
|
+
}
|
|
9
|
+
}
|
|
10
|
+
}
|
|
11
|
+
ul {
|
|
12
|
+
list-style: none;
|
|
13
|
+
padding: 0;
|
|
14
|
+
margin: 0;
|
|
15
|
+
display: flex;
|
|
16
|
+
flex-direction: column;
|
|
17
|
+
flex-wrap: wrap;
|
|
18
|
+
justify-content: center;
|
|
19
|
+
|
|
20
|
+
li {
|
|
21
|
+
button {
|
|
22
|
+
background: transparent;
|
|
23
|
+
color: #000;
|
|
24
|
+
font-weight: 300;
|
|
25
|
+
padding: 0px;
|
|
26
|
+
border-radius: 0px;
|
|
27
|
+
min-width: auto;
|
|
28
|
+
margin: 0;
|
|
29
|
+
justify-content: normal;
|
|
30
|
+
|
|
31
|
+
&:hover {
|
|
32
|
+
color: #f00;
|
|
33
|
+
}
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
a {
|
|
37
|
+
text-decoration: none;
|
|
38
|
+
color: #000;
|
|
39
|
+
font-weight: 300;
|
|
40
|
+
|
|
41
|
+
&:hover {
|
|
42
|
+
color: #f00;
|
|
43
|
+
}
|
|
44
|
+
}
|
|
45
|
+
}
|
|
46
|
+
}
|
|
47
|
+
}
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
import { useMemo } from "react";
|
|
2
|
+
import { Icon } from "../icon/Icon";
|
|
3
|
+
import "./message.css";
|
|
4
|
+
export type MessageProps = {
|
|
5
|
+
text: string;
|
|
6
|
+
severity: string;
|
|
7
|
+
className?: string;
|
|
8
|
+
};
|
|
9
|
+
export const Message = ({ text, severity, className }: MessageProps) => {
|
|
10
|
+
const icon = useMemo(() => {
|
|
11
|
+
switch (severity) {
|
|
12
|
+
case "info":
|
|
13
|
+
return "bi-info-circle";
|
|
14
|
+
case "warning":
|
|
15
|
+
return "bi-exclamation-triangle";
|
|
16
|
+
case "error":
|
|
17
|
+
return "bi-x-circle";
|
|
18
|
+
case "success":
|
|
19
|
+
return "bi-check-circle";
|
|
20
|
+
default:
|
|
21
|
+
return "bi-info-circle";
|
|
22
|
+
}
|
|
23
|
+
}, [severity]);
|
|
24
|
+
return (
|
|
25
|
+
<div className={`message message--${severity} ${className ?? ""}`}>
|
|
26
|
+
<Icon classIcon={icon} />
|
|
27
|
+
<span className="message-text">{text}</span>
|
|
28
|
+
</div>
|
|
29
|
+
);
|
|
30
|
+
};
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
import { Message } from "./Message";
|
|
2
|
+
|
|
3
|
+
export const MessageView = () => {
|
|
4
|
+
const messages = [
|
|
5
|
+
{ text: "Information message", severity: "info" },
|
|
6
|
+
{ text: "Warning message", severity: "warning" },
|
|
7
|
+
{ text: "Error message", severity: "error" },
|
|
8
|
+
{ text: "Success message", severity: "success" },
|
|
9
|
+
];
|
|
10
|
+
return (
|
|
11
|
+
<div>
|
|
12
|
+
{messages.map((msg, index) => (
|
|
13
|
+
<Message
|
|
14
|
+
className="mb-2"
|
|
15
|
+
key={index}
|
|
16
|
+
text={msg.text}
|
|
17
|
+
severity={msg.severity}
|
|
18
|
+
/>
|
|
19
|
+
))}
|
|
20
|
+
</div>
|
|
21
|
+
);
|
|
22
|
+
};
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
.message {
|
|
2
|
+
padding: 0.75rem 1rem;
|
|
3
|
+
display: flex;
|
|
4
|
+
align-items: center;
|
|
5
|
+
border-radius: 4px;
|
|
6
|
+
.message-text {
|
|
7
|
+
margin-left: 0.5rem;
|
|
8
|
+
}
|
|
9
|
+
&.message--info {
|
|
10
|
+
background-color: #d9edf7;
|
|
11
|
+
color: #31708f;
|
|
12
|
+
}
|
|
13
|
+
&.message--success {
|
|
14
|
+
background-color: #dff0d8;
|
|
15
|
+
color: #3c763d;
|
|
16
|
+
}
|
|
17
|
+
&.message--warning {
|
|
18
|
+
background-color: #fcf8e3;
|
|
19
|
+
color: #8a6d3b;
|
|
20
|
+
}
|
|
21
|
+
&.message--error {
|
|
22
|
+
background-color: #f2dede;
|
|
23
|
+
color: #a94442;
|
|
24
|
+
}
|
|
25
|
+
&.message--default {
|
|
26
|
+
background-color: #f5f5f5;
|
|
27
|
+
color: #333333;
|
|
28
|
+
}
|
|
29
|
+
}
|
|
@@ -0,0 +1,59 @@
|
|
|
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
|
+
closeOnOverlayClick?: boolean;
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
export const Modal: React.FC<ModalProps> = ({
|
|
20
|
+
isOpen,
|
|
21
|
+
onClose,
|
|
22
|
+
children,
|
|
23
|
+
onSubmit,
|
|
24
|
+
titleButton,
|
|
25
|
+
title,
|
|
26
|
+
styleContainer = {},
|
|
27
|
+
classNameContainer = "",
|
|
28
|
+
closeOnOverlayClick = true,
|
|
29
|
+
}) => {
|
|
30
|
+
if (!isOpen) return null;
|
|
31
|
+
const handleOverlayMouseDown = () => {
|
|
32
|
+
if (closeOnOverlayClick) {
|
|
33
|
+
onClose();
|
|
34
|
+
}
|
|
35
|
+
};
|
|
36
|
+
return createPortal(
|
|
37
|
+
<div className="modal-overlay" onMouseDown={handleOverlayMouseDown}>
|
|
38
|
+
<div
|
|
39
|
+
className={`modal-container ${classNameContainer}`}
|
|
40
|
+
style={styleContainer}
|
|
41
|
+
onMouseDown={(e) => e.stopPropagation()}
|
|
42
|
+
>
|
|
43
|
+
<div className="modal-header">
|
|
44
|
+
{title && <h2 className="modal-title">{title}</h2>}
|
|
45
|
+
<div className="modal-close-button" onClick={onClose}>
|
|
46
|
+
<Icon classIcon="bi-x-lg" />
|
|
47
|
+
</div>
|
|
48
|
+
</div>
|
|
49
|
+
<div className="modal-content">{children}</div>
|
|
50
|
+
{onSubmit && (
|
|
51
|
+
<div className="d-flex justify-content-end">
|
|
52
|
+
<Button onClick={onSubmit} title={titleButton ?? ""} />
|
|
53
|
+
</div>
|
|
54
|
+
)}
|
|
55
|
+
</div>
|
|
56
|
+
</div>,
|
|
57
|
+
document.body,
|
|
58
|
+
);
|
|
59
|
+
};
|
|
@@ -0,0 +1,26 @@
|
|
|
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
|
+
closeOnOverlayClick={false}
|
|
19
|
+
onClose={() => setIsOpen(false)}
|
|
20
|
+
isOpen={isOpen}
|
|
21
|
+
>
|
|
22
|
+
test
|
|
23
|
+
</Modal>
|
|
24
|
+
</div>
|
|
25
|
+
);
|
|
26
|
+
};
|
|
@@ -0,0 +1,71 @@
|
|
|
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
|
+
flex-direction: column;
|
|
24
|
+
overflow: hidden;
|
|
25
|
+
box-shadow: 0 4px 6px rgba(0, 0, 0, 0.1);
|
|
26
|
+
padding: 20px;
|
|
27
|
+
position: relative;
|
|
28
|
+
animation: fadeIn 0.3s ease;
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
.modal-header {
|
|
32
|
+
display: flex;
|
|
33
|
+
justify-content: space-between;
|
|
34
|
+
align-items: center;
|
|
35
|
+
margin-bottom: 10px;
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
.modal-title {
|
|
39
|
+
font-size: 1.25rem;
|
|
40
|
+
margin: 0;
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
.modal-close-button {
|
|
44
|
+
background: transparent;
|
|
45
|
+
border: none;
|
|
46
|
+
position: absolute;
|
|
47
|
+
right: 10px;
|
|
48
|
+
top: 10px;
|
|
49
|
+
cursor: pointer;
|
|
50
|
+
}
|
|
51
|
+
|
|
52
|
+
.modal-close-button:hover {
|
|
53
|
+
color: red;
|
|
54
|
+
}
|
|
55
|
+
|
|
56
|
+
.modal-content {
|
|
57
|
+
margin-top: 10px;
|
|
58
|
+
flex: 1;
|
|
59
|
+
overflow: hidden;
|
|
60
|
+
}
|
|
61
|
+
|
|
62
|
+
@keyframes fadeIn {
|
|
63
|
+
from {
|
|
64
|
+
opacity: 0;
|
|
65
|
+
transform: scale(0.9);
|
|
66
|
+
}
|
|
67
|
+
to {
|
|
68
|
+
opacity: 1;
|
|
69
|
+
transform: scale(1);
|
|
70
|
+
}
|
|
71
|
+
}
|
|
@@ -0,0 +1,195 @@
|
|
|
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
|
+
id?: string;
|
|
32
|
+
closeOverlay?: (close: boolean) => void;
|
|
33
|
+
};
|
|
34
|
+
|
|
35
|
+
export const OverlayPanel = forwardRef(
|
|
36
|
+
(
|
|
37
|
+
{
|
|
38
|
+
referenceElement,
|
|
39
|
+
position,
|
|
40
|
+
coordonnees,
|
|
41
|
+
children,
|
|
42
|
+
show,
|
|
43
|
+
id,
|
|
44
|
+
closeOverlay,
|
|
45
|
+
}: OverlayPanelProps,
|
|
46
|
+
ref: React.Ref<{
|
|
47
|
+
setCoords?: (coords: { top: number; left: number }) => void;
|
|
48
|
+
}>
|
|
49
|
+
) => {
|
|
50
|
+
const { activeOverlayId, setActiveOverlay } = useOverlayContext();
|
|
51
|
+
const [isShow, setIsShow] = useState(show || false);
|
|
52
|
+
const [coords, setCoords] = useState<{ top: number; left: number }>(
|
|
53
|
+
coordonnees ?? { top: 0, left: 0 }
|
|
54
|
+
);
|
|
55
|
+
const boxRef = useRef<HTMLDivElement>(null);
|
|
56
|
+
const overlayId = useId();
|
|
57
|
+
useImperativeHandle(ref, () => ({
|
|
58
|
+
setCoords,
|
|
59
|
+
}));
|
|
60
|
+
|
|
61
|
+
useEffect(() => {
|
|
62
|
+
if (activeOverlayId !== overlayId) {
|
|
63
|
+
setIsShow(false);
|
|
64
|
+
}
|
|
65
|
+
}, [activeOverlayId, overlayId]);
|
|
66
|
+
|
|
67
|
+
useEffect(() => {
|
|
68
|
+
const updatePosition = () => {
|
|
69
|
+
if (!position && coordonnees) {
|
|
70
|
+
setCoords(coordonnees);
|
|
71
|
+
} else if (referenceElement) {
|
|
72
|
+
const rect = referenceElement.getBoundingClientRect();
|
|
73
|
+
const boxRect = boxRef.current?.getBoundingClientRect();
|
|
74
|
+
const { innerWidth, innerHeight } = window;
|
|
75
|
+
|
|
76
|
+
if (boxRect) {
|
|
77
|
+
// Positions par défaut si définies
|
|
78
|
+
let top, left;
|
|
79
|
+
const positions = {
|
|
80
|
+
topRight: () => ({
|
|
81
|
+
top: rect.top - boxRect.height,
|
|
82
|
+
left: rect.right - boxRect.width,
|
|
83
|
+
}),
|
|
84
|
+
topLeft: () => ({
|
|
85
|
+
top: rect.top - boxRect.height,
|
|
86
|
+
left: rect.left,
|
|
87
|
+
}),
|
|
88
|
+
bottomRight: () => ({
|
|
89
|
+
top: rect.bottom,
|
|
90
|
+
left: rect.right - boxRect.width,
|
|
91
|
+
}),
|
|
92
|
+
bottomLeft: () => ({
|
|
93
|
+
top: rect.bottom,
|
|
94
|
+
left: rect.left,
|
|
95
|
+
}),
|
|
96
|
+
left: () => ({
|
|
97
|
+
top: rect.top + rect.height / 2 - boxRect.height / 2,
|
|
98
|
+
left: rect.left - boxRect.width,
|
|
99
|
+
}),
|
|
100
|
+
right: () => ({
|
|
101
|
+
top: rect.top + rect.height / 2 - boxRect.height / 2,
|
|
102
|
+
left: rect.right,
|
|
103
|
+
}),
|
|
104
|
+
};
|
|
105
|
+
|
|
106
|
+
if (position && positions[position]) {
|
|
107
|
+
// Si une position est définie, on tente de l'appliquer
|
|
108
|
+
({ top, left } = positions[position]());
|
|
109
|
+
} else {
|
|
110
|
+
// Sinon, on adapte dynamiquement
|
|
111
|
+
left = rect.right;
|
|
112
|
+
top = rect.bottom;
|
|
113
|
+
|
|
114
|
+
if (rect.right + boxRect.width > innerWidth) {
|
|
115
|
+
left = rect.left - boxRect.width; // Manque d'espace à droite → afficher à gauche
|
|
116
|
+
}
|
|
117
|
+
|
|
118
|
+
if (rect.bottom + boxRect.height > innerHeight) {
|
|
119
|
+
top = rect.top - boxRect.height; // Manque d'espace en bas → afficher en haut
|
|
120
|
+
}
|
|
121
|
+
}
|
|
122
|
+
|
|
123
|
+
setCoords({ top, left: left < 0 ? 0 : left });
|
|
124
|
+
}
|
|
125
|
+
}
|
|
126
|
+
};
|
|
127
|
+
|
|
128
|
+
if (isShow) {
|
|
129
|
+
updatePosition();
|
|
130
|
+
window.addEventListener("resize", updatePosition);
|
|
131
|
+
}
|
|
132
|
+
|
|
133
|
+
return () => window.removeEventListener("resize", updatePosition);
|
|
134
|
+
}, [referenceElement, isShow, position]);
|
|
135
|
+
|
|
136
|
+
const openOverlay = () => {
|
|
137
|
+
setIsShow(true);
|
|
138
|
+
setActiveOverlay(overlayId);
|
|
139
|
+
};
|
|
140
|
+
|
|
141
|
+
const closeOverlayHandler = useCallback(
|
|
142
|
+
(e: any) => {
|
|
143
|
+
e.stopPropagation();
|
|
144
|
+
setIsShow(false);
|
|
145
|
+
setActiveOverlay(null);
|
|
146
|
+
if (closeOverlay) {
|
|
147
|
+
closeOverlay(false);
|
|
148
|
+
}
|
|
149
|
+
},
|
|
150
|
+
[closeOverlay, setActiveOverlay]
|
|
151
|
+
);
|
|
152
|
+
useEffect(() => {
|
|
153
|
+
const handleClickOutside = (event: MouseEvent) => {
|
|
154
|
+
if (boxRef.current && !boxRef.current.contains(event.target as Node)) {
|
|
155
|
+
closeOverlayHandler(event);
|
|
156
|
+
}
|
|
157
|
+
};
|
|
158
|
+
|
|
159
|
+
if (isShow) {
|
|
160
|
+
document.addEventListener("mousedown", handleClickOutside);
|
|
161
|
+
}
|
|
162
|
+
|
|
163
|
+
return () => {
|
|
164
|
+
document.removeEventListener("mousedown", handleClickOutside);
|
|
165
|
+
};
|
|
166
|
+
}, [isShow, closeOverlayHandler]);
|
|
167
|
+
useEffect(() => {
|
|
168
|
+
if (show) {
|
|
169
|
+
openOverlay();
|
|
170
|
+
}
|
|
171
|
+
}, [show]);
|
|
172
|
+
|
|
173
|
+
if (!isShow) return null;
|
|
174
|
+
|
|
175
|
+
return ReactDOM.createPortal(
|
|
176
|
+
<OverlayPanelStyled ref={boxRef} $top={coords.top} $left={coords.left}>
|
|
177
|
+
<div
|
|
178
|
+
className={`overlayPanel ${
|
|
179
|
+
coords.top > 0 || coords.left > 0 ? "visible" : "hide"
|
|
180
|
+
}`}
|
|
181
|
+
>
|
|
182
|
+
<button
|
|
183
|
+
id={id ?? ""}
|
|
184
|
+
className="toggle-btn"
|
|
185
|
+
onClick={closeOverlayHandler}
|
|
186
|
+
>
|
|
187
|
+
<Icon classIcon="bi-x-lg" />
|
|
188
|
+
</button>
|
|
189
|
+
{children}
|
|
190
|
+
</div>
|
|
191
|
+
</OverlayPanelStyled>,
|
|
192
|
+
document.body
|
|
193
|
+
);
|
|
194
|
+
}
|
|
195
|
+
);
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
import { useRef, useState } from "react";
|
|
2
|
+
import { Icon } from "../icon/Icon";
|
|
3
|
+
import { OverlayPanel } from "./OverlayPanel";
|
|
4
|
+
|
|
5
|
+
export const OverlayPanelView = () => {
|
|
6
|
+
const refButton = useRef<HTMLDivElement>(null);
|
|
7
|
+
const [openOverlay, setOpenOverlay] = useState(false);
|
|
8
|
+
|
|
9
|
+
return (
|
|
10
|
+
<>
|
|
11
|
+
<div ref={refButton} onClick={() => setOpenOverlay(!openOverlay)}>
|
|
12
|
+
<Icon classIcon="bi-list" />
|
|
13
|
+
</div>
|
|
14
|
+
{refButton.current && (
|
|
15
|
+
<OverlayPanel
|
|
16
|
+
position="bottomRight"
|
|
17
|
+
show={openOverlay}
|
|
18
|
+
closeOverlay={setOpenOverlay}
|
|
19
|
+
referenceElement={refButton.current}
|
|
20
|
+
children={<div>boom</div>}
|
|
21
|
+
/>
|
|
22
|
+
)}
|
|
23
|
+
</>
|
|
24
|
+
);
|
|
25
|
+
};
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
import React, { createContext, useContext, useState } from "react";
|
|
2
|
+
|
|
3
|
+
interface OverlayContextType {
|
|
4
|
+
activeOverlayId: string | null;
|
|
5
|
+
setActiveOverlay: (id: string | null) => void;
|
|
6
|
+
}
|
|
7
|
+
|
|
8
|
+
const OverlayContext = createContext<OverlayContextType | undefined>(undefined);
|
|
9
|
+
|
|
10
|
+
export const OverlayProvider: React.FC<{ children: React.ReactNode }> = ({
|
|
11
|
+
children,
|
|
12
|
+
}) => {
|
|
13
|
+
const [activeOverlayId, setActiveOverlay] = useState<string | null>(null);
|
|
14
|
+
|
|
15
|
+
return (
|
|
16
|
+
<OverlayContext.Provider value={{ activeOverlayId, setActiveOverlay }}>
|
|
17
|
+
{children}
|
|
18
|
+
</OverlayContext.Provider>
|
|
19
|
+
);
|
|
20
|
+
};
|
|
21
|
+
|
|
22
|
+
export const useOverlayContext = () => {
|
|
23
|
+
const context = useContext(OverlayContext);
|
|
24
|
+
if (!context) {
|
|
25
|
+
throw new Error("useOverlayContext must be used within an OverlayProvider");
|
|
26
|
+
}
|
|
27
|
+
return context;
|
|
28
|
+
};
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
.overlayPanel {
|
|
2
|
+
position: relative;
|
|
3
|
+
|
|
4
|
+
&.hide {
|
|
5
|
+
visibility: hidden;
|
|
6
|
+
}
|
|
7
|
+
&.visible {
|
|
8
|
+
visibility: visible !important;
|
|
9
|
+
}
|
|
10
|
+
button {
|
|
11
|
+
span {
|
|
12
|
+
text-align: left;
|
|
13
|
+
}
|
|
14
|
+
}
|
|
15
|
+
.toggle-btn {
|
|
16
|
+
display: flex;
|
|
17
|
+
justify-content: flex-end;
|
|
18
|
+
background-color: transparent;
|
|
19
|
+
border: none;
|
|
20
|
+
color: #333;
|
|
21
|
+
cursor: pointer;
|
|
22
|
+
font-size: 18px;
|
|
23
|
+
margin: 0;
|
|
24
|
+
min-width: 10px;
|
|
25
|
+
right: 0;
|
|
26
|
+
padding: 0;
|
|
27
|
+
position: absolute;
|
|
28
|
+
padding: 0px;
|
|
29
|
+
z-index: 2;
|
|
30
|
+
|
|
31
|
+
i {
|
|
32
|
+
font-size: 1rem;
|
|
33
|
+
}
|
|
34
|
+
}
|
|
35
|
+
}
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import styled from "styled-components";
|
|
2
|
+
|
|
3
|
+
interface OverlayPanelStyledProps {
|
|
4
|
+
$top?: number;
|
|
5
|
+
$left?: number;
|
|
6
|
+
}
|
|
7
|
+
|
|
8
|
+
export const OverlayPanelStyled = styled.div<OverlayPanelStyledProps>`
|
|
9
|
+
position: absolute;
|
|
10
|
+
z-index: 5;
|
|
11
|
+
top: ${({ $top }) => $top}px;
|
|
12
|
+
left: ${({ $left }) => $left}px;
|
|
13
|
+
background-color: white;
|
|
14
|
+
padding: 10px;
|
|
15
|
+
box-shadow: 0 4px 8px rgba(0, 0, 0, 0.2);
|
|
16
|
+
border-radius: 2px;
|
|
17
|
+
border: 1px solid #ede;
|
|
18
|
+
`;
|