kelt-ui-kit-react 1.2.4 → 1.2.5
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 +31 -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 +1 -1
- 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 +241 -241
- package/src/dataTable/DataTable.view.tsx +59 -59
- package/src/dataTable/dataTable.css +17 -17
- 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 +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,103 +1,103 @@
|
|
|
1
|
-
import { useCallback, useEffect, useState } from "react";
|
|
2
|
-
import { CardInterface } from "../card/card.interface";
|
|
3
|
-
import { Icon } from "../icon/Icon";
|
|
4
|
-
import { IconSizeEnum } from "../icon/iconSize.enum";
|
|
5
|
-
import "./quantity.css";
|
|
6
|
-
export interface QuantityProps {
|
|
7
|
-
setQuantity?: (item: CardInterface, qte: number) => void;
|
|
8
|
-
item: CardInterface;
|
|
9
|
-
onClickQuantity?: (item: CardInterface) => void;
|
|
10
|
-
pas: number;
|
|
11
|
-
disabled?: boolean;
|
|
12
|
-
disabledPlus?: boolean;
|
|
13
|
-
disabledMinus?: boolean;
|
|
14
|
-
}
|
|
15
|
-
export const Quantity = ({
|
|
16
|
-
setQuantity,
|
|
17
|
-
item,
|
|
18
|
-
onClickQuantity,
|
|
19
|
-
disabled,
|
|
20
|
-
disabledPlus,
|
|
21
|
-
disabledMinus,
|
|
22
|
-
pas,
|
|
23
|
-
}: QuantityProps) => {
|
|
24
|
-
const [qte, setQte] = useState(pas);
|
|
25
|
-
|
|
26
|
-
const changeQuantity = useCallback(
|
|
27
|
-
(qte: number) => {
|
|
28
|
-
if (disabled) {
|
|
29
|
-
return;
|
|
30
|
-
}
|
|
31
|
-
setQte(qte);
|
|
32
|
-
if (setQuantity) {
|
|
33
|
-
setQuantity(item, qte);
|
|
34
|
-
}
|
|
35
|
-
},
|
|
36
|
-
[setQte, setQuantity]
|
|
37
|
-
);
|
|
38
|
-
|
|
39
|
-
const incrementQte = useCallback(
|
|
40
|
-
(e: React.MouseEvent<HTMLDivElement, MouseEvent>) => {
|
|
41
|
-
e.stopPropagation();
|
|
42
|
-
if (disabled || disabledPlus) {
|
|
43
|
-
return;
|
|
44
|
-
}
|
|
45
|
-
const newQuantity = qte + pas;
|
|
46
|
-
changeQuantity(Math.round(newQuantity * 100) / 100);
|
|
47
|
-
},
|
|
48
|
-
[qte, changeQuantity]
|
|
49
|
-
);
|
|
50
|
-
|
|
51
|
-
const decrementQte = useCallback(
|
|
52
|
-
(e: React.MouseEvent<HTMLDivElement, MouseEvent>) => {
|
|
53
|
-
e.stopPropagation();
|
|
54
|
-
if (disabled || disabledMinus) {
|
|
55
|
-
return;
|
|
56
|
-
}
|
|
57
|
-
if (qte === 0) {
|
|
58
|
-
return qte;
|
|
59
|
-
}
|
|
60
|
-
const newQuantity = qte - pas;
|
|
61
|
-
changeQuantity(Math.round(newQuantity * 100) / 100);
|
|
62
|
-
},
|
|
63
|
-
[changeQuantity, qte]
|
|
64
|
-
);
|
|
65
|
-
useEffect(() => {
|
|
66
|
-
if (item.quantity) {
|
|
67
|
-
setQte(item.quantity);
|
|
68
|
-
}
|
|
69
|
-
}, [item.quantity, setQte]);
|
|
70
|
-
const handleClick = useCallback(
|
|
71
|
-
(e: React.MouseEvent<HTMLSpanElement, MouseEvent>) => {
|
|
72
|
-
e.stopPropagation();
|
|
73
|
-
if (onClickQuantity) {
|
|
74
|
-
onClickQuantity(item);
|
|
75
|
-
}
|
|
76
|
-
},
|
|
77
|
-
[onClickQuantity, item]
|
|
78
|
-
);
|
|
79
|
-
|
|
80
|
-
return (
|
|
81
|
-
<div className="qte ">
|
|
82
|
-
<div
|
|
83
|
-
onClick={(e) => decrementQte(e)}
|
|
84
|
-
className={`qte-action qte-action--minus ${
|
|
85
|
-
disabled || disabledMinus ? "disabled" : ""
|
|
86
|
-
} `}
|
|
87
|
-
>
|
|
88
|
-
<Icon size={IconSizeEnum.LARGE} classIcon="bi bi-dash-square" />
|
|
89
|
-
</div>
|
|
90
|
-
<span onClick={(e) => handleClick(e)} className="qte-label">
|
|
91
|
-
{qte}
|
|
92
|
-
</span>
|
|
93
|
-
<div
|
|
94
|
-
onClick={(e) => incrementQte(e)}
|
|
95
|
-
className={`qte-action qte-action--plus ${
|
|
96
|
-
disabled || disabledPlus ? "disabled" : ""
|
|
97
|
-
}`}
|
|
98
|
-
>
|
|
99
|
-
<Icon size={IconSizeEnum.LARGE} classIcon="bi bi-plus-square" />
|
|
100
|
-
</div>
|
|
101
|
-
</div>
|
|
102
|
-
);
|
|
103
|
-
};
|
|
1
|
+
import { useCallback, useEffect, useState } from "react";
|
|
2
|
+
import { CardInterface } from "../card/card.interface";
|
|
3
|
+
import { Icon } from "../icon/Icon";
|
|
4
|
+
import { IconSizeEnum } from "../icon/iconSize.enum";
|
|
5
|
+
import "./quantity.css";
|
|
6
|
+
export interface QuantityProps {
|
|
7
|
+
setQuantity?: (item: CardInterface, qte: number) => void;
|
|
8
|
+
item: CardInterface;
|
|
9
|
+
onClickQuantity?: (item: CardInterface) => void;
|
|
10
|
+
pas: number;
|
|
11
|
+
disabled?: boolean;
|
|
12
|
+
disabledPlus?: boolean;
|
|
13
|
+
disabledMinus?: boolean;
|
|
14
|
+
}
|
|
15
|
+
export const Quantity = ({
|
|
16
|
+
setQuantity,
|
|
17
|
+
item,
|
|
18
|
+
onClickQuantity,
|
|
19
|
+
disabled,
|
|
20
|
+
disabledPlus,
|
|
21
|
+
disabledMinus,
|
|
22
|
+
pas,
|
|
23
|
+
}: QuantityProps) => {
|
|
24
|
+
const [qte, setQte] = useState(pas);
|
|
25
|
+
|
|
26
|
+
const changeQuantity = useCallback(
|
|
27
|
+
(qte: number) => {
|
|
28
|
+
if (disabled) {
|
|
29
|
+
return;
|
|
30
|
+
}
|
|
31
|
+
setQte(qte);
|
|
32
|
+
if (setQuantity) {
|
|
33
|
+
setQuantity(item, qte);
|
|
34
|
+
}
|
|
35
|
+
},
|
|
36
|
+
[setQte, setQuantity]
|
|
37
|
+
);
|
|
38
|
+
|
|
39
|
+
const incrementQte = useCallback(
|
|
40
|
+
(e: React.MouseEvent<HTMLDivElement, MouseEvent>) => {
|
|
41
|
+
e.stopPropagation();
|
|
42
|
+
if (disabled || disabledPlus) {
|
|
43
|
+
return;
|
|
44
|
+
}
|
|
45
|
+
const newQuantity = qte + pas;
|
|
46
|
+
changeQuantity(Math.round(newQuantity * 100) / 100);
|
|
47
|
+
},
|
|
48
|
+
[qte, changeQuantity]
|
|
49
|
+
);
|
|
50
|
+
|
|
51
|
+
const decrementQte = useCallback(
|
|
52
|
+
(e: React.MouseEvent<HTMLDivElement, MouseEvent>) => {
|
|
53
|
+
e.stopPropagation();
|
|
54
|
+
if (disabled || disabledMinus) {
|
|
55
|
+
return;
|
|
56
|
+
}
|
|
57
|
+
if (qte === 0) {
|
|
58
|
+
return qte;
|
|
59
|
+
}
|
|
60
|
+
const newQuantity = qte - pas;
|
|
61
|
+
changeQuantity(Math.round(newQuantity * 100) / 100);
|
|
62
|
+
},
|
|
63
|
+
[changeQuantity, qte]
|
|
64
|
+
);
|
|
65
|
+
useEffect(() => {
|
|
66
|
+
if (item.quantity) {
|
|
67
|
+
setQte(item.quantity);
|
|
68
|
+
}
|
|
69
|
+
}, [item.quantity, setQte]);
|
|
70
|
+
const handleClick = useCallback(
|
|
71
|
+
(e: React.MouseEvent<HTMLSpanElement, MouseEvent>) => {
|
|
72
|
+
e.stopPropagation();
|
|
73
|
+
if (onClickQuantity) {
|
|
74
|
+
onClickQuantity(item);
|
|
75
|
+
}
|
|
76
|
+
},
|
|
77
|
+
[onClickQuantity, item]
|
|
78
|
+
);
|
|
79
|
+
|
|
80
|
+
return (
|
|
81
|
+
<div className="qte ">
|
|
82
|
+
<div
|
|
83
|
+
onClick={(e) => decrementQte(e)}
|
|
84
|
+
className={`qte-action qte-action--minus ${
|
|
85
|
+
disabled || disabledMinus ? "disabled" : ""
|
|
86
|
+
} `}
|
|
87
|
+
>
|
|
88
|
+
<Icon size={IconSizeEnum.LARGE} classIcon="bi bi-dash-square" />
|
|
89
|
+
</div>
|
|
90
|
+
<span onClick={(e) => handleClick(e)} className="qte-label">
|
|
91
|
+
{qte}
|
|
92
|
+
</span>
|
|
93
|
+
<div
|
|
94
|
+
onClick={(e) => incrementQte(e)}
|
|
95
|
+
className={`qte-action qte-action--plus ${
|
|
96
|
+
disabled || disabledPlus ? "disabled" : ""
|
|
97
|
+
}`}
|
|
98
|
+
>
|
|
99
|
+
<Icon size={IconSizeEnum.LARGE} classIcon="bi bi-plus-square" />
|
|
100
|
+
</div>
|
|
101
|
+
</div>
|
|
102
|
+
);
|
|
103
|
+
};
|
|
@@ -1,26 +1,26 @@
|
|
|
1
|
-
.qte {
|
|
2
|
-
display: flex;
|
|
3
|
-
align-items: center;
|
|
4
|
-
.qte-label {
|
|
5
|
-
width: 20px;
|
|
6
|
-
text-align: center;
|
|
7
|
-
}
|
|
8
|
-
.qte-action {
|
|
9
|
-
cursor: pointer;
|
|
10
|
-
margin-right: 1.5rem;
|
|
11
|
-
&.disabled {
|
|
12
|
-
opacity: 0.5;
|
|
13
|
-
cursor: not-allowed;
|
|
14
|
-
}
|
|
15
|
-
.bi {
|
|
16
|
-
color: #333;
|
|
17
|
-
}
|
|
18
|
-
&.qte-action--plus {
|
|
19
|
-
margin-left: 0.5rem;
|
|
20
|
-
margin-right: 0rem;
|
|
21
|
-
}
|
|
22
|
-
&.qte-action--minus {
|
|
23
|
-
margin-right: 0.5rem;
|
|
24
|
-
}
|
|
25
|
-
}
|
|
26
|
-
}
|
|
1
|
+
.qte {
|
|
2
|
+
display: flex;
|
|
3
|
+
align-items: center;
|
|
4
|
+
.qte-label {
|
|
5
|
+
width: 20px;
|
|
6
|
+
text-align: center;
|
|
7
|
+
}
|
|
8
|
+
.qte-action {
|
|
9
|
+
cursor: pointer;
|
|
10
|
+
margin-right: 1.5rem;
|
|
11
|
+
&.disabled {
|
|
12
|
+
opacity: 0.5;
|
|
13
|
+
cursor: not-allowed;
|
|
14
|
+
}
|
|
15
|
+
.bi {
|
|
16
|
+
color: #333;
|
|
17
|
+
}
|
|
18
|
+
&.qte-action--plus {
|
|
19
|
+
margin-left: 0.5rem;
|
|
20
|
+
margin-right: 0rem;
|
|
21
|
+
}
|
|
22
|
+
&.qte-action--minus {
|
|
23
|
+
margin-right: 0.5rem;
|
|
24
|
+
}
|
|
25
|
+
}
|
|
26
|
+
}
|
package/src/search/Search.tsx
CHANGED
|
@@ -1,161 +1,161 @@
|
|
|
1
|
-
import {
|
|
2
|
-
forwardRef,
|
|
3
|
-
useCallback,
|
|
4
|
-
useEffect,
|
|
5
|
-
useImperativeHandle,
|
|
6
|
-
useMemo,
|
|
7
|
-
useRef,
|
|
8
|
-
useState,
|
|
9
|
-
} from "react";
|
|
10
|
-
import { DynamicForm } from "../form/Form";
|
|
11
|
-
import { TypeInputEnum } from "../form/form.enum";
|
|
12
|
-
import { FormInterface, FormValuesInterface } from "../form/form.interface";
|
|
13
|
-
import { Icon } from "../icon/Icon";
|
|
14
|
-
import "./search.css";
|
|
15
|
-
|
|
16
|
-
interface SearchProps {
|
|
17
|
-
children?: JSX.Element;
|
|
18
|
-
placeholder?: string;
|
|
19
|
-
isVisible?: boolean;
|
|
20
|
-
focus?: boolean;
|
|
21
|
-
name?: string;
|
|
22
|
-
id?: string;
|
|
23
|
-
debounceTime?: number;
|
|
24
|
-
handleChange?: (values: FormValuesInterface<FormData>) => void;
|
|
25
|
-
setIsVisible?: (visible: boolean) => void;
|
|
26
|
-
}
|
|
27
|
-
|
|
28
|
-
interface FormData {
|
|
29
|
-
recherche: string;
|
|
30
|
-
[key: string]: string | number | boolean | Date;
|
|
31
|
-
}
|
|
32
|
-
|
|
33
|
-
export const Search = forwardRef<
|
|
34
|
-
{
|
|
35
|
-
clearInput: (name: string) => void;
|
|
36
|
-
resetForm: () => void;
|
|
37
|
-
focusInitialElement: () => void;
|
|
38
|
-
},
|
|
39
|
-
SearchProps
|
|
40
|
-
>(
|
|
41
|
-
(
|
|
42
|
-
{
|
|
43
|
-
children,
|
|
44
|
-
name,
|
|
45
|
-
placeholder,
|
|
46
|
-
isVisible,
|
|
47
|
-
focus,
|
|
48
|
-
debounceTime,
|
|
49
|
-
handleChange,
|
|
50
|
-
setIsVisible,
|
|
51
|
-
id,
|
|
52
|
-
},
|
|
53
|
-
ref
|
|
54
|
-
) => {
|
|
55
|
-
const [isOpen, setIsOpen] = useState(isVisible ?? false);
|
|
56
|
-
const debounceRef = useRef<NodeJS.Timeout | null>(null);
|
|
57
|
-
const formRef = useRef<{
|
|
58
|
-
clearInput: (name: string) => void;
|
|
59
|
-
resetForm: () => void;
|
|
60
|
-
focusInitialElement: () => void;
|
|
61
|
-
}>(null);
|
|
62
|
-
|
|
63
|
-
const initialValues: FormInterface[] = useMemo(
|
|
64
|
-
() => [
|
|
65
|
-
{
|
|
66
|
-
value: "",
|
|
67
|
-
id: id,
|
|
68
|
-
name: name ?? "recherche",
|
|
69
|
-
placeholder: placeholder ?? "Recherche",
|
|
70
|
-
type: TypeInputEnum.TEXT,
|
|
71
|
-
focus: focus,
|
|
72
|
-
icon: "bi-search",
|
|
73
|
-
className: "search-input",
|
|
74
|
-
autoComplete: "off",
|
|
75
|
-
},
|
|
76
|
-
],
|
|
77
|
-
[placeholder, focus]
|
|
78
|
-
);
|
|
79
|
-
|
|
80
|
-
useEffect(() => {
|
|
81
|
-
if (isVisible !== undefined) {
|
|
82
|
-
setIsOpen(isVisible);
|
|
83
|
-
}
|
|
84
|
-
}, [isVisible]);
|
|
85
|
-
|
|
86
|
-
const setShowSearch = useCallback(
|
|
87
|
-
(value: boolean) => {
|
|
88
|
-
if (setIsVisible) {
|
|
89
|
-
setIsVisible(value);
|
|
90
|
-
}
|
|
91
|
-
setIsOpen(value);
|
|
92
|
-
},
|
|
93
|
-
[setIsVisible]
|
|
94
|
-
);
|
|
95
|
-
|
|
96
|
-
const onChange = useCallback(
|
|
97
|
-
(values: FormValuesInterface<FormData>) => {
|
|
98
|
-
if (!values || !values[name ?? "recherche"]) {
|
|
99
|
-
return setShowSearch(false);
|
|
100
|
-
}
|
|
101
|
-
setShowSearch(true);
|
|
102
|
-
|
|
103
|
-
if (debounceRef.current) {
|
|
104
|
-
clearTimeout(debounceRef.current);
|
|
105
|
-
}
|
|
106
|
-
|
|
107
|
-
debounceRef.current = setTimeout(() => {
|
|
108
|
-
if (handleChange) {
|
|
109
|
-
handleChange(values);
|
|
110
|
-
}
|
|
111
|
-
}, debounceTime ?? 500);
|
|
112
|
-
},
|
|
113
|
-
[setShowSearch, handleChange, debounceTime]
|
|
114
|
-
);
|
|
115
|
-
|
|
116
|
-
const handleSubmit = useCallback(
|
|
117
|
-
(values: FormValuesInterface<FormData>) => {
|
|
118
|
-
console.log("Form Submitted: ", values);
|
|
119
|
-
},
|
|
120
|
-
[]
|
|
121
|
-
);
|
|
122
|
-
|
|
123
|
-
// Expose clearInput et resetForm via le ref du parent
|
|
124
|
-
useImperativeHandle(ref, () => ({
|
|
125
|
-
clearInput: (name: string) => {
|
|
126
|
-
formRef.current?.clearInput(name);
|
|
127
|
-
},
|
|
128
|
-
resetForm: () => {
|
|
129
|
-
formRef.current?.resetForm();
|
|
130
|
-
},
|
|
131
|
-
focusInitialElement: () => {
|
|
132
|
-
formRef.current?.focusInitialElement();
|
|
133
|
-
},
|
|
134
|
-
}));
|
|
135
|
-
|
|
136
|
-
return (
|
|
137
|
-
<div className="search">
|
|
138
|
-
<DynamicForm
|
|
139
|
-
ref={formRef}
|
|
140
|
-
onSubmit={handleSubmit}
|
|
141
|
-
onChange={onChange}
|
|
142
|
-
hideSubmit={true}
|
|
143
|
-
initialForm={initialValues}
|
|
144
|
-
/>
|
|
145
|
-
{isOpen && (
|
|
146
|
-
<div className="search-result">
|
|
147
|
-
<div className="search-result-close">
|
|
148
|
-
<button
|
|
149
|
-
className="toggle-btn"
|
|
150
|
-
onClick={() => setShowSearch(false)}
|
|
151
|
-
>
|
|
152
|
-
<Icon classIcon="bi-x-lg" />
|
|
153
|
-
</button>
|
|
154
|
-
</div>
|
|
155
|
-
<div className="search-result-content">{children}</div>
|
|
156
|
-
</div>
|
|
157
|
-
)}
|
|
158
|
-
</div>
|
|
159
|
-
);
|
|
160
|
-
}
|
|
161
|
-
);
|
|
1
|
+
import {
|
|
2
|
+
forwardRef,
|
|
3
|
+
useCallback,
|
|
4
|
+
useEffect,
|
|
5
|
+
useImperativeHandle,
|
|
6
|
+
useMemo,
|
|
7
|
+
useRef,
|
|
8
|
+
useState,
|
|
9
|
+
} from "react";
|
|
10
|
+
import { DynamicForm } from "../form/Form";
|
|
11
|
+
import { TypeInputEnum } from "../form/form.enum";
|
|
12
|
+
import { FormInterface, FormValuesInterface } from "../form/form.interface";
|
|
13
|
+
import { Icon } from "../icon/Icon";
|
|
14
|
+
import "./search.css";
|
|
15
|
+
|
|
16
|
+
interface SearchProps {
|
|
17
|
+
children?: JSX.Element;
|
|
18
|
+
placeholder?: string;
|
|
19
|
+
isVisible?: boolean;
|
|
20
|
+
focus?: boolean;
|
|
21
|
+
name?: string;
|
|
22
|
+
id?: string;
|
|
23
|
+
debounceTime?: number;
|
|
24
|
+
handleChange?: (values: FormValuesInterface<FormData>) => void;
|
|
25
|
+
setIsVisible?: (visible: boolean) => void;
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
interface FormData {
|
|
29
|
+
recherche: string;
|
|
30
|
+
[key: string]: string | number | boolean | Date;
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
export const Search = forwardRef<
|
|
34
|
+
{
|
|
35
|
+
clearInput: (name: string) => void;
|
|
36
|
+
resetForm: () => void;
|
|
37
|
+
focusInitialElement: () => void;
|
|
38
|
+
},
|
|
39
|
+
SearchProps
|
|
40
|
+
>(
|
|
41
|
+
(
|
|
42
|
+
{
|
|
43
|
+
children,
|
|
44
|
+
name,
|
|
45
|
+
placeholder,
|
|
46
|
+
isVisible,
|
|
47
|
+
focus,
|
|
48
|
+
debounceTime,
|
|
49
|
+
handleChange,
|
|
50
|
+
setIsVisible,
|
|
51
|
+
id,
|
|
52
|
+
},
|
|
53
|
+
ref
|
|
54
|
+
) => {
|
|
55
|
+
const [isOpen, setIsOpen] = useState(isVisible ?? false);
|
|
56
|
+
const debounceRef = useRef<NodeJS.Timeout | null>(null);
|
|
57
|
+
const formRef = useRef<{
|
|
58
|
+
clearInput: (name: string) => void;
|
|
59
|
+
resetForm: () => void;
|
|
60
|
+
focusInitialElement: () => void;
|
|
61
|
+
}>(null);
|
|
62
|
+
|
|
63
|
+
const initialValues: FormInterface[] = useMemo(
|
|
64
|
+
() => [
|
|
65
|
+
{
|
|
66
|
+
value: "",
|
|
67
|
+
id: id,
|
|
68
|
+
name: name ?? "recherche",
|
|
69
|
+
placeholder: placeholder ?? "Recherche",
|
|
70
|
+
type: TypeInputEnum.TEXT,
|
|
71
|
+
focus: focus,
|
|
72
|
+
icon: "bi-search",
|
|
73
|
+
className: "search-input",
|
|
74
|
+
autoComplete: "off",
|
|
75
|
+
},
|
|
76
|
+
],
|
|
77
|
+
[placeholder, focus]
|
|
78
|
+
);
|
|
79
|
+
|
|
80
|
+
useEffect(() => {
|
|
81
|
+
if (isVisible !== undefined) {
|
|
82
|
+
setIsOpen(isVisible);
|
|
83
|
+
}
|
|
84
|
+
}, [isVisible]);
|
|
85
|
+
|
|
86
|
+
const setShowSearch = useCallback(
|
|
87
|
+
(value: boolean) => {
|
|
88
|
+
if (setIsVisible) {
|
|
89
|
+
setIsVisible(value);
|
|
90
|
+
}
|
|
91
|
+
setIsOpen(value);
|
|
92
|
+
},
|
|
93
|
+
[setIsVisible]
|
|
94
|
+
);
|
|
95
|
+
|
|
96
|
+
const onChange = useCallback(
|
|
97
|
+
(values: FormValuesInterface<FormData>) => {
|
|
98
|
+
if (!values || !values[name ?? "recherche"]) {
|
|
99
|
+
return setShowSearch(false);
|
|
100
|
+
}
|
|
101
|
+
setShowSearch(true);
|
|
102
|
+
|
|
103
|
+
if (debounceRef.current) {
|
|
104
|
+
clearTimeout(debounceRef.current);
|
|
105
|
+
}
|
|
106
|
+
|
|
107
|
+
debounceRef.current = setTimeout(() => {
|
|
108
|
+
if (handleChange) {
|
|
109
|
+
handleChange(values);
|
|
110
|
+
}
|
|
111
|
+
}, debounceTime ?? 500);
|
|
112
|
+
},
|
|
113
|
+
[setShowSearch, handleChange, debounceTime]
|
|
114
|
+
);
|
|
115
|
+
|
|
116
|
+
const handleSubmit = useCallback(
|
|
117
|
+
(values: FormValuesInterface<FormData>) => {
|
|
118
|
+
console.log("Form Submitted: ", values);
|
|
119
|
+
},
|
|
120
|
+
[]
|
|
121
|
+
);
|
|
122
|
+
|
|
123
|
+
// Expose clearInput et resetForm via le ref du parent
|
|
124
|
+
useImperativeHandle(ref, () => ({
|
|
125
|
+
clearInput: (name: string) => {
|
|
126
|
+
formRef.current?.clearInput(name);
|
|
127
|
+
},
|
|
128
|
+
resetForm: () => {
|
|
129
|
+
formRef.current?.resetForm();
|
|
130
|
+
},
|
|
131
|
+
focusInitialElement: () => {
|
|
132
|
+
formRef.current?.focusInitialElement();
|
|
133
|
+
},
|
|
134
|
+
}));
|
|
135
|
+
|
|
136
|
+
return (
|
|
137
|
+
<div className="search">
|
|
138
|
+
<DynamicForm
|
|
139
|
+
ref={formRef}
|
|
140
|
+
onSubmit={handleSubmit}
|
|
141
|
+
onChange={onChange}
|
|
142
|
+
hideSubmit={true}
|
|
143
|
+
initialForm={initialValues}
|
|
144
|
+
/>
|
|
145
|
+
{isOpen && (
|
|
146
|
+
<div className="search-result">
|
|
147
|
+
<div className="search-result-close">
|
|
148
|
+
<button
|
|
149
|
+
className="toggle-btn"
|
|
150
|
+
onClick={() => setShowSearch(false)}
|
|
151
|
+
>
|
|
152
|
+
<Icon classIcon="bi-x-lg" />
|
|
153
|
+
</button>
|
|
154
|
+
</div>
|
|
155
|
+
<div className="search-result-content">{children}</div>
|
|
156
|
+
</div>
|
|
157
|
+
)}
|
|
158
|
+
</div>
|
|
159
|
+
);
|
|
160
|
+
}
|
|
161
|
+
);
|
|
@@ -1,14 +1,14 @@
|
|
|
1
|
-
import { FormValuesInterface } from "../form/form.interface";
|
|
2
|
-
import { Search } from "./Search";
|
|
3
|
-
interface FormData {
|
|
4
|
-
recherche: string;
|
|
5
|
-
[key: string]: string | number | boolean | Date; // Signature d'index ajoutée
|
|
6
|
-
}
|
|
7
|
-
export const SearchView = (): JSX.Element => {
|
|
8
|
-
const onChange = (values: FormValuesInterface<FormData>) => {
|
|
9
|
-
console.log(values);
|
|
10
|
-
};
|
|
11
|
-
return (
|
|
12
|
-
<Search focus={true} handleChange={onChange} children={<div>test</div>} />
|
|
13
|
-
);
|
|
14
|
-
};
|
|
1
|
+
import { FormValuesInterface } from "../form/form.interface";
|
|
2
|
+
import { Search } from "./Search";
|
|
3
|
+
interface FormData {
|
|
4
|
+
recherche: string;
|
|
5
|
+
[key: string]: string | number | boolean | Date; // Signature d'index ajoutée
|
|
6
|
+
}
|
|
7
|
+
export const SearchView = (): JSX.Element => {
|
|
8
|
+
const onChange = (values: FormValuesInterface<FormData>) => {
|
|
9
|
+
console.log(values);
|
|
10
|
+
};
|
|
11
|
+
return (
|
|
12
|
+
<Search focus={true} handleChange={onChange} children={<div>test</div>} />
|
|
13
|
+
);
|
|
14
|
+
};
|