react-frontend-common-components 0.0.76 → 0.0.79
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/dist/index.d.ts +7 -5
- package/dist/index.js +13 -27
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +14 -28
- package/dist/index.mjs.map +1 -1
- package/package.json +40 -40
- package/rollup.config.js +44 -44
- package/src/components/app-avatar/app-avatar.tsx +24 -24
- package/src/components/app-back-arrow/app-back-arrow.css +17 -17
- package/src/components/app-back-arrow/app-back-arrow.tsx +37 -37
- package/src/components/app-badge/app-badge.css +11 -11
- package/src/components/app-badge/app-badge.tsx +44 -44
- package/src/components/app-bread-crumb/app-bread-crumb.tsx +16 -16
- package/src/components/app-button/app-button.css +13 -13
- package/src/components/app-button/app-button.tsx +51 -51
- package/src/components/app-card/app-card.css +8 -8
- package/src/components/app-card/app-card.tsx +43 -43
- package/src/components/app-carousel/app-carousel.css +68 -68
- package/src/components/app-carousel/app-carousel.tsx +62 -62
- package/src/components/app-chart/app-chart.css +6 -6
- package/src/components/app-chart/app-chart.tsx +98 -98
- package/src/components/app-checkbox-text/app-checkbox-text.css +12 -12
- package/src/components/app-checkbox-text/app-checkbox-text.tsx +32 -32
- package/src/components/app-collapse/app-collapse.tsx +57 -57
- package/src/components/app-custom-loader/app-custom-loader.css +116 -116
- package/src/components/app-custom-loader/app-custom-loader.tsx +23 -23
- package/src/components/app-divider/app-divider.tsx +16 -16
- package/src/components/app-float-button/app-float-button.tsx +23 -23
- package/src/components/app-image-box/app-image-box.css +22 -22
- package/src/components/app-image-box/app-image-box.tsx +42 -42
- package/src/components/app-input/app-input.css +59 -59
- package/src/components/app-input/app-input.tsx +93 -93
- package/src/components/app-label/app-label.css +5 -5
- package/src/components/app-label/app-label.tsx +34 -34
- package/src/components/app-list/app-list.tsx +26 -26
- package/src/components/app-loader/app-loader.css +16 -16
- package/src/components/app-loader/app-loader.tsx +28 -28
- package/src/components/app-location-map/app-location-map.css +4 -4
- package/src/components/app-location-map/app-location-map.tsx +62 -62
- package/src/components/app-modal/app-modal.css +34 -34
- package/src/components/app-modal/app-modal.tsx +61 -61
- package/src/components/app-otp-field/app-otp-field.css +28 -28
- package/src/components/app-otp-field/app-otp-field.tsx +70 -70
- package/src/components/app-pagination/app-pagination.tsx +40 -40
- package/src/components/app-password-input/app-password-input.css +41 -41
- package/src/components/app-password-input/app-password-input.tsx +90 -90
- package/src/components/app-phone-input/app-phone-input.css +12 -12
- package/src/components/app-phone-input/app-phone-input.tsx +56 -56
- package/src/components/app-popover/app-popover.css +5 -5
- package/src/components/app-popover/app-popover.tsx +45 -45
- package/src/components/app-progress/app-progress.tsx +40 -40
- package/src/components/app-radio-group/app-radio-group.css +6 -6
- package/src/components/app-radio-group/app-radio-group.tsx +45 -45
- package/src/components/app-select/app-select.css +33 -33
- package/src/components/app-select/app-select.tsx +90 -59
- package/src/components/app-select-add/app-select-add.css +21 -21
- package/src/components/app-select-add/app-select-add.tsx +34 -34
- package/src/components/app-sidebar/app-sidebar.css +49 -49
- package/src/components/app-sidebar/app-sidebar.tsx +87 -87
- package/src/components/app-tab/app-tab.css +22 -22
- package/src/components/app-tab/app-tab.tsx +31 -31
- package/src/components/app-table/app-table.tsx +42 -42
- package/src/components/app-tag/app-tag.css +11 -11
- package/src/components/app-tag/app-tag.tsx +48 -48
- package/src/components/app-textarea/app-textarea.css +25 -25
- package/src/components/app-textarea/app-textarea.tsx +59 -59
- package/src/components/app-title/app-title.css +12 -12
- package/src/components/app-title/app-title.tsx +28 -28
- package/src/components/app-toggle-button/app-toggle-button.css +27 -27
- package/src/components/app-toggle-button/app-toggle-button.tsx +43 -43
- package/src/components/app-upload-image/app-upload-image.css +26 -26
- package/src/components/app-upload-image/app-upload-image.tsx +90 -90
- package/src/components/over-view-card/over-view-card.css +15 -15
- package/src/components/over-view-card/over-view-card.tsx +26 -26
- package/src/index.ts +38 -38
- package/src/themes/icons/icons.tsx +146 -146
- package/src/themes/images/profile-img.svg +14 -14
- package/tsconfig.json +20 -20
@@ -1,90 +1,90 @@
|
|
1
|
-
import React, { useState, useRef } from "react";
|
2
|
-
import Icons from "../../themes/icons/icons";
|
3
|
-
import "./app-upload-image.css";
|
4
|
-
|
5
|
-
interface AppUploadImageProps {
|
6
|
-
className?: string;
|
7
|
-
uploadIcon?: React.ReactNode;
|
8
|
-
value?: string;
|
9
|
-
text?: string;
|
10
|
-
onFileChange?: (file: File | null) => void;
|
11
|
-
alertMessages?: {
|
12
|
-
invalidType?: string;
|
13
|
-
sizeExceed?: string;
|
14
|
-
};
|
15
|
-
acceptedFormats?: string[];
|
16
|
-
maxSizeMb?: number;
|
17
|
-
altText?: string;
|
18
|
-
}
|
19
|
-
|
20
|
-
const AppUploadImage = ({
|
21
|
-
className,
|
22
|
-
uploadIcon,
|
23
|
-
value = "",
|
24
|
-
text = "Upload Image",
|
25
|
-
onFileChange,
|
26
|
-
alertMessages = {
|
27
|
-
invalidType: "You can only upload JPG/PNG/SVG file!",
|
28
|
-
sizeExceed: "Image must be smaller than 2MB!",
|
29
|
-
},
|
30
|
-
acceptedFormats = ["image/jpeg", "image/png", "image/svg+xml"],
|
31
|
-
maxSizeMb = 2,
|
32
|
-
altText = "Profile Image",
|
33
|
-
}: AppUploadImageProps) => {
|
34
|
-
const [imageUrl, setImageUrl] = useState<string>(value);
|
35
|
-
const fileInputRef = useRef<HTMLInputElement>(null);
|
36
|
-
|
37
|
-
const handleButtonClick = () => {
|
38
|
-
fileInputRef.current?.click();
|
39
|
-
};
|
40
|
-
|
41
|
-
const handleFileChange = (event: React.ChangeEvent<HTMLInputElement>) => {
|
42
|
-
const file = event.target.files?.[0];
|
43
|
-
if (file) {
|
44
|
-
const isAcceptedFormat = acceptedFormats.includes(file.type);
|
45
|
-
const isLtMaxSize = file.size / 1024 / 1024 < maxSizeMb;
|
46
|
-
|
47
|
-
if (!isAcceptedFormat) {
|
48
|
-
alert(alertMessages.invalidType);
|
49
|
-
return;
|
50
|
-
}
|
51
|
-
|
52
|
-
if (!isLtMaxSize) {
|
53
|
-
alert(alertMessages.sizeExceed);
|
54
|
-
return;
|
55
|
-
}
|
56
|
-
|
57
|
-
const reader = new FileReader();
|
58
|
-
reader.onloadend = () => {
|
59
|
-
setImageUrl(reader.result as string);
|
60
|
-
if (onFileChange) {
|
61
|
-
onFileChange(file);
|
62
|
-
}
|
63
|
-
};
|
64
|
-
reader.readAsDataURL(file);
|
65
|
-
} else if (onFileChange) {
|
66
|
-
onFileChange(null);
|
67
|
-
}
|
68
|
-
};
|
69
|
-
|
70
|
-
return (
|
71
|
-
<div className={`profileImageContainer ${className}`}>
|
72
|
-
<div className={imageUrl === "" ? "altTextWrapper" : ""}>
|
73
|
-
<img className={"profileImage"} src={imageUrl} alt={altText} />
|
74
|
-
</div>
|
75
|
-
<button className={"uploadButton"} onClick={handleButtonClick}>
|
76
|
-
<span>{uploadIcon || Icons.uploadIcon}</span>
|
77
|
-
{text}
|
78
|
-
</button>
|
79
|
-
<input
|
80
|
-
type="file"
|
81
|
-
accept={acceptedFormats.join(",")}
|
82
|
-
className={"fileInput"}
|
83
|
-
ref={fileInputRef}
|
84
|
-
onChange={handleFileChange}
|
85
|
-
/>
|
86
|
-
</div>
|
87
|
-
);
|
88
|
-
};
|
89
|
-
|
90
|
-
export default AppUploadImage;
|
1
|
+
import React, { useState, useRef } from "react";
|
2
|
+
import Icons from "../../themes/icons/icons";
|
3
|
+
import "./app-upload-image.css";
|
4
|
+
|
5
|
+
interface AppUploadImageProps {
|
6
|
+
className?: string;
|
7
|
+
uploadIcon?: React.ReactNode;
|
8
|
+
value?: string;
|
9
|
+
text?: string;
|
10
|
+
onFileChange?: (file: File | null) => void;
|
11
|
+
alertMessages?: {
|
12
|
+
invalidType?: string;
|
13
|
+
sizeExceed?: string;
|
14
|
+
};
|
15
|
+
acceptedFormats?: string[];
|
16
|
+
maxSizeMb?: number;
|
17
|
+
altText?: string;
|
18
|
+
}
|
19
|
+
|
20
|
+
const AppUploadImage = ({
|
21
|
+
className,
|
22
|
+
uploadIcon,
|
23
|
+
value = "",
|
24
|
+
text = "Upload Image",
|
25
|
+
onFileChange,
|
26
|
+
alertMessages = {
|
27
|
+
invalidType: "You can only upload JPG/PNG/SVG file!",
|
28
|
+
sizeExceed: "Image must be smaller than 2MB!",
|
29
|
+
},
|
30
|
+
acceptedFormats = ["image/jpeg", "image/png", "image/svg+xml"],
|
31
|
+
maxSizeMb = 2,
|
32
|
+
altText = "Profile Image",
|
33
|
+
}: AppUploadImageProps) => {
|
34
|
+
const [imageUrl, setImageUrl] = useState<string>(value);
|
35
|
+
const fileInputRef = useRef<HTMLInputElement>(null);
|
36
|
+
|
37
|
+
const handleButtonClick = () => {
|
38
|
+
fileInputRef.current?.click();
|
39
|
+
};
|
40
|
+
|
41
|
+
const handleFileChange = (event: React.ChangeEvent<HTMLInputElement>) => {
|
42
|
+
const file = event.target.files?.[0];
|
43
|
+
if (file) {
|
44
|
+
const isAcceptedFormat = acceptedFormats.includes(file.type);
|
45
|
+
const isLtMaxSize = file.size / 1024 / 1024 < maxSizeMb;
|
46
|
+
|
47
|
+
if (!isAcceptedFormat) {
|
48
|
+
alert(alertMessages.invalidType);
|
49
|
+
return;
|
50
|
+
}
|
51
|
+
|
52
|
+
if (!isLtMaxSize) {
|
53
|
+
alert(alertMessages.sizeExceed);
|
54
|
+
return;
|
55
|
+
}
|
56
|
+
|
57
|
+
const reader = new FileReader();
|
58
|
+
reader.onloadend = () => {
|
59
|
+
setImageUrl(reader.result as string);
|
60
|
+
if (onFileChange) {
|
61
|
+
onFileChange(file);
|
62
|
+
}
|
63
|
+
};
|
64
|
+
reader.readAsDataURL(file);
|
65
|
+
} else if (onFileChange) {
|
66
|
+
onFileChange(null);
|
67
|
+
}
|
68
|
+
};
|
69
|
+
|
70
|
+
return (
|
71
|
+
<div className={`profileImageContainer ${className}`}>
|
72
|
+
<div className={imageUrl === "" ? "altTextWrapper" : ""}>
|
73
|
+
<img className={"profileImage"} src={imageUrl} alt={altText} />
|
74
|
+
</div>
|
75
|
+
<button className={"uploadButton"} onClick={handleButtonClick}>
|
76
|
+
<span>{uploadIcon || Icons.uploadIcon}</span>
|
77
|
+
{text}
|
78
|
+
</button>
|
79
|
+
<input
|
80
|
+
type="file"
|
81
|
+
accept={acceptedFormats.join(",")}
|
82
|
+
className={"fileInput"}
|
83
|
+
ref={fileInputRef}
|
84
|
+
onChange={handleFileChange}
|
85
|
+
/>
|
86
|
+
</div>
|
87
|
+
);
|
88
|
+
};
|
89
|
+
|
90
|
+
export default AppUploadImage;
|
@@ -1,15 +1,15 @@
|
|
1
|
-
.overViewCard {
|
2
|
-
border-radius: 12px;
|
3
|
-
padding: 0.5rem 1rem;
|
4
|
-
background-color: #f9f9f9;
|
5
|
-
width: max-content;
|
6
|
-
display: flex;
|
7
|
-
flex-direction: column;
|
8
|
-
align-items: center;
|
9
|
-
gap: 0.5rem;
|
10
|
-
.text {
|
11
|
-
font-size: 14px;
|
12
|
-
font-weight: 700;
|
13
|
-
line-height: normal;
|
14
|
-
}
|
15
|
-
}
|
1
|
+
.overViewCard {
|
2
|
+
border-radius: 12px;
|
3
|
+
padding: 0.5rem 1rem;
|
4
|
+
background-color: #f9f9f9;
|
5
|
+
width: max-content;
|
6
|
+
display: flex;
|
7
|
+
flex-direction: column;
|
8
|
+
align-items: center;
|
9
|
+
gap: 0.5rem;
|
10
|
+
.text {
|
11
|
+
font-size: 14px;
|
12
|
+
font-weight: 700;
|
13
|
+
line-height: normal;
|
14
|
+
}
|
15
|
+
}
|
@@ -1,26 +1,26 @@
|
|
1
|
-
import React from "react";
|
2
|
-
import { Typography } from "antd";
|
3
|
-
import "./over-view-card.css";
|
4
|
-
|
5
|
-
const { Text } = Typography;
|
6
|
-
|
7
|
-
interface OverViewCardProps {
|
8
|
-
className?: string;
|
9
|
-
text?: string;
|
10
|
-
number?: number | string;
|
11
|
-
}
|
12
|
-
|
13
|
-
const OverViewCard = ({ className, text, number }: OverViewCardProps) => {
|
14
|
-
// Format the number with leading zeros (e.g., display 08)
|
15
|
-
const formattedNumber =
|
16
|
-
number !== undefined ? number.toString().padStart(2, "0") : "";
|
17
|
-
|
18
|
-
return (
|
19
|
-
<div className={`overViewCard ${className}`}>
|
20
|
-
<span className="text">{text}</span>
|
21
|
-
<span>{formattedNumber}</span>
|
22
|
-
</div>
|
23
|
-
);
|
24
|
-
};
|
25
|
-
|
26
|
-
export default OverViewCard;
|
1
|
+
import React from "react";
|
2
|
+
import { Typography } from "antd";
|
3
|
+
import "./over-view-card.css";
|
4
|
+
|
5
|
+
const { Text } = Typography;
|
6
|
+
|
7
|
+
interface OverViewCardProps {
|
8
|
+
className?: string;
|
9
|
+
text?: string;
|
10
|
+
number?: number | string;
|
11
|
+
}
|
12
|
+
|
13
|
+
const OverViewCard = ({ className, text, number }: OverViewCardProps) => {
|
14
|
+
// Format the number with leading zeros (e.g., display 08)
|
15
|
+
const formattedNumber =
|
16
|
+
number !== undefined ? number.toString().padStart(2, "0") : "";
|
17
|
+
|
18
|
+
return (
|
19
|
+
<div className={`overViewCard ${className}`}>
|
20
|
+
<span className="text">{text}</span>
|
21
|
+
<span>{formattedNumber}</span>
|
22
|
+
</div>
|
23
|
+
);
|
24
|
+
};
|
25
|
+
|
26
|
+
export default OverViewCard;
|
package/src/index.ts
CHANGED
@@ -1,38 +1,38 @@
|
|
1
|
-
export { default as AppInput } from "./components/app-input/app-input";
|
2
|
-
export { default as AppButton } from "./components/app-button/app-button";
|
3
|
-
export { default as AppSidebar } from "./components/app-sidebar/app-sidebar";
|
4
|
-
export { default as AppTextarea } from "./components/app-textarea/app-textarea";
|
5
|
-
export { default as AppTab } from "./components/app-tab/app-tab";
|
6
|
-
export { default as AppBackArrow } from "./components/app-back-arrow/app-back-arrow";
|
7
|
-
export { default as AppBadge } from "./components/app-badge/app-badge";
|
8
|
-
export { default as OverViewCard } from "./components/over-view-card/over-view-card";
|
9
|
-
export { default as AppChart } from "./components/app-chart/app-chart";
|
10
|
-
export { default as AppImageBox } from "./components/app-image-box/app-image-box";
|
11
|
-
export { default as AppAvatar } from "./components/app-avatar/app-avatar";
|
12
|
-
export { default as AppCheckboxText } from "./components/app-checkbox-text/app-checkbox-text";
|
13
|
-
export { default as AppCollapse } from "./components/app-collapse/app-collapse";
|
14
|
-
export { default as AppCustomLoader } from "./components/app-custom-loader/app-custom-loader";
|
15
|
-
export { default as AppLocationMap } from "./components/app-location-map/app-location-map";
|
16
|
-
export { default as AppModal } from "./components/app-modal/app-modal";
|
17
|
-
export { default as AppOtpField } from "./components/app-otp-field/app-otp-field";
|
18
|
-
export { default as AppPagination } from "./components/app-pagination/app-pagination";
|
19
|
-
export { default as AppPasswordInput } from "./components/app-password-input/app-password-input";
|
20
|
-
export { default as AppTitle } from "./components/app-title/app-title";
|
21
|
-
export { default as AppToggleButton } from "./components/app-toggle-button/app-toggle-button";
|
22
|
-
export { default as AppUploadImage } from "./components/app-upload-image/app-upload-image";
|
23
|
-
export { default as AppRadioGroup } from "./components/app-radio-group/app-radio-group";
|
24
|
-
export { default as AppSelect } from "./components/app-select/app-select";
|
25
|
-
export { default as AppSelectAdd } from "./components/app-select-add/app-select-add";
|
26
|
-
export { default as AppTag } from "./components/app-tag/app-tag";
|
27
|
-
export { default as AppList } from "./components/app-list/app-list";
|
28
|
-
export { default as AppLoader } from "./components/app-loader/app-loader";
|
29
|
-
export { default as AppDivider } from "./components/app-divider/app-divider";
|
30
|
-
export { default as AppLabel } from "./components/app-label/app-label";
|
31
|
-
export { default as AppBreadcrumb } from "./components/app-bread-crumb/app-bread-crumb";
|
32
|
-
export { default as AppCard } from "./components/app-card/app-card";
|
33
|
-
export { default as AppCarousel } from "./components/app-carousel/app-carousel";
|
34
|
-
export { default as AppTable } from "./components/app-table/app-table";
|
35
|
-
export { default as AppProgress } from "./components/app-progress/app-progress";
|
36
|
-
export { default as AppPopover } from "./components/app-popover/app-popover";
|
37
|
-
export { default as AppFloatButton } from "./components/app-float-button/app-float-button";
|
38
|
-
export { default as AppPhoneInput } from "./components/app-phone-input/app-phone-input";
|
1
|
+
export { default as AppInput } from "./components/app-input/app-input";
|
2
|
+
export { default as AppButton } from "./components/app-button/app-button";
|
3
|
+
export { default as AppSidebar } from "./components/app-sidebar/app-sidebar";
|
4
|
+
export { default as AppTextarea } from "./components/app-textarea/app-textarea";
|
5
|
+
export { default as AppTab } from "./components/app-tab/app-tab";
|
6
|
+
export { default as AppBackArrow } from "./components/app-back-arrow/app-back-arrow";
|
7
|
+
export { default as AppBadge } from "./components/app-badge/app-badge";
|
8
|
+
export { default as OverViewCard } from "./components/over-view-card/over-view-card";
|
9
|
+
export { default as AppChart } from "./components/app-chart/app-chart";
|
10
|
+
export { default as AppImageBox } from "./components/app-image-box/app-image-box";
|
11
|
+
export { default as AppAvatar } from "./components/app-avatar/app-avatar";
|
12
|
+
export { default as AppCheckboxText } from "./components/app-checkbox-text/app-checkbox-text";
|
13
|
+
export { default as AppCollapse } from "./components/app-collapse/app-collapse";
|
14
|
+
export { default as AppCustomLoader } from "./components/app-custom-loader/app-custom-loader";
|
15
|
+
export { default as AppLocationMap } from "./components/app-location-map/app-location-map";
|
16
|
+
export { default as AppModal } from "./components/app-modal/app-modal";
|
17
|
+
export { default as AppOtpField } from "./components/app-otp-field/app-otp-field";
|
18
|
+
export { default as AppPagination } from "./components/app-pagination/app-pagination";
|
19
|
+
export { default as AppPasswordInput } from "./components/app-password-input/app-password-input";
|
20
|
+
export { default as AppTitle } from "./components/app-title/app-title";
|
21
|
+
export { default as AppToggleButton } from "./components/app-toggle-button/app-toggle-button";
|
22
|
+
export { default as AppUploadImage } from "./components/app-upload-image/app-upload-image";
|
23
|
+
export { default as AppRadioGroup } from "./components/app-radio-group/app-radio-group";
|
24
|
+
export { default as AppSelect } from "./components/app-select/app-select";
|
25
|
+
export { default as AppSelectAdd } from "./components/app-select-add/app-select-add";
|
26
|
+
export { default as AppTag } from "./components/app-tag/app-tag";
|
27
|
+
export { default as AppList } from "./components/app-list/app-list";
|
28
|
+
export { default as AppLoader } from "./components/app-loader/app-loader";
|
29
|
+
export { default as AppDivider } from "./components/app-divider/app-divider";
|
30
|
+
export { default as AppLabel } from "./components/app-label/app-label";
|
31
|
+
export { default as AppBreadcrumb } from "./components/app-bread-crumb/app-bread-crumb";
|
32
|
+
export { default as AppCard } from "./components/app-card/app-card";
|
33
|
+
export { default as AppCarousel } from "./components/app-carousel/app-carousel";
|
34
|
+
export { default as AppTable } from "./components/app-table/app-table";
|
35
|
+
export { default as AppProgress } from "./components/app-progress/app-progress";
|
36
|
+
export { default as AppPopover } from "./components/app-popover/app-popover";
|
37
|
+
export { default as AppFloatButton } from "./components/app-float-button/app-float-button";
|
38
|
+
export { default as AppPhoneInput } from "./components/app-phone-input/app-phone-input";
|