@tenancy.nz/ui 1.0.0 → 1.0.2
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 +0 -69
- package/dist/cjs/components/Alert.cjs +48 -0
- package/dist/cjs/components/Alert.styled.cjs +41 -0
- package/dist/cjs/components/Autocomplete.cjs +176 -0
- package/dist/cjs/components/Autocomplete.styled.cjs +15 -0
- package/dist/cjs/components/Avatar.cjs +52 -0
- package/dist/cjs/components/Avatar.styled.cjs +24 -0
- package/dist/cjs/components/AvatarCropDialog.cjs +200 -0
- package/dist/cjs/components/AvatarCropDialog.styled.cjs +21 -0
- package/dist/cjs/components/AvatarInput.cjs +215 -0
- package/dist/cjs/components/AvatarInput.styled.cjs +151 -0
- package/dist/cjs/components/Badge.cjs +83 -0
- package/dist/cjs/components/Badge.styled.cjs +23 -0
- package/dist/cjs/components/BankAccountInput.cjs +296 -0
- package/dist/cjs/components/BankAccountInput.styled.cjs +163 -0
- package/dist/cjs/components/Bar.cjs +44 -0
- package/dist/cjs/components/Bar.styled.cjs +22 -0
- package/dist/cjs/components/BaseModal.cjs +41 -0
- package/dist/cjs/components/BaseModal.styled.cjs +20 -0
- package/dist/cjs/components/BooleanInput.cjs +173 -0
- package/dist/cjs/components/BooleanInput.styled.cjs +65 -0
- package/dist/cjs/components/BorderedGrid.cjs +46 -0
- package/dist/cjs/components/Box.cjs +97 -0
- package/dist/cjs/components/Button.cjs +48 -0
- package/dist/cjs/components/Button.styled.cjs +106 -0
- package/dist/cjs/components/Card.cjs +61 -0
- package/dist/cjs/components/Card.styled.cjs +15 -0
- package/dist/cjs/components/CardContent.cjs +21 -0
- package/dist/cjs/components/CardContent.styled.cjs +10 -0
- package/dist/cjs/components/Checkbox.cjs +49 -0
- package/dist/cjs/components/Checkbox.styled.cjs +25 -0
- package/dist/cjs/components/CircularProgress.cjs +14 -0
- package/dist/cjs/components/CollapsedText.cjs +88 -0
- package/dist/cjs/components/CollapsedText.styled.cjs +52 -0
- package/dist/cjs/components/Confirmation.cjs +60 -0
- package/dist/cjs/components/Container.cjs +21 -0
- package/dist/cjs/components/CroppedImageInput.cjs +465 -0
- package/dist/cjs/components/CroppedImageInput.styled.cjs +91 -0
- package/dist/cjs/components/CroppedImageInputActions.cjs +78 -0
- package/dist/cjs/components/DateInput.cjs +218 -0
- package/dist/cjs/components/DateInput.styled.cjs +26 -0
- package/dist/cjs/components/DateNumberInput.cjs +175 -0
- package/dist/cjs/components/DateNumberInput.styled.cjs +58 -0
- package/dist/cjs/components/DatePicker.cjs +134 -0
- package/dist/cjs/components/DatePicker.styled.cjs +17 -0
- package/dist/cjs/components/DateSelect.cjs +212 -0
- package/dist/cjs/components/DateSelect.styled.cjs +15 -0
- package/dist/cjs/components/Divider.cjs +67 -0
- package/dist/cjs/components/Divider.styled.cjs +62 -0
- package/dist/cjs/components/DropZone.cjs +153 -0
- package/dist/cjs/components/DropZone.styled.cjs +76 -0
- package/dist/cjs/components/Embed.cjs +41 -0
- package/dist/cjs/components/Embed.styled.cjs +38 -0
- package/dist/cjs/components/FileUpload.cjs +319 -0
- package/dist/cjs/components/FileUpload.styled.cjs +47 -0
- package/dist/cjs/components/FileUploadButton.cjs +117 -0
- package/dist/cjs/components/FileUploadButtonLoader.cjs +27 -0
- package/dist/cjs/components/FileViewer.cjs +117 -0
- package/dist/cjs/components/FileViewer.styled.cjs +29 -0
- package/dist/cjs/components/FlashMessage.cjs +69 -0
- package/dist/cjs/components/FormControl.cjs +102 -0
- package/dist/cjs/components/FormControl.styled.cjs +22 -0
- package/dist/cjs/components/FormFocus.cjs +37 -0
- package/dist/cjs/components/FormLabel.cjs +24 -0
- package/dist/cjs/components/FormLabel.styled.cjs +55 -0
- package/dist/cjs/components/Grid.cjs +52 -0
- package/dist/cjs/components/Grid.styled.cjs +12 -0
- package/dist/cjs/components/Heading.cjs +41 -0
- package/dist/cjs/components/IconButton.cjs +31 -0
- package/dist/cjs/components/IconButton.styled.cjs +31 -0
- package/dist/cjs/components/Icons.cjs +62 -0
- package/dist/cjs/components/LinearProgress.cjs +14 -0
- package/dist/cjs/components/Link.cjs +37 -0
- package/dist/cjs/components/Link.styled.cjs +39 -0
- package/dist/cjs/components/Media.cjs +44 -0
- package/dist/cjs/components/Media.styled.cjs +46 -0
- package/dist/cjs/components/Modal.cjs +56 -0
- package/dist/cjs/components/ModalActions.cjs +23 -0
- package/dist/cjs/components/ModalContent.cjs +32 -0
- package/dist/cjs/components/ModalHeader.cjs +24 -0
- package/dist/cjs/components/ModalHeader.styled.cjs +29 -0
- package/dist/cjs/components/Nameplate.cjs +110 -0
- package/dist/cjs/components/Nameplate.styled.cjs +49 -0
- package/dist/cjs/components/Pagination.cjs +147 -0
- package/dist/cjs/components/Pagination.styled.cjs +83 -0
- package/dist/cjs/components/Paper.cjs +34 -0
- package/dist/cjs/components/Paper.styled.cjs +63 -0
- package/dist/cjs/components/Popper.cjs +64 -0
- package/dist/cjs/components/PropertyCard.cjs +222 -0
- package/dist/cjs/components/PropertyCard.styled.cjs +67 -0
- package/dist/cjs/components/Radio.cjs +49 -0
- package/dist/cjs/components/Radio.styled.cjs +25 -0
- package/dist/cjs/components/Rating.cjs +14 -0
- package/dist/cjs/components/Select.cjs +105 -0
- package/dist/cjs/components/Select.styled.cjs +104 -0
- package/dist/cjs/components/Skeleton.cjs +23 -0
- package/dist/cjs/components/StatusMessage.cjs +27 -0
- package/dist/cjs/components/StepIcon.cjs +50 -0
- package/dist/cjs/components/StepIcon.styled.cjs +57 -0
- package/dist/cjs/components/Stepper.cjs +58 -0
- package/dist/cjs/components/Stepper.styled.cjs +61 -0
- package/dist/cjs/components/SuccessModal.cjs +43 -0
- package/dist/cjs/components/SuccessModal.styled.cjs +22 -0
- package/dist/cjs/components/Switch.cjs +46 -0
- package/dist/cjs/components/Switch.styled.cjs +109 -0
- package/dist/cjs/components/Tab.cjs +39 -0
- package/dist/cjs/components/Tab.styled.cjs +14 -0
- package/dist/cjs/components/TabPanel.cjs +30 -0
- package/dist/cjs/components/TabPanel.styled.cjs +12 -0
- package/dist/cjs/components/Table.cjs +21 -0
- package/dist/cjs/components/TableBody.cjs +21 -0
- package/dist/cjs/components/TableCell.cjs +21 -0
- package/dist/cjs/components/TableContainer.cjs +21 -0
- package/dist/cjs/components/TableFooter.cjs +21 -0
- package/dist/cjs/components/TableHead.cjs +21 -0
- package/dist/cjs/components/TableRow.cjs +21 -0
- package/dist/cjs/components/Tabs.cjs +65 -0
- package/dist/cjs/components/Tabs.styled.cjs +90 -0
- package/dist/cjs/components/Tag.cjs +37 -0
- package/dist/cjs/components/Tag.styled.cjs +120 -0
- package/dist/cjs/components/Text.cjs +36 -0
- package/dist/cjs/components/TextInput.cjs +145 -0
- package/dist/cjs/components/TextInput.styled.cjs +117 -0
- package/dist/cjs/components/ThemeProvider.cjs +43 -0
- package/dist/cjs/components/TimeInput.cjs +248 -0
- package/dist/cjs/components/TimeInput.styled.cjs +38 -0
- package/dist/cjs/components/Tooltip.cjs +40 -0
- package/dist/cjs/components/Tooltip.styled.cjs +55 -0
- package/dist/cjs/components/Truncate.cjs +23 -0
- package/dist/cjs/index.cjs +182 -0
- package/dist/cjs/theme/index.cjs +252 -0
- package/dist/cjs/utils/animations.cjs +68 -0
- package/dist/cjs/utils/colors.cjs +31 -0
- package/dist/cjs/utils/constants.cjs +8 -0
- package/dist/cjs/utils/files.cjs +44 -0
- package/dist/cjs/utils/helpers/array.cjs +24 -0
- package/dist/cjs/utils/helpers/boolean.cjs +25 -0
- package/dist/cjs/utils/helpers/date.cjs +11 -0
- package/dist/cjs/utils/helpers/dateSelect.cjs +41 -0
- package/dist/cjs/utils/helpers/file.cjs +53 -0
- package/dist/cjs/utils/helpers/index.cjs +36 -0
- package/dist/cjs/utils/helpers/number.cjs +18 -0
- package/dist/cjs/utils/helpers/object.cjs +97 -0
- package/dist/cjs/utils/helpers/string.cjs +21 -0
- package/dist/cjs/utils/helpers/time.cjs +64 -0
- package/dist/cjs/utils/loadFont.cjs +19 -0
- package/dist/cjs/utils/useResize.cjs +24 -0
- package/dist/esm/components/Alert.js +44 -0
- package/dist/esm/components/Alert.styled.js +36 -0
- package/dist/esm/components/Autocomplete.js +172 -0
- package/dist/esm/components/Autocomplete.styled.js +13 -0
- package/dist/esm/components/Avatar.js +48 -0
- package/dist/esm/components/Avatar.styled.js +22 -0
- package/dist/esm/components/AvatarCropDialog.js +196 -0
- package/dist/esm/components/AvatarCropDialog.styled.js +19 -0
- package/dist/esm/components/AvatarInput.js +211 -0
- package/dist/esm/components/AvatarInput.styled.js +143 -0
- package/dist/esm/components/Badge.js +79 -0
- package/dist/esm/components/Badge.styled.js +21 -0
- package/dist/esm/components/BankAccountInput.js +292 -0
- package/dist/esm/components/BankAccountInput.styled.js +158 -0
- package/dist/esm/components/Bar.js +40 -0
- package/dist/esm/components/Bar.styled.js +20 -0
- package/dist/esm/components/BaseModal.js +37 -0
- package/dist/esm/components/BaseModal.styled.js +16 -0
- package/dist/esm/components/BooleanInput.js +169 -0
- package/dist/esm/components/BooleanInput.styled.js +62 -0
- package/dist/esm/components/BorderedGrid.js +42 -0
- package/dist/esm/components/Box.js +93 -0
- package/dist/esm/components/Button.js +44 -0
- package/dist/esm/components/Button.styled.js +96 -0
- package/dist/esm/components/Card.js +57 -0
- package/dist/esm/components/Card.styled.js +13 -0
- package/dist/esm/components/CardContent.js +17 -0
- package/dist/esm/components/CardContent.styled.js +8 -0
- package/dist/esm/components/Checkbox.js +45 -0
- package/dist/esm/components/Checkbox.styled.js +23 -0
- package/dist/esm/components/CircularProgress.js +10 -0
- package/dist/esm/components/CollapsedText.js +84 -0
- package/dist/esm/components/CollapsedText.styled.js +48 -0
- package/dist/esm/components/Confirmation.js +56 -0
- package/dist/esm/components/Container.js +17 -0
- package/dist/esm/components/CroppedImageInput.js +461 -0
- package/dist/esm/components/CroppedImageInput.styled.js +85 -0
- package/dist/esm/components/CroppedImageInputActions.js +74 -0
- package/dist/esm/components/DateInput.js +214 -0
- package/dist/esm/components/DateInput.styled.js +21 -0
- package/dist/esm/components/DateNumberInput.js +171 -0
- package/dist/esm/components/DateNumberInput.styled.js +55 -0
- package/dist/esm/components/DatePicker.js +130 -0
- package/dist/esm/components/DatePicker.styled.js +15 -0
- package/dist/esm/components/DateSelect.js +208 -0
- package/dist/esm/components/DateSelect.styled.js +11 -0
- package/dist/esm/components/Divider.js +63 -0
- package/dist/esm/components/Divider.styled.js +60 -0
- package/dist/esm/components/DropZone.js +149 -0
- package/dist/esm/components/DropZone.styled.js +71 -0
- package/dist/esm/components/Embed.js +37 -0
- package/dist/esm/components/Embed.styled.js +34 -0
- package/dist/esm/components/FileUpload.js +315 -0
- package/dist/esm/components/FileUpload.styled.js +43 -0
- package/dist/esm/components/FileUploadButton.js +113 -0
- package/dist/esm/components/FileUploadButtonLoader.js +23 -0
- package/dist/esm/components/FileViewer.js +113 -0
- package/dist/esm/components/FileViewer.styled.js +25 -0
- package/dist/esm/components/FlashMessage.js +65 -0
- package/dist/esm/components/FormControl.js +98 -0
- package/dist/esm/components/FormControl.styled.js +18 -0
- package/dist/esm/components/FormFocus.js +33 -0
- package/dist/esm/components/FormLabel.js +20 -0
- package/dist/esm/components/FormLabel.styled.js +51 -0
- package/dist/esm/components/Grid.js +48 -0
- package/dist/esm/components/Grid.styled.js +10 -0
- package/dist/esm/components/Heading.js +37 -0
- package/dist/esm/components/IconButton.js +27 -0
- package/dist/esm/components/IconButton.styled.js +27 -0
- package/dist/esm/components/Icons.js +58 -0
- package/dist/esm/components/LinearProgress.js +10 -0
- package/dist/esm/components/Link.js +33 -0
- package/dist/esm/components/Link.styled.js +37 -0
- package/dist/esm/components/Media.js +40 -0
- package/dist/esm/components/Media.styled.js +42 -0
- package/dist/esm/components/Modal.js +52 -0
- package/dist/esm/components/ModalActions.js +19 -0
- package/dist/esm/components/ModalContent.js +28 -0
- package/dist/esm/components/ModalHeader.js +20 -0
- package/dist/esm/components/ModalHeader.styled.js +25 -0
- package/dist/esm/components/Nameplate.js +106 -0
- package/dist/esm/components/Nameplate.styled.js +44 -0
- package/dist/esm/components/Pagination.js +143 -0
- package/dist/esm/components/Pagination.styled.js +79 -0
- package/dist/esm/components/Paper.js +30 -0
- package/dist/esm/components/Paper.styled.js +59 -0
- package/dist/esm/components/Popper.js +60 -0
- package/dist/esm/components/PropertyCard.js +218 -0
- package/dist/esm/components/PropertyCard.styled.js +62 -0
- package/dist/esm/components/Radio.js +45 -0
- package/dist/esm/components/Radio.styled.js +23 -0
- package/dist/esm/components/Rating.js +10 -0
- package/dist/esm/components/Select.js +101 -0
- package/dist/esm/components/Select.styled.js +95 -0
- package/dist/esm/components/Skeleton.js +19 -0
- package/dist/esm/components/StatusMessage.js +23 -0
- package/dist/esm/components/StepIcon.js +46 -0
- package/dist/esm/components/StepIcon.styled.js +54 -0
- package/dist/esm/components/Stepper.js +54 -0
- package/dist/esm/components/Stepper.styled.js +59 -0
- package/dist/esm/components/SuccessModal.js +39 -0
- package/dist/esm/components/SuccessModal.styled.js +19 -0
- package/dist/esm/components/Switch.js +42 -0
- package/dist/esm/components/Switch.styled.js +103 -0
- package/dist/esm/components/Tab.js +35 -0
- package/dist/esm/components/Tab.styled.js +12 -0
- package/dist/esm/components/TabPanel.js +26 -0
- package/dist/esm/components/TabPanel.styled.js +10 -0
- package/dist/esm/components/Table.js +17 -0
- package/dist/esm/components/TableBody.js +17 -0
- package/dist/esm/components/TableCell.js +17 -0
- package/dist/esm/components/TableContainer.js +17 -0
- package/dist/esm/components/TableFooter.js +17 -0
- package/dist/esm/components/TableHead.js +17 -0
- package/dist/esm/components/TableRow.js +17 -0
- package/dist/esm/components/Tabs.js +61 -0
- package/dist/esm/components/Tabs.styled.js +88 -0
- package/dist/esm/components/Tag.js +33 -0
- package/dist/esm/components/Tag.styled.js +114 -0
- package/dist/esm/components/Text.js +32 -0
- package/dist/esm/components/TextInput.js +141 -0
- package/dist/esm/components/TextInput.styled.js +105 -0
- package/dist/esm/components/ThemeProvider.js +39 -0
- package/dist/esm/components/TimeInput.js +244 -0
- package/dist/esm/components/TimeInput.styled.js +34 -0
- package/dist/esm/components/Tooltip.js +36 -0
- package/dist/esm/components/Tooltip.styled.js +51 -0
- package/dist/esm/components/Truncate.js +19 -0
- package/dist/esm/index.js +84 -0
- package/dist/esm/theme/index.js +247 -0
- package/dist/esm/utils/animations.js +60 -0
- package/dist/esm/utils/colors.js +28 -0
- package/dist/esm/utils/constants.js +5 -0
- package/dist/esm/utils/files.js +39 -0
- package/dist/esm/utils/helpers/array.js +20 -0
- package/dist/esm/utils/helpers/boolean.js +16 -0
- package/dist/esm/utils/helpers/date.js +6 -0
- package/dist/esm/utils/helpers/dateSelect.js +35 -0
- package/dist/esm/utils/helpers/file.js +47 -0
- package/dist/esm/utils/helpers/index.js +6 -0
- package/dist/esm/utils/helpers/number.js +15 -0
- package/dist/esm/utils/helpers/object.js +88 -0
- package/dist/esm/utils/helpers/string.js +15 -0
- package/dist/esm/utils/helpers/time.js +59 -0
- package/dist/esm/utils/loadFont.js +15 -0
- package/dist/esm/utils/useResize.js +20 -0
- package/package.json +2 -2
|
@@ -0,0 +1,53 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
'use strict';
|
|
3
|
+
|
|
4
|
+
var mime = require('mime/lite');
|
|
5
|
+
|
|
6
|
+
const getFileNameFromURL = (file) => {
|
|
7
|
+
if (file.url) {
|
|
8
|
+
const cleanURL = file.url.split(/[?#]/)[0];
|
|
9
|
+
return cleanURL.substring(cleanURL.lastIndexOf("/") + 1);
|
|
10
|
+
}
|
|
11
|
+
return "";
|
|
12
|
+
};
|
|
13
|
+
const getFileName = (file) => {
|
|
14
|
+
if (file.filename) {
|
|
15
|
+
return file.filename;
|
|
16
|
+
}
|
|
17
|
+
if (file.url) {
|
|
18
|
+
return getFileNameFromURL(file);
|
|
19
|
+
}
|
|
20
|
+
return "";
|
|
21
|
+
};
|
|
22
|
+
const getFileExtension = (file) => {
|
|
23
|
+
if (file.filetype) {
|
|
24
|
+
return mime.getExtension(file.filetype);
|
|
25
|
+
}
|
|
26
|
+
let filetype = mime.getType(getFileName(file));
|
|
27
|
+
if (!filetype) {
|
|
28
|
+
filetype = mime.getType(getFileNameFromURL(file));
|
|
29
|
+
}
|
|
30
|
+
if (filetype) {
|
|
31
|
+
return mime.getExtension(filetype);
|
|
32
|
+
}
|
|
33
|
+
return "unsupported";
|
|
34
|
+
};
|
|
35
|
+
const isImage = (file) => {
|
|
36
|
+
const extension = getFileExtension(file);
|
|
37
|
+
const extensions = ["jpg", "jpeg", "png", "gif", "svg"];
|
|
38
|
+
return extensions.includes(extension);
|
|
39
|
+
};
|
|
40
|
+
const formatBytes = (bytes, decimals = 2) => {
|
|
41
|
+
if (bytes === 0) return "0 Bytes";
|
|
42
|
+
const k = 1024;
|
|
43
|
+
const dm = decimals < 0 ? 0 : decimals;
|
|
44
|
+
const sizes = ["Bytes", "KB", "MB"];
|
|
45
|
+
const i = Math.floor(Math.log(bytes) / Math.log(k));
|
|
46
|
+
return `${parseFloat((bytes / k ** i).toFixed(dm))}${sizes[i]}`;
|
|
47
|
+
};
|
|
48
|
+
|
|
49
|
+
exports.formatBytes = formatBytes;
|
|
50
|
+
exports.getFileExtension = getFileExtension;
|
|
51
|
+
exports.getFileName = getFileName;
|
|
52
|
+
exports.getFileNameFromURL = getFileNameFromURL;
|
|
53
|
+
exports.isImage = isImage;
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
'use strict';
|
|
3
|
+
|
|
4
|
+
var array = require('./array.cjs');
|
|
5
|
+
var boolean = require('./boolean.cjs');
|
|
6
|
+
var file = require('./file.cjs');
|
|
7
|
+
var string = require('./string.cjs');
|
|
8
|
+
var time = require('./time.cjs');
|
|
9
|
+
|
|
10
|
+
|
|
11
|
+
|
|
12
|
+
exports.arrayUnique = array.arrayUnique;
|
|
13
|
+
exports.implode = array.implode;
|
|
14
|
+
exports.range = array.range;
|
|
15
|
+
exports.isArray = boolean.isArray;
|
|
16
|
+
exports.isEmpty = boolean.isEmpty;
|
|
17
|
+
exports.isFunction = boolean.isFunction;
|
|
18
|
+
exports.isNotEmpty = boolean.isNotEmpty;
|
|
19
|
+
exports.isNumber = boolean.isNumber;
|
|
20
|
+
exports.isNumeric = boolean.isNumeric;
|
|
21
|
+
exports.isObject = boolean.isObject;
|
|
22
|
+
exports.isString = boolean.isString;
|
|
23
|
+
exports.formatBytes = file.formatBytes;
|
|
24
|
+
exports.getFileExtension = file.getFileExtension;
|
|
25
|
+
exports.getFileName = file.getFileName;
|
|
26
|
+
exports.getFileNameFromURL = file.getFileNameFromURL;
|
|
27
|
+
exports.isImage = file.isImage;
|
|
28
|
+
exports.strPadStart = string.strPadStart;
|
|
29
|
+
exports.stripNonNumeric = string.stripNonNumeric;
|
|
30
|
+
exports.stripTags = string.stripTags;
|
|
31
|
+
exports.toString = string.toString;
|
|
32
|
+
exports.ucFirstChar = string.ucFirstChar;
|
|
33
|
+
exports.getHourOptions = time.getHourOptions;
|
|
34
|
+
exports.getMeridianOptions = time.getMeridianOptions;
|
|
35
|
+
exports.getMinuteOptions = time.getMinuteOptions;
|
|
36
|
+
exports.parseTimeStrByFormat = time.parseTimeStrByFormat;
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
'use strict';
|
|
3
|
+
|
|
4
|
+
var boolean = require('./boolean.cjs');
|
|
5
|
+
|
|
6
|
+
const toNumber = (val, radix = 10) => boolean.isNumeric(val) ? parseInt(val, radix) : false;
|
|
7
|
+
const toFloat = (val, decimals) => {
|
|
8
|
+
if (boolean.isNumeric(val) || !isNaN(val)) {
|
|
9
|
+
if (decimals) {
|
|
10
|
+
return parseFloat(val).toFixed(decimals);
|
|
11
|
+
}
|
|
12
|
+
return parseFloat(val);
|
|
13
|
+
}
|
|
14
|
+
return false;
|
|
15
|
+
};
|
|
16
|
+
|
|
17
|
+
exports.toFloat = toFloat;
|
|
18
|
+
exports.toNumber = toNumber;
|
|
@@ -0,0 +1,97 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
'use strict';
|
|
3
|
+
|
|
4
|
+
var boolean = require('./boolean.cjs');
|
|
5
|
+
|
|
6
|
+
const pick = (object, props) => {
|
|
7
|
+
if (!boolean.isObject(object)) {
|
|
8
|
+
console.error("first argument should be an object.");
|
|
9
|
+
return false;
|
|
10
|
+
}
|
|
11
|
+
if (!boolean.isArray(props)) {
|
|
12
|
+
console.error("second argument should be an array.");
|
|
13
|
+
return false;
|
|
14
|
+
}
|
|
15
|
+
return props.reduce((prevVal, curVal) => {
|
|
16
|
+
if (object.hasOwnProperty(curVal)) {
|
|
17
|
+
return {
|
|
18
|
+
...prevVal,
|
|
19
|
+
[curVal]: object[curVal]
|
|
20
|
+
};
|
|
21
|
+
}
|
|
22
|
+
return prevVal;
|
|
23
|
+
}, {});
|
|
24
|
+
};
|
|
25
|
+
const transformArrToObject = (arr, prop) => {
|
|
26
|
+
if (prop) {
|
|
27
|
+
return arr.reduce(
|
|
28
|
+
(obj, item) => ({
|
|
29
|
+
...obj,
|
|
30
|
+
[item[prop]]: item
|
|
31
|
+
}),
|
|
32
|
+
{}
|
|
33
|
+
);
|
|
34
|
+
}
|
|
35
|
+
return { ...arr };
|
|
36
|
+
};
|
|
37
|
+
const objectHasAllValues = (obj) => {
|
|
38
|
+
if (boolean.isEmpty(obj)) {
|
|
39
|
+
return false;
|
|
40
|
+
}
|
|
41
|
+
return Object.values(obj).every(boolean.isNotEmpty);
|
|
42
|
+
};
|
|
43
|
+
const objectHasSomeValues = (obj) => {
|
|
44
|
+
if (boolean.isEmpty(obj)) {
|
|
45
|
+
return false;
|
|
46
|
+
}
|
|
47
|
+
return Object.values(obj).some(boolean.isNotEmpty);
|
|
48
|
+
};
|
|
49
|
+
const getObjectProp = (obj, prop, fallback = "") => prop.split(".").reduce((value, key) => boolean.isObject(value) && value[key] || fallback, obj);
|
|
50
|
+
const objectRemoveEmpty = (obj) => {
|
|
51
|
+
if (!boolean.isObject(obj)) {
|
|
52
|
+
return {};
|
|
53
|
+
}
|
|
54
|
+
return Object.entries(obj).filter(([, value]) => !!value).reduce(
|
|
55
|
+
(carry, [k, value]) => ({
|
|
56
|
+
...carry,
|
|
57
|
+
[k]: value
|
|
58
|
+
}),
|
|
59
|
+
{}
|
|
60
|
+
);
|
|
61
|
+
};
|
|
62
|
+
const objectOmit = (obj, props) => {
|
|
63
|
+
if (!boolean.isObject(obj)) {
|
|
64
|
+
return {};
|
|
65
|
+
}
|
|
66
|
+
const omit = boolean.isString(props) ? [props] : props;
|
|
67
|
+
return Object.keys(obj).reduce((carry, k) => {
|
|
68
|
+
if (omit.includes(k)) {
|
|
69
|
+
return carry;
|
|
70
|
+
}
|
|
71
|
+
return {
|
|
72
|
+
...carry,
|
|
73
|
+
[k]: obj[k]
|
|
74
|
+
};
|
|
75
|
+
}, {});
|
|
76
|
+
};
|
|
77
|
+
const objectDeepMerge = (target, source) => {
|
|
78
|
+
for (let key in source) {
|
|
79
|
+
if (source.hasOwnProperty(key)) {
|
|
80
|
+
if (boolean.isObject(source[key]) && boolean.isObject(target[key])) {
|
|
81
|
+
objectDeepMerge(target[key], source[key]);
|
|
82
|
+
} else {
|
|
83
|
+
target[key] = source[key];
|
|
84
|
+
}
|
|
85
|
+
}
|
|
86
|
+
}
|
|
87
|
+
return target;
|
|
88
|
+
};
|
|
89
|
+
|
|
90
|
+
exports.getObjectProp = getObjectProp;
|
|
91
|
+
exports.objectDeepMerge = objectDeepMerge;
|
|
92
|
+
exports.objectHasAllValues = objectHasAllValues;
|
|
93
|
+
exports.objectHasSomeValues = objectHasSomeValues;
|
|
94
|
+
exports.objectOmit = objectOmit;
|
|
95
|
+
exports.objectRemoveEmpty = objectRemoveEmpty;
|
|
96
|
+
exports.pick = pick;
|
|
97
|
+
exports.transformArrToObject = transformArrToObject;
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
'use strict';
|
|
3
|
+
|
|
4
|
+
var boolean = require('./boolean.cjs');
|
|
5
|
+
|
|
6
|
+
const stripTags = (str) => str.replace(/(<([^>]+)>)/gi, "");
|
|
7
|
+
const stripNonNumeric = (str) => {
|
|
8
|
+
if (str && boolean.isString(str)) {
|
|
9
|
+
return str.replace(/\D/g, "");
|
|
10
|
+
}
|
|
11
|
+
return "";
|
|
12
|
+
};
|
|
13
|
+
const toString = (val) => String(val);
|
|
14
|
+
const strPadStart = (str, targetLength, padString = "") => toString(str).padStart(targetLength, padString);
|
|
15
|
+
const ucFirstChar = (val) => `${String(val).charAt(0).toUpperCase()}${String(val).slice(1)}`;
|
|
16
|
+
|
|
17
|
+
exports.strPadStart = strPadStart;
|
|
18
|
+
exports.stripNonNumeric = stripNonNumeric;
|
|
19
|
+
exports.stripTags = stripTags;
|
|
20
|
+
exports.toString = toString;
|
|
21
|
+
exports.ucFirstChar = ucFirstChar;
|
|
@@ -0,0 +1,64 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
'use strict';
|
|
3
|
+
|
|
4
|
+
var dayjs = require('dayjs');
|
|
5
|
+
var customParseFormat = require('dayjs/plugin/customParseFormat');
|
|
6
|
+
var array = require('./array.cjs');
|
|
7
|
+
var string = require('./string.cjs');
|
|
8
|
+
|
|
9
|
+
dayjs.extend(customParseFormat);
|
|
10
|
+
const getHourOptions = (disableFirstOption = false) => {
|
|
11
|
+
const options = array.range(1, 12).map((hour) => {
|
|
12
|
+
const formatted = string.strPadStart(hour, 2, "0");
|
|
13
|
+
return {
|
|
14
|
+
label: formatted,
|
|
15
|
+
value: formatted
|
|
16
|
+
};
|
|
17
|
+
});
|
|
18
|
+
return [
|
|
19
|
+
{
|
|
20
|
+
label: "",
|
|
21
|
+
value: "",
|
|
22
|
+
disabled: disableFirstOption
|
|
23
|
+
},
|
|
24
|
+
...options
|
|
25
|
+
];
|
|
26
|
+
};
|
|
27
|
+
const getMinuteOptions = (min, max, step, disableFirstOption = false) => {
|
|
28
|
+
const options = array.range(min, max, step).map((minute) => {
|
|
29
|
+
const formatted = string.strPadStart(minute, 2, "0");
|
|
30
|
+
return {
|
|
31
|
+
label: formatted,
|
|
32
|
+
value: formatted
|
|
33
|
+
};
|
|
34
|
+
});
|
|
35
|
+
return [
|
|
36
|
+
{
|
|
37
|
+
label: "",
|
|
38
|
+
value: "",
|
|
39
|
+
disabled: disableFirstOption
|
|
40
|
+
},
|
|
41
|
+
...options
|
|
42
|
+
];
|
|
43
|
+
};
|
|
44
|
+
const getMeridianOptions = (disableFirstOption = false) => [
|
|
45
|
+
{
|
|
46
|
+
label: "",
|
|
47
|
+
value: "",
|
|
48
|
+
disabled: disableFirstOption
|
|
49
|
+
},
|
|
50
|
+
{
|
|
51
|
+
label: "AM",
|
|
52
|
+
value: "am"
|
|
53
|
+
},
|
|
54
|
+
{
|
|
55
|
+
label: "PM",
|
|
56
|
+
value: "pm"
|
|
57
|
+
}
|
|
58
|
+
];
|
|
59
|
+
const parseTimeStrByFormat = (timeStr, format = "HH:mm:ss") => dayjs(timeStr, format);
|
|
60
|
+
|
|
61
|
+
exports.getHourOptions = getHourOptions;
|
|
62
|
+
exports.getMeridianOptions = getMeridianOptions;
|
|
63
|
+
exports.getMinuteOptions = getMinuteOptions;
|
|
64
|
+
exports.parseTimeStrByFormat = parseTimeStrByFormat;
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
'use strict';
|
|
3
|
+
|
|
4
|
+
Object.defineProperty(exports, '__esModule', { value: true });
|
|
5
|
+
|
|
6
|
+
var index = require('../theme/index.cjs');
|
|
7
|
+
|
|
8
|
+
const fontLinkId = "storybook-font-link-tag";
|
|
9
|
+
const loadFont = () => {
|
|
10
|
+
if (!document.getElementById(fontLinkId)) {
|
|
11
|
+
const fontLink = document.createElement("link");
|
|
12
|
+
fontLink.id = fontLinkId;
|
|
13
|
+
fontLink.href = index.fontUrl;
|
|
14
|
+
fontLink.rel = "stylesheet";
|
|
15
|
+
document.head.appendChild(fontLink);
|
|
16
|
+
}
|
|
17
|
+
};
|
|
18
|
+
|
|
19
|
+
exports.default = loadFont;
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
'use strict';
|
|
3
|
+
|
|
4
|
+
Object.defineProperty(exports, '__esModule', { value: true });
|
|
5
|
+
|
|
6
|
+
var React = require('react');
|
|
7
|
+
|
|
8
|
+
const useResize = (ref) => {
|
|
9
|
+
const [width, setWidth] = React.useState(0);
|
|
10
|
+
const [height, setHeight] = React.useState(0);
|
|
11
|
+
React.useEffect(() => {
|
|
12
|
+
const handleResize = () => {
|
|
13
|
+
setWidth(ref.current.offsetWidth);
|
|
14
|
+
setHeight(ref.current.offsetHeight);
|
|
15
|
+
};
|
|
16
|
+
window.addEventListener("resize", handleResize);
|
|
17
|
+
return () => {
|
|
18
|
+
window.removeEventListener("resize", handleResize);
|
|
19
|
+
};
|
|
20
|
+
}, [ref]);
|
|
21
|
+
return { width, height };
|
|
22
|
+
};
|
|
23
|
+
|
|
24
|
+
exports.default = useResize;
|
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
import { jsxs, jsx } from 'react/jsx-runtime';
|
|
3
|
+
import CheckCircleOutlineOutlinedIcon from '@mui/icons-material/CheckCircleOutlineOutlined';
|
|
4
|
+
import ErrorOutlineOutlinedIcon from '@mui/icons-material/ErrorOutlineOutlined';
|
|
5
|
+
import InfoOutlinedIcon from '@mui/icons-material/InfoOutlined';
|
|
6
|
+
import WarningAmberOutlinedIcon from '@mui/icons-material/WarningAmberOutlined';
|
|
7
|
+
import StyledAlert, { StyledAlertTitle } from './Alert.styled.js';
|
|
8
|
+
|
|
9
|
+
const variantMap = {
|
|
10
|
+
contained: "filled"
|
|
11
|
+
};
|
|
12
|
+
const icons = {
|
|
13
|
+
info: /* @__PURE__ */ jsx(InfoOutlinedIcon, { sx: { fontSize: 24 } }),
|
|
14
|
+
success: /* @__PURE__ */ jsx(CheckCircleOutlineOutlinedIcon, { sx: { fontSize: 24 } }),
|
|
15
|
+
error: /* @__PURE__ */ jsx(ErrorOutlineOutlinedIcon, { sx: { fontSize: 24 } }),
|
|
16
|
+
warning: /* @__PURE__ */ jsx(WarningAmberOutlinedIcon, { sx: { fontSize: 24 } })
|
|
17
|
+
};
|
|
18
|
+
function Alert({
|
|
19
|
+
children,
|
|
20
|
+
color = "info",
|
|
21
|
+
icon = true,
|
|
22
|
+
title = void 0,
|
|
23
|
+
variant = "standard",
|
|
24
|
+
...rest
|
|
25
|
+
}) {
|
|
26
|
+
return /* @__PURE__ */ jsxs(
|
|
27
|
+
StyledAlert,
|
|
28
|
+
{
|
|
29
|
+
color,
|
|
30
|
+
variant: variantMap[variant] || variant,
|
|
31
|
+
severity: color,
|
|
32
|
+
iconMapping: icons,
|
|
33
|
+
closeText: "undo",
|
|
34
|
+
...rest,
|
|
35
|
+
...(!icon || !color || !icons[color]) && { icon: false },
|
|
36
|
+
children: [
|
|
37
|
+
title && /* @__PURE__ */ jsx(StyledAlertTitle, { children: title }),
|
|
38
|
+
children
|
|
39
|
+
]
|
|
40
|
+
}
|
|
41
|
+
);
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
export { Alert as default };
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
import { css } from '@emotion/react';
|
|
3
|
+
import Alert from '@mui/material/Alert';
|
|
4
|
+
import AlertTitle from '@mui/material/AlertTitle';
|
|
5
|
+
import { styled } from '@mui/material/styles';
|
|
6
|
+
import { getObjectProp } from '../utils/helpers/object.js';
|
|
7
|
+
|
|
8
|
+
const standardStyles = ({ color, theme }) => css`
|
|
9
|
+
border: 1px solid currentColor;
|
|
10
|
+
background-color: ${getObjectProp(theme, `vars.palette.${color}.light`)};
|
|
11
|
+
color: ${getObjectProp(theme, `vars.palette.${color}.main`)};
|
|
12
|
+
`;
|
|
13
|
+
const outlinedStyles = ({ color, theme }) => css`
|
|
14
|
+
background-color: transparent;
|
|
15
|
+
border: 1px solid currentColor;
|
|
16
|
+
color: ${getObjectProp(theme, `vars.palette.${color}.main`)};
|
|
17
|
+
`;
|
|
18
|
+
const StyledAlertTitle = styled(
|
|
19
|
+
AlertTitle
|
|
20
|
+
)`
|
|
21
|
+
font-size: inherit;
|
|
22
|
+
`;
|
|
23
|
+
const StyledAlert = styled(Alert)`
|
|
24
|
+
${({ color, theme, variant }) => css`
|
|
25
|
+
font-size: ${getObjectProp(theme, "typography.fontSize")}px;
|
|
26
|
+
padding: 8px 16px;
|
|
27
|
+
${variant === "standard" && standardStyles({ color, theme })}
|
|
28
|
+
${variant === "outlined" && outlinedStyles({ color, theme })}
|
|
29
|
+
|
|
30
|
+
.MuiAlert-action {
|
|
31
|
+
margin-right: 0;
|
|
32
|
+
}
|
|
33
|
+
`}
|
|
34
|
+
`;
|
|
35
|
+
|
|
36
|
+
export { StyledAlertTitle, StyledAlert as default };
|
|
@@ -0,0 +1,172 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
import { jsx } from 'react/jsx-runtime';
|
|
3
|
+
import { useState } from 'react';
|
|
4
|
+
import PropTypes from 'prop-types';
|
|
5
|
+
import KeyboardArrowDownIcon from '@mui/icons-material/KeyboardArrowDown';
|
|
6
|
+
import FormControl from './FormControl.js';
|
|
7
|
+
import { StyledAutocomplete } from './Autocomplete.styled.js';
|
|
8
|
+
import TextInput from './TextInput.js';
|
|
9
|
+
|
|
10
|
+
function Autocomplete({
|
|
11
|
+
disabled = false,
|
|
12
|
+
edges = "smooth",
|
|
13
|
+
fullWidth = true,
|
|
14
|
+
helperText = "",
|
|
15
|
+
helperTextPlacement = "below",
|
|
16
|
+
label = "",
|
|
17
|
+
placeholder = "",
|
|
18
|
+
popupIcon = void 0,
|
|
19
|
+
required = false,
|
|
20
|
+
size = "medium",
|
|
21
|
+
variant = "outlined",
|
|
22
|
+
showError = false,
|
|
23
|
+
errorMessage = "",
|
|
24
|
+
name,
|
|
25
|
+
hideLabel = false,
|
|
26
|
+
disableIconRotation = false,
|
|
27
|
+
TextInputProps = {},
|
|
28
|
+
onChange = () => {
|
|
29
|
+
},
|
|
30
|
+
textInputAttrs = {},
|
|
31
|
+
...rest
|
|
32
|
+
}) {
|
|
33
|
+
const [selectedValue, setSelectedValue] = useState(rest.value || null);
|
|
34
|
+
const handleChange = (event, val, ...extras) => {
|
|
35
|
+
setSelectedValue(val);
|
|
36
|
+
onChange(event, val, ...extras);
|
|
37
|
+
};
|
|
38
|
+
return /* @__PURE__ */ jsx(
|
|
39
|
+
FormControl,
|
|
40
|
+
{
|
|
41
|
+
name,
|
|
42
|
+
fullWidth,
|
|
43
|
+
label,
|
|
44
|
+
helperText,
|
|
45
|
+
helperTextPlacement,
|
|
46
|
+
disabled,
|
|
47
|
+
required,
|
|
48
|
+
showError,
|
|
49
|
+
errorMessage,
|
|
50
|
+
hideLabel,
|
|
51
|
+
edges,
|
|
52
|
+
children: /* @__PURE__ */ jsx(
|
|
53
|
+
StyledAutocomplete,
|
|
54
|
+
{
|
|
55
|
+
disabled,
|
|
56
|
+
iconrotation: disableIconRotation ? "no" : "yes",
|
|
57
|
+
popupIcon: popupIcon === void 0 ? /* @__PURE__ */ jsx(KeyboardArrowDownIcon, {}) : popupIcon,
|
|
58
|
+
renderInput: ({ inputProps, InputProps, ...params }) => /* @__PURE__ */ jsx(
|
|
59
|
+
TextInput,
|
|
60
|
+
{
|
|
61
|
+
...params,
|
|
62
|
+
disabled,
|
|
63
|
+
name,
|
|
64
|
+
variant,
|
|
65
|
+
size,
|
|
66
|
+
edges,
|
|
67
|
+
required,
|
|
68
|
+
value: selectedValue,
|
|
69
|
+
placeholder,
|
|
70
|
+
inputProps: {
|
|
71
|
+
autoComplete: "off",
|
|
72
|
+
...textInputAttrs,
|
|
73
|
+
...inputProps
|
|
74
|
+
},
|
|
75
|
+
slotProps: {
|
|
76
|
+
input: {
|
|
77
|
+
...TextInputProps,
|
|
78
|
+
...InputProps
|
|
79
|
+
}
|
|
80
|
+
},
|
|
81
|
+
showError,
|
|
82
|
+
message: errorMessage,
|
|
83
|
+
ref: InputProps.ref
|
|
84
|
+
}
|
|
85
|
+
),
|
|
86
|
+
onChange: handleChange,
|
|
87
|
+
...rest
|
|
88
|
+
}
|
|
89
|
+
)
|
|
90
|
+
}
|
|
91
|
+
);
|
|
92
|
+
}
|
|
93
|
+
Autocomplete.propTypes = {
|
|
94
|
+
/**
|
|
95
|
+
* If `true`, the `input` element will be disabled.
|
|
96
|
+
*/
|
|
97
|
+
disabled: PropTypes.bool,
|
|
98
|
+
/**
|
|
99
|
+
* Prevent icon rotating on open
|
|
100
|
+
*/
|
|
101
|
+
disableIconRotation: PropTypes.bool,
|
|
102
|
+
/**
|
|
103
|
+
* Make button edges rounded or square
|
|
104
|
+
*/
|
|
105
|
+
edges: PropTypes.oneOf(["normal", "rounded", "sharp"]),
|
|
106
|
+
/**
|
|
107
|
+
* If `true`, the input will take up the full width of its container.
|
|
108
|
+
*/
|
|
109
|
+
fullWidth: PropTypes.bool,
|
|
110
|
+
/**
|
|
111
|
+
* Field name.
|
|
112
|
+
*/
|
|
113
|
+
name: PropTypes.string.isRequired,
|
|
114
|
+
/**
|
|
115
|
+
* The helper text content.
|
|
116
|
+
*/
|
|
117
|
+
helperText: PropTypes.string,
|
|
118
|
+
/**
|
|
119
|
+
* Placed the helper text above or below the input.
|
|
120
|
+
*/
|
|
121
|
+
helperTextPlacement: PropTypes.oneOf(["above", "below"]),
|
|
122
|
+
/**
|
|
123
|
+
* The label content.
|
|
124
|
+
*/
|
|
125
|
+
label: PropTypes.string,
|
|
126
|
+
/**
|
|
127
|
+
* The short hint displayed in the input before the user enters a value.
|
|
128
|
+
*/
|
|
129
|
+
placeholder: PropTypes.string,
|
|
130
|
+
/**
|
|
131
|
+
* The icon that displays the arrow.
|
|
132
|
+
*/
|
|
133
|
+
popupIcon: PropTypes.any,
|
|
134
|
+
/**
|
|
135
|
+
* If `true`, the label is displayed as required and the `input` element` will be required.
|
|
136
|
+
*/
|
|
137
|
+
required: PropTypes.bool,
|
|
138
|
+
/**
|
|
139
|
+
* The size to use.
|
|
140
|
+
*/
|
|
141
|
+
size: PropTypes.oneOf(["medium", "small"]),
|
|
142
|
+
/**
|
|
143
|
+
* Props to pass to the TextField component.
|
|
144
|
+
*/
|
|
145
|
+
TextInputProps: PropTypes.object,
|
|
146
|
+
/**
|
|
147
|
+
* Pass HTML attrs to the TextField component.
|
|
148
|
+
*/
|
|
149
|
+
textInputAttrs: PropTypes.shape({}),
|
|
150
|
+
/**
|
|
151
|
+
* The variant to use.
|
|
152
|
+
*/
|
|
153
|
+
variant: PropTypes.oneOf(["filled", "outlined"]),
|
|
154
|
+
/**
|
|
155
|
+
* Whether or not to display an error message (if there is a message to display).
|
|
156
|
+
*/
|
|
157
|
+
showError: PropTypes.bool,
|
|
158
|
+
/**
|
|
159
|
+
* The error message to display if showError === true
|
|
160
|
+
*/
|
|
161
|
+
errorMessage: PropTypes.string,
|
|
162
|
+
/**
|
|
163
|
+
* Make label visible only to screen readers
|
|
164
|
+
*/
|
|
165
|
+
hideLabel: PropTypes.bool,
|
|
166
|
+
/**
|
|
167
|
+
* Function to handle value chage
|
|
168
|
+
*/
|
|
169
|
+
onChange: PropTypes.func
|
|
170
|
+
};
|
|
171
|
+
|
|
172
|
+
export { Autocomplete as default };
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
import Autocomplete from '@mui/material/Autocomplete';
|
|
3
|
+
import { styled } from '@mui/material/styles';
|
|
4
|
+
|
|
5
|
+
const StyledAutocomplete = styled(
|
|
6
|
+
Autocomplete
|
|
7
|
+
)(({ iconrotation }) => ({
|
|
8
|
+
"& .MuiAutocomplete-popupIndicatorOpen": {
|
|
9
|
+
transform: iconrotation === "yes" ? null : "rotate(0)"
|
|
10
|
+
}
|
|
11
|
+
}));
|
|
12
|
+
|
|
13
|
+
export { StyledAutocomplete };
|
|
@@ -0,0 +1,48 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
import { jsx } from 'react/jsx-runtime';
|
|
3
|
+
import 'react';
|
|
4
|
+
import PropTypes from 'prop-types';
|
|
5
|
+
import { StyledAvatar } from './Avatar.styled.js';
|
|
6
|
+
|
|
7
|
+
function Avatar({
|
|
8
|
+
children = null,
|
|
9
|
+
size = "small",
|
|
10
|
+
src = "",
|
|
11
|
+
srcSet = "",
|
|
12
|
+
variant = "",
|
|
13
|
+
...rest
|
|
14
|
+
}) {
|
|
15
|
+
const props = { size, src, srcSet, variant, ...rest };
|
|
16
|
+
return /* @__PURE__ */ jsx(StyledAvatar, { ...props, children });
|
|
17
|
+
}
|
|
18
|
+
Avatar.propTypes = {
|
|
19
|
+
/**
|
|
20
|
+
* Used in combination with src to provide an alt
|
|
21
|
+
* attribute for the rendered img element.
|
|
22
|
+
*/
|
|
23
|
+
alt: PropTypes.string.isRequired,
|
|
24
|
+
/**
|
|
25
|
+
* Used to render icon or text elements inside the
|
|
26
|
+
* Avatar if src is not set. This can be an element,
|
|
27
|
+
* or just a string.
|
|
28
|
+
*/
|
|
29
|
+
children: PropTypes.node,
|
|
30
|
+
/**
|
|
31
|
+
* Defines the size of component
|
|
32
|
+
*/
|
|
33
|
+
size: PropTypes.oneOf(["small", "medium", "large"]),
|
|
34
|
+
/**
|
|
35
|
+
* The `src` attribute for the `img` element.
|
|
36
|
+
*/
|
|
37
|
+
src: PropTypes.string,
|
|
38
|
+
/**
|
|
39
|
+
* The `srcSet` attribute for the `img` element. Use this attribute for responsive image display.
|
|
40
|
+
*/
|
|
41
|
+
srcSet: PropTypes.string,
|
|
42
|
+
/**
|
|
43
|
+
* The shape of the avatar.
|
|
44
|
+
*/
|
|
45
|
+
variant: PropTypes.oneOf(["circular", "rounded", "square"])
|
|
46
|
+
};
|
|
47
|
+
|
|
48
|
+
export { Avatar as default };
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
import styled, { css } from 'styled-components';
|
|
3
|
+
import MuiAvatar from '@mui/material/Avatar';
|
|
4
|
+
|
|
5
|
+
const sizeFn = (size) => {
|
|
6
|
+
const sizes = {
|
|
7
|
+
large: 50,
|
|
8
|
+
medium: 40,
|
|
9
|
+
small: 30
|
|
10
|
+
};
|
|
11
|
+
return sizes[size];
|
|
12
|
+
};
|
|
13
|
+
const StyledAvatar = styled(MuiAvatar)`
|
|
14
|
+
${({ size }) => css`
|
|
15
|
+
&& {
|
|
16
|
+
width: ${sizeFn(size)}px;
|
|
17
|
+
height: ${sizeFn(size)}px;
|
|
18
|
+
}
|
|
19
|
+
`}
|
|
20
|
+
`;
|
|
21
|
+
|
|
22
|
+
export { StyledAvatar };
|