cemtrik-dependencies 1.0.7 → 1.0.9
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/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "cemtrik-dependencies",
|
|
3
|
-
"version": "1.0.
|
|
3
|
+
"version": "1.0.9",
|
|
4
4
|
"scripts": {
|
|
5
5
|
"dev": "next dev -p 3000",
|
|
6
6
|
"build": "next build",
|
|
@@ -44,8 +44,7 @@
|
|
|
44
44
|
"postcss-loader": "^6.1.1",
|
|
45
45
|
"prettier": "^2.8.8",
|
|
46
46
|
"style-loader": "^3.3.3",
|
|
47
|
-
"tailwindcss": "^2.2.19"
|
|
48
|
-
"webpack": "^5.85.0"
|
|
47
|
+
"tailwindcss": "^2.2.19"
|
|
49
48
|
},
|
|
50
49
|
"lint-staged": {
|
|
51
50
|
"*.(js|ts)": "npm run lint"
|
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
import Alert from "./components/atoms/Alert";
|
|
2
|
+
import Avatar from "./components/atoms/Avatar";
|
|
3
|
+
import Bullets from "./components/atoms/Bullets";
|
|
4
|
+
import ButtonOutline from "./components/atoms/ButtonOutline";
|
|
5
|
+
import ButtonPagination from "./components/atoms/ButtonPagination";
|
|
6
|
+
import ButtonSolid from "./components/atoms/ButtonSolid";
|
|
7
|
+
import Checkbox from "./components/atoms/Checkbox";
|
|
8
|
+
import ConfirmationAbandoningCreation from "./components/atoms/ConfirmationAbandoningCreation";
|
|
9
|
+
import Divider from "./components/atoms/Divider";
|
|
10
|
+
import GoBack from "./components/atoms/GoBack";
|
|
11
|
+
import Input from "./components/atoms/Input";
|
|
12
|
+
import InputDropdown from "./components/atoms/InputDropdown";
|
|
13
|
+
import Select from "./components/atoms/Select";
|
|
14
|
+
import Spinner from "./components/atoms/Spinner";
|
|
15
|
+
import Switch from "./components/atoms/Switch";
|
|
16
|
+
import Textarea from "./components/atoms/Textarea";
|
|
17
|
+
import Tooltip from "./components/atoms/Tooltip";
|
|
18
|
+
import Dropdown from "./components/molecules/Dropdown";
|
|
19
|
+
import Modal from "./components/molecules/Modal";
|
|
20
|
+
import Pagination from "./components/molecules/Pagination";
|
|
21
|
+
import Accordion from "./components/templates/Accordion";
|
|
22
|
+
|
|
23
|
+
export {
|
|
24
|
+
Alert,
|
|
25
|
+
Avatar,
|
|
26
|
+
Bullets,
|
|
27
|
+
ButtonOutline,
|
|
28
|
+
ButtonPagination,
|
|
29
|
+
ButtonSolid,
|
|
30
|
+
Checkbox,
|
|
31
|
+
ConfirmationAbandoningCreation,
|
|
32
|
+
Divider,
|
|
33
|
+
GoBack,
|
|
34
|
+
Input,
|
|
35
|
+
InputDropdown,
|
|
36
|
+
Select,
|
|
37
|
+
Spinner,
|
|
38
|
+
Switch,
|
|
39
|
+
Textarea,
|
|
40
|
+
Tooltip,
|
|
41
|
+
Dropdown,
|
|
42
|
+
Modal,
|
|
43
|
+
Pagination,
|
|
44
|
+
Accordion,
|
|
45
|
+
};
|
package/components.js
DELETED
|
@@ -1,47 +0,0 @@
|
|
|
1
|
-
import Alert from "./src/components/atoms/Alert";
|
|
2
|
-
import Avatar from "./src/components/atoms/Avatar";
|
|
3
|
-
import Bullets from "./src/components/atoms/Bullets";
|
|
4
|
-
import ButtonOutline from "./src/components/atoms/ButtonOutline";
|
|
5
|
-
import ButtonPagination from "./src/components/atoms/ButtonPagination";
|
|
6
|
-
import ButtonSolid from "./src/components/atoms/ButtonSolid";
|
|
7
|
-
import Checkbox from "./src/components/atoms/Checkbox";
|
|
8
|
-
import ConfirmationAbandoningCreation from "./src/components/atoms/ConfirmationAbandoningCreation";
|
|
9
|
-
import Divider from "./src/components/atoms/Divider";
|
|
10
|
-
import GoBack from "./src/components/atoms/GoBack";
|
|
11
|
-
import Input from "./src/components/atoms/Input";
|
|
12
|
-
import InputDropdown from "./src/components/atoms/InputDropdown";
|
|
13
|
-
import Select from "./src/components/atoms/Select";
|
|
14
|
-
import Spinner from "./src/components/atoms/Spinner";
|
|
15
|
-
import Switch from "./src/components/atoms/Switch";
|
|
16
|
-
import Textarea from "./src/components/atoms/Textarea";
|
|
17
|
-
import Tooltip from "./src/components/atoms/Tooltip";
|
|
18
|
-
import UploadImage from "./src/components/atoms/UploadImage";
|
|
19
|
-
import Dropdown from "./src/components/molecules/Dropdown";
|
|
20
|
-
import Modal from "./src/components/molecules/Modal";
|
|
21
|
-
import Pagination from "./src/components/molecules/Pagination";
|
|
22
|
-
import Accordion from "./src/components/templates/Accordion";
|
|
23
|
-
|
|
24
|
-
export {
|
|
25
|
-
Alert,
|
|
26
|
-
Avatar,
|
|
27
|
-
Bullets,
|
|
28
|
-
ButtonOutline,
|
|
29
|
-
ButtonPagination,
|
|
30
|
-
ButtonSolid,
|
|
31
|
-
Checkbox,
|
|
32
|
-
ConfirmationAbandoningCreation,
|
|
33
|
-
Divider,
|
|
34
|
-
GoBack,
|
|
35
|
-
Input,
|
|
36
|
-
InputDropdown,
|
|
37
|
-
Select,
|
|
38
|
-
Spinner,
|
|
39
|
-
Switch,
|
|
40
|
-
Textarea,
|
|
41
|
-
Tooltip,
|
|
42
|
-
UploadImage,
|
|
43
|
-
Dropdown,
|
|
44
|
-
Modal,
|
|
45
|
-
Pagination,
|
|
46
|
-
Accordion,
|
|
47
|
-
};
|
|
@@ -1,55 +0,0 @@
|
|
|
1
|
-
// 1.- libraries
|
|
2
|
-
import { useState } from "react";
|
|
3
|
-
import Image from "next/image";
|
|
4
|
-
|
|
5
|
-
// 2.- utils
|
|
6
|
-
import { classNames } from "../../../utils";
|
|
7
|
-
|
|
8
|
-
const UploadImage = ({ src, width, height, className = "", uploadImg }) => {
|
|
9
|
-
const [imagePreview, setImagePreview] = useState(null);
|
|
10
|
-
|
|
11
|
-
const handleChange = (e) => {
|
|
12
|
-
const { files } = e.target;
|
|
13
|
-
const [file] = files;
|
|
14
|
-
|
|
15
|
-
const reader = new FileReader();
|
|
16
|
-
reader.readAsDataURL(file);
|
|
17
|
-
|
|
18
|
-
reader.onload = function (e) {
|
|
19
|
-
uploadImg(reader.result);
|
|
20
|
-
setImagePreview(reader.result);
|
|
21
|
-
};
|
|
22
|
-
|
|
23
|
-
// reader.onerror = function () {
|
|
24
|
-
// setImagePreview(null);
|
|
25
|
-
// };
|
|
26
|
-
};
|
|
27
|
-
|
|
28
|
-
return (
|
|
29
|
-
<div className="flex items-center justify-center w-full">
|
|
30
|
-
<label
|
|
31
|
-
htmlFor="dropzone-file"
|
|
32
|
-
className="flex flex-col items-center justify-center w-11 h-11 border-2 border-gray-300 border-dashed rounded-full cursor-pointer bg-gray-50 dark:hover:bg-bray-800 dark:bg-gray-700 hover:bg-gray-100 dark:border-gray-600 dark:hover:border-gray-500 dark:hover:bg-gray-600 overflow-hidden"
|
|
33
|
-
>
|
|
34
|
-
<div className="flex flex-col items-center justify-center pt-5 pb-6">
|
|
35
|
-
<Image
|
|
36
|
-
src={imagePreview ?? src}
|
|
37
|
-
alt="preview_img"
|
|
38
|
-
width={width}
|
|
39
|
-
height={height}
|
|
40
|
-
className={classNames("w-auto h-auto", className !== "" && className)}
|
|
41
|
-
/>
|
|
42
|
-
</div>
|
|
43
|
-
<input
|
|
44
|
-
id="dropzone-file"
|
|
45
|
-
type="file"
|
|
46
|
-
className="hidden"
|
|
47
|
-
onChange={handleChange}
|
|
48
|
-
data-testid="file"
|
|
49
|
-
/>
|
|
50
|
-
</label>
|
|
51
|
-
</div>
|
|
52
|
-
);
|
|
53
|
-
};
|
|
54
|
-
|
|
55
|
-
export default UploadImage;
|
|
@@ -1,36 +0,0 @@
|
|
|
1
|
-
import { render, fireEvent, waitFor, act } from "@testing-library/react";
|
|
2
|
-
import UploadImage from "./index";
|
|
3
|
-
|
|
4
|
-
describe("UploadImage", () => {
|
|
5
|
-
it("renders UploadImage component without errors", () => {
|
|
6
|
-
render(
|
|
7
|
-
<UploadImage
|
|
8
|
-
className="w-full"
|
|
9
|
-
src="https://images.unsplash.com/photo"
|
|
10
|
-
width={200}
|
|
11
|
-
height={200}
|
|
12
|
-
/>,
|
|
13
|
-
);
|
|
14
|
-
});
|
|
15
|
-
|
|
16
|
-
it("upload img", async () => {
|
|
17
|
-
const mockUploadImg = jest.fn();
|
|
18
|
-
const component = render(
|
|
19
|
-
<UploadImage
|
|
20
|
-
src="https://images.unsplash.com/photo"
|
|
21
|
-
width={200}
|
|
22
|
-
height={200}
|
|
23
|
-
uploadImg={mockUploadImg}
|
|
24
|
-
/>,
|
|
25
|
-
);
|
|
26
|
-
const inputFile = component.getByTestId("file");
|
|
27
|
-
const file = new File(["file content"], "", { type: "text/plain" });
|
|
28
|
-
const changeEvent = { target: { files: [file] } };
|
|
29
|
-
|
|
30
|
-
await act(async () => {
|
|
31
|
-
fireEvent.change(inputFile, changeEvent);
|
|
32
|
-
await waitFor(() => {});
|
|
33
|
-
});
|
|
34
|
-
expect(mockUploadImg).toHaveBeenCalled();
|
|
35
|
-
});
|
|
36
|
-
});
|