@cashub/ui 0.21.0 → 0.22.0
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/Tab/Tab.js +9 -13
- package/Tab/TabList.js +14 -32
- package/Tab/TabPanel.js +21 -58
- package/Tab/TabTab.js +20 -40
- package/Tab/index.js +2 -10
- package/Tab/subComponent/TabContext.js +2 -5
- package/animate/Collapse.js +26 -53
- package/animate/Loader.js +21 -26
- package/animate/NumberCounter.js +22 -44
- package/animate/PulseRing.js +9 -21
- package/animate/Spinner.js +2 -10
- package/animate/index.js +5 -11
- package/backdrop/BaseBackdrop.js +2 -9
- package/backdrop/LoadingBackdrop.js +2 -9
- package/backdrop/ModalBackdrop.js +2 -9
- package/backdrop/index.js +3 -7
- package/badge/Badge.js +2 -11
- package/badge/BadgeDot.js +2 -10
- package/badge/BadgeFill.js +15 -20
- package/badge/BadgeWithText.js +6 -13
- package/badge/index.js +4 -9
- package/billing/BarChart.js +10 -17
- package/billing/Grid.js +11 -15
- package/billing/Header2.js +6 -9
- package/billing/Header3.js +9 -16
- package/billing/Paragraph.js +8 -14
- package/billing/ParagraphGroup.js +6 -9
- package/billing/ParagraphText.js +7 -12
- package/billing/Section.js +13 -23
- package/billing/SectionBody.js +5 -8
- package/billing/SectionHeader.js +7 -12
- package/breadcrumb/Breadcrumb.js +11 -21
- package/breadcrumb/index.js +1 -3
- package/button/Button.js +41 -38
- package/button/ButtonGroup.js +21 -18
- package/button/IconButton.js +29 -29
- package/button/ScrollToTopButton.js +12 -39
- package/button/index.js +4 -9
- package/callout/Callout.js +13 -26
- package/callout/index.js +1 -3
- package/chart/BarChart.js +28 -53
- package/chart/DoughnutChart.js +23 -62
- package/chart/LineChart.js +33 -55
- package/chart/SingleBarChart.js +11 -17
- package/chart/index.js +5 -12
- package/chart/utils/customTooltip.js +26 -43
- package/chart/utils/htmlLegendPlugin.js +24 -30
- package/chart/utils/index.js +3 -7
- package/chart/utils/padEmptyChartBar.js +24 -22
- package/container/FlexContainer.js +14 -12
- package/container/index.js +1 -3
- package/cropper/Cropper.js +21 -34
- package/cropper/CropperModalHandler.js +15 -21
- package/cropper/index.js +2 -5
- package/cropper/subComponent/CropImageModal.js +23 -58
- package/datetimePicker/DatePicker.js +103 -217
- package/datetimePicker/DatePickerV2.js +116 -221
- package/datetimePicker/DatetimePicker.js +27 -48
- package/datetimePicker/DatetimePickerV2.js +115 -231
- package/datetimePicker/TimeInput.js +9 -22
- package/datetimePicker/TimePicker.js +94 -151
- package/datetimePicker/TimePickerStyle.js +2 -9
- package/datetimePicker/accordion/Month.js +70 -90
- package/datetimePicker/accordion/Year.js +91 -135
- package/datetimePicker/hooks/index.js +3 -7
- package/datetimePicker/hooks/useChangeNumber.js +14 -27
- package/datetimePicker/hooks/useDecrease.js +19 -35
- package/datetimePicker/hooks/useIncrease.js +19 -35
- package/datetimePicker/index.js +7 -15
- package/datetimePicker/provider/constant.js +2 -3
- package/datetimePicker/subComponent/Accordion.js +108 -158
- package/datetimePicker/subComponent/CustomTimeInput.js +18 -48
- package/datetimePicker/subComponent/DateTimePickerContext.js +2 -5
- package/datetimePicker/utils/GMTDate.js +3 -7
- package/datetimePicker/utils/pad.js +2 -6
- package/datetimePicker/utils/toUTC0.js +3 -6
- package/descriptionList/DescriptionDetail.js +5 -10
- package/descriptionList/DescriptionList.js +5 -10
- package/descriptionList/DescriptionTerm.js +2 -9
- package/descriptionList/index.js +3 -7
- package/divider/Divider.js +9 -12
- package/divider/index.js +1 -3
- package/dropdown/Dropdown.js +28 -65
- package/dropdown/DropdownButtonOption.js +2 -9
- package/dropdown/DropdownContent.js +33 -64
- package/dropdown/DropdownDivOption.js +2 -9
- package/dropdown/DropdownItem.js +10 -16
- package/dropdown/DropdownLinkOption.js +2 -9
- package/dropdown/DropdownToggle.js +18 -38
- package/dropdown/index.js +6 -17
- package/dropdown/subComponent/DropdownContext.js +2 -5
- package/dropzone/FileDropzone.js +148 -302
- package/dropzone/ImageDropzone.js +96 -171
- package/dropzone/index.js +2 -5
- package/dropzone/subComponent/Message.js +7 -14
- package/figure/IconFigure.js +9 -16
- package/figure/ImageFigure.js +11 -17
- package/figure/index.js +2 -5
- package/file/HiddenFileInput.js +5 -14
- package/file/index.js +1 -3
- package/form/Checkbox.js +34 -43
- package/form/FormItem.js +2 -9
- package/form/Input.js +18 -15
- package/form/Label.js +20 -13
- package/form/MutedText.js +5 -10
- package/form/RadioButton.js +20 -32
- package/form/Searchbox.js +21 -65
- package/form/Slider.js +25 -0
- package/form/SwitchButton.js +34 -39
- package/form/Textarea.js +2 -11
- package/form/TreeView.js +64 -0
- package/form/index.js +16 -19
- package/grid/Column.js +17 -17
- package/grid/Grid.js +13 -14
- package/grid/index.js +2 -5
- package/heading/Heading1.js +5 -10
- package/heading/Heading2.js +9 -12
- package/heading/Heading3.js +21 -18
- package/heading/index.js +3 -7
- package/helmet/Helmet.js +6 -9
- package/helmet/index.js +2 -5
- package/iconbox/ApplicationIconBox.js +25 -31
- package/iconbox/IconBox.js +11 -24
- package/iconbox/IconBoxV2.js +14 -26
- package/iconbox/index.js +3 -7
- package/iconbox/subComponent/IconBoxFigure.js +25 -20
- package/iconbox/subComponent/IconBoxImage.js +15 -18
- package/image/ImageFluid.js +2 -10
- package/image/UploadImage.js +65 -113
- package/image/index.js +2 -5
- package/index.js +44 -130
- package/jsoneditor/JsonEditor.js +10 -32
- package/jsoneditor/index.js +1 -3
- package/keyframe/Pulse.js +2 -7
- package/keyframe/Spin.js +2 -7
- package/link/LinkSpan.js +22 -35
- package/link/index.js +1 -3
- package/map/GoogleMap.js +122 -175
- package/map/GoogleReverseGeolocation.js +79 -186
- package/map/LeafletMap.js +78 -132
- package/map/LeafletReverseGeolocation.js +49 -121
- package/map/index.js +4 -9
- package/map/subComponent/BasicLeafletMap.js +8 -14
- package/map/subComponent/GoogleMapContainer.js +5 -10
- package/map/subComponent/GoogleMapPopup.js +66 -123
- package/map/subComponent/GoogleMapWrapper.js +13 -32
- package/map/subComponent/GoogleMarkerSpiderfier.js +14 -24
- package/map/subComponent/LeafletDrawControl.js +47 -84
- package/map/subComponent/LeafletMapContainer.js +5 -10
- package/map/subComponent/MapSearchBoxControl.js +24 -70
- package/modal/StateModal.js +41 -100
- package/modal/TitleModal.js +89 -190
- package/modal/index.js +2 -5
- package/package.json +1 -1
- package/paginate/Paginate.js +40 -54
- package/paginate/index.js +1 -3
- package/popover/Popover.js +39 -87
- package/popover/index.js +1 -3
- package/qrcode/QRCode.js +10 -23
- package/qrcode/QRCodeContainter.js +8 -16
- package/qrcode/index.js +2 -5
- package/ribbon/Ribbon.js +4 -15
- package/ribbon/index.js +1 -3
- package/section/Section.js +57 -39
- package/section/SectionBody.js +15 -22
- package/section/SectionHeader.js +27 -27
- package/section/SectionToolbar.js +2 -9
- package/section/SectionToolbarItem.js +2 -9
- package/section/index.js +5 -11
- package/select/InputSelect.js +103 -215
- package/select/Select.js +204 -362
- package/select/index.js +2 -5
- package/select/subComponent/ListBox.js +9 -12
- package/select/subComponent/Option.js +8 -16
- package/select/subComponent/OptionGroup.js +2 -9
- package/select/subComponent/Options.js +5 -11
- package/select/subComponent/SearchBox.js +9 -29
- package/select/subComponent/SelectedMultiple.js +8 -16
- package/select/subComponent/SelectedSingle.js +2 -9
- package/styles/GlobalStyle.js +169 -91
- package/styles/config/breakpoint.style.js +2 -3
- package/styles/config/header.style.js +2 -3
- package/styles/config/sidebar.style.js +2 -3
- package/styles/index.js +2 -5
- package/styles/mixin/backgroundColor.js +17 -14
- package/styles/mixin/borderColor.js +17 -14
- package/styles/mixin/color.js +17 -14
- package/styles/mixin/colorOnBackground.js +17 -14
- package/styles/mixin/inputPlaceholder.js +3 -9
- package/styles/mixin/media.js +3 -11
- package/styles/mixin/rounded.js +13 -12
- package/styles/mixin/scrollbar.js +7 -13
- package/styles/theme/dark.theme.js +20 -20
- package/styles/theme/light.theme.js +20 -20
- package/styles/theme/white.theme.js +20 -20
- package/styles/themes.js +2 -8
- package/table/GridTable.js +105 -143
- package/table/ImageBox.js +8 -18
- package/table/PermissionTable.js +25 -25
- package/table/Table.js +137 -153
- package/table/__mock__/columns.js +2 -3
- package/table/__mock__/data.js +2 -3
- package/table/hooks/index.js +2 -5
- package/table/hooks/useCalculateDataRange.js +9 -36
- package/table/hooks/useGenerateSort.js +6 -17
- package/table/index.js +4 -9
- package/table/subComponent/BaseTableHeadCell.js +15 -21
- package/table/subComponent/GridTableFooter.js +5 -10
- package/table/subComponent/GridTableHeadCell.js +5 -10
- package/table/subComponent/Resizer.js +17 -44
- package/table/subComponent/TableFooter.js +5 -10
- package/table/subComponent/TableFooterInfo.js +2 -9
- package/table/subComponent/TableFooterPager.js +5 -12
- package/table/subComponent/TableHeadCell.js +2 -9
- package/table/subComponent/TableSort.js +13 -19
- package/tagify/TagifyStyle.js +2 -9
- package/tagify/Tags.js +15 -37
- package/tagify/index.js +2 -5
- package/text/Paragraph.js +25 -20
- package/text/index.js +1 -3
- package/timeline/Timeline.js +28 -37
- package/timeline/index.js +1 -3
- package/toast/CustomToastContainer.js +2 -9
- package/toast/MessageContainer.js +9 -18
- package/toast/index.js +3 -8
- package/toast/show.js +18 -28
- package/tooltip/Tooltip.js +48 -97
- package/tooltip/index.js +1 -3
- package/wizard/Wizard.js +63 -133
- package/wizard/index.js +1 -3
package/iconbox/index.js
CHANGED
|
@@ -5,27 +5,23 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
5
5
|
});
|
|
6
6
|
Object.defineProperty(exports, "ApplicationIconBox", {
|
|
7
7
|
enumerable: true,
|
|
8
|
-
get: function
|
|
8
|
+
get: function () {
|
|
9
9
|
return _ApplicationIconBox.default;
|
|
10
10
|
}
|
|
11
11
|
});
|
|
12
12
|
Object.defineProperty(exports, "IconBox", {
|
|
13
13
|
enumerable: true,
|
|
14
|
-
get: function
|
|
14
|
+
get: function () {
|
|
15
15
|
return _IconBox.default;
|
|
16
16
|
}
|
|
17
17
|
});
|
|
18
18
|
Object.defineProperty(exports, "IconBoxV2", {
|
|
19
19
|
enumerable: true,
|
|
20
|
-
get: function
|
|
20
|
+
get: function () {
|
|
21
21
|
return _IconBoxV.default;
|
|
22
22
|
}
|
|
23
23
|
});
|
|
24
|
-
|
|
25
24
|
var _ApplicationIconBox = _interopRequireDefault(require("./ApplicationIconBox"));
|
|
26
|
-
|
|
27
25
|
var _IconBox = _interopRequireDefault(require("./IconBox"));
|
|
28
|
-
|
|
29
26
|
var _IconBoxV = _interopRequireDefault(require("./IconBoxV2"));
|
|
30
|
-
|
|
31
27
|
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
@@ -4,34 +4,39 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
4
4
|
value: true
|
|
5
5
|
});
|
|
6
6
|
exports.default = void 0;
|
|
7
|
-
|
|
8
7
|
var _styledComponents = _interopRequireDefault(require("styled-components"));
|
|
9
|
-
|
|
10
8
|
var _templateObject;
|
|
11
|
-
|
|
12
9
|
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
13
|
-
|
|
14
10
|
function _taggedTemplateLiteral(strings, raw) { if (!raw) { raw = strings.slice(0); } return Object.freeze(Object.defineProperties(strings, { raw: { value: Object.freeze(raw) } })); }
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
11
|
+
const IconBoxFigure = _styledComponents.default.figure(_templateObject || (_templateObject = _taggedTemplateLiteral(["\n flex: 0 0 120px;\n\n ", "\n ", "\n ", "\n ", "\n\n ", "\n ", "\n"])), _ref => {
|
|
12
|
+
let {
|
|
13
|
+
marginRight
|
|
14
|
+
} = _ref;
|
|
18
15
|
return marginRight && 'margin-right: var(--spacing);';
|
|
19
|
-
},
|
|
20
|
-
|
|
16
|
+
}, _ref2 => {
|
|
17
|
+
let {
|
|
18
|
+
paddingRight
|
|
19
|
+
} = _ref2;
|
|
21
20
|
return paddingRight && 'padding-right: var(--spacing);';
|
|
22
|
-
},
|
|
23
|
-
|
|
21
|
+
}, _ref3 => {
|
|
22
|
+
let {
|
|
23
|
+
paddingRightS
|
|
24
|
+
} = _ref3;
|
|
24
25
|
return paddingRightS && 'padding-right: var(--spacing-s);';
|
|
25
|
-
},
|
|
26
|
-
|
|
26
|
+
}, _ref4 => {
|
|
27
|
+
let {
|
|
28
|
+
paddingBottomS
|
|
29
|
+
} = _ref4;
|
|
27
30
|
return paddingBottomS && 'padding-bottom: var(--spacing-s);';
|
|
28
|
-
},
|
|
29
|
-
|
|
31
|
+
}, _ref5 => {
|
|
32
|
+
let {
|
|
33
|
+
sizeS
|
|
34
|
+
} = _ref5;
|
|
30
35
|
return sizeS && 'flex-basis: 80px;';
|
|
31
|
-
},
|
|
32
|
-
|
|
36
|
+
}, _ref6 => {
|
|
37
|
+
let {
|
|
38
|
+
sizeXS
|
|
39
|
+
} = _ref6;
|
|
33
40
|
return sizeXS && 'flex-basis: 40px;';
|
|
34
41
|
});
|
|
35
|
-
|
|
36
|
-
var _default = IconBoxFigure;
|
|
37
|
-
exports.default = _default;
|
|
42
|
+
var _default = exports.default = IconBoxFigure;
|
|
@@ -4,29 +4,26 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
4
4
|
value: true
|
|
5
5
|
});
|
|
6
6
|
exports.default = void 0;
|
|
7
|
-
|
|
8
7
|
var _styledComponents = _interopRequireDefault(require("styled-components"));
|
|
9
|
-
|
|
10
8
|
var _templateObject;
|
|
11
|
-
|
|
12
9
|
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
13
|
-
|
|
14
10
|
function _taggedTemplateLiteral(strings, raw) { if (!raw) { raw = strings.slice(0); } return Object.freeze(Object.defineProperties(strings, { raw: { value: Object.freeze(raw) } })); }
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
}
|
|
21
|
-
var rounded = _ref.rounded;
|
|
11
|
+
const IconBoxImage = _styledComponents.default.img.attrs(() => ({
|
|
12
|
+
crossOrigin: 'anonymous'
|
|
13
|
+
}))(_templateObject || (_templateObject = _taggedTemplateLiteral(["\n width: 120px;\n height: 120px;\n\n ", "\n\n ", "\n\n ", "\n"])), _ref => {
|
|
14
|
+
let {
|
|
15
|
+
rounded
|
|
16
|
+
} = _ref;
|
|
22
17
|
return rounded && 'border-radius: var(--border-radius);';
|
|
23
|
-
},
|
|
24
|
-
|
|
18
|
+
}, _ref2 => {
|
|
19
|
+
let {
|
|
20
|
+
sizeS
|
|
21
|
+
} = _ref2;
|
|
25
22
|
return sizeS && "\n width: 80px;\n height: 80px;\n ";
|
|
26
|
-
},
|
|
27
|
-
|
|
23
|
+
}, _ref3 => {
|
|
24
|
+
let {
|
|
25
|
+
sizeXS
|
|
26
|
+
} = _ref3;
|
|
28
27
|
return sizeXS && "\n width: 40px;\n height: 40px;\n ";
|
|
29
28
|
});
|
|
30
|
-
|
|
31
|
-
var _default = IconBoxImage;
|
|
32
|
-
exports.default = _default;
|
|
29
|
+
var _default = exports.default = IconBoxImage;
|
package/image/ImageFluid.js
CHANGED
|
@@ -4,18 +4,10 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
4
4
|
value: true
|
|
5
5
|
});
|
|
6
6
|
exports.default = void 0;
|
|
7
|
-
|
|
8
7
|
var _styledComponents = _interopRequireDefault(require("styled-components"));
|
|
9
|
-
|
|
10
8
|
var _rounded = _interopRequireDefault(require("../styles/mixin/rounded"));
|
|
11
|
-
|
|
12
9
|
var _templateObject;
|
|
13
|
-
|
|
14
10
|
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
15
|
-
|
|
16
11
|
function _taggedTemplateLiteral(strings, raw) { if (!raw) { raw = strings.slice(0); } return Object.freeze(Object.defineProperties(strings, { raw: { value: Object.freeze(raw) } })); }
|
|
17
|
-
|
|
18
|
-
var
|
|
19
|
-
|
|
20
|
-
var _default = ImageFluid;
|
|
21
|
-
exports.default = _default;
|
|
12
|
+
const ImageFluid = _styledComponents.default.img(_templateObject || (_templateObject = _taggedTemplateLiteral(["\n width: 100%;\n height: 100%;\n object-fit: cover;\n\n ", "\n"])), _rounded.default);
|
|
13
|
+
var _default = exports.default = ImageFluid;
|
package/image/UploadImage.js
CHANGED
|
@@ -4,113 +4,67 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
4
4
|
value: true
|
|
5
5
|
});
|
|
6
6
|
exports.default = void 0;
|
|
7
|
-
|
|
8
7
|
var _react = require("react");
|
|
9
|
-
|
|
10
8
|
var _reactI18next = require("react-i18next");
|
|
11
|
-
|
|
12
9
|
var _styledComponents = _interopRequireDefault(require("styled-components"));
|
|
13
|
-
|
|
14
10
|
var _fa = require("react-icons/fa");
|
|
15
|
-
|
|
16
11
|
var _md = require("react-icons/md");
|
|
17
|
-
|
|
18
12
|
var _utils = require("@cashub/utils");
|
|
19
|
-
|
|
20
13
|
var _toast = require("../toast");
|
|
21
|
-
|
|
22
14
|
var _HiddenFileInput = _interopRequireDefault(require("../file/HiddenFileInput"));
|
|
23
|
-
|
|
24
15
|
var _ImageFigure = _interopRequireDefault(require("../figure/ImageFigure"));
|
|
25
|
-
|
|
26
16
|
var _ImageFluid = _interopRequireDefault(require("./ImageFluid"));
|
|
27
|
-
|
|
28
17
|
var _jsxRuntime = require("react/jsx-runtime");
|
|
29
|
-
|
|
30
18
|
var _templateObject, _templateObject2, _templateObject3, _templateObject4, _templateObject5, _templateObject6;
|
|
31
|
-
|
|
32
19
|
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
33
|
-
|
|
34
20
|
function _taggedTemplateLiteral(strings, raw) { if (!raw) { raw = strings.slice(0); } return Object.freeze(Object.defineProperties(strings, { raw: { value: Object.freeze(raw) } })); }
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
_ref$roundedCircle = _ref.roundedCircle,
|
|
56
|
-
roundedCircle = _ref$roundedCircle === void 0 ? false : _ref$roundedCircle,
|
|
57
|
-
cropperHandler = _ref.cropperHandler,
|
|
58
|
-
onBlur = _ref.onBlur,
|
|
59
|
-
onClear = _ref.onClear,
|
|
60
|
-
_ref$allowClear = _ref.allowClear,
|
|
61
|
-
allowClear = _ref$allowClear === void 0 ? false : _ref$allowClear;
|
|
62
|
-
|
|
63
|
-
var _useTranslation = (0, _reactI18next.useTranslation)(),
|
|
64
|
-
t = _useTranslation.t;
|
|
65
|
-
|
|
66
|
-
var refWrapper = (0, _react.useRef)();
|
|
67
|
-
|
|
68
|
-
var _useState = (0, _react.useState)(src),
|
|
69
|
-
_useState2 = _slicedToArray(_useState, 2),
|
|
70
|
-
currentSrc = _useState2[0],
|
|
71
|
-
setCurrentSrc = _useState2[1];
|
|
72
|
-
|
|
73
|
-
var _useState3 = (0, _react.useState)(null),
|
|
74
|
-
_useState4 = _slicedToArray(_useState3, 2),
|
|
75
|
-
currentFile = _useState4[0],
|
|
76
|
-
setCurrentFile = _useState4[1];
|
|
77
|
-
|
|
78
|
-
var _useState5 = (0, _react.useState)(0),
|
|
79
|
-
_useState6 = _slicedToArray(_useState5, 2),
|
|
80
|
-
focusCount = _useState6[0],
|
|
81
|
-
setFocusCount = _useState6[1];
|
|
82
|
-
|
|
83
|
-
var handleAvatarRemove = function handleAvatarRemove() {
|
|
21
|
+
const UploadImage = /*#__PURE__*/(0, _react.forwardRef)((_ref, ref) => {
|
|
22
|
+
var _ref$current;
|
|
23
|
+
let {
|
|
24
|
+
id,
|
|
25
|
+
src,
|
|
26
|
+
alt = 'user avatar',
|
|
27
|
+
roundedCircle = false,
|
|
28
|
+
cropperHandler,
|
|
29
|
+
onBlur,
|
|
30
|
+
onClear,
|
|
31
|
+
allowClear = false
|
|
32
|
+
} = _ref;
|
|
33
|
+
const {
|
|
34
|
+
t
|
|
35
|
+
} = (0, _reactI18next.useTranslation)();
|
|
36
|
+
const refWrapper = (0, _react.useRef)();
|
|
37
|
+
const [currentSrc, setCurrentSrc] = (0, _react.useState)(src);
|
|
38
|
+
const [currentFile, setCurrentFile] = (0, _react.useState)(null);
|
|
39
|
+
const [focusCount, setFocusCount] = (0, _react.useState)(0);
|
|
40
|
+
const handleAvatarRemove = () => {
|
|
84
41
|
setCurrentSrc(src);
|
|
85
42
|
ref.current.value = '';
|
|
86
43
|
setCurrentFile(null);
|
|
87
44
|
};
|
|
88
|
-
|
|
89
|
-
var restoreFile = (0, _react.useCallback)(function () {
|
|
45
|
+
const restoreFile = (0, _react.useCallback)(() => {
|
|
90
46
|
if (!currentFile) return;
|
|
91
|
-
|
|
47
|
+
const dataTransfer = new DataTransfer();
|
|
92
48
|
dataTransfer.items.add(currentFile);
|
|
93
49
|
ref.current.files = dataTransfer.files;
|
|
94
50
|
}, [ref, currentFile]);
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
51
|
+
const handleImageFile = (0, _react.useCallback)((file, src) => {
|
|
52
|
+
const dataTransfer = new DataTransfer();
|
|
53
|
+
const changedImageFile = (0, _utils.dataURLtoFile)(src, file.name);
|
|
98
54
|
dataTransfer.items.add(changedImageFile);
|
|
99
55
|
setCurrentSrc(src);
|
|
100
56
|
setCurrentFile(changedImageFile);
|
|
101
57
|
ref.current.files = dataTransfer.files;
|
|
102
58
|
}, [ref]);
|
|
103
|
-
|
|
104
|
-
var handleOnChange = function handleOnChange(files) {
|
|
59
|
+
const handleOnChange = files => {
|
|
105
60
|
if (files.length === 0) {
|
|
106
61
|
// close file selector or cancel upload file need to restore to last uploaded file
|
|
107
62
|
restoreFile();
|
|
108
63
|
} else {
|
|
109
|
-
|
|
110
|
-
|
|
64
|
+
const fileType = files[0].name.slice(files[0].name.lastIndexOf('.')).toLowerCase();
|
|
111
65
|
if (['.jpeg', '.bmp', '.jpg', '.png'].includes(fileType)) {
|
|
112
66
|
if (files[0].size < 2097152) {
|
|
113
|
-
|
|
67
|
+
const srcUrl = URL.createObjectURL(files[0]);
|
|
114
68
|
handleCrop(srcUrl, files[0]);
|
|
115
69
|
} else {
|
|
116
70
|
ref.current.value = '';
|
|
@@ -132,49 +86,45 @@ var UploadImage = /*#__PURE__*/(0, _react.forwardRef)(function (_ref, ref) {
|
|
|
132
86
|
}
|
|
133
87
|
}
|
|
134
88
|
};
|
|
135
|
-
|
|
136
|
-
var handleCrop = (0, _react.useCallback)(function (src, file) {
|
|
89
|
+
const handleCrop = (0, _react.useCallback)((src, file) => {
|
|
137
90
|
cropperHandler({
|
|
138
|
-
src
|
|
139
|
-
file
|
|
91
|
+
src,
|
|
92
|
+
file,
|
|
140
93
|
width: 160,
|
|
141
94
|
height: 160,
|
|
142
|
-
onCrop:
|
|
95
|
+
onCrop: croppedSrc => {
|
|
143
96
|
handleImageFile(file, croppedSrc);
|
|
144
97
|
},
|
|
145
|
-
onClose:
|
|
146
|
-
(0, _utils.getBase64DataUrlFromFile)(file,
|
|
98
|
+
onClose: () => {
|
|
99
|
+
(0, _utils.getBase64DataUrlFromFile)(file, dataUrl => {
|
|
147
100
|
handleImageFile(file, dataUrl);
|
|
148
101
|
});
|
|
149
102
|
}
|
|
150
103
|
});
|
|
151
104
|
}, [cropperHandler, handleImageFile]);
|
|
152
|
-
|
|
153
|
-
var handleFocus = function handleFocus(event) {
|
|
105
|
+
const handleFocus = event => {
|
|
154
106
|
event.preventDefault();
|
|
155
107
|
event.stopPropagation();
|
|
156
|
-
|
|
157
108
|
if (event.target.tagName === 'BUTTON') {
|
|
158
109
|
setFocusCount(focusCount + 1);
|
|
159
110
|
}
|
|
160
111
|
};
|
|
161
|
-
|
|
162
|
-
var handleBlur = function handleBlur(event) {
|
|
112
|
+
const handleBlur = event => {
|
|
163
113
|
event.preventDefault();
|
|
164
|
-
event.stopPropagation();
|
|
114
|
+
event.stopPropagation();
|
|
165
115
|
|
|
116
|
+
// if click figure,after click button
|
|
166
117
|
if (refWrapper.current.contains(event.relatedTarget)) return;
|
|
167
|
-
|
|
168
118
|
if (event.target === refWrapper.current && onBlur) {
|
|
169
119
|
onBlur();
|
|
170
120
|
}
|
|
171
121
|
};
|
|
172
|
-
|
|
173
|
-
(0, _react.useEffect)(function () {
|
|
122
|
+
(0, _react.useEffect)(() => {
|
|
174
123
|
setCurrentSrc(src);
|
|
175
|
-
}, [src, ref]);
|
|
124
|
+
}, [src, ref]);
|
|
176
125
|
|
|
177
|
-
|
|
126
|
+
// if click button icon,can focus figure element
|
|
127
|
+
(0, _react.useEffect)(() => {
|
|
178
128
|
if (focusCount === 2) {
|
|
179
129
|
refWrapper.current.focus();
|
|
180
130
|
setFocusCount(0);
|
|
@@ -196,13 +146,13 @@ var UploadImage = /*#__PURE__*/(0, _react.forwardRef)(function (_ref, ref) {
|
|
|
196
146
|
roundedCircle: roundedCircle,
|
|
197
147
|
children: [ref.current && ref.current.files && ref.current.files.length !== 0 && /*#__PURE__*/(0, _jsxRuntime.jsx)(CropButton, {
|
|
198
148
|
roundedCircle: roundedCircle,
|
|
199
|
-
onClick:
|
|
149
|
+
onClick: () => {
|
|
200
150
|
handleCrop(currentSrc, ref.current.files[0]);
|
|
201
151
|
},
|
|
202
152
|
children: /*#__PURE__*/(0, _jsxRuntime.jsx)(_md.MdCrop, {})
|
|
203
153
|
}), /*#__PURE__*/(0, _jsxRuntime.jsx)(ModifyButton, {
|
|
204
154
|
roundedCircle: roundedCircle,
|
|
205
|
-
onClick:
|
|
155
|
+
onClick: () => {
|
|
206
156
|
ref.current.click();
|
|
207
157
|
},
|
|
208
158
|
children: /*#__PURE__*/(0, _jsxRuntime.jsx)(_fa.FaPen, {})
|
|
@@ -211,40 +161,42 @@ var UploadImage = /*#__PURE__*/(0, _react.forwardRef)(function (_ref, ref) {
|
|
|
211
161
|
ref: ref && ref,
|
|
212
162
|
id: id,
|
|
213
163
|
accept: ".jpeg, .bmp, .jpg, .png",
|
|
214
|
-
onChange:
|
|
215
|
-
return handleOnChange(event.target.files);
|
|
216
|
-
}
|
|
164
|
+
onChange: event => handleOnChange(event.target.files)
|
|
217
165
|
}), ref && ref.current && ref.current.files && ref.current.files.length !== 0 && /*#__PURE__*/(0, _jsxRuntime.jsx)(RemoveIcon, {
|
|
218
166
|
onClick: handleAvatarRemove,
|
|
219
167
|
roundedCircle: roundedCircle,
|
|
220
168
|
children: /*#__PURE__*/(0, _jsxRuntime.jsx)(_fa.FaTimes, {})
|
|
221
|
-
}), allowClear && src && ref && !((_ref$current = ref.current) !== null && _ref$current !== void 0 && (_ref$current
|
|
169
|
+
}), allowClear && src && ref && !((_ref$current = ref.current) !== null && _ref$current !== void 0 && (_ref$current = _ref$current.files) !== null && _ref$current !== void 0 && _ref$current.length) > 0 && /*#__PURE__*/(0, _jsxRuntime.jsx)(RemoveIcon, {
|
|
222
170
|
onClick: onClear,
|
|
223
171
|
roundedCircle: roundedCircle,
|
|
224
172
|
children: /*#__PURE__*/(0, _jsxRuntime.jsx)(_fa.FaTimes, {})
|
|
225
173
|
})]
|
|
226
174
|
});
|
|
227
175
|
});
|
|
228
|
-
|
|
229
|
-
|
|
230
|
-
|
|
231
|
-
|
|
176
|
+
const Wrapper = (0, _styledComponents.default)(_ImageFigure.default)(_templateObject || (_templateObject = _taggedTemplateLiteral(["\n position: relative;\n padding: var(--spacing-xs);\n"])));
|
|
177
|
+
const ButtonGroup = _styledComponents.default.div(_templateObject2 || (_templateObject2 = _taggedTemplateLiteral(["\n position: absolute;\n top: -16px;\n right: -12px;\n\n ", "\n"])), _ref2 => {
|
|
178
|
+
let {
|
|
179
|
+
rounded
|
|
180
|
+
} = _ref2;
|
|
232
181
|
return rounded && "\n top: 0;\n right: 0;\n ";
|
|
233
182
|
});
|
|
234
|
-
|
|
235
|
-
|
|
236
|
-
|
|
237
|
-
|
|
238
|
-
|
|
183
|
+
const ActionButton = _styledComponents.default.button(_templateObject3 || (_templateObject3 = _taggedTemplateLiteral(["\n display: inline-flex;\n justify-content: center;\n align-items: center;\n cursor: pointer;\n width: 32px;\n height: 32px;\n border: none;\n"])));
|
|
184
|
+
const CropButton = (0, _styledComponents.default)(ActionButton)(_templateObject4 || (_templateObject4 = _taggedTemplateLiteral(["\n color: var(--font-on-primary);\n background: var(--color-primary);\n border-radius: var(--border-radius);\n\n ", "\n"])), _ref3 => {
|
|
185
|
+
let {
|
|
186
|
+
roundedCircle
|
|
187
|
+
} = _ref3;
|
|
239
188
|
return roundedCircle && "\n position: relative;\n top: -16px;\n ";
|
|
240
189
|
});
|
|
241
|
-
|
|
242
|
-
|
|
190
|
+
const ModifyButton = (0, _styledComponents.default)(ActionButton)(_templateObject5 || (_templateObject5 = _taggedTemplateLiteral(["\n color: var(--font-on-primary);\n background: var(--color-primary);\n border-radius: var(--border-radius);\n margin-left: var(--spacing-xs);\n\n ", "\n"])), _ref4 => {
|
|
191
|
+
let {
|
|
192
|
+
roundedCircle
|
|
193
|
+
} = _ref4;
|
|
243
194
|
return roundedCircle && "\n position: relative;\n top: 4px;\n ";
|
|
244
195
|
});
|
|
245
|
-
|
|
246
|
-
|
|
196
|
+
const RemoveIcon = (0, _styledComponents.default)(ActionButton)(_templateObject6 || (_templateObject6 = _taggedTemplateLiteral(["\n position: absolute;\n color: var(--font-on-danger);\n background: var(--color-danger);\n border-radius: var(--border-radius);\n bottom: -12px;\n right: -12px;\n\n ", "\n"])), _ref5 => {
|
|
197
|
+
let {
|
|
198
|
+
roundedCircle
|
|
199
|
+
} = _ref5;
|
|
247
200
|
return roundedCircle && "\n bottom: 0;\n right: 4px;\n ";
|
|
248
201
|
});
|
|
249
|
-
var _default = UploadImage;
|
|
250
|
-
exports.default = _default;
|
|
202
|
+
var _default = exports.default = UploadImage;
|
package/image/index.js
CHANGED
|
@@ -5,19 +5,16 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
5
5
|
});
|
|
6
6
|
Object.defineProperty(exports, "ImageFluid", {
|
|
7
7
|
enumerable: true,
|
|
8
|
-
get: function
|
|
8
|
+
get: function () {
|
|
9
9
|
return _ImageFluid.default;
|
|
10
10
|
}
|
|
11
11
|
});
|
|
12
12
|
Object.defineProperty(exports, "UploadImage", {
|
|
13
13
|
enumerable: true,
|
|
14
|
-
get: function
|
|
14
|
+
get: function () {
|
|
15
15
|
return _UploadImage.default;
|
|
16
16
|
}
|
|
17
17
|
});
|
|
18
|
-
|
|
19
18
|
var _ImageFluid = _interopRequireDefault(require("./ImageFluid"));
|
|
20
|
-
|
|
21
19
|
var _UploadImage = _interopRequireDefault(require("./UploadImage"));
|
|
22
|
-
|
|
23
20
|
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|