contentoh-components-library 21.2.102 → 21.2.104
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/.env.development +2 -5
- package/.env.production +25 -25
- package/dist/components/atoms/GeneralButton/index.js +6 -2
- package/dist/components/atoms/Select/VersionSelect.js +2 -1
- package/dist/components/molecules/CustomSelect/CustomSelect.stories.js +22 -21
- package/dist/components/molecules/CustomSelect/SelectItem.js +1 -10
- package/dist/components/molecules/HeaderTop/index.js +5 -10
- package/dist/components/molecules/HeaderTop/styles.js +1 -1
- package/dist/components/organisms/CreateVersion/RenderChilds.js +11 -11
- package/dist/components/organisms/CreateVersion/index.js +30 -89
- package/dist/components/organisms/OrderDetail/OrderDetail.stories.js +1 -1
- package/dist/components/organisms/OrderDetail/index.js +20 -11
- package/dist/components/organisms/OrderDetail/styles.js +1 -1
- package/dist/components/organisms/OrderDetail/utils/Table/styles.js +1 -1
- package/dist/components/organisms/OrderDetail/utils/Table/utils.js +45 -15
- package/dist/components/organisms/VersionSelector/index.js +28 -2
- package/dist/components/pages/ProviderProductEdition/ProviderProductEdition.stories.js +69 -147
- package/dist/components/pages/ProviderProductEdition/index.js +2 -22
- package/dist/components/pages/RetailerProductEdition/RetailerProductEdition.stories.js +77 -67
- package/dist/components/pages/RetailerProductEdition/index.js +5 -24
- package/dist/global-files/fonts.css +0 -12
- package/dist/global-files/variables.js +0 -2
- package/dist/index.js +46 -254
- package/package.json +1 -12
- package/src/components/atoms/GeneralButton/index.js +4 -1
- package/src/components/atoms/Select/VersionSelect.js +4 -2
- package/src/components/molecules/CustomSelect/CustomSelect.stories.js +12 -20
- package/src/components/molecules/CustomSelect/SelectItem.js +0 -7
- package/src/components/molecules/HeaderTop/index.js +6 -11
- package/src/components/molecules/HeaderTop/styles.js +0 -4
- package/src/components/organisms/CreateVersion/RenderChilds.js +28 -34
- package/src/components/organisms/CreateVersion/index.js +16 -36
- package/src/components/organisms/OrderDetail/OrderDetail.stories.js +1 -1
- package/src/components/organisms/OrderDetail/index.js +19 -12
- package/src/components/organisms/OrderDetail/styles.js +1 -0
- package/src/components/organisms/OrderDetail/utils/Table/styles.js +30 -0
- package/src/components/organisms/OrderDetail/utils/Table/utils.js +30 -15
- package/src/components/organisms/VersionSelector/index.js +18 -3
- package/src/components/pages/ProviderProductEdition/ProviderProductEdition.stories.js +75 -166
- package/src/components/pages/ProviderProductEdition/index.js +2 -21
- package/src/components/pages/RetailerProductEdition/RetailerProductEdition.stories.js +79 -67
- package/src/components/pages/RetailerProductEdition/index.js +2 -14
- package/src/global-files/customHooks.js +2 -2
- package/src/global-files/fonts.css +0 -12
- package/src/global-files/variables.js +0 -2
- package/src/index.js +0 -16
- package/dist/assets/images/customSelect/starIcon.svg +0 -14
- package/dist/assets/images/defaultImages/Spinner.gif +0 -0
- package/dist/assets/images/defaultImages/notFound.svg +0 -124
- package/dist/components/atoms/ButtonFileChooser/ButtonFileChooser.stories.js +0 -72
- package/dist/components/atoms/ButtonFileChooser/index.js +0 -118
- package/dist/components/atoms/ButtonFileChooser/styles.js +0 -20
- package/dist/components/atoms/ButtonV2/ButtonV2.stories.js +0 -66
- package/dist/components/atoms/ButtonV2/index.js +0 -111
- package/dist/components/atoms/ButtonV2/styles.js +0 -53
- package/dist/components/atoms/CustomIcon/CustomIcon.stories.js +0 -50
- package/dist/components/atoms/CustomIcon/index.js +0 -40
- package/dist/components/atoms/CustomIcon/styles.js +0 -33
- package/dist/components/atoms/IconFile/IconFile.stories.js +0 -48
- package/dist/components/atoms/IconFile/index.js +0 -249
- package/dist/components/atoms/IconFile/styles.js +0 -23
- package/dist/components/atoms/Image/Image.stories.js +0 -73
- package/dist/components/atoms/Image/index.js +0 -76
- package/dist/components/atoms/Image/styles.js +0 -43
- package/dist/components/atoms/ImageLink/ImageLink.stories.js +0 -63
- package/dist/components/atoms/ImageLink/index.js +0 -77
- package/dist/components/atoms/ImageLink/styles.js +0 -40
- package/dist/components/atoms/ImagePreview/ImagePreview.stories.js +0 -70
- package/dist/components/atoms/ImagePreview/index.js +0 -222
- package/dist/components/atoms/ImagePreview/styles.js +0 -44
- package/dist/components/atoms/InputText/InputText.stories.js +0 -60
- package/dist/components/atoms/InputText/index.js +0 -66
- package/dist/components/atoms/InputText/styles.js +0 -32
- package/dist/components/atoms/NotFound/NotFound.stories.js +0 -36
- package/dist/components/atoms/NotFound/index.js +0 -75
- package/dist/components/atoms/NotFound/styles.js +0 -20
- package/dist/components/atoms/SelectItemV2/SelectItemV2.stories.js +0 -45
- package/dist/components/atoms/SelectItemV2/index.js +0 -46
- package/dist/components/atoms/SelectItemV2/styles.js +0 -23
- package/dist/components/atoms/Tooltip/Tooltip.stories.js +0 -66
- package/dist/components/atoms/Tooltip/index.js +0 -72
- package/dist/components/atoms/Tooltip/styles.js +0 -20
- package/dist/components/molecules/ButtonDownloadFile/DownloadFile.stories.js +0 -66
- package/dist/components/molecules/ButtonDownloadFile/index.js +0 -179
- package/dist/components/molecules/ButtonDownloadFile/styles.js +0 -23
- package/dist/components/molecules/Dropdown/Dropdown.stories.js +0 -96
- package/dist/components/molecules/Dropdown/index.js +0 -148
- package/dist/components/molecules/Dropdown/styles.js +0 -26
- package/dist/components/molecules/ImageTooltip/ImageTooltip.stories.js +0 -72
- package/dist/components/molecules/ImageTooltip/index.js +0 -84
- package/dist/components/molecules/ImageTooltip/styles.js +0 -33
- package/dist/components/molecules/SelectV2/SelectV2.stories.js +0 -119
- package/dist/components/molecules/SelectV2/index.js +0 -298
- package/dist/components/molecules/SelectV2/styles.js +0 -42
- package/dist/components/organisms/Chat/Chat.stories.js +0 -215
- package/dist/components/organisms/Chat/ChatLists/ChatLists.stories.js +0 -83
- package/dist/components/organisms/Chat/ChatLists/index.js +0 -160
- package/dist/components/organisms/Chat/ChatLists/styles.js +0 -29
- package/dist/components/organisms/Chat/ContainerItems/ContainerItems.stories.js +0 -176
- package/dist/components/organisms/Chat/ContainerItems/index.js +0 -569
- package/dist/components/organisms/Chat/ContainerItems/styles.js +0 -20
- package/dist/components/organisms/Chat/ContentChat/ContentChat.stories.js +0 -142
- package/dist/components/organisms/Chat/ContentChat/index.js +0 -1422
- package/dist/components/organisms/Chat/ContentChat/styles.js +0 -20
- package/dist/components/organisms/Chat/Footer/Footer.stories.js +0 -43
- package/dist/components/organisms/Chat/Footer/index.js +0 -984
- package/dist/components/organisms/Chat/Footer/styles.js +0 -32
- package/dist/components/organisms/Chat/Header/Header.stories.js +0 -96
- package/dist/components/organisms/Chat/Header/index.js +0 -84
- package/dist/components/organisms/Chat/Header/styles.js +0 -20
- package/dist/components/organisms/Chat/index.js +0 -327
- package/dist/components/organisms/Chat/styles.js +0 -29
- package/dist/components/organisms/Modal/Modal.stories.js +0 -66
- package/dist/components/organisms/Modal/index.js +0 -95
- package/dist/components/organisms/Modal/styles.js +0 -20
- package/dist/global-files/handle_http.js +0 -383
- package/dist/global-files/utils.js +0 -472
- package/src/assets/images/customSelect/starIcon.svg +0 -14
- package/src/assets/images/defaultImages/Spinner.gif +0 -0
- package/src/assets/images/defaultImages/notFound.svg +0 -124
- package/src/components/atoms/ButtonFileChooser/ButtonFileChooser.stories.js +0 -47
- package/src/components/atoms/ButtonFileChooser/index.js +0 -69
- package/src/components/atoms/ButtonFileChooser/styles.js +0 -4
- package/src/components/atoms/ButtonV2/ButtonV2.stories.js +0 -51
- package/src/components/atoms/ButtonV2/index.js +0 -79
- package/src/components/atoms/ButtonV2/styles.js +0 -195
- package/src/components/atoms/CustomIcon/CustomIcon.stories.js +0 -36
- package/src/components/atoms/CustomIcon/index.js +0 -41
- package/src/components/atoms/CustomIcon/styles.js +0 -85
- package/src/components/atoms/IconFile/IconFile.stories.js +0 -35
- package/src/components/atoms/IconFile/index.js +0 -119
- package/src/components/atoms/IconFile/styles.js +0 -67
- package/src/components/atoms/Image/Image.stories.js +0 -51
- package/src/components/atoms/Image/index.js +0 -55
- package/src/components/atoms/Image/styles.js +0 -34
- package/src/components/atoms/ImageLink/ImageLink.stories.js +0 -43
- package/src/components/atoms/ImageLink/index.js +0 -57
- package/src/components/atoms/ImageLink/styles.js +0 -30
- package/src/components/atoms/ImagePreview/ImagePreview.stories.js +0 -52
- package/src/components/atoms/ImagePreview/index.js +0 -191
- package/src/components/atoms/ImagePreview/styles.js +0 -77
- package/src/components/atoms/InputText/InputText.stories.js +0 -39
- package/src/components/atoms/InputText/index.js +0 -61
- package/src/components/atoms/InputText/styles.js +0 -89
- package/src/components/atoms/NotFound/NotFound.stories.js +0 -19
- package/src/components/atoms/NotFound/index.js +0 -52
- package/src/components/atoms/NotFound/styles.js +0 -55
- package/src/components/atoms/SelectItemV2/SelectItemV2.stories.js +0 -26
- package/src/components/atoms/SelectItemV2/index.js +0 -45
- package/src/components/atoms/SelectItemV2/styles.js +0 -55
- package/src/components/atoms/Tooltip/Tooltip.stories.js +0 -51
- package/src/components/atoms/Tooltip/index.js +0 -59
- package/src/components/atoms/Tooltip/styles.js +0 -42
- package/src/components/molecules/ButtonDownloadFile/DownloadFile.stories.js +0 -54
- package/src/components/molecules/ButtonDownloadFile/index.js +0 -111
- package/src/components/molecules/ButtonDownloadFile/styles.js +0 -66
- package/src/components/molecules/Dropdown/Dropdown.stories.js +0 -101
- package/src/components/molecules/Dropdown/index.js +0 -142
- package/src/components/molecules/Dropdown/styles.js +0 -75
- package/src/components/molecules/ImageTooltip/ImageTooltip.stories.js +0 -46
- package/src/components/molecules/ImageTooltip/index.js +0 -62
- package/src/components/molecules/ImageTooltip/styles.js +0 -18
- package/src/components/molecules/SelectV2/SelectV2.stories.js +0 -114
- package/src/components/molecules/SelectV2/index.js +0 -332
- package/src/components/molecules/SelectV2/styles.js +0 -100
- package/src/components/organisms/Chat/Chat.stories.js +0 -199
- package/src/components/organisms/Chat/ChatLists/ChatLists.stories.js +0 -65
- package/src/components/organisms/Chat/ChatLists/Rotoplas.jpeg +0 -0
- package/src/components/organisms/Chat/ChatLists/THD.png +0 -0
- package/src/components/organisms/Chat/ChatLists/index.js +0 -141
- package/src/components/organisms/Chat/ChatLists/styles.js +0 -162
- package/src/components/organisms/Chat/ContainerItems/ContainerItems.stories.js +0 -142
- package/src/components/organisms/Chat/ContainerItems/index.js +0 -549
- package/src/components/organisms/Chat/ContainerItems/styles.js +0 -328
- package/src/components/organisms/Chat/ContentChat/ContentChat.stories.js +0 -102
- package/src/components/organisms/Chat/ContentChat/Rotoplas.jpeg +0 -0
- package/src/components/organisms/Chat/ContentChat/THD.png +0 -0
- package/src/components/organisms/Chat/ContentChat/index.js +0 -900
- package/src/components/organisms/Chat/ContentChat/styles.js +0 -41
- package/src/components/organisms/Chat/Footer/Footer.stories.js +0 -22
- package/src/components/organisms/Chat/Footer/index.js +0 -669
- package/src/components/organisms/Chat/Footer/styles.js +0 -286
- package/src/components/organisms/Chat/Header/Header.stories.js +0 -66
- package/src/components/organisms/Chat/Header/index.js +0 -94
- package/src/components/organisms/Chat/Header/styles.js +0 -49
- package/src/components/organisms/Chat/index.js +0 -294
- package/src/components/organisms/Chat/styles.js +0 -42
- package/src/components/organisms/Modal/Modal.stories.js +0 -55
- package/src/components/organisms/Modal/index.js +0 -97
- package/src/components/organisms/Modal/styles.js +0 -103
- package/src/global-files/handle_http.js +0 -231
- package/src/global-files/utils.js +0 -300
|
@@ -1,75 +0,0 @@
|
|
|
1
|
-
import { FontFamily } from "../../../global-files/variables";
|
|
2
|
-
import styled from "styled-components";
|
|
3
|
-
|
|
4
|
-
export const Container = styled.div`
|
|
5
|
-
width: fit-content;
|
|
6
|
-
|
|
7
|
-
.containerIntern {
|
|
8
|
-
width: inherit;
|
|
9
|
-
border: inherit;
|
|
10
|
-
border-radius: inherit;
|
|
11
|
-
|
|
12
|
-
> * {
|
|
13
|
-
width: inherit;
|
|
14
|
-
border: inherit;
|
|
15
|
-
border-radius: inherit;
|
|
16
|
-
}
|
|
17
|
-
}
|
|
18
|
-
|
|
19
|
-
> .MuiTooltip-popper {
|
|
20
|
-
background-color: transparent;
|
|
21
|
-
|
|
22
|
-
.dropdownMenu {
|
|
23
|
-
--background: white;
|
|
24
|
-
box-shadow: 0px 0px 10px 1px gray;
|
|
25
|
-
background-color: var(--background);
|
|
26
|
-
padding: 0px 0px;
|
|
27
|
-
border-radius: 7px;
|
|
28
|
-
display: flex;
|
|
29
|
-
flex-direction: column;
|
|
30
|
-
gap: 0px;
|
|
31
|
-
overflow: auto;
|
|
32
|
-
max-width: ${({ maxWidthDropdown }) =>
|
|
33
|
-
maxWidthDropdown ? maxWidthDropdown : "400px"};
|
|
34
|
-
max-height: ${({ maxHeightDropdown }) =>
|
|
35
|
-
maxHeightDropdown ? maxHeightDropdown : "80vh"};
|
|
36
|
-
|
|
37
|
-
.dropdownItem {
|
|
38
|
-
width: 100%;
|
|
39
|
-
border-radius: 0px;
|
|
40
|
-
border: none;
|
|
41
|
-
|
|
42
|
-
.button {
|
|
43
|
-
justify-content: flex-start;
|
|
44
|
-
border: inherit;
|
|
45
|
-
text-align: left;
|
|
46
|
-
font-family: ${FontFamily.RobotoRegular};
|
|
47
|
-
padding: 10px;
|
|
48
|
-
gap: 11px;
|
|
49
|
-
|
|
50
|
-
.icon {
|
|
51
|
-
font-size: calc(var(--size) + 1px);
|
|
52
|
-
opacity: 0.75;
|
|
53
|
-
}
|
|
54
|
-
}
|
|
55
|
-
|
|
56
|
-
&.iconDefault .button .icon {
|
|
57
|
-
opacity: 0;
|
|
58
|
-
}
|
|
59
|
-
}
|
|
60
|
-
}
|
|
61
|
-
|
|
62
|
-
&[data-popper-placement*="bottom"] .dropdownMenu {
|
|
63
|
-
margin-top: 10px;
|
|
64
|
-
}
|
|
65
|
-
&[data-popper-placement*="top"] .dropdownMenu {
|
|
66
|
-
margin-bottom: 10px;
|
|
67
|
-
}
|
|
68
|
-
&[data-popper-placement*="left"] .dropdownMenu {
|
|
69
|
-
margin-right: 10px;
|
|
70
|
-
}
|
|
71
|
-
&[data-popper-placement*="right"] .dropdownMenu {
|
|
72
|
-
margin-left: 10px;
|
|
73
|
-
}
|
|
74
|
-
}
|
|
75
|
-
`;
|
|
@@ -1,46 +0,0 @@
|
|
|
1
|
-
import { ImageTooltip } from "./index";
|
|
2
|
-
|
|
3
|
-
export default {
|
|
4
|
-
title: "Components/molecules/ImageTooltip",
|
|
5
|
-
component: ImageTooltip,
|
|
6
|
-
argTypes: {},
|
|
7
|
-
};
|
|
8
|
-
|
|
9
|
-
const Template = (args) => <ImageTooltip {...args} />;
|
|
10
|
-
|
|
11
|
-
const keyS3_test =
|
|
12
|
-
"84300/1/chat/playa-213f791b-d890-48e1-be19-28bf5a95d517.jpeg";
|
|
13
|
-
const srcTest = `https://content-management-images.s3.amazonaws.com/${keyS3_test}`;
|
|
14
|
-
export const ImageTooltipTest = Template.bind({});
|
|
15
|
-
ImageTooltipTest.args = {
|
|
16
|
-
width: "200px",
|
|
17
|
-
sizeLoading: "50",
|
|
18
|
-
colorLoading: "#bbbbbb",
|
|
19
|
-
src: "bn",
|
|
20
|
-
componentDefault: <label> test error </label>,
|
|
21
|
-
componentTooltip: <label> mensaje del tooltip test </label>,
|
|
22
|
-
};
|
|
23
|
-
|
|
24
|
-
const keyS3_OK =
|
|
25
|
-
"84300/1/chat/f6579ed5-16e5-48d8-ace5-6be8e8e68f53-38896acf-9179-4686-9088-9784df624ab8.png";
|
|
26
|
-
const srcOK = `https://content-management-images.s3.amazonaws.com/${keyS3_OK}`;
|
|
27
|
-
export const ImageTooltipOK = Template.bind({});
|
|
28
|
-
ImageTooltipOK.args = {
|
|
29
|
-
width: "250px",
|
|
30
|
-
sizeLoading: "40",
|
|
31
|
-
src: srcOK,
|
|
32
|
-
componentDefault: <label> img no cargada </label>,
|
|
33
|
-
componentTooltip: <label> mensaje del tooltip OK </label>,
|
|
34
|
-
};
|
|
35
|
-
|
|
36
|
-
const keyS3_ERROR =
|
|
37
|
-
"84300/1/chat/21dba1da-3c60-42c4-97bd-033664808256-fb19ff57-b91c-4ef2-ba2a-d857b55fb33b.svg";
|
|
38
|
-
const srcERROR = `https://content-management-images.s3.amazonaws.com/${keyS3_ERROR}`;
|
|
39
|
-
export const ImageTooltipERROR = Template.bind({});
|
|
40
|
-
ImageTooltipERROR.args = {
|
|
41
|
-
width: "300px",
|
|
42
|
-
sizeLoading: "60",
|
|
43
|
-
src: srcERROR,
|
|
44
|
-
componentDefault: <label> ERROR al cargar </label>,
|
|
45
|
-
componentTooltip: <label> mensaje del tooltip ERROR </label>,
|
|
46
|
-
};
|
|
@@ -1,62 +0,0 @@
|
|
|
1
|
-
import { Container, ContainerLoading, Img } from "./styles";
|
|
2
|
-
import { FontAwesomeIcon as Icon } from "@fortawesome/react-fontawesome";
|
|
3
|
-
import { faSpinner as iconLoading } from "@fortawesome/free-solid-svg-icons";
|
|
4
|
-
import { useState, useEffect } from "react";
|
|
5
|
-
import { Tooltip } from "../../atoms/Tooltip";
|
|
6
|
-
|
|
7
|
-
export const ImageTooltip = (props) => {
|
|
8
|
-
const {
|
|
9
|
-
className, // string
|
|
10
|
-
width, // string
|
|
11
|
-
sizeLoading, // number
|
|
12
|
-
colorLoading, // string
|
|
13
|
-
classNameLoading, // string
|
|
14
|
-
src, // imagen a cargar (string)
|
|
15
|
-
componentDefault, // componente a mostrar en caso de que no cargue src (JSX)
|
|
16
|
-
classNameImg, // string
|
|
17
|
-
classNameTooltip,
|
|
18
|
-
componentTooltip,
|
|
19
|
-
} = props;
|
|
20
|
-
const [imgLoad, setImgLoad] = useState();
|
|
21
|
-
const [loading, setLoading] = useState(false);
|
|
22
|
-
|
|
23
|
-
/* solo para hacer pruebas en modo dev
|
|
24
|
-
useEffect(() => {
|
|
25
|
-
setTimeout(() => {
|
|
26
|
-
setLoading(false);
|
|
27
|
-
}, 5000);
|
|
28
|
-
}, []);
|
|
29
|
-
*/
|
|
30
|
-
|
|
31
|
-
return (
|
|
32
|
-
<Tooltip
|
|
33
|
-
position={"topCenter"}
|
|
34
|
-
addArrow={false}
|
|
35
|
-
transitionType={"zoom"}
|
|
36
|
-
followCursor={false}
|
|
37
|
-
className={className}
|
|
38
|
-
classNameTooltip={classNameTooltip}
|
|
39
|
-
componentTooltip={imgLoad !== undefined && !loading && componentTooltip}
|
|
40
|
-
>
|
|
41
|
-
{src && (imgLoad === undefined || loading) && (
|
|
42
|
-
<ContainerLoading
|
|
43
|
-
className={classNameLoading}
|
|
44
|
-
sizeLoading={sizeLoading}
|
|
45
|
-
colorLoading={colorLoading}
|
|
46
|
-
>
|
|
47
|
-
<Icon pulse icon={iconLoading} />
|
|
48
|
-
</ContainerLoading>
|
|
49
|
-
)}
|
|
50
|
-
|
|
51
|
-
{(!src || (imgLoad === false && !loading)) && componentDefault}
|
|
52
|
-
|
|
53
|
-
<Img
|
|
54
|
-
className={classNameImg}
|
|
55
|
-
src={src}
|
|
56
|
-
onLoad={(event) => setImgLoad(true)}
|
|
57
|
-
onError={(event) => setImgLoad(false)}
|
|
58
|
-
show={imgLoad === true && !loading}
|
|
59
|
-
/>
|
|
60
|
-
</Tooltip>
|
|
61
|
-
);
|
|
62
|
-
};
|
|
@@ -1,18 +0,0 @@
|
|
|
1
|
-
import styled from "styled-components";
|
|
2
|
-
import { GlobalColors, FontFamily } from "../../../global-files/variables";
|
|
3
|
-
|
|
4
|
-
export const ContainerLoading = styled.div`
|
|
5
|
-
width: 100%;
|
|
6
|
-
display: grid;
|
|
7
|
-
place-items: center;
|
|
8
|
-
min-width: min-content;
|
|
9
|
-
font-size: ${({ sizeLoading }) => (sizeLoading ? sizeLoading : "30")}px;
|
|
10
|
-
color: ${({ colorLoading }) => (colorLoading ? colorLoading : "#9e2674")};
|
|
11
|
-
padding: 5px;
|
|
12
|
-
`;
|
|
13
|
-
|
|
14
|
-
export const Img = styled.img`
|
|
15
|
-
display: ${({ show }) => (show ? "grid" : "none")};
|
|
16
|
-
width: 100%;
|
|
17
|
-
object-fit: contain;
|
|
18
|
-
`;
|
|
@@ -1,114 +0,0 @@
|
|
|
1
|
-
import { SelectV2 } from "./index";
|
|
2
|
-
|
|
3
|
-
export default {
|
|
4
|
-
title: "Components/molecules/SelectV2",
|
|
5
|
-
component: SelectV2,
|
|
6
|
-
argTypes: {
|
|
7
|
-
positionDropdown: {
|
|
8
|
-
options: [
|
|
9
|
-
undefined,
|
|
10
|
-
"topStart",
|
|
11
|
-
"topEnd",
|
|
12
|
-
"topCenter",
|
|
13
|
-
"rightStart",
|
|
14
|
-
"rightEnd",
|
|
15
|
-
"rightCenter",
|
|
16
|
-
"bottomStart",
|
|
17
|
-
"bottomEnd",
|
|
18
|
-
"bottomCenter",
|
|
19
|
-
"leftStart",
|
|
20
|
-
"leftEnd",
|
|
21
|
-
"leftCenter",
|
|
22
|
-
],
|
|
23
|
-
control: { type: "select" },
|
|
24
|
-
},
|
|
25
|
-
triggerType: {
|
|
26
|
-
options: [undefined, "hover", "click"],
|
|
27
|
-
control: { type: "select" },
|
|
28
|
-
},
|
|
29
|
-
typeSelectItems: {
|
|
30
|
-
options: [undefined, "checkbox", "marginCheckbox", "labelOnly"],
|
|
31
|
-
control: { type: "select" },
|
|
32
|
-
},
|
|
33
|
-
borderType: {
|
|
34
|
-
options: [undefined, "rectangle", "oval"],
|
|
35
|
-
control: { type: "select" },
|
|
36
|
-
},
|
|
37
|
-
alignmentItemsOverflow: {
|
|
38
|
-
options: [undefined, "columns", "rows"],
|
|
39
|
-
control: { type: "select" },
|
|
40
|
-
},
|
|
41
|
-
},
|
|
42
|
-
};
|
|
43
|
-
|
|
44
|
-
const Template = (args) => <SelectV2 {...args} />;
|
|
45
|
-
|
|
46
|
-
export const SelectV2Test = Template.bind({});
|
|
47
|
-
SelectV2Test.args = {
|
|
48
|
-
items: [
|
|
49
|
-
{
|
|
50
|
-
label: "Palomitas de maiz",
|
|
51
|
-
value: 1,
|
|
52
|
-
selected: false,
|
|
53
|
-
},
|
|
54
|
-
{
|
|
55
|
-
label: "Sabritas",
|
|
56
|
-
value: 2,
|
|
57
|
-
selected: true,
|
|
58
|
-
},
|
|
59
|
-
{
|
|
60
|
-
label: "sabritas Doritos",
|
|
61
|
-
value: 3,
|
|
62
|
-
selected: false,
|
|
63
|
-
},
|
|
64
|
-
{
|
|
65
|
-
label:
|
|
66
|
-
"Este es un texto muy largo que deberia llegar al limite establecido para el width",
|
|
67
|
-
value: 4,
|
|
68
|
-
selected: true,
|
|
69
|
-
},
|
|
70
|
-
{
|
|
71
|
-
label: "galletas",
|
|
72
|
-
value: 5,
|
|
73
|
-
selected: false,
|
|
74
|
-
},
|
|
75
|
-
{
|
|
76
|
-
label: "jugo de uva",
|
|
77
|
-
value: 6,
|
|
78
|
-
selected: false,
|
|
79
|
-
},
|
|
80
|
-
],
|
|
81
|
-
triggerType: "hover",
|
|
82
|
-
selectButton: {
|
|
83
|
-
className: "btnSelectPrueba",
|
|
84
|
-
type: "whiteS3",
|
|
85
|
-
transparent: undefined,
|
|
86
|
-
disabled: false,
|
|
87
|
-
label: "select de prueba",
|
|
88
|
-
size: 12,
|
|
89
|
-
borderType: "oval",
|
|
90
|
-
},
|
|
91
|
-
defaultItem: {
|
|
92
|
-
label: "Ningun filtro",
|
|
93
|
-
itemType: undefined,
|
|
94
|
-
showLabelInSelect: true,
|
|
95
|
-
},
|
|
96
|
-
inputSearch: {
|
|
97
|
-
className: "inputBusqueda",
|
|
98
|
-
defaultText: "hola",
|
|
99
|
-
},
|
|
100
|
-
typeSelectItems: undefined,
|
|
101
|
-
borderType: undefined,
|
|
102
|
-
maxWidthSelect: "150px",
|
|
103
|
-
maxWidthDropdown: "300px",
|
|
104
|
-
maxHeightDropdown: "300px",
|
|
105
|
-
maxWidthItems: "100px",
|
|
106
|
-
alignmentItemsOverflow: undefined,
|
|
107
|
-
multiple: true,
|
|
108
|
-
classNameSelect: "selectPrueba",
|
|
109
|
-
classNameDropdown: "dropdownSelectPrueba",
|
|
110
|
-
positionDropdown: undefined,
|
|
111
|
-
onChange: (selectedItems) => {
|
|
112
|
-
console.log("selectedItems:", selectedItems);
|
|
113
|
-
},
|
|
114
|
-
};
|
|
@@ -1,332 +0,0 @@
|
|
|
1
|
-
import { useEffect, useRef, useState } from "react";
|
|
2
|
-
import {
|
|
3
|
-
ClickAwayListener,
|
|
4
|
-
Fade,
|
|
5
|
-
Grow,
|
|
6
|
-
Popper,
|
|
7
|
-
Tooltip as TooltipMUI,
|
|
8
|
-
Zoom,
|
|
9
|
-
} from "@mui/material";
|
|
10
|
-
import { Container, ContainerSelect } from "./styles";
|
|
11
|
-
import React from "react";
|
|
12
|
-
import { ButtonV2 } from "../../atoms/ButtonV2";
|
|
13
|
-
import {
|
|
14
|
-
faCaretDown as IconDownArrow,
|
|
15
|
-
faSearch as IconSearch,
|
|
16
|
-
} from "@fortawesome/free-solid-svg-icons";
|
|
17
|
-
import { isArrayEmpty, isStringEmpty } from "../../../global-files/utils";
|
|
18
|
-
import { SelectItemV2 } from "../../atoms/SelectItemV2";
|
|
19
|
-
import { InputText } from "../../atoms/InputText";
|
|
20
|
-
|
|
21
|
-
export const SelectV2 = (props) => {
|
|
22
|
-
const {
|
|
23
|
-
items /* [
|
|
24
|
-
{
|
|
25
|
-
label: string,
|
|
26
|
-
value: string | number,
|
|
27
|
-
selected: (boolean) true -> item seleccionado al inicio
|
|
28
|
-
} ,
|
|
29
|
-
...
|
|
30
|
-
] */,
|
|
31
|
-
triggerType, // (string) "hover" | "click"
|
|
32
|
-
selectButton /* {
|
|
33
|
-
className: string,
|
|
34
|
-
type: (string) tipos validos de ButtonV2,
|
|
35
|
-
transparent: boolean,
|
|
36
|
-
disabled: boolean,
|
|
37
|
-
label: string ,
|
|
38
|
-
size: number ,
|
|
39
|
-
} */,
|
|
40
|
-
defaultItem /* {
|
|
41
|
-
label: string,
|
|
42
|
-
itemType: (string) "checkbox" | "marginCheckbox" | "labelOnly"
|
|
43
|
-
showLabelInSelect: boolean, cuando esta seleccionado ver label en el btnSelect??
|
|
44
|
-
} */,
|
|
45
|
-
inputSearch /* {
|
|
46
|
-
className: string,
|
|
47
|
-
defaultText: string ,
|
|
48
|
-
} */,
|
|
49
|
-
maxWidthSelect, // string
|
|
50
|
-
maxWidthDropdown, // string
|
|
51
|
-
maxHeightDropdown, // string
|
|
52
|
-
maxWidthItems, // string
|
|
53
|
-
alignmentItemsOverflow, // (string) "columns" | "rows" -> por default "rows"
|
|
54
|
-
typeSelectItems, // (string) "checkbox" | "marginCheckbox" | "labelOnly"
|
|
55
|
-
multiple, // (boolean) se permite multiple seleccion??
|
|
56
|
-
borderType, // (string) "rectangle" | "oval" -> por default oval
|
|
57
|
-
classNameSelect, // (string) clase del container select
|
|
58
|
-
classNameDropdown, // (string) clase del contenedor tooltip
|
|
59
|
-
positionDropdown, // (string) posicion del contenedor tooltip (values en object positions)
|
|
60
|
-
onChange, // (selectedItems: []) = {} array con los values de los items seleccionados
|
|
61
|
-
} = props;
|
|
62
|
-
const positions = {
|
|
63
|
-
topStart: "top-start",
|
|
64
|
-
topEnd: "top-end",
|
|
65
|
-
topCenter: "top",
|
|
66
|
-
|
|
67
|
-
rightStart: "right-start",
|
|
68
|
-
rightEnd: "right-end",
|
|
69
|
-
rightCenter: "right",
|
|
70
|
-
|
|
71
|
-
bottomStart: "bottom-start",
|
|
72
|
-
bottomEnd: "bottom-end",
|
|
73
|
-
bottomCenter: "bottom",
|
|
74
|
-
|
|
75
|
-
leftStart: "left-start",
|
|
76
|
-
leftEnd: "left-end",
|
|
77
|
-
leftCenter: "left",
|
|
78
|
-
};
|
|
79
|
-
const [selectedItems, setSelectedItems] = useState(); // { .. }
|
|
80
|
-
const [customItems, setCustomItems] = useState([]);
|
|
81
|
-
const [showDropdown, setShowDropdown] = useState(false);
|
|
82
|
-
const [labelSelect, setLabelSelect] = useState("Sin titulo");
|
|
83
|
-
const [textInputSearch, setTextInputSearch] = useState("");
|
|
84
|
-
|
|
85
|
-
const refInputTextSearch = useRef();
|
|
86
|
-
|
|
87
|
-
// cada que cambie la lista de items
|
|
88
|
-
useEffect(() => {
|
|
89
|
-
if (isArrayEmpty(items)) {
|
|
90
|
-
setSelectedItems({});
|
|
91
|
-
return;
|
|
92
|
-
}
|
|
93
|
-
// items iniciales seleccionados
|
|
94
|
-
let initialSelectedItems = {};
|
|
95
|
-
items.forEach((item) => {
|
|
96
|
-
if (item.selected) {
|
|
97
|
-
if (multiple) initialSelectedItems[item.value] = item.value;
|
|
98
|
-
else initialSelectedItems = { [item.value]: item.value };
|
|
99
|
-
}
|
|
100
|
-
});
|
|
101
|
-
setSelectedItems(initialSelectedItems);
|
|
102
|
-
}, [items]);
|
|
103
|
-
|
|
104
|
-
// cada que cambien los items seleccionados
|
|
105
|
-
useEffect(() => {
|
|
106
|
-
if (!selectedItems) return;
|
|
107
|
-
renderItems();
|
|
108
|
-
renderLabelSelect();
|
|
109
|
-
onChange && onChange(Object.values(selectedItems));
|
|
110
|
-
}, [selectedItems]);
|
|
111
|
-
|
|
112
|
-
// evento click de cada item de la lista
|
|
113
|
-
const onClickItem = (isSelected, value) => {
|
|
114
|
-
let selectedItemsCopy = { ...selectedItems };
|
|
115
|
-
if (isSelected) {
|
|
116
|
-
multiple
|
|
117
|
-
? (selectedItemsCopy[value] = value)
|
|
118
|
-
: (selectedItemsCopy = { [value]: value });
|
|
119
|
-
} else delete selectedItemsCopy[value];
|
|
120
|
-
setSelectedItems(selectedItemsCopy);
|
|
121
|
-
};
|
|
122
|
-
|
|
123
|
-
const onClickSearch = () => {
|
|
124
|
-
setTextInputSearch(textInputSearch.trim());
|
|
125
|
-
refInputTextSearch?.current && refInputTextSearch.current.blur();
|
|
126
|
-
renderItems(textInputSearch.trim());
|
|
127
|
-
};
|
|
128
|
-
|
|
129
|
-
const renderLabelSelect = () => {
|
|
130
|
-
if (!selectedItems) return;
|
|
131
|
-
const selectedItemsCopy = Object.values(selectedItems);
|
|
132
|
-
if (selectedItemsCopy.length > 1) {
|
|
133
|
-
setLabelSelect("Personalizado");
|
|
134
|
-
} else if (selectedItemsCopy.length === 1) {
|
|
135
|
-
let labelItem = undefined;
|
|
136
|
-
for (const item of items) {
|
|
137
|
-
if (item.value == selectedItemsCopy[0]) {
|
|
138
|
-
labelItem = item.label;
|
|
139
|
-
break;
|
|
140
|
-
}
|
|
141
|
-
}
|
|
142
|
-
!isStringEmpty(labelItem)
|
|
143
|
-
? setLabelSelect(labelItem)
|
|
144
|
-
: setLabelSelect("Sin titulo");
|
|
145
|
-
} else {
|
|
146
|
-
if (
|
|
147
|
-
!isStringEmpty(defaultItem?.label) &&
|
|
148
|
-
defaultItem?.showLabelInSelect
|
|
149
|
-
) {
|
|
150
|
-
setLabelSelect(defaultItem.label);
|
|
151
|
-
} else if (!isStringEmpty(selectButton?.label)) {
|
|
152
|
-
setLabelSelect(selectButton.label);
|
|
153
|
-
} else {
|
|
154
|
-
setLabelSelect("Sin titulo");
|
|
155
|
-
}
|
|
156
|
-
}
|
|
157
|
-
};
|
|
158
|
-
|
|
159
|
-
const renderItems = (textSearch = "") => {
|
|
160
|
-
if (isArrayEmpty(items)) setCustomItems([]);
|
|
161
|
-
setCustomItems(
|
|
162
|
-
items.map((item, index) => {
|
|
163
|
-
if (
|
|
164
|
-
!isStringEmpty(textSearch) &&
|
|
165
|
-
!item.label
|
|
166
|
-
.trim()
|
|
167
|
-
.toLowerCase()
|
|
168
|
-
.includes(textSearch.trim().toLowerCase())
|
|
169
|
-
) {
|
|
170
|
-
return null;
|
|
171
|
-
}
|
|
172
|
-
return (
|
|
173
|
-
<SelectItemV2
|
|
174
|
-
key={classNameSelect + "_item" + index}
|
|
175
|
-
label={item.label}
|
|
176
|
-
value={item.value}
|
|
177
|
-
checkbox={
|
|
178
|
-
typeSelectItems === "checkbox"
|
|
179
|
-
? true
|
|
180
|
-
: typeSelectItems === "marginCheckbox"
|
|
181
|
-
? false
|
|
182
|
-
: undefined
|
|
183
|
-
}
|
|
184
|
-
selected={selectedItems && selectedItems[item.value] ? true : false}
|
|
185
|
-
onClick={onClickItem}
|
|
186
|
-
/>
|
|
187
|
-
);
|
|
188
|
-
})
|
|
189
|
-
);
|
|
190
|
-
};
|
|
191
|
-
|
|
192
|
-
return (
|
|
193
|
-
<ClickAwayListener
|
|
194
|
-
onClickAway={(event) => {
|
|
195
|
-
if (triggerType !== "hover") setShowDropdown(false);
|
|
196
|
-
}}
|
|
197
|
-
>
|
|
198
|
-
<Container
|
|
199
|
-
className={!isStringEmpty(classNameSelect) ? classNameSelect : ""}
|
|
200
|
-
borderType={borderType}
|
|
201
|
-
maxWidthSelect={maxWidthSelect}
|
|
202
|
-
maxWidthDropdown={maxWidthDropdown}
|
|
203
|
-
maxHeightDropdown={maxHeightDropdown}
|
|
204
|
-
alignmentItemsOverflow={alignmentItemsOverflow}
|
|
205
|
-
maxWidthItems={maxWidthItems}
|
|
206
|
-
>
|
|
207
|
-
<TooltipMUI
|
|
208
|
-
{...props}
|
|
209
|
-
placement={positions[positionDropdown] ?? positions.bottomCenter}
|
|
210
|
-
open={triggerType !== "hover" ? showDropdown : undefined}
|
|
211
|
-
arrow={false}
|
|
212
|
-
componentsProps={{
|
|
213
|
-
tooltip: {
|
|
214
|
-
className:
|
|
215
|
-
"dropdownSelect" +
|
|
216
|
-
(isStringEmpty(classNameDropdown)
|
|
217
|
-
? ""
|
|
218
|
-
: " " + classNameDropdown),
|
|
219
|
-
},
|
|
220
|
-
popper: { disablePortal: true },
|
|
221
|
-
transition: { timeout: 300 },
|
|
222
|
-
}}
|
|
223
|
-
TransitionComponent={Fade}
|
|
224
|
-
enterDelay={100}
|
|
225
|
-
followCursor={false}
|
|
226
|
-
disableFocusListener
|
|
227
|
-
disableTouchListener
|
|
228
|
-
disableHoverListener={triggerType !== "hover"}
|
|
229
|
-
title={
|
|
230
|
-
<>
|
|
231
|
-
{/* input search */}
|
|
232
|
-
{inputSearch && (
|
|
233
|
-
<div
|
|
234
|
-
className={
|
|
235
|
-
"container-inputSearch" +
|
|
236
|
-
(!isStringEmpty(inputSearch?.className)
|
|
237
|
-
? " " + inputSearch.className
|
|
238
|
-
: "")
|
|
239
|
-
}
|
|
240
|
-
>
|
|
241
|
-
<ButtonV2
|
|
242
|
-
className="buttonSearch"
|
|
243
|
-
type={"gray"}
|
|
244
|
-
transparent
|
|
245
|
-
size={14}
|
|
246
|
-
icon={IconSearch}
|
|
247
|
-
onClick={(event) => {
|
|
248
|
-
if (
|
|
249
|
-
isStringEmpty(textInputSearch) &&
|
|
250
|
-
refInputTextSearch?.current
|
|
251
|
-
) {
|
|
252
|
-
setTextInputSearch("");
|
|
253
|
-
refInputTextSearch.current.focus();
|
|
254
|
-
} else {
|
|
255
|
-
onClickSearch();
|
|
256
|
-
}
|
|
257
|
-
}}
|
|
258
|
-
/>
|
|
259
|
-
|
|
260
|
-
<InputText
|
|
261
|
-
className="inputSearch"
|
|
262
|
-
type="black"
|
|
263
|
-
transparent
|
|
264
|
-
size={12}
|
|
265
|
-
placeHolder={
|
|
266
|
-
isStringEmpty(inputSearch?.defaultText)
|
|
267
|
-
? "Texto a buscar"
|
|
268
|
-
: inputSearch.defaultText
|
|
269
|
-
}
|
|
270
|
-
text={textInputSearch}
|
|
271
|
-
onChangeText={(newValue) => setTextInputSearch(newValue)}
|
|
272
|
-
onEnter={(event) => onClickSearch()}
|
|
273
|
-
refInputText={refInputTextSearch}
|
|
274
|
-
/>
|
|
275
|
-
</div>
|
|
276
|
-
)}
|
|
277
|
-
|
|
278
|
-
{/* item por default */}
|
|
279
|
-
{defaultItem && (
|
|
280
|
-
<SelectItemV2
|
|
281
|
-
label={defaultItem.label}
|
|
282
|
-
value={null}
|
|
283
|
-
checkbox={
|
|
284
|
-
defaultItem.itemType === "checkbox"
|
|
285
|
-
? true
|
|
286
|
-
: defaultItem.itemType === "marginCheckbox"
|
|
287
|
-
? false
|
|
288
|
-
: undefined
|
|
289
|
-
}
|
|
290
|
-
selected={
|
|
291
|
-
selectedItems && Object.keys(selectedItems).length
|
|
292
|
-
? false
|
|
293
|
-
: true
|
|
294
|
-
}
|
|
295
|
-
onClick={(isSelected, value) => {
|
|
296
|
-
selectedItems &&
|
|
297
|
-
Object.keys(selectedItems).length &&
|
|
298
|
-
setSelectedItems({});
|
|
299
|
-
}}
|
|
300
|
-
/>
|
|
301
|
-
)}
|
|
302
|
-
|
|
303
|
-
{/* lista de items */}
|
|
304
|
-
<div className="container-items">{customItems}</div>
|
|
305
|
-
</>
|
|
306
|
-
}
|
|
307
|
-
>
|
|
308
|
-
<ContainerSelect className={"container-buttonSelect"}>
|
|
309
|
-
<ButtonV2
|
|
310
|
-
className={
|
|
311
|
-
"buttonSelect" +
|
|
312
|
-
(!isStringEmpty(selectButton?.className)
|
|
313
|
-
? " " + selectButton.className
|
|
314
|
-
: "")
|
|
315
|
-
}
|
|
316
|
-
disabled={selectButton?.disabled}
|
|
317
|
-
type={selectButton?.type}
|
|
318
|
-
transparent={selectButton?.transparent}
|
|
319
|
-
label={labelSelect}
|
|
320
|
-
size={selectButton?.size}
|
|
321
|
-
icon={IconDownArrow}
|
|
322
|
-
iconPosition="end"
|
|
323
|
-
onClick={(event) => {
|
|
324
|
-
if (triggerType !== "hover") setShowDropdown((prev) => !prev);
|
|
325
|
-
}}
|
|
326
|
-
/>
|
|
327
|
-
</ContainerSelect>
|
|
328
|
-
</TooltipMUI>
|
|
329
|
-
</Container>
|
|
330
|
-
</ClickAwayListener>
|
|
331
|
-
);
|
|
332
|
-
};
|