@cashub/ui 0.21.0 → 0.21.1
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 +9 -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 +13 -15
- package/form/Label.js +10 -13
- package/form/MutedText.js +5 -10
- package/form/RadioButton.js +20 -32
- package/form/Searchbox.js +21 -65
- package/form/Slider.js +14 -0
- package/form/SwitchButton.js +34 -39
- package/form/Textarea.js +2 -11
- package/form/index.js +9 -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/dropzone/FileDropzone.js
CHANGED
|
@@ -1,140 +1,51 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
|
|
3
|
-
function _typeof(obj) { "@babel/helpers - typeof"; return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function (obj) { return typeof obj; } : function (obj) { return obj && "function" == typeof Symbol && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }, _typeof(obj); }
|
|
4
|
-
|
|
5
3
|
Object.defineProperty(exports, "__esModule", {
|
|
6
4
|
value: true
|
|
7
5
|
});
|
|
8
6
|
exports.default = void 0;
|
|
9
|
-
|
|
10
7
|
var _react = require("react");
|
|
11
|
-
|
|
12
8
|
var _styledComponents = _interopRequireDefault(require("styled-components"));
|
|
13
|
-
|
|
14
9
|
var _fi = require("react-icons/fi");
|
|
15
|
-
|
|
16
10
|
var _fa = require("react-icons/fa");
|
|
17
|
-
|
|
18
11
|
var _utils = require("@cashub/utils");
|
|
19
|
-
|
|
20
12
|
var _media = _interopRequireDefault(require("../styles/mixin/media"));
|
|
21
|
-
|
|
22
13
|
var _file = _interopRequireDefault(require("../assets/icons/file.svg"));
|
|
23
|
-
|
|
24
14
|
var _HiddenFileInput = _interopRequireDefault(require("../file/HiddenFileInput"));
|
|
25
|
-
|
|
26
15
|
var _Message = _interopRequireDefault(require("./subComponent/Message"));
|
|
27
|
-
|
|
28
16
|
var _jsxRuntime = require("react/jsx-runtime");
|
|
29
|
-
|
|
30
17
|
var _templateObject, _templateObject2, _templateObject3, _templateObject4, _templateObject5, _templateObject6, _templateObject7, _templateObject8, _templateObject9, _templateObject10, _templateObject11;
|
|
31
|
-
|
|
32
18
|
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
33
|
-
|
|
34
19
|
function _taggedTemplateLiteral(strings, raw) { if (!raw) { raw = strings.slice(0); } return Object.freeze(Object.defineProperties(strings, { raw: { value: Object.freeze(raw) } })); }
|
|
35
|
-
|
|
36
|
-
function _regeneratorRuntime() { "use strict"; /*! regenerator-runtime -- Copyright (c) 2014-present, Facebook, Inc. -- license (MIT): https://github.com/facebook/regenerator/blob/main/LICENSE */ _regeneratorRuntime = function _regeneratorRuntime() { return exports; }; var exports = {}, Op = Object.prototype, hasOwn = Op.hasOwnProperty, $Symbol = "function" == typeof Symbol ? Symbol : {}, iteratorSymbol = $Symbol.iterator || "@@iterator", asyncIteratorSymbol = $Symbol.asyncIterator || "@@asyncIterator", toStringTagSymbol = $Symbol.toStringTag || "@@toStringTag"; function define(obj, key, value) { return Object.defineProperty(obj, key, { value: value, enumerable: !0, configurable: !0, writable: !0 }), obj[key]; } try { define({}, ""); } catch (err) { define = function define(obj, key, value) { return obj[key] = value; }; } function wrap(innerFn, outerFn, self, tryLocsList) { var protoGenerator = outerFn && outerFn.prototype instanceof Generator ? outerFn : Generator, generator = Object.create(protoGenerator.prototype), context = new Context(tryLocsList || []); return generator._invoke = function (innerFn, self, context) { var state = "suspendedStart"; return function (method, arg) { if ("executing" === state) throw new Error("Generator is already running"); if ("completed" === state) { if ("throw" === method) throw arg; return doneResult(); } for (context.method = method, context.arg = arg;;) { var delegate = context.delegate; if (delegate) { var delegateResult = maybeInvokeDelegate(delegate, context); if (delegateResult) { if (delegateResult === ContinueSentinel) continue; return delegateResult; } } if ("next" === context.method) context.sent = context._sent = context.arg;else if ("throw" === context.method) { if ("suspendedStart" === state) throw state = "completed", context.arg; context.dispatchException(context.arg); } else "return" === context.method && context.abrupt("return", context.arg); state = "executing"; var record = tryCatch(innerFn, self, context); if ("normal" === record.type) { if (state = context.done ? "completed" : "suspendedYield", record.arg === ContinueSentinel) continue; return { value: record.arg, done: context.done }; } "throw" === record.type && (state = "completed", context.method = "throw", context.arg = record.arg); } }; }(innerFn, self, context), generator; } function tryCatch(fn, obj, arg) { try { return { type: "normal", arg: fn.call(obj, arg) }; } catch (err) { return { type: "throw", arg: err }; } } exports.wrap = wrap; var ContinueSentinel = {}; function Generator() {} function GeneratorFunction() {} function GeneratorFunctionPrototype() {} var IteratorPrototype = {}; define(IteratorPrototype, iteratorSymbol, function () { return this; }); var getProto = Object.getPrototypeOf, NativeIteratorPrototype = getProto && getProto(getProto(values([]))); NativeIteratorPrototype && NativeIteratorPrototype !== Op && hasOwn.call(NativeIteratorPrototype, iteratorSymbol) && (IteratorPrototype = NativeIteratorPrototype); var Gp = GeneratorFunctionPrototype.prototype = Generator.prototype = Object.create(IteratorPrototype); function defineIteratorMethods(prototype) { ["next", "throw", "return"].forEach(function (method) { define(prototype, method, function (arg) { return this._invoke(method, arg); }); }); } function AsyncIterator(generator, PromiseImpl) { function invoke(method, arg, resolve, reject) { var record = tryCatch(generator[method], generator, arg); if ("throw" !== record.type) { var result = record.arg, value = result.value; return value && "object" == _typeof(value) && hasOwn.call(value, "__await") ? PromiseImpl.resolve(value.__await).then(function (value) { invoke("next", value, resolve, reject); }, function (err) { invoke("throw", err, resolve, reject); }) : PromiseImpl.resolve(value).then(function (unwrapped) { result.value = unwrapped, resolve(result); }, function (error) { return invoke("throw", error, resolve, reject); }); } reject(record.arg); } var previousPromise; this._invoke = function (method, arg) { function callInvokeWithMethodAndArg() { return new PromiseImpl(function (resolve, reject) { invoke(method, arg, resolve, reject); }); } return previousPromise = previousPromise ? previousPromise.then(callInvokeWithMethodAndArg, callInvokeWithMethodAndArg) : callInvokeWithMethodAndArg(); }; } function maybeInvokeDelegate(delegate, context) { var method = delegate.iterator[context.method]; if (undefined === method) { if (context.delegate = null, "throw" === context.method) { if (delegate.iterator.return && (context.method = "return", context.arg = undefined, maybeInvokeDelegate(delegate, context), "throw" === context.method)) return ContinueSentinel; context.method = "throw", context.arg = new TypeError("The iterator does not provide a 'throw' method"); } return ContinueSentinel; } var record = tryCatch(method, delegate.iterator, context.arg); if ("throw" === record.type) return context.method = "throw", context.arg = record.arg, context.delegate = null, ContinueSentinel; var info = record.arg; return info ? info.done ? (context[delegate.resultName] = info.value, context.next = delegate.nextLoc, "return" !== context.method && (context.method = "next", context.arg = undefined), context.delegate = null, ContinueSentinel) : info : (context.method = "throw", context.arg = new TypeError("iterator result is not an object"), context.delegate = null, ContinueSentinel); } function pushTryEntry(locs) { var entry = { tryLoc: locs[0] }; 1 in locs && (entry.catchLoc = locs[1]), 2 in locs && (entry.finallyLoc = locs[2], entry.afterLoc = locs[3]), this.tryEntries.push(entry); } function resetTryEntry(entry) { var record = entry.completion || {}; record.type = "normal", delete record.arg, entry.completion = record; } function Context(tryLocsList) { this.tryEntries = [{ tryLoc: "root" }], tryLocsList.forEach(pushTryEntry, this), this.reset(!0); } function values(iterable) { if (iterable) { var iteratorMethod = iterable[iteratorSymbol]; if (iteratorMethod) return iteratorMethod.call(iterable); if ("function" == typeof iterable.next) return iterable; if (!isNaN(iterable.length)) { var i = -1, next = function next() { for (; ++i < iterable.length;) { if (hasOwn.call(iterable, i)) return next.value = iterable[i], next.done = !1, next; } return next.value = undefined, next.done = !0, next; }; return next.next = next; } } return { next: doneResult }; } function doneResult() { return { value: undefined, done: !0 }; } return GeneratorFunction.prototype = GeneratorFunctionPrototype, define(Gp, "constructor", GeneratorFunctionPrototype), define(GeneratorFunctionPrototype, "constructor", GeneratorFunction), GeneratorFunction.displayName = define(GeneratorFunctionPrototype, toStringTagSymbol, "GeneratorFunction"), exports.isGeneratorFunction = function (genFun) { var ctor = "function" == typeof genFun && genFun.constructor; return !!ctor && (ctor === GeneratorFunction || "GeneratorFunction" === (ctor.displayName || ctor.name)); }, exports.mark = function (genFun) { return Object.setPrototypeOf ? Object.setPrototypeOf(genFun, GeneratorFunctionPrototype) : (genFun.__proto__ = GeneratorFunctionPrototype, define(genFun, toStringTagSymbol, "GeneratorFunction")), genFun.prototype = Object.create(Gp), genFun; }, exports.awrap = function (arg) { return { __await: arg }; }, defineIteratorMethods(AsyncIterator.prototype), define(AsyncIterator.prototype, asyncIteratorSymbol, function () { return this; }), exports.AsyncIterator = AsyncIterator, exports.async = function (innerFn, outerFn, self, tryLocsList, PromiseImpl) { void 0 === PromiseImpl && (PromiseImpl = Promise); var iter = new AsyncIterator(wrap(innerFn, outerFn, self, tryLocsList), PromiseImpl); return exports.isGeneratorFunction(outerFn) ? iter : iter.next().then(function (result) { return result.done ? result.value : iter.next(); }); }, defineIteratorMethods(Gp), define(Gp, toStringTagSymbol, "Generator"), define(Gp, iteratorSymbol, function () { return this; }), define(Gp, "toString", function () { return "[object Generator]"; }), exports.keys = function (object) { var keys = []; for (var key in object) { keys.push(key); } return keys.reverse(), function next() { for (; keys.length;) { var key = keys.pop(); if (key in object) return next.value = key, next.done = !1, next; } return next.done = !0, next; }; }, exports.values = values, Context.prototype = { constructor: Context, reset: function reset(skipTempReset) { if (this.prev = 0, this.next = 0, this.sent = this._sent = undefined, this.done = !1, this.delegate = null, this.method = "next", this.arg = undefined, this.tryEntries.forEach(resetTryEntry), !skipTempReset) for (var name in this) { "t" === name.charAt(0) && hasOwn.call(this, name) && !isNaN(+name.slice(1)) && (this[name] = undefined); } }, stop: function stop() { this.done = !0; var rootRecord = this.tryEntries[0].completion; if ("throw" === rootRecord.type) throw rootRecord.arg; return this.rval; }, dispatchException: function dispatchException(exception) { if (this.done) throw exception; var context = this; function handle(loc, caught) { return record.type = "throw", record.arg = exception, context.next = loc, caught && (context.method = "next", context.arg = undefined), !!caught; } for (var i = this.tryEntries.length - 1; i >= 0; --i) { var entry = this.tryEntries[i], record = entry.completion; if ("root" === entry.tryLoc) return handle("end"); if (entry.tryLoc <= this.prev) { var hasCatch = hasOwn.call(entry, "catchLoc"), hasFinally = hasOwn.call(entry, "finallyLoc"); if (hasCatch && hasFinally) { if (this.prev < entry.catchLoc) return handle(entry.catchLoc, !0); if (this.prev < entry.finallyLoc) return handle(entry.finallyLoc); } else if (hasCatch) { if (this.prev < entry.catchLoc) return handle(entry.catchLoc, !0); } else { if (!hasFinally) throw new Error("try statement without catch or finally"); if (this.prev < entry.finallyLoc) return handle(entry.finallyLoc); } } } }, abrupt: function abrupt(type, arg) { for (var i = this.tryEntries.length - 1; i >= 0; --i) { var entry = this.tryEntries[i]; if (entry.tryLoc <= this.prev && hasOwn.call(entry, "finallyLoc") && this.prev < entry.finallyLoc) { var finallyEntry = entry; break; } } finallyEntry && ("break" === type || "continue" === type) && finallyEntry.tryLoc <= arg && arg <= finallyEntry.finallyLoc && (finallyEntry = null); var record = finallyEntry ? finallyEntry.completion : {}; return record.type = type, record.arg = arg, finallyEntry ? (this.method = "next", this.next = finallyEntry.finallyLoc, ContinueSentinel) : this.complete(record); }, complete: function complete(record, afterLoc) { if ("throw" === record.type) throw record.arg; return "break" === record.type || "continue" === record.type ? this.next = record.arg : "return" === record.type ? (this.rval = this.arg = record.arg, this.method = "return", this.next = "end") : "normal" === record.type && afterLoc && (this.next = afterLoc), ContinueSentinel; }, finish: function finish(finallyLoc) { for (var i = this.tryEntries.length - 1; i >= 0; --i) { var entry = this.tryEntries[i]; if (entry.finallyLoc === finallyLoc) return this.complete(entry.completion, entry.afterLoc), resetTryEntry(entry), ContinueSentinel; } }, catch: function _catch(tryLoc) { for (var i = this.tryEntries.length - 1; i >= 0; --i) { var entry = this.tryEntries[i]; if (entry.tryLoc === tryLoc) { var record = entry.completion; if ("throw" === record.type) { var thrown = record.arg; resetTryEntry(entry); } return thrown; } } throw new Error("illegal catch attempt"); }, delegateYield: function delegateYield(iterable, resultName, nextLoc) { return this.delegate = { iterator: values(iterable), resultName: resultName, nextLoc: nextLoc }, "next" === this.method && (this.arg = undefined), ContinueSentinel; } }, exports; }
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
function _iterableToArrayLimit(arr, i) { var _i = arr == null ? null : typeof Symbol !== "undefined" && arr[Symbol.iterator] || arr["@@iterator"]; if (_i == null) return; var _arr = []; var _n = true; var _d = false; var _s, _e; try { for (_i = _i.call(arr); !(_n = (_s = _i.next()).done); _n = true) { _arr.push(_s.value); if (i && _arr.length === i) break; } } catch (err) { _d = true; _e = err; } finally { try { if (!_n && _i["return"] != null) _i["return"](); } finally { if (_d) throw _e; } } return _arr; }
|
|
65
|
-
|
|
66
|
-
function _arrayWithHoles(arr) { if (Array.isArray(arr)) return arr; }
|
|
67
|
-
|
|
68
|
-
var FileDropzone = function FileDropzone(_ref) {
|
|
69
|
-
var message = _ref.message,
|
|
70
|
-
accept = _ref.accept,
|
|
71
|
-
translation = _ref.translation,
|
|
72
|
-
state = _ref.state,
|
|
73
|
-
_ref$chunking = _ref.chunking,
|
|
74
|
-
chunking = _ref$chunking === void 0 ? true : _ref$chunking,
|
|
75
|
-
_ref$chunkSize = _ref.chunkSize,
|
|
76
|
-
chunkSize = _ref$chunkSize === void 0 ? 6000000 : _ref$chunkSize,
|
|
77
|
-
onAddedFile = _ref.onAddedFile,
|
|
78
|
-
onRemovedFile = _ref.onRemovedFile,
|
|
79
|
-
onPausedUpload = _ref.onPausedUpload,
|
|
80
|
-
onCanceledFile = _ref.onCanceledFile,
|
|
81
|
-
onUploading = _ref.onUploading,
|
|
82
|
-
onCompleted = _ref.onCompleted,
|
|
83
|
-
onError = _ref.onError;
|
|
84
|
-
var inputRef = (0, _react.useRef)(null);
|
|
85
|
-
|
|
86
|
-
var _useState = (0, _react.useState)(false),
|
|
87
|
-
_useState2 = _slicedToArray(_useState, 2),
|
|
88
|
-
dragging = _useState2[0],
|
|
89
|
-
setDragging = _useState2[1];
|
|
90
|
-
|
|
91
|
-
var _useState3 = (0, _react.useState)([]),
|
|
92
|
-
_useState4 = _slicedToArray(_useState3, 2),
|
|
93
|
-
files = _useState4[0],
|
|
94
|
-
setFiles = _useState4[1];
|
|
95
|
-
|
|
96
|
-
var _useState5 = (0, _react.useState)(0),
|
|
97
|
-
_useState6 = _slicedToArray(_useState5, 2),
|
|
98
|
-
percentage = _useState6[0],
|
|
99
|
-
setPercentage = _useState6[1];
|
|
100
|
-
|
|
101
|
-
var _useState7 = (0, _react.useState)(false),
|
|
102
|
-
_useState8 = _slicedToArray(_useState7, 2),
|
|
103
|
-
isPausing = _useState8[0],
|
|
104
|
-
setIsPausing = _useState8[1];
|
|
105
|
-
|
|
106
|
-
var _useState9 = (0, _react.useState)(0),
|
|
107
|
-
_useState10 = _slicedToArray(_useState9, 2),
|
|
108
|
-
total = _useState10[0],
|
|
109
|
-
setTotal = _useState10[1];
|
|
110
|
-
|
|
111
|
-
var _useState11 = (0, _react.useState)(0),
|
|
112
|
-
_useState12 = _slicedToArray(_useState11, 2),
|
|
113
|
-
index = _useState12[0],
|
|
114
|
-
setIndex = _useState12[1];
|
|
115
|
-
|
|
116
|
-
var _useState13 = (0, _react.useState)(0),
|
|
117
|
-
_useState14 = _slicedToArray(_useState13, 2),
|
|
118
|
-
successCount = _useState14[0],
|
|
119
|
-
setSuccessCount = _useState14[1];
|
|
120
|
-
|
|
121
|
-
var _useState15 = (0, _react.useState)(false),
|
|
122
|
-
_useState16 = _slicedToArray(_useState15, 2),
|
|
123
|
-
hasFail = _useState16[0],
|
|
124
|
-
setHasFail = _useState16[1];
|
|
125
|
-
|
|
126
|
-
var _useState17 = (0, _react.useState)(false),
|
|
127
|
-
_useState18 = _slicedToArray(_useState17, 2),
|
|
128
|
-
isCompleted = _useState18[0],
|
|
129
|
-
setIsCompleted = _useState18[1];
|
|
130
|
-
|
|
131
|
-
var _useState19 = (0, _react.useState)([]),
|
|
132
|
-
_useState20 = _slicedToArray(_useState19, 2),
|
|
133
|
-
failUploadIndexes = _useState20[0],
|
|
134
|
-
setFailUploadIndexes = _useState20[1];
|
|
135
|
-
|
|
136
|
-
var texts = (0, _react.useMemo)(function () {
|
|
137
|
-
var defaultTexts = {
|
|
20
|
+
const FileDropzone = _ref => {
|
|
21
|
+
let {
|
|
22
|
+
message,
|
|
23
|
+
accept,
|
|
24
|
+
translation,
|
|
25
|
+
state,
|
|
26
|
+
chunking = true,
|
|
27
|
+
chunkSize = 6000000,
|
|
28
|
+
onAddedFile,
|
|
29
|
+
onRemovedFile,
|
|
30
|
+
onPausedUpload,
|
|
31
|
+
onCanceledFile,
|
|
32
|
+
onUploading,
|
|
33
|
+
onCompleted,
|
|
34
|
+
onError
|
|
35
|
+
} = _ref;
|
|
36
|
+
const inputRef = (0, _react.useRef)(null);
|
|
37
|
+
const [dragging, setDragging] = (0, _react.useState)(false);
|
|
38
|
+
const [files, setFiles] = (0, _react.useState)([]);
|
|
39
|
+
const [percentage, setPercentage] = (0, _react.useState)(0);
|
|
40
|
+
const [isPausing, setIsPausing] = (0, _react.useState)(false);
|
|
41
|
+
const [total, setTotal] = (0, _react.useState)(0);
|
|
42
|
+
const [index, setIndex] = (0, _react.useState)(0);
|
|
43
|
+
const [successCount, setSuccessCount] = (0, _react.useState)(0);
|
|
44
|
+
const [hasFail, setHasFail] = (0, _react.useState)(false);
|
|
45
|
+
const [isCompleted, setIsCompleted] = (0, _react.useState)(false);
|
|
46
|
+
const [failUploadIndexes, setFailUploadIndexes] = (0, _react.useState)([]);
|
|
47
|
+
const texts = (0, _react.useMemo)(() => {
|
|
48
|
+
const defaultTexts = {
|
|
138
49
|
Cancel: 'Cancel Upload',
|
|
139
50
|
FileIcon: 'File Icon',
|
|
140
51
|
Pause: 'Pause Upload',
|
|
@@ -142,13 +53,16 @@ var FileDropzone = function FileDropzone(_ref) {
|
|
|
142
53
|
Resume: 'Resume Upload',
|
|
143
54
|
Retry: 'Retry Upload'
|
|
144
55
|
};
|
|
145
|
-
return
|
|
56
|
+
return {
|
|
57
|
+
...defaultTexts,
|
|
58
|
+
...translation
|
|
59
|
+
};
|
|
146
60
|
}, [translation]);
|
|
147
|
-
|
|
61
|
+
const handleClick = (0, _react.useCallback)(() => {
|
|
148
62
|
if (files.length > 0) return;
|
|
149
63
|
inputRef.current.click();
|
|
150
64
|
}, [files]);
|
|
151
|
-
|
|
65
|
+
const handleReset = (0, _react.useCallback)(() => {
|
|
152
66
|
setFiles([]);
|
|
153
67
|
setPercentage(0);
|
|
154
68
|
setIsPausing(false);
|
|
@@ -158,223 +72,160 @@ var FileDropzone = function FileDropzone(_ref) {
|
|
|
158
72
|
setHasFail(false);
|
|
159
73
|
setIsCompleted(false);
|
|
160
74
|
setFailUploadIndexes([]);
|
|
161
|
-
}, []);
|
|
162
|
-
|
|
163
|
-
var handleKeyUp = (0, _react.useCallback)(function (event) {
|
|
164
|
-
var key = event.keyCode;
|
|
75
|
+
}, []);
|
|
165
76
|
|
|
77
|
+
// handle keyboard interaction
|
|
78
|
+
const handleKeyUp = (0, _react.useCallback)(event => {
|
|
79
|
+
const key = event.keyCode;
|
|
166
80
|
switch (key) {
|
|
167
81
|
case _utils.KEY_CODE.ENTER:
|
|
168
82
|
handleClick();
|
|
169
83
|
break;
|
|
170
|
-
|
|
171
84
|
default:
|
|
172
85
|
break;
|
|
173
86
|
}
|
|
174
87
|
}, [handleClick]);
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
88
|
+
const handleKeyDown = (0, _react.useCallback)(event => {
|
|
89
|
+
const key = event.keyCode;
|
|
178
90
|
switch (key) {
|
|
179
91
|
case _utils.KEY_CODE.ENTER:
|
|
180
92
|
event.preventDefault();
|
|
181
93
|
break;
|
|
182
|
-
|
|
183
94
|
default:
|
|
184
95
|
break;
|
|
185
96
|
}
|
|
186
97
|
}, []);
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
98
|
+
const handleFileChange = (0, _react.useCallback)(event => {
|
|
99
|
+
const {
|
|
100
|
+
files: newFiles
|
|
101
|
+
} = event.target;
|
|
190
102
|
if (newFiles.length > 0 && files.length === 0) {
|
|
191
103
|
if (onAddedFile) {
|
|
192
104
|
onAddedFile(newFiles[0]);
|
|
193
105
|
}
|
|
194
|
-
|
|
195
106
|
setFiles([newFiles[0]]);
|
|
196
107
|
setTotal(chunking ? Math.ceil(newFiles[0].size / chunkSize) : 1);
|
|
197
108
|
}
|
|
198
|
-
|
|
199
109
|
inputRef.current.value = '';
|
|
200
110
|
}, [files, onAddedFile, chunking, chunkSize]);
|
|
201
|
-
|
|
111
|
+
const handleDragEnter = (0, _react.useCallback)(event => {
|
|
202
112
|
event.preventDefault();
|
|
203
113
|
event.stopPropagation();
|
|
204
114
|
if (files.length === 0) setDragging(true);
|
|
205
115
|
}, [files]);
|
|
206
|
-
|
|
116
|
+
const handleDragOver = (0, _react.useCallback)(event => {
|
|
207
117
|
event.preventDefault();
|
|
208
118
|
event.stopPropagation();
|
|
209
119
|
if (files.length === 0) setDragging(true);
|
|
210
120
|
}, [files]);
|
|
211
|
-
|
|
121
|
+
const handleDragLeave = (0, _react.useCallback)(event => {
|
|
212
122
|
event.preventDefault();
|
|
213
123
|
event.stopPropagation();
|
|
214
124
|
setDragging(false);
|
|
215
125
|
}, []);
|
|
216
|
-
|
|
126
|
+
const handleDrop = (0, _react.useCallback)(event => {
|
|
217
127
|
event.preventDefault();
|
|
218
128
|
event.stopPropagation();
|
|
219
|
-
|
|
220
129
|
if (files.length === 0) {
|
|
221
130
|
setDragging(false);
|
|
222
|
-
|
|
223
|
-
|
|
224
|
-
|
|
131
|
+
const {
|
|
132
|
+
dataTransfer
|
|
133
|
+
} = event;
|
|
134
|
+
const {
|
|
135
|
+
files: newFiles
|
|
136
|
+
} = dataTransfer;
|
|
225
137
|
if (newFiles.length > 0) {
|
|
226
138
|
if (onAddedFile) {
|
|
227
139
|
onAddedFile(newFiles[0]);
|
|
228
140
|
}
|
|
229
|
-
|
|
230
141
|
setFiles([newFiles[0]]);
|
|
231
142
|
setTotal(chunking ? Math.ceil(newFiles[0].size / chunkSize) : 1);
|
|
232
143
|
}
|
|
233
144
|
}
|
|
234
145
|
}, [files, onAddedFile, chunkSize, chunking]);
|
|
235
|
-
|
|
236
|
-
|
|
237
|
-
|
|
238
|
-
|
|
239
|
-
|
|
240
|
-
|
|
241
|
-
|
|
242
|
-
|
|
243
|
-
|
|
244
|
-
|
|
245
|
-
|
|
246
|
-
|
|
247
|
-
|
|
248
|
-
|
|
249
|
-
|
|
250
|
-
|
|
251
|
-
|
|
252
|
-
|
|
253
|
-
|
|
254
|
-
|
|
255
|
-
|
|
256
|
-
|
|
257
|
-
|
|
258
|
-
|
|
259
|
-
|
|
260
|
-
|
|
261
|
-
|
|
262
|
-
|
|
263
|
-
|
|
264
|
-
return
|
|
265
|
-
|
|
266
|
-
|
|
267
|
-
|
|
268
|
-
|
|
269
|
-
|
|
270
|
-
|
|
271
|
-
|
|
272
|
-
|
|
273
|
-
|
|
274
|
-
|
|
275
|
-
_context.t0 = _context["catch"](4);
|
|
276
|
-
setHasFail(true);
|
|
277
|
-
setFailUploadIndexes(function (previous) {
|
|
278
|
-
return [].concat(_toConsumableArray(previous), [index]);
|
|
279
|
-
});
|
|
280
|
-
|
|
281
|
-
case 14:
|
|
282
|
-
_context.next = 30;
|
|
283
|
-
break;
|
|
284
|
-
|
|
285
|
-
case 16:
|
|
286
|
-
start = index * chunkSize;
|
|
287
|
-
end = Math.min(start + chunkSize, file.size);
|
|
288
|
-
chunkData = file.slice(start, end);
|
|
289
|
-
|
|
290
|
-
if (!onUploading) {
|
|
291
|
-
_context.next = 30;
|
|
292
|
-
break;
|
|
293
|
-
}
|
|
294
|
-
|
|
295
|
-
_context.prev = 20;
|
|
296
|
-
_context.next = 23;
|
|
297
|
-
return onUploading(chunkData, file.name, index);
|
|
298
|
-
|
|
299
|
-
case 23:
|
|
300
|
-
setSuccessCount(function (previous) {
|
|
146
|
+
const handleUpload = (0, _react.useCallback)(async function (index) {
|
|
147
|
+
let setNext = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : true;
|
|
148
|
+
const [file] = files;
|
|
149
|
+
if (!chunking) {
|
|
150
|
+
if (onUploading) {
|
|
151
|
+
try {
|
|
152
|
+
await onUploading(file, file.name, index);
|
|
153
|
+
setSuccessCount(previous => {
|
|
154
|
+
return previous + 1;
|
|
155
|
+
});
|
|
156
|
+
} catch (error) {
|
|
157
|
+
setHasFail(true);
|
|
158
|
+
setFailUploadIndexes(previous => {
|
|
159
|
+
return [...previous, index];
|
|
160
|
+
});
|
|
161
|
+
}
|
|
162
|
+
}
|
|
163
|
+
} else {
|
|
164
|
+
const start = index * chunkSize;
|
|
165
|
+
const end = Math.min(start + chunkSize, file.size);
|
|
166
|
+
const chunkData = file.slice(start, end);
|
|
167
|
+
if (onUploading) {
|
|
168
|
+
try {
|
|
169
|
+
await onUploading(chunkData, file.name, index);
|
|
170
|
+
setSuccessCount(previous => {
|
|
171
|
+
return previous + 1;
|
|
172
|
+
});
|
|
173
|
+
if (setNext) {
|
|
174
|
+
setIndex(previous => {
|
|
175
|
+
return previous + 1;
|
|
176
|
+
});
|
|
177
|
+
}
|
|
178
|
+
} catch (error) {
|
|
179
|
+
if (error.message !== 'canceled') {
|
|
180
|
+
setHasFail(true);
|
|
181
|
+
setFailUploadIndexes(previous => {
|
|
182
|
+
return [...previous, index];
|
|
183
|
+
});
|
|
184
|
+
if (setNext) {
|
|
185
|
+
setIndex(previous => {
|
|
301
186
|
return previous + 1;
|
|
302
187
|
});
|
|
303
|
-
|
|
304
|
-
if (setNext) {
|
|
305
|
-
setIndex(function (previous) {
|
|
306
|
-
return previous + 1;
|
|
307
|
-
});
|
|
308
|
-
}
|
|
309
|
-
|
|
310
|
-
_context.next = 30;
|
|
311
|
-
break;
|
|
312
|
-
|
|
313
|
-
case 27:
|
|
314
|
-
_context.prev = 27;
|
|
315
|
-
_context.t1 = _context["catch"](20);
|
|
316
|
-
|
|
317
|
-
if (_context.t1.message !== 'canceled') {
|
|
318
|
-
setHasFail(true);
|
|
319
|
-
setFailUploadIndexes(function (previous) {
|
|
320
|
-
return [].concat(_toConsumableArray(previous), [index]);
|
|
321
|
-
});
|
|
322
|
-
|
|
323
|
-
if (setNext) {
|
|
324
|
-
setIndex(function (previous) {
|
|
325
|
-
return previous + 1;
|
|
326
|
-
});
|
|
327
|
-
}
|
|
328
|
-
}
|
|
329
|
-
|
|
330
|
-
case 30:
|
|
331
|
-
case "end":
|
|
332
|
-
return _context.stop();
|
|
188
|
+
}
|
|
333
189
|
}
|
|
334
190
|
}
|
|
335
|
-
}
|
|
336
|
-
}
|
|
337
|
-
|
|
338
|
-
|
|
339
|
-
return _ref2.apply(this, arguments);
|
|
340
|
-
};
|
|
341
|
-
}(), [files, chunking, chunkSize, onUploading]);
|
|
342
|
-
var handlePauseUpload = (0, _react.useCallback)(function () {
|
|
191
|
+
}
|
|
192
|
+
}
|
|
193
|
+
}, [files, chunking, chunkSize, onUploading]);
|
|
194
|
+
const handlePauseUpload = (0, _react.useCallback)(() => {
|
|
343
195
|
if (onPausedUpload) onPausedUpload();
|
|
344
196
|
setIsPausing(true);
|
|
345
197
|
}, [onPausedUpload]);
|
|
346
|
-
|
|
198
|
+
const handleResumeUpload = (0, _react.useCallback)(() => {
|
|
347
199
|
setIsPausing(false);
|
|
348
200
|
}, []);
|
|
349
|
-
|
|
350
|
-
|
|
351
|
-
|
|
201
|
+
const handleRetryUpload = (0, _react.useCallback)(() => {
|
|
202
|
+
const retryIndexes = [...failUploadIndexes];
|
|
352
203
|
setHasFail(false);
|
|
353
204
|
setFailUploadIndexes([]);
|
|
354
|
-
retryIndexes.forEach(
|
|
205
|
+
retryIndexes.forEach(index => {
|
|
355
206
|
handleUpload(index, false);
|
|
356
207
|
});
|
|
357
208
|
}, [failUploadIndexes, handleUpload]);
|
|
358
|
-
|
|
209
|
+
const handleCancelUpload = (0, _react.useCallback)(event => {
|
|
359
210
|
event.stopPropagation();
|
|
360
211
|
if (onCanceledFile) onCanceledFile(files[0]);
|
|
361
212
|
handleReset();
|
|
362
213
|
}, [files, onCanceledFile, handleReset]);
|
|
363
|
-
|
|
214
|
+
const handleRemoveFile = (0, _react.useCallback)(event => {
|
|
364
215
|
if (event) event.stopPropagation();
|
|
365
216
|
if (onRemovedFile) onRemovedFile(files[0]);
|
|
366
217
|
handleReset();
|
|
367
218
|
}, [files, onRemovedFile, handleReset]);
|
|
368
|
-
|
|
219
|
+
const handleComplete = (0, _react.useCallback)(() => {
|
|
369
220
|
if (onCompleted) {
|
|
370
221
|
onCompleted();
|
|
371
222
|
setIsCompleted(true);
|
|
372
223
|
}
|
|
373
224
|
}, [onCompleted]);
|
|
374
|
-
|
|
225
|
+
const handleError = (0, _react.useCallback)(() => {
|
|
375
226
|
if (onError) onError();
|
|
376
227
|
}, [onError]);
|
|
377
|
-
|
|
228
|
+
const messageItem = (0, _react.useMemo)(() => {
|
|
378
229
|
return /*#__PURE__*/(0, _jsxRuntime.jsxs)(_Message.default, {
|
|
379
230
|
dragging: dragging,
|
|
380
231
|
children: [/*#__PURE__*/(0, _jsxRuntime.jsx)(_fi.FiUpload, {
|
|
@@ -386,11 +237,10 @@ var FileDropzone = function FileDropzone(_ref) {
|
|
|
386
237
|
})]
|
|
387
238
|
});
|
|
388
239
|
}, [dragging, message]);
|
|
389
|
-
|
|
240
|
+
const previewItem = (0, _react.useMemo)(() => {
|
|
390
241
|
if (files.length === 0) {
|
|
391
242
|
return null;
|
|
392
243
|
}
|
|
393
|
-
|
|
394
244
|
return /*#__PURE__*/(0, _jsxRuntime.jsxs)(Preview, {
|
|
395
245
|
children: [/*#__PURE__*/(0, _jsxRuntime.jsx)(PreviewImage, {
|
|
396
246
|
children: /*#__PURE__*/(0, _jsxRuntime.jsx)("img", {
|
|
@@ -438,32 +288,35 @@ var FileDropzone = function FileDropzone(_ref) {
|
|
|
438
288
|
})]
|
|
439
289
|
})]
|
|
440
290
|
});
|
|
441
|
-
}, [texts, files, percentage, chunking, isPausing, state.isUploading, hasFail, handleCancelUpload, handlePauseUpload, handleRemoveFile, handleResumeUpload, handleRetryUpload]);
|
|
291
|
+
}, [texts, files, percentage, chunking, isPausing, state.isUploading, hasFail, handleCancelUpload, handlePauseUpload, handleRemoveFile, handleResumeUpload, handleRetryUpload]);
|
|
442
292
|
|
|
443
|
-
|
|
293
|
+
// uploading
|
|
294
|
+
(0, _react.useEffect)(() => {
|
|
444
295
|
if (state.isUploading && !isPausing) {
|
|
445
296
|
if (index < total) {
|
|
446
297
|
handleUpload(index);
|
|
447
298
|
}
|
|
448
299
|
}
|
|
449
|
-
}, [state.isUploading, isPausing, total, index, handleUpload]);
|
|
300
|
+
}, [state.isUploading, isPausing, total, index, handleUpload]);
|
|
450
301
|
|
|
451
|
-
|
|
302
|
+
// removing
|
|
303
|
+
(0, _react.useEffect)(() => {
|
|
452
304
|
if (state.isRemoving) {
|
|
453
305
|
handleRemoveFile();
|
|
454
306
|
}
|
|
455
|
-
}, [state.isRemoving, handleRemoveFile]);
|
|
307
|
+
}, [state.isRemoving, handleRemoveFile]);
|
|
456
308
|
|
|
457
|
-
|
|
309
|
+
// set percentage and check complete
|
|
310
|
+
(0, _react.useEffect)(() => {
|
|
458
311
|
if (total <= 0) return;
|
|
459
312
|
setPercentage(Math.ceil(successCount / total * 100));
|
|
460
|
-
|
|
461
313
|
if (!isCompleted && successCount === total) {
|
|
462
314
|
handleComplete();
|
|
463
315
|
}
|
|
464
|
-
}, [total, isCompleted, successCount, handleComplete]);
|
|
316
|
+
}, [total, isCompleted, successCount, handleComplete]);
|
|
465
317
|
|
|
466
|
-
|
|
318
|
+
// check has upload fail
|
|
319
|
+
(0, _react.useEffect)(() => {
|
|
467
320
|
if (hasFail && successCount + failUploadIndexes.length === total) {
|
|
468
321
|
handleError();
|
|
469
322
|
}
|
|
@@ -486,49 +339,42 @@ var FileDropzone = function FileDropzone(_ref) {
|
|
|
486
339
|
}), files.length === 0 ? messageItem : previewItem]
|
|
487
340
|
});
|
|
488
341
|
};
|
|
489
|
-
|
|
490
|
-
|
|
491
|
-
|
|
342
|
+
const Dropzone = _styledComponents.default.div(_templateObject || (_templateObject = _taggedTemplateLiteral(["\n min-height: 200px;\n border: 4px dashed var(--border-color);\n border-radius: var(--border-radius);\n color: var(--font-on-background);\n display: flex;\n flex-direction: column;\n justify-content: center;\n align-items: center;\n padding: 0 var(--spacing-s);\n cursor: ", ";\n\n ", ";\n\n &:focus {\n border-color: var(--color-primary);\n }\n"])), _ref2 => {
|
|
343
|
+
let {
|
|
344
|
+
reachedLimit
|
|
345
|
+
} = _ref2;
|
|
492
346
|
return reachedLimit ? 'default' : 'pointer';
|
|
493
|
-
},
|
|
494
|
-
|
|
347
|
+
}, _ref3 => {
|
|
348
|
+
let {
|
|
349
|
+
dragging
|
|
350
|
+
} = _ref3;
|
|
495
351
|
return dragging && 'border-color: var(--color-primary);';
|
|
496
352
|
});
|
|
497
|
-
|
|
498
353
|
Dropzone.displayName = 'Dropzone';
|
|
499
|
-
|
|
500
|
-
var Preview = _styledComponents.default.div(_templateObject2 || (_templateObject2 = _taggedTemplateLiteral(["\n max-width: 50%;\n display: flex;\n align-items: center;\n text-align: center;\n\n ", "\n\n ", "\n"])), _media.default.laptop(_templateObject3 || (_templateObject3 = _taggedTemplateLiteral(["\n max-width: 75%;\n "]))), _media.default.tablet(_templateObject4 || (_templateObject4 = _taggedTemplateLiteral(["\n max-width: 100%;\n "]))));
|
|
501
|
-
|
|
354
|
+
const Preview = _styledComponents.default.div(_templateObject2 || (_templateObject2 = _taggedTemplateLiteral(["\n max-width: 50%;\n display: flex;\n align-items: center;\n text-align: center;\n\n ", "\n\n ", "\n"])), _media.default.laptop(_templateObject3 || (_templateObject3 = _taggedTemplateLiteral(["\n max-width: 75%;\n "]))), _media.default.tablet(_templateObject4 || (_templateObject4 = _taggedTemplateLiteral(["\n max-width: 100%;\n "]))));
|
|
502
355
|
Preview.displayName = 'Preview';
|
|
503
|
-
|
|
504
|
-
var PreviewImage = _styledComponents.default.div(_templateObject5 || (_templateObject5 = _taggedTemplateLiteral(["\n margin-right: var(--spacing-xs);\n\n > img {\n width: 120px;\n margin-bottom: var(--spacing-xs);\n }\n"])));
|
|
505
|
-
|
|
356
|
+
const PreviewImage = _styledComponents.default.div(_templateObject5 || (_templateObject5 = _taggedTemplateLiteral(["\n margin-right: var(--spacing-xs);\n\n > img {\n width: 120px;\n margin-bottom: var(--spacing-xs);\n }\n"])));
|
|
506
357
|
PreviewImage.displayName = 'PreviewImage';
|
|
507
|
-
|
|
508
|
-
var PreviewDetails = _styledComponents.default.div(_templateObject6 || (_templateObject6 = _taggedTemplateLiteral(["\n overflow: hidden;\n min-width: 200px;\n\n > * {\n margin-bottom: var(--spacing-xs);\n }\n\n > .ellipsis {\n overflow: hidden;\n white-space: nowrap;\n text-overflow: ellipsis;\n }\n"])));
|
|
509
|
-
|
|
358
|
+
const PreviewDetails = _styledComponents.default.div(_templateObject6 || (_templateObject6 = _taggedTemplateLiteral(["\n overflow: hidden;\n min-width: 200px;\n\n > * {\n margin-bottom: var(--spacing-xs);\n }\n\n > .ellipsis {\n overflow: hidden;\n white-space: nowrap;\n text-overflow: ellipsis;\n }\n"])));
|
|
510
359
|
PreviewDetails.displayName = 'PreviewDetails';
|
|
360
|
+
const Progress = _styledComponents.default.div(_templateObject7 || (_templateObject7 = _taggedTemplateLiteral(["\n display: flex;\n justify-content: center;\n align-items: center;\n"])));
|
|
511
361
|
|
|
512
|
-
|
|
513
|
-
|
|
514
|
-
|
|
515
|
-
|
|
516
|
-
|
|
362
|
+
// fix:color
|
|
363
|
+
const ProgressBar = _styledComponents.default.div(_templateObject8 || (_templateObject8 = _taggedTemplateLiteral(["\n flex: 1;\n height: 1.25rem;\n border-radius: var(--border-radius);\n position: relative;\n overflow: hidden;\n border: 1px solid var(--color-primary);\n\n &::before {\n position: absolute;\n content: '';\n width: ", "%;\n top: 0;\n bottom: 0;\n left: 0;\n right: 0;\n background: linear-gradient(to bottom, #00bdff, #597ef7);\n transition: width 300ms ease-in-out;\n }\n\n > span {\n position: absolute;\n width: 100%;\n top: 0;\n bottom: 0;\n left: 0;\n right: 0;\n }\n"])), _ref4 => {
|
|
364
|
+
let {
|
|
365
|
+
percentage
|
|
366
|
+
} = _ref4;
|
|
517
367
|
return percentage;
|
|
518
368
|
});
|
|
519
|
-
|
|
520
369
|
ProgressBar.displayName = 'ProgressBar';
|
|
521
|
-
|
|
522
|
-
|
|
523
|
-
|
|
524
|
-
|
|
525
|
-
|
|
526
|
-
}
|
|
527
|
-
var danger = _ref6.danger;
|
|
370
|
+
const Button = _styledComponents.default.span.attrs(() => ({
|
|
371
|
+
role: 'button'
|
|
372
|
+
}))(_templateObject9 || (_templateObject9 = _taggedTemplateLiteral(["\n display: flex;\n justify-content: center;\n align-items: center;\n flex: 0 0 auto;\n cursor: pointer;\n width: 1.25rem;\n height: 1.25rem;\n color: var(--font-on-primary);\n background: var(--color-primary);\n border-radius: var(--border-radius);\n margin-left: var(--spacing-xs);\n padding: 0.25rem;\n\n ", "\n"])), _ref5 => {
|
|
373
|
+
let {
|
|
374
|
+
danger
|
|
375
|
+
} = _ref5;
|
|
528
376
|
return danger && "\n background: var(--color-danger);\n ";
|
|
529
377
|
});
|
|
530
|
-
|
|
531
|
-
|
|
532
|
-
var
|
|
533
|
-
var _default = FileDropzone;
|
|
534
|
-
exports.default = _default;
|
|
378
|
+
const PauseButton = (0, _styledComponents.default)(Button)(_templateObject10 || (_templateObject10 = _taggedTemplateLiteral(["\n padding: 5px;\n"])));
|
|
379
|
+
const ResumeButton = (0, _styledComponents.default)(Button)(_templateObject11 || (_templateObject11 = _taggedTemplateLiteral(["\n padding: 5px 5px 5px 6px;\n"])));
|
|
380
|
+
var _default = exports.default = FileDropzone;
|