@douyinfe/semi-foundation 2.19.0-beta.0 → 2.19.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/anchor/anchor.scss +1 -8
- package/anchor/rtl.scss +0 -1
- package/anchor/variables.scss +1 -0
- package/calendar/eventUtil.ts +8 -7
- package/calendar/foundation.ts +14 -14
- package/datePicker/monthsGridFoundation.ts +10 -3
- package/dropdown/foundation.ts +2 -1
- package/dropdown/menuFoundation.ts +2 -1
- package/getBabelConfig.js +0 -12
- package/lib/cjs/anchor/anchor.css +1 -10
- package/lib/cjs/anchor/anchor.scss +1 -8
- package/lib/cjs/anchor/constants.js +1 -4
- package/lib/cjs/anchor/foundation.js +5 -12
- package/lib/cjs/anchor/linkFoundation.js +4 -9
- package/lib/cjs/anchor/rtl.scss +0 -1
- package/lib/cjs/anchor/variables.scss +1 -0
- package/lib/cjs/autoComplete/constants.js +1 -4
- package/lib/cjs/autoComplete/foundation.js +14 -33
- package/lib/cjs/autoComplete/optionFoundation.js +4 -9
- package/lib/cjs/avatar/constants.js +1 -4
- package/lib/cjs/avatar/foundation.js +4 -9
- package/lib/cjs/backtop/constants.js +1 -4
- package/lib/cjs/backtop/foundation.js +4 -9
- package/lib/cjs/badge/constants.js +1 -4
- package/lib/cjs/banner/constants.js +1 -4
- package/lib/cjs/banner/foundation.js +4 -9
- package/lib/cjs/base/constants.js +2 -6
- package/lib/cjs/base/env.js +1 -4
- package/lib/cjs/base/foundation.js +5 -10
- package/lib/cjs/base/index.js +3 -6
- package/lib/cjs/breadcrumb/constants.js +1 -4
- package/lib/cjs/breadcrumb/foundation.js +6 -13
- package/lib/cjs/breadcrumb/itemFoundation.js +4 -9
- package/lib/cjs/button/constants.js +1 -4
- package/lib/cjs/calendar/constants.js +1 -4
- package/lib/cjs/calendar/eventUtil.d.ts +3 -3
- package/lib/cjs/calendar/eventUtil.js +28 -53
- package/lib/cjs/calendar/foundation.js +63 -85
- package/lib/cjs/card/constants.js +1 -4
- package/lib/cjs/carousel/constants.js +1 -4
- package/lib/cjs/carousel/foundation.js +5 -12
- package/lib/cjs/cascader/constants.js +1 -4
- package/lib/cjs/cascader/foundation.js +55 -100
- package/lib/cjs/cascader/util.js +9 -30
- package/lib/cjs/checkbox/checkboxFoundation.js +6 -13
- package/lib/cjs/checkbox/checkboxGroupFoundation.js +9 -18
- package/lib/cjs/checkbox/constants.js +1 -4
- package/lib/cjs/collapse/constants.js +1 -4
- package/lib/cjs/collapse/foundation.js +9 -20
- package/lib/cjs/collapsible/constants.js +1 -4
- package/lib/cjs/datePicker/_utils/formatter.js +3 -12
- package/lib/cjs/datePicker/_utils/getDayOfWeek.js +1 -4
- package/lib/cjs/datePicker/_utils/getDefaultFormatToken.js +1 -4
- package/lib/cjs/datePicker/_utils/getDefaultPickerDate.js +5 -10
- package/lib/cjs/datePicker/_utils/getFullDateOffset.js +3 -6
- package/lib/cjs/datePicker/_utils/getInsetInputFormatToken.js +2 -11
- package/lib/cjs/datePicker/_utils/getInsetInputValueFromInsetInputStr.js +1 -4
- package/lib/cjs/datePicker/_utils/getMonthTable.js +2 -11
- package/lib/cjs/datePicker/_utils/getMonthsInYear.js +3 -16
- package/lib/cjs/datePicker/_utils/getYears.js +2 -9
- package/lib/cjs/datePicker/_utils/index.js +16 -30
- package/lib/cjs/datePicker/_utils/isAfter.js +3 -6
- package/lib/cjs/datePicker/_utils/isBefore.js +3 -6
- package/lib/cjs/datePicker/_utils/isBetween.js +3 -6
- package/lib/cjs/datePicker/_utils/isDate.js +1 -4
- package/lib/cjs/datePicker/_utils/isSameDay.js +3 -6
- package/lib/cjs/datePicker/_utils/isTimestamp.js +3 -6
- package/lib/cjs/datePicker/_utils/isUnixTimestamp.js +3 -6
- package/lib/cjs/datePicker/_utils/isValidDate.js +1 -4
- package/lib/cjs/datePicker/_utils/isWithinInterval.js +3 -6
- package/lib/cjs/datePicker/_utils/parser.js +1 -4
- package/lib/cjs/datePicker/constants.js +3 -10
- package/lib/cjs/datePicker/foundation.js +42 -85
- package/lib/cjs/datePicker/inputFoundation.js +7 -20
- package/lib/cjs/datePicker/monthFoundation.js +5 -12
- package/lib/cjs/datePicker/monthsGridFoundation.js +47 -68
- package/lib/cjs/datePicker/yearAndMonthFoundation.js +4 -9
- package/lib/cjs/descriptions/constants.js +1 -4
- package/lib/cjs/divider/constants.js +1 -4
- package/lib/cjs/dropdown/constants.js +1 -4
- package/lib/cjs/dropdown/foundation.js +7 -15
- package/lib/cjs/dropdown/menuFoundation.js +11 -31
- package/lib/cjs/empty/constants.js +1 -4
- package/lib/cjs/form/constants.js +1 -4
- package/lib/cjs/form/foundation.js +64 -104
- package/lib/cjs/form/interface.js +1 -3
- package/lib/cjs/form/utils.js +14 -29
- package/lib/cjs/grid/constants.js +1 -4
- package/lib/cjs/icons/constants.js +1 -4
- package/lib/cjs/input/constants.js +1 -4
- package/lib/cjs/input/foundation.js +7 -18
- package/lib/cjs/input/textareaFoundation.js +6 -13
- package/lib/cjs/input/util/calculateNodeHeight.js +3 -17
- package/lib/cjs/input/util/getSizingData.js +5 -10
- package/lib/cjs/inputNumber/constants.js +4 -11
- package/lib/cjs/inputNumber/foundation.js +11 -30
- package/lib/cjs/layout/constants.js +1 -4
- package/lib/cjs/list/constants.js +1 -4
- package/lib/cjs/modal/constants.js +1 -4
- package/lib/cjs/modal/modalContentFoundation.js +4 -9
- package/lib/cjs/modal/modalFoundation.js +4 -9
- package/lib/cjs/navigation/NavItem.js +6 -21
- package/lib/cjs/navigation/constants.js +1 -4
- package/lib/cjs/navigation/foundation.js +22 -37
- package/lib/cjs/navigation/itemFoundation.js +4 -9
- package/lib/cjs/navigation/subNavFoundation.js +10 -21
- package/lib/cjs/notification/constants.js +1 -4
- package/lib/cjs/notification/notificationFoundation.js +5 -12
- package/lib/cjs/notification/notificationListFoundation.js +4 -9
- package/lib/cjs/overflowList/constants.js +3 -10
- package/lib/cjs/overflowList/foundation.js +12 -29
- package/lib/cjs/pagination/constants.js +1 -4
- package/lib/cjs/pagination/foundation.js +18 -37
- package/lib/cjs/popconfirm/constants.js +1 -4
- package/lib/cjs/popconfirm/popconfirmFoundation.js +3 -6
- package/lib/cjs/popover/constants.js +2 -9
- package/lib/cjs/progress/constants.js +1 -4
- package/lib/cjs/radio/constants.js +1 -4
- package/lib/cjs/radio/radioFoundation.js +3 -6
- package/lib/cjs/radio/radioGroupFoundation.js +6 -11
- package/lib/cjs/radio/radioInnerFoundation.js +5 -10
- package/lib/cjs/rating/constants.js +1 -4
- package/lib/cjs/rating/foundation.js +7 -20
- package/lib/cjs/scrollList/constants.js +1 -4
- package/lib/cjs/scrollList/foundation.js +3 -6
- package/lib/cjs/scrollList/itemFoundation.js +8 -21
- package/lib/cjs/scrollList/scrollTo.js +1 -4
- package/lib/cjs/select/constants.js +1 -4
- package/lib/cjs/select/foundation.js +56 -98
- package/lib/cjs/select/optionFoundation.js +4 -9
- package/lib/cjs/sideSheet/constants.js +1 -4
- package/lib/cjs/sideSheet/sideSheetFoundation.js +6 -15
- package/lib/cjs/skeleton/constants.js +1 -4
- package/lib/cjs/slider/constants.js +1 -4
- package/lib/cjs/slider/foundation.js +13 -24
- package/lib/cjs/space/constants.js +1 -4
- package/lib/cjs/spin/constants.js +1 -4
- package/lib/cjs/spin/foundation.js +5 -12
- package/lib/cjs/steps/constants.js +1 -4
- package/lib/cjs/switch/constants.js +1 -4
- package/lib/cjs/switch/foundation.js +4 -9
- package/lib/cjs/table/bodyFoundation.js +9 -22
- package/lib/cjs/table/cellFoundation.js +3 -6
- package/lib/cjs/table/constants.js +1 -4
- package/lib/cjs/table/foundation.js +76 -117
- package/lib/cjs/table/tableRowFoundation.js +3 -6
- package/lib/cjs/table/tableSelectionCellFoundation.js +3 -6
- package/lib/cjs/table/utils.js +42 -71
- package/lib/cjs/tabs/constants.js +1 -4
- package/lib/cjs/tabs/foundation.js +8 -23
- package/lib/cjs/tag/constants.js +1 -4
- package/lib/cjs/tagInput/constants.js +1 -4
- package/lib/cjs/tagInput/foundation.js +12 -31
- package/lib/cjs/tagInput/utils/getSplitedArray.js +3 -6
- package/lib/cjs/timePicker/ComboxFoundation.js +10 -29
- package/lib/cjs/timePicker/constants.js +1 -4
- package/lib/cjs/timePicker/foundation.js +26 -45
- package/lib/cjs/timePicker/inputFoundation.js +4 -9
- package/lib/cjs/timePicker/utils/index.js +7 -14
- package/lib/cjs/timePicker/utils/localeDate.js +2 -9
- package/lib/cjs/timeline/constants.js +1 -4
- package/lib/cjs/toast/constants.js +1 -4
- package/lib/cjs/toast/toastFoundation.js +5 -12
- package/lib/cjs/toast/toastListFoundation.js +5 -12
- package/lib/cjs/tooltip/constants.js +1 -4
- package/lib/cjs/tooltip/foundation.js +29 -56
- package/lib/cjs/transfer/constants.js +1 -4
- package/lib/cjs/transfer/foundation.js +24 -47
- package/lib/cjs/transfer/transferUtils.js +16 -45
- package/lib/cjs/tree/constants.js +1 -4
- package/lib/cjs/tree/foundation.js +41 -76
- package/lib/cjs/tree/treeUtil.js +60 -107
- package/lib/cjs/treeSelect/constants.js +1 -4
- package/lib/cjs/treeSelect/foundation.js +49 -82
- package/lib/cjs/typography/constants.js +1 -4
- package/lib/cjs/upload/constants.js +1 -4
- package/lib/cjs/upload/foundation.js +56 -112
- package/lib/cjs/upload/utils.js +13 -32
- package/lib/cjs/utils/Event.js +9 -23
- package/lib/cjs/utils/FocusHandle.js +6 -15
- package/lib/cjs/utils/Logger.js +1 -4
- package/lib/cjs/utils/Store.js +5 -20
- package/lib/cjs/utils/a11y.js +8 -13
- package/lib/cjs/utils/array.js +6 -15
- package/lib/cjs/utils/arrayMove.js +3 -12
- package/lib/cjs/utils/classnames.js +6 -15
- package/lib/cjs/utils/date-fns-extra.js +7 -18
- package/lib/cjs/utils/dom.js +5 -12
- package/lib/cjs/utils/function.js +1 -4
- package/lib/cjs/utils/getDataAttr.js +2 -13
- package/lib/cjs/utils/getHighlight.js +7 -22
- package/lib/cjs/utils/getMotionObjFromProps.js +4 -9
- package/lib/cjs/utils/index.js +5 -15
- package/lib/cjs/utils/isBothNaN.js +1 -4
- package/lib/cjs/utils/isElement.js +1 -4
- package/lib/cjs/utils/isEnterPress.js +3 -6
- package/lib/cjs/utils/isEscPress.js +3 -6
- package/lib/cjs/utils/isNullOrUndefined.js +1 -4
- package/lib/cjs/utils/isNumber.js +1 -4
- package/lib/cjs/utils/isObject.js +1 -4
- package/lib/cjs/utils/isPromise.js +3 -6
- package/lib/cjs/utils/isString.js +1 -4
- package/lib/cjs/utils/keyCode.js +1 -4
- package/lib/cjs/utils/log.js +3 -6
- package/lib/cjs/utils/number.js +1 -4
- package/lib/cjs/utils/object.js +10 -27
- package/lib/cjs/utils/set.js +4 -9
- package/lib/cjs/utils/shallowEqualObjects.js +3 -10
- package/lib/cjs/utils/touchPolyfill.js +5 -12
- package/lib/cjs/utils/type.js +1 -3
- package/lib/cjs/utils/uuid.js +3 -14
- package/lib/cjs/utils/warning.js +1 -4
- package/lib/es/anchor/anchor.css +1 -10
- package/lib/es/anchor/anchor.scss +1 -8
- package/lib/es/anchor/foundation.js +2 -4
- package/lib/es/anchor/linkFoundation.js +1 -2
- package/lib/es/anchor/rtl.scss +0 -1
- package/lib/es/anchor/variables.scss +1 -0
- package/lib/es/autoComplete/foundation.js +11 -26
- package/lib/es/autoComplete/optionFoundation.js +1 -2
- package/lib/es/avatar/foundation.js +1 -2
- package/lib/es/backtop/foundation.js +1 -2
- package/lib/es/banner/foundation.js +1 -2
- package/lib/es/base/foundation.js +2 -3
- package/lib/es/breadcrumb/foundation.js +3 -6
- package/lib/es/breadcrumb/itemFoundation.js +1 -2
- package/lib/es/calendar/eventUtil.d.ts +3 -3
- package/lib/es/calendar/eventUtil.js +27 -56
- package/lib/es/calendar/foundation.js +60 -90
- package/lib/es/carousel/foundation.js +2 -4
- package/lib/es/cascader/foundation.js +49 -94
- package/lib/es/cascader/util.js +6 -21
- package/lib/es/checkbox/checkboxFoundation.js +3 -6
- package/lib/es/checkbox/checkboxGroupFoundation.js +6 -9
- package/lib/es/collapse/foundation.js +6 -10
- package/lib/es/datePicker/_utils/formatter.js +2 -5
- package/lib/es/datePicker/_utils/getDefaultPickerDate.js +2 -3
- package/lib/es/datePicker/_utils/getInsetInputFormatToken.js +1 -4
- package/lib/es/datePicker/_utils/getMonthTable.js +1 -5
- package/lib/es/datePicker/_utils/getMonthsInYear.js +2 -9
- package/lib/es/datePicker/_utils/getYears.js +1 -3
- package/lib/es/datePicker/constants.js +2 -7
- package/lib/es/datePicker/foundation.js +39 -70
- package/lib/es/datePicker/inputFoundation.js +4 -11
- package/lib/es/datePicker/monthFoundation.js +2 -4
- package/lib/es/datePicker/monthsGridFoundation.js +40 -55
- package/lib/es/datePicker/yearAndMonthFoundation.js +1 -2
- package/lib/es/dropdown/foundation.js +4 -7
- package/lib/es/dropdown/menuFoundation.js +8 -21
- package/lib/es/form/foundation.js +59 -91
- package/lib/es/form/utils.js +11 -19
- package/lib/es/input/foundation.js +4 -9
- package/lib/es/input/textareaFoundation.js +3 -5
- package/lib/es/input/util/calculateNodeHeight.js +2 -10
- package/lib/es/input/util/getSizingData.js +2 -5
- package/lib/es/inputNumber/constants.js +3 -8
- package/lib/es/inputNumber/foundation.js +8 -18
- package/lib/es/modal/modalContentFoundation.js +1 -2
- package/lib/es/modal/modalFoundation.js +1 -2
- package/lib/es/navigation/NavItem.js +5 -11
- package/lib/es/navigation/foundation.js +19 -25
- package/lib/es/navigation/itemFoundation.js +1 -3
- package/lib/es/navigation/subNavFoundation.js +7 -13
- package/lib/es/notification/notificationFoundation.js +2 -4
- package/lib/es/notification/notificationListFoundation.js +1 -3
- package/lib/es/overflowList/constants.js +2 -3
- package/lib/es/overflowList/foundation.js +9 -23
- package/lib/es/pagination/foundation.js +15 -28
- package/lib/es/popover/constants.js +1 -2
- package/lib/es/radio/radioGroupFoundation.js +3 -4
- package/lib/es/radio/radioInnerFoundation.js +2 -3
- package/lib/es/rating/foundation.js +4 -13
- package/lib/es/scrollList/itemFoundation.js +5 -13
- package/lib/es/select/foundation.js +50 -88
- package/lib/es/select/optionFoundation.js +1 -2
- package/lib/es/sideSheet/sideSheetFoundation.js +3 -7
- package/lib/es/slider/foundation.js +10 -16
- package/lib/es/spin/foundation.js +2 -4
- package/lib/es/switch/foundation.js +1 -2
- package/lib/es/table/bodyFoundation.js +6 -11
- package/lib/es/table/foundation.js +67 -93
- package/lib/es/table/utils.js +33 -51
- package/lib/es/tabs/foundation.js +5 -18
- package/lib/es/tagInput/foundation.js +9 -21
- package/lib/es/timePicker/ComboxFoundation.js +7 -16
- package/lib/es/timePicker/foundation.js +23 -37
- package/lib/es/timePicker/inputFoundation.js +1 -2
- package/lib/es/timePicker/utils/index.js +4 -6
- package/lib/es/timePicker/utils/localeDate.js +1 -2
- package/lib/es/toast/toastFoundation.js +2 -4
- package/lib/es/toast/toastListFoundation.js +2 -4
- package/lib/es/tooltip/foundation.js +26 -46
- package/lib/es/transfer/foundation.js +21 -43
- package/lib/es/transfer/transferUtils.js +13 -33
- package/lib/es/tree/foundation.js +38 -70
- package/lib/es/tree/treeUtil.js +57 -109
- package/lib/es/treeSelect/foundation.js +45 -73
- package/lib/es/upload/foundation.js +52 -118
- package/lib/es/upload/utils.js +12 -25
- package/lib/es/utils/Event.js +5 -12
- package/lib/es/utils/FocusHandle.js +3 -7
- package/lib/es/utils/Store.js +4 -12
- package/lib/es/utils/a11y.js +5 -6
- package/lib/es/utils/array.js +3 -5
- package/lib/es/utils/arrayMove.js +2 -6
- package/lib/es/utils/classnames.js +3 -6
- package/lib/es/utils/date-fns-extra.js +6 -14
- package/lib/es/utils/dom.js +1 -2
- package/lib/es/utils/getDataAttr.js +1 -5
- package/lib/es/utils/getHighlight.js +4 -14
- package/lib/es/utils/getMotionObjFromProps.js +1 -2
- package/lib/es/utils/object.js +7 -15
- package/lib/es/utils/set.js +1 -2
- package/lib/es/utils/shallowEqualObjects.js +2 -5
- package/lib/es/utils/touchPolyfill.js +2 -6
- package/lib/es/utils/uuid.js +2 -7
- package/package.json +2 -4
- package/select/foundation.ts +2 -2
|
@@ -1,45 +1,10 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
var _Object$defineProperty = require("@babel/runtime-corejs3/core-js-stable/object/define-property");
|
|
6
|
-
|
|
7
|
-
var _interopRequireDefault = require("@babel/runtime-corejs3/helpers/interopRequireDefault");
|
|
8
|
-
|
|
9
|
-
_Object$defineProperty(exports, "__esModule", {
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
10
4
|
value: true
|
|
11
5
|
});
|
|
12
|
-
|
|
13
6
|
exports.default = void 0;
|
|
14
7
|
|
|
15
|
-
var _promise = _interopRequireDefault(require("@babel/runtime-corejs3/core-js-stable/promise"));
|
|
16
|
-
|
|
17
|
-
var _assign = _interopRequireDefault(require("@babel/runtime-corejs3/core-js-stable/object/assign"));
|
|
18
|
-
|
|
19
|
-
var _concat = _interopRequireDefault(require("@babel/runtime-corejs3/core-js-stable/instance/concat"));
|
|
20
|
-
|
|
21
|
-
var _from = _interopRequireDefault(require("@babel/runtime-corejs3/core-js-stable/array/from"));
|
|
22
|
-
|
|
23
|
-
var _filter = _interopRequireDefault(require("@babel/runtime-corejs3/core-js-stable/instance/filter"));
|
|
24
|
-
|
|
25
|
-
var _map = _interopRequireDefault(require("@babel/runtime-corejs3/core-js-stable/instance/map"));
|
|
26
|
-
|
|
27
|
-
var _slice = _interopRequireDefault(require("@babel/runtime-corejs3/core-js-stable/instance/slice"));
|
|
28
|
-
|
|
29
|
-
var _splice = _interopRequireDefault(require("@babel/runtime-corejs3/core-js-stable/instance/splice"));
|
|
30
|
-
|
|
31
|
-
var _forEach = _interopRequireDefault(require("@babel/runtime-corejs3/core-js-stable/instance/for-each"));
|
|
32
|
-
|
|
33
|
-
var _findIndex = _interopRequireDefault(require("@babel/runtime-corejs3/core-js-stable/instance/find-index"));
|
|
34
|
-
|
|
35
|
-
var _keys = _interopRequireDefault(require("@babel/runtime-corejs3/core-js-stable/object/keys"));
|
|
36
|
-
|
|
37
|
-
var _url = _interopRequireDefault(require("@babel/runtime-corejs3/core-js-stable/url"));
|
|
38
|
-
|
|
39
|
-
var _trim = _interopRequireDefault(require("@babel/runtime-corejs3/core-js-stable/instance/trim"));
|
|
40
|
-
|
|
41
|
-
var _some = _interopRequireDefault(require("@babel/runtime-corejs3/core-js-stable/instance/some"));
|
|
42
|
-
|
|
43
8
|
var _foundation = _interopRequireDefault(require("../base/foundation"));
|
|
44
9
|
|
|
45
10
|
var _isPromise = _interopRequireDefault(require("../utils/isPromise"));
|
|
@@ -50,6 +15,8 @@ var _constants = require("./constants");
|
|
|
50
15
|
|
|
51
16
|
var _utils = require("./utils");
|
|
52
17
|
|
|
18
|
+
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
19
|
+
|
|
53
20
|
var __awaiter = void 0 && (void 0).__awaiter || function (thisArg, _arguments, P, generator) {
|
|
54
21
|
function adopt(value) {
|
|
55
22
|
return value instanceof P ? value : new P(function (resolve) {
|
|
@@ -57,7 +24,7 @@ var __awaiter = void 0 && (void 0).__awaiter || function (thisArg, _arguments, P
|
|
|
57
24
|
});
|
|
58
25
|
}
|
|
59
26
|
|
|
60
|
-
return new (P || (P =
|
|
27
|
+
return new (P || (P = Promise))(function (resolve, reject) {
|
|
61
28
|
function fulfilled(value) {
|
|
62
29
|
try {
|
|
63
30
|
step(generator.next(value));
|
|
@@ -95,7 +62,7 @@ const {
|
|
|
95
62
|
|
|
96
63
|
class UploadFoundation extends _foundation.default {
|
|
97
64
|
constructor(adapter) {
|
|
98
|
-
super(
|
|
65
|
+
super(Object.assign({}, adapter));
|
|
99
66
|
}
|
|
100
67
|
|
|
101
68
|
destroy() {
|
|
@@ -103,8 +70,6 @@ class UploadFoundation extends _foundation.default {
|
|
|
103
70
|
}
|
|
104
71
|
|
|
105
72
|
getError(_ref) {
|
|
106
|
-
var _context, _context2;
|
|
107
|
-
|
|
108
73
|
let {
|
|
109
74
|
action,
|
|
110
75
|
xhr,
|
|
@@ -112,7 +77,7 @@ class UploadFoundation extends _foundation.default {
|
|
|
112
77
|
fileName
|
|
113
78
|
} = _ref;
|
|
114
79
|
const status = xhr ? xhr.status : 0;
|
|
115
|
-
const msg = message ||
|
|
80
|
+
const msg = message || "cannot post ".concat(fileName, " to ").concat(action, ", xhr status: ").concat(status, "'");
|
|
116
81
|
const err = new Error(msg);
|
|
117
82
|
err.status = status;
|
|
118
83
|
err.method = 'post';
|
|
@@ -195,10 +160,10 @@ class UploadFoundation extends _foundation.default {
|
|
|
195
160
|
const {
|
|
196
161
|
fileList
|
|
197
162
|
} = this.getStates();
|
|
198
|
-
let files =
|
|
163
|
+
let files = Array.from(currentFileList); // When the selected file
|
|
199
164
|
|
|
200
165
|
if (typeof accept !== 'undefined') {
|
|
201
|
-
files =
|
|
166
|
+
files = files.filter(item => {
|
|
202
167
|
const isValid = this.checkFileFormat(accept, item);
|
|
203
168
|
|
|
204
169
|
if (!isValid) {
|
|
@@ -217,7 +182,7 @@ class UploadFoundation extends _foundation.default {
|
|
|
217
182
|
}
|
|
218
183
|
}
|
|
219
184
|
|
|
220
|
-
files =
|
|
185
|
+
files = files.map(file => {
|
|
221
186
|
if (transformFile) {
|
|
222
187
|
file = transformFile(file);
|
|
223
188
|
}
|
|
@@ -244,7 +209,7 @@ class UploadFoundation extends _foundation.default {
|
|
|
244
209
|
|
|
245
210
|
if (limit === 1) {
|
|
246
211
|
// Replace the current file with the last file
|
|
247
|
-
files =
|
|
212
|
+
files = files.slice(-1);
|
|
248
213
|
|
|
249
214
|
this._adapter.notifyFileSelect(files);
|
|
250
215
|
|
|
@@ -256,7 +221,7 @@ class UploadFoundation extends _foundation.default {
|
|
|
256
221
|
|
|
257
222
|
|
|
258
223
|
const restNum = limit - fileList.length;
|
|
259
|
-
files =
|
|
224
|
+
files = files.slice(0, restNum);
|
|
260
225
|
}
|
|
261
226
|
}
|
|
262
227
|
|
|
@@ -282,7 +247,7 @@ class UploadFoundation extends _foundation.default {
|
|
|
282
247
|
replaceIdx,
|
|
283
248
|
fileList
|
|
284
249
|
} = this.getStates();
|
|
285
|
-
let newFile =
|
|
250
|
+
let newFile = Array.from(currentFileList).pop();
|
|
286
251
|
|
|
287
252
|
if (typeof accept !== 'undefined') {
|
|
288
253
|
if (!this.checkFileFormat(accept, newFile)) {
|
|
@@ -311,7 +276,7 @@ class UploadFoundation extends _foundation.default {
|
|
|
311
276
|
|
|
312
277
|
const newFileItem = this.buildFileItem(newFile, uploadTrigger);
|
|
313
278
|
const newFileList = [...fileList];
|
|
314
|
-
|
|
279
|
+
newFileList.splice(replaceIdx, 1, newFileItem);
|
|
315
280
|
|
|
316
281
|
this._adapter.notifyChange({
|
|
317
282
|
currentFile: newFileItem,
|
|
@@ -363,7 +328,7 @@ class UploadFoundation extends _foundation.default {
|
|
|
363
328
|
const {
|
|
364
329
|
uploadTrigger
|
|
365
330
|
} = this.getProps();
|
|
366
|
-
const currentFiles =
|
|
331
|
+
const currentFiles = files.map(item => this.buildFileItem(item, uploadTrigger));
|
|
367
332
|
|
|
368
333
|
this._adapter.notifyChange({
|
|
369
334
|
fileList: currentFiles,
|
|
@@ -378,15 +343,13 @@ class UploadFoundation extends _foundation.default {
|
|
|
378
343
|
}
|
|
379
344
|
|
|
380
345
|
addFilesToList(files) {
|
|
381
|
-
|
|
382
|
-
|
|
383
|
-
const fileList = (0, _slice.default)(_context3 = this.getState('fileList')).call(_context3);
|
|
346
|
+
const fileList = this.getState('fileList').slice();
|
|
384
347
|
const {
|
|
385
348
|
uploadTrigger
|
|
386
349
|
} = this.getProps();
|
|
387
|
-
const currentFiles =
|
|
388
|
-
|
|
389
|
-
const index =
|
|
350
|
+
const currentFiles = files.map(item => this.buildFileItem(item, uploadTrigger));
|
|
351
|
+
currentFiles.forEach(file => {
|
|
352
|
+
const index = fileList.findIndex(item => item.uid === file.uid);
|
|
390
353
|
|
|
391
354
|
if (index !== -1) {
|
|
392
355
|
fileList[index] = file;
|
|
@@ -422,10 +385,10 @@ class UploadFoundation extends _foundation.default {
|
|
|
422
385
|
const unAcceptFileList = []; // 当次选中的文件
|
|
423
386
|
// current selected file
|
|
424
387
|
|
|
425
|
-
let currentFileList =
|
|
388
|
+
let currentFileList = Array.from(files);
|
|
426
389
|
|
|
427
390
|
if (typeof accept !== 'undefined') {
|
|
428
|
-
currentFileList =
|
|
391
|
+
currentFileList = currentFileList.filter(item => {
|
|
429
392
|
const isValid = this.checkFileFormat(accept, item);
|
|
430
393
|
|
|
431
394
|
if (!isValid) {
|
|
@@ -444,7 +407,7 @@ class UploadFoundation extends _foundation.default {
|
|
|
444
407
|
}
|
|
445
408
|
}
|
|
446
409
|
|
|
447
|
-
currentFileList =
|
|
410
|
+
currentFileList = currentFileList.map(file => {
|
|
448
411
|
if (!file.uid) {
|
|
449
412
|
file.uid = (0, _uuid.getUuidv4)();
|
|
450
413
|
}
|
|
@@ -471,7 +434,7 @@ class UploadFoundation extends _foundation.default {
|
|
|
471
434
|
if (limit === 1) {
|
|
472
435
|
// 使用最后面的文件对当前文件进行替换
|
|
473
436
|
// Use the last file to replace the current file
|
|
474
|
-
currentFileList =
|
|
437
|
+
currentFileList = currentFileList.slice(-1);
|
|
475
438
|
|
|
476
439
|
this._adapter.notifyFileSelect(currentFileList);
|
|
477
440
|
|
|
@@ -484,17 +447,17 @@ class UploadFoundation extends _foundation.default {
|
|
|
484
447
|
|
|
485
448
|
|
|
486
449
|
const restNum = limit - fileList.length;
|
|
487
|
-
currentFileList =
|
|
450
|
+
currentFileList = currentFileList.slice(0, restNum);
|
|
488
451
|
|
|
489
452
|
this._adapter.notifyExceed(currentFileList);
|
|
490
453
|
}
|
|
491
454
|
}
|
|
492
455
|
|
|
493
|
-
const fileItemList =
|
|
494
|
-
const newFileList =
|
|
456
|
+
const fileItemList = currentFileList.map(file => this.buildFileItem(file, uploadTrigger));
|
|
457
|
+
const newFileList = fileList.slice();
|
|
495
458
|
|
|
496
459
|
if (typeof index !== 'undefined') {
|
|
497
|
-
|
|
460
|
+
newFileList.splice(index, 0, ...fileItemList);
|
|
498
461
|
} else {
|
|
499
462
|
newFileList.push(...fileItemList);
|
|
500
463
|
}
|
|
@@ -516,15 +479,13 @@ class UploadFoundation extends _foundation.default {
|
|
|
516
479
|
|
|
517
480
|
|
|
518
481
|
manualUpload() {
|
|
519
|
-
var _context4;
|
|
520
|
-
|
|
521
482
|
// find the list of files that have not been uploaded
|
|
522
|
-
const waitToUploadFileList =
|
|
483
|
+
const waitToUploadFileList = this.getState('fileList').filter(item => item.status === FILE_STATUS_WAIT_UPLOAD);
|
|
523
484
|
this.startUpload(waitToUploadFileList);
|
|
524
485
|
}
|
|
525
486
|
|
|
526
487
|
startUpload(fileList) {
|
|
527
|
-
|
|
488
|
+
fileList.forEach(file => {
|
|
528
489
|
if (!file._sizeInvalid) {
|
|
529
490
|
this.upload(file);
|
|
530
491
|
}
|
|
@@ -572,35 +533,30 @@ class UploadFoundation extends _foundation.default {
|
|
|
572
533
|
|
|
573
534
|
case buResult && (0, _isPromise.default)(buResult):
|
|
574
535
|
{
|
|
575
|
-
|
|
576
|
-
var _context5;
|
|
577
|
-
|
|
536
|
+
Promise.resolve(buResult).then(resolveData => {
|
|
578
537
|
let newResult = {
|
|
579
538
|
shouldUpload: true
|
|
580
539
|
};
|
|
581
|
-
const typeOfResolveData =
|
|
540
|
+
const typeOfResolveData = Object.prototype.toString.call(resolveData).slice(8, -1);
|
|
582
541
|
|
|
583
542
|
if (typeOfResolveData === 'Object') {
|
|
584
|
-
newResult =
|
|
543
|
+
newResult = Object.assign(Object.assign({}, newResult), resolveData);
|
|
585
544
|
}
|
|
586
545
|
|
|
587
546
|
this.handleBeforeUploadResultInObject(newResult, file);
|
|
588
547
|
}, rejectVal => {
|
|
589
|
-
var _context6;
|
|
590
|
-
|
|
591
548
|
let newResult = {
|
|
592
549
|
shouldUpload: false,
|
|
593
550
|
status: _constants.strings.FILE_STATUS_VALID_FAIL
|
|
594
551
|
};
|
|
595
|
-
const typeOfRejectData =
|
|
552
|
+
const typeOfRejectData = Object.prototype.toString.call(rejectVal).slice(8, -1);
|
|
596
553
|
|
|
597
554
|
if (typeOfRejectData === 'Object') {
|
|
598
|
-
newResult =
|
|
555
|
+
newResult = Object.assign(Object.assign({}, newResult), rejectVal);
|
|
599
556
|
}
|
|
600
557
|
|
|
601
558
|
this.handleBeforeUploadResultInObject(newResult, file);
|
|
602
559
|
});
|
|
603
|
-
|
|
604
560
|
break;
|
|
605
561
|
}
|
|
606
562
|
// sync validate - object
|
|
@@ -618,8 +574,6 @@ class UploadFoundation extends _foundation.default {
|
|
|
618
574
|
|
|
619
575
|
|
|
620
576
|
handleBeforeUploadResultInObject(buResult, file) {
|
|
621
|
-
var _context7;
|
|
622
|
-
|
|
623
577
|
const {
|
|
624
578
|
shouldUpload,
|
|
625
579
|
status,
|
|
@@ -627,10 +581,10 @@ class UploadFoundation extends _foundation.default {
|
|
|
627
581
|
validateMessage,
|
|
628
582
|
fileInstance
|
|
629
583
|
} = buResult;
|
|
630
|
-
let newFileList =
|
|
584
|
+
let newFileList = this.getState('fileList').slice();
|
|
631
585
|
|
|
632
586
|
if (autoRemove) {
|
|
633
|
-
newFileList =
|
|
587
|
+
newFileList = newFileList.filter(item => item.uid !== file.uid);
|
|
634
588
|
} else {
|
|
635
589
|
const index = this._getFileIndex(file, newFileList);
|
|
636
590
|
|
|
@@ -685,13 +639,11 @@ class UploadFoundation extends _foundation.default {
|
|
|
685
639
|
} = option;
|
|
686
640
|
|
|
687
641
|
if (data) {
|
|
688
|
-
var _context8;
|
|
689
|
-
|
|
690
642
|
if (typeof data === 'function') {
|
|
691
643
|
data = data(fileInstance);
|
|
692
644
|
}
|
|
693
645
|
|
|
694
|
-
|
|
646
|
+
Object.keys(data).forEach(key => {
|
|
695
647
|
formData.append(key, data[key]);
|
|
696
648
|
});
|
|
697
649
|
} // add file
|
|
@@ -776,7 +728,7 @@ class UploadFoundation extends _foundation.default {
|
|
|
776
728
|
const {
|
|
777
729
|
fileList
|
|
778
730
|
} = this.getStates();
|
|
779
|
-
const newFileList =
|
|
731
|
+
const newFileList = fileList.slice();
|
|
780
732
|
let percent = 0;
|
|
781
733
|
|
|
782
734
|
if (e.total > 0) {
|
|
@@ -860,7 +812,7 @@ class UploadFoundation extends _foundation.default {
|
|
|
860
812
|
body = this.getBody(xhr);
|
|
861
813
|
}
|
|
862
814
|
|
|
863
|
-
const newFileList =
|
|
815
|
+
const newFileList = fileList.slice();
|
|
864
816
|
const {
|
|
865
817
|
afterUpload
|
|
866
818
|
} = this.getProps();
|
|
@@ -886,7 +838,7 @@ class UploadFoundation extends _foundation.default {
|
|
|
886
838
|
status ? newFileList[index].status = status : null;
|
|
887
839
|
validateMessage ? newFileList[index].validateMessage = validateMessage : null;
|
|
888
840
|
name ? newFileList[index].name = name : null;
|
|
889
|
-
autoRemove ?
|
|
841
|
+
autoRemove ? newFileList.splice(index, 1) : null;
|
|
890
842
|
}
|
|
891
843
|
|
|
892
844
|
this._adapter.notifySuccess(body, fileInstance, newFileList);
|
|
@@ -900,7 +852,7 @@ class UploadFoundation extends _foundation.default {
|
|
|
900
852
|
}
|
|
901
853
|
|
|
902
854
|
_getFileIndex(file, fileList) {
|
|
903
|
-
return
|
|
855
|
+
return fileList.findIndex(item => item.uid === file.uid);
|
|
904
856
|
}
|
|
905
857
|
|
|
906
858
|
handleRemove(file) {
|
|
@@ -915,14 +867,13 @@ class UploadFoundation extends _foundation.default {
|
|
|
915
867
|
const {
|
|
916
868
|
fileList
|
|
917
869
|
} = this.getStates();
|
|
918
|
-
|
|
919
|
-
_promise.default.resolve(this._adapter.notifyBeforeRemove(file, fileList)).then(res => {
|
|
870
|
+
Promise.resolve(this._adapter.notifyBeforeRemove(file, fileList)).then(res => {
|
|
920
871
|
// prevent remove while user return false
|
|
921
872
|
if (res === false) {
|
|
922
873
|
return;
|
|
923
874
|
}
|
|
924
875
|
|
|
925
|
-
const newFileList =
|
|
876
|
+
const newFileList = fileList.slice();
|
|
926
877
|
|
|
927
878
|
const index = this._getFileIndex(file, fileList);
|
|
928
879
|
|
|
@@ -930,7 +881,7 @@ class UploadFoundation extends _foundation.default {
|
|
|
930
881
|
return;
|
|
931
882
|
}
|
|
932
883
|
|
|
933
|
-
|
|
884
|
+
newFileList.splice(index, 1);
|
|
934
885
|
|
|
935
886
|
this._adapter.notifyRemove(file.fileInstance, newFileList, file);
|
|
936
887
|
|
|
@@ -962,7 +913,7 @@ class UploadFoundation extends _foundation.default {
|
|
|
962
913
|
const {
|
|
963
914
|
action
|
|
964
915
|
} = this.getProps();
|
|
965
|
-
const newFileList =
|
|
916
|
+
const newFileList = fileList.slice();
|
|
966
917
|
const error = this.getError({
|
|
967
918
|
action,
|
|
968
919
|
xhr,
|
|
@@ -994,7 +945,7 @@ class UploadFoundation extends _foundation.default {
|
|
|
994
945
|
return;
|
|
995
946
|
}
|
|
996
947
|
|
|
997
|
-
|
|
948
|
+
Promise.resolve(this._adapter.notifyBeforeClear(fileList)).then(res => {
|
|
998
949
|
if (res === false) {
|
|
999
950
|
return;
|
|
1000
951
|
}
|
|
@@ -1011,12 +962,11 @@ class UploadFoundation extends _foundation.default {
|
|
|
1011
962
|
|
|
1012
963
|
_createURL(fileInstance) {
|
|
1013
964
|
// https://stackoverflow.com/questions/31742072/filereader-vs-window-url-createobjecturl
|
|
1014
|
-
const url =
|
|
1015
|
-
|
|
965
|
+
const url = URL.createObjectURL(fileInstance);
|
|
1016
966
|
const {
|
|
1017
967
|
localUrls
|
|
1018
968
|
} = this.getStates();
|
|
1019
|
-
const newUrls =
|
|
969
|
+
const newUrls = localUrls.slice();
|
|
1020
970
|
newUrls.push(url);
|
|
1021
971
|
|
|
1022
972
|
this._adapter.updateLocalUrls(newUrls);
|
|
@@ -1030,14 +980,14 @@ class UploadFoundation extends _foundation.default {
|
|
|
1030
980
|
const {
|
|
1031
981
|
localUrls
|
|
1032
982
|
} = this.getStates();
|
|
1033
|
-
|
|
983
|
+
localUrls.forEach(url => {
|
|
1034
984
|
this._releaseBlob(url);
|
|
1035
985
|
});
|
|
1036
986
|
}
|
|
1037
987
|
|
|
1038
988
|
_releaseBlob(url) {
|
|
1039
989
|
try {
|
|
1040
|
-
|
|
990
|
+
URL.revokeObjectURL(url);
|
|
1041
991
|
} catch (error) {
|
|
1042
992
|
console.log(error);
|
|
1043
993
|
}
|
|
@@ -1068,10 +1018,8 @@ class UploadFoundation extends _foundation.default {
|
|
|
1068
1018
|
|
|
1069
1019
|
handleDirectoryDrop(e) {
|
|
1070
1020
|
return __awaiter(this, void 0, void 0, function* () {
|
|
1071
|
-
|
|
1072
|
-
|
|
1073
|
-
const fileList = (0, _slice.default)(_context9 = this.getState('fileList')).call(_context9);
|
|
1074
|
-
const items = (0, _slice.default)([]).call(e.dataTransfer.items);
|
|
1021
|
+
const fileList = this.getState('fileList').slice();
|
|
1022
|
+
const items = [].slice.call(e.dataTransfer.items);
|
|
1075
1023
|
const files = yield (0, _utils.mapFileTree)(items);
|
|
1076
1024
|
this.handleChange(files);
|
|
1077
1025
|
|
|
@@ -1082,8 +1030,6 @@ class UploadFoundation extends _foundation.default {
|
|
|
1082
1030
|
}
|
|
1083
1031
|
|
|
1084
1032
|
handleDrop(e) {
|
|
1085
|
-
var _context10;
|
|
1086
|
-
|
|
1087
1033
|
// Block file opening in browser
|
|
1088
1034
|
e.preventDefault();
|
|
1089
1035
|
e.stopPropagation();
|
|
@@ -1091,7 +1037,7 @@ class UploadFoundation extends _foundation.default {
|
|
|
1091
1037
|
disabled,
|
|
1092
1038
|
directory
|
|
1093
1039
|
} = this.getProps();
|
|
1094
|
-
const fileList =
|
|
1040
|
+
const fileList = this.getState('fileList').slice();
|
|
1095
1041
|
|
|
1096
1042
|
if (!disabled) {
|
|
1097
1043
|
if (directory) {
|
|
@@ -1099,7 +1045,7 @@ class UploadFoundation extends _foundation.default {
|
|
|
1099
1045
|
return;
|
|
1100
1046
|
}
|
|
1101
1047
|
|
|
1102
|
-
const files =
|
|
1048
|
+
const files = Array.from(e.dataTransfer.files);
|
|
1103
1049
|
this.handleChange(files);
|
|
1104
1050
|
|
|
1105
1051
|
this._adapter.updateDragAreaStatus(DRAG_AREA_DEFAULT);
|
|
@@ -1127,18 +1073,16 @@ class UploadFoundation extends _foundation.default {
|
|
|
1127
1073
|
|
|
1128
1074
|
|
|
1129
1075
|
checkFileFormat(accept, file) {
|
|
1130
|
-
|
|
1131
|
-
|
|
1132
|
-
const acceptTypes = (0, _filter.default)(_context11 = (0, _map.default)(_context12 = accept.split(',')).call(_context12, type => (0, _trim.default)(type).call(type))).call(_context11, type => type);
|
|
1076
|
+
const acceptTypes = accept.split(',').map(type => type.trim()).filter(type => type);
|
|
1133
1077
|
const mimeType = file.type || ''; // Get the large class to which MIMEtype belongs, eg: image/jpeg = > image, application/= > application
|
|
1134
1078
|
|
|
1135
1079
|
const baseMimeType = mimeType.replace(/\/.*$/, '');
|
|
1136
|
-
return
|
|
1080
|
+
return acceptTypes.some(type => {
|
|
1137
1081
|
// When accepted as a suffix filename such as [.jpeg]
|
|
1138
1082
|
if (type.charAt(0) === '.') {
|
|
1139
1083
|
const fileName = file.name || '';
|
|
1140
1084
|
const acceptExtension = type.split('.').pop().toLowerCase();
|
|
1141
|
-
return (0,
|
|
1085
|
+
return (0, _utils.endsWith)(fileName.toLowerCase(), acceptExtension);
|
|
1142
1086
|
} // When accepted as a general class such as [image/*] or [video/*]
|
|
1143
1087
|
|
|
1144
1088
|
|
package/lib/cjs/upload/utils.js
CHANGED
|
@@ -1,31 +1,14 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
var _interopRequireDefault = require("@babel/runtime-corejs3/helpers/interopRequireDefault");
|
|
6
|
-
|
|
7
|
-
_Object$defineProperty(exports, "__esModule", {
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
8
4
|
value: true
|
|
9
5
|
});
|
|
10
|
-
|
|
11
6
|
exports.byteMB = exports.byteKB = void 0;
|
|
12
7
|
exports.endsWith = endsWith;
|
|
13
8
|
exports.getFileSize = getFileSize;
|
|
14
9
|
exports.loopFiles = loopFiles;
|
|
15
10
|
exports.mapFileTree = mapFileTree;
|
|
16
11
|
|
|
17
|
-
var _promise = _interopRequireDefault(require("@babel/runtime-corejs3/core-js-stable/promise"));
|
|
18
|
-
|
|
19
|
-
var _indexOf = _interopRequireDefault(require("@babel/runtime-corejs3/core-js-stable/instance/index-of"));
|
|
20
|
-
|
|
21
|
-
var _slice = _interopRequireDefault(require("@babel/runtime-corejs3/core-js-stable/instance/slice"));
|
|
22
|
-
|
|
23
|
-
var _concat = _interopRequireDefault(require("@babel/runtime-corejs3/core-js-stable/instance/concat"));
|
|
24
|
-
|
|
25
|
-
var _defineProperties = _interopRequireDefault(require("@babel/runtime-corejs3/core-js-stable/object/define-properties"));
|
|
26
|
-
|
|
27
|
-
var _map = _interopRequireDefault(require("@babel/runtime-corejs3/core-js-stable/instance/map"));
|
|
28
|
-
|
|
29
12
|
var __awaiter = void 0 && (void 0).__awaiter || function (thisArg, _arguments, P, generator) {
|
|
30
13
|
function adopt(value) {
|
|
31
14
|
return value instanceof P ? value : new P(function (resolve) {
|
|
@@ -33,7 +16,7 @@ var __awaiter = void 0 && (void 0).__awaiter || function (thisArg, _arguments, P
|
|
|
33
16
|
});
|
|
34
17
|
}
|
|
35
18
|
|
|
36
|
-
return new (P || (P =
|
|
19
|
+
return new (P || (P = Promise))(function (resolve, reject) {
|
|
37
20
|
function fulfilled(value) {
|
|
38
21
|
try {
|
|
39
22
|
step(generator.next(value));
|
|
@@ -76,19 +59,19 @@ function getFileSize(number) {
|
|
|
76
59
|
}
|
|
77
60
|
|
|
78
61
|
function endsWith(str, suffix) {
|
|
79
|
-
return
|
|
62
|
+
return str.indexOf(suffix, str.length - suffix.length) !== -1;
|
|
80
63
|
}
|
|
81
64
|
|
|
82
65
|
function loopFiles(item) {
|
|
83
66
|
return __awaiter(this, void 0, void 0, function* () {
|
|
84
|
-
return new
|
|
67
|
+
return new Promise((res, rej) => {
|
|
85
68
|
const dirReader = item.createReader();
|
|
86
69
|
let fileList = [];
|
|
87
70
|
|
|
88
71
|
function sequence() {
|
|
89
72
|
dirReader.readEntries(entries => {
|
|
90
|
-
const entryList =
|
|
91
|
-
fileList =
|
|
73
|
+
const entryList = Array.prototype.slice.apply(entries);
|
|
74
|
+
fileList = fileList.concat(entryList); // Check if all the file has been viewed
|
|
92
75
|
|
|
93
76
|
const isFinished = !entryList.length;
|
|
94
77
|
|
|
@@ -115,19 +98,19 @@ function mapFileTree(items) {
|
|
|
115
98
|
item.path = path;
|
|
116
99
|
|
|
117
100
|
if (item.isFile) {
|
|
118
|
-
promises.push(new
|
|
101
|
+
promises.push(new Promise((res, rej) => {
|
|
119
102
|
item.file(file => {
|
|
120
103
|
if (item.fullPath && !file.webkitRelativePath) {
|
|
121
104
|
// This file is provided to the user based on the relative path of the drag and drop folder
|
|
122
105
|
// If you drag the Upload folder, the path of the internal file may be Upload/File/a.png, etc
|
|
123
|
-
|
|
106
|
+
Object.defineProperties(file, {
|
|
124
107
|
webkitRelativePath: {
|
|
125
108
|
writable: true
|
|
126
109
|
}
|
|
127
110
|
}); //@ts-ignore add webkitRelativePath property into file
|
|
128
111
|
|
|
129
112
|
file.webkitRelativePath = item.fullPath.replace(/^\//, '');
|
|
130
|
-
|
|
113
|
+
Object.defineProperties(file, {
|
|
131
114
|
webkitRelativePath: {
|
|
132
115
|
writable: false
|
|
133
116
|
}
|
|
@@ -141,20 +124,18 @@ function mapFileTree(items) {
|
|
|
141
124
|
const entries = yield loopFiles(item);
|
|
142
125
|
|
|
143
126
|
for (let index = 0; index < entries.length; index++) {
|
|
144
|
-
var _context;
|
|
145
|
-
|
|
146
127
|
const entry = entries[index];
|
|
147
|
-
yield _traverseFileTree(entry,
|
|
128
|
+
yield _traverseFileTree(entry, "".concat(path).concat(item.name, "/"));
|
|
148
129
|
}
|
|
149
130
|
}
|
|
150
131
|
});
|
|
151
132
|
|
|
152
133
|
try {
|
|
153
|
-
const batches =
|
|
134
|
+
const batches = items.map(i => _traverseFileTree(i.webkitGetAsEntry())); // Perform asynchronous operations to add the required promises to the queue
|
|
154
135
|
|
|
155
|
-
yield
|
|
136
|
+
yield Promise.all(batches); // Execution queue
|
|
156
137
|
|
|
157
|
-
const result = yield
|
|
138
|
+
const result = yield Promise.all(promises);
|
|
158
139
|
return result;
|
|
159
140
|
} catch (error) {
|
|
160
141
|
console.warn('Captured error while loop directory.');
|
package/lib/cjs/utils/Event.js
CHANGED
|
@@ -1,30 +1,17 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
var _interopRequireDefault = require("@babel/runtime-corejs3/helpers/interopRequireDefault");
|
|
6
|
-
|
|
7
|
-
_Object$defineProperty(exports, "__esModule", {
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
8
4
|
value: true
|
|
9
5
|
});
|
|
10
|
-
|
|
11
6
|
exports.default = void 0;
|
|
12
7
|
|
|
13
|
-
var _map = _interopRequireDefault(require("@babel/runtime-corejs3/core-js-stable/map"));
|
|
14
|
-
|
|
15
|
-
var _isArray = _interopRequireDefault(require("@babel/runtime-corejs3/core-js-stable/array/is-array"));
|
|
16
|
-
|
|
17
|
-
var _findIndex = _interopRequireDefault(require("@babel/runtime-corejs3/core-js-stable/instance/find-index"));
|
|
18
|
-
|
|
19
|
-
var _splice = _interopRequireDefault(require("@babel/runtime-corejs3/core-js-stable/instance/splice"));
|
|
20
|
-
|
|
21
|
-
var _forEach = _interopRequireDefault(require("@babel/runtime-corejs3/core-js-stable/instance/for-each"));
|
|
22
|
-
|
|
23
8
|
var _isNullOrUndefined = _interopRequireDefault(require("./isNullOrUndefined"));
|
|
24
9
|
|
|
10
|
+
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
11
|
+
|
|
25
12
|
class Event {
|
|
26
13
|
constructor() {
|
|
27
|
-
this._eventMap = new
|
|
14
|
+
this._eventMap = new Map();
|
|
28
15
|
}
|
|
29
16
|
|
|
30
17
|
on(event, callback) {
|
|
@@ -56,11 +43,11 @@ class Event {
|
|
|
56
43
|
if (typeof callback === 'function') {
|
|
57
44
|
const callbacks = this._eventMap.get(event);
|
|
58
45
|
|
|
59
|
-
if (
|
|
46
|
+
if (Array.isArray(callbacks) && callbacks.length) {
|
|
60
47
|
let index = -1; // eslint-disable-next-line max-depth
|
|
61
48
|
|
|
62
|
-
while ((index =
|
|
63
|
-
|
|
49
|
+
while ((index = callbacks.findIndex(cb => cb === callback)) > -1) {
|
|
50
|
+
callbacks.splice(index, 1);
|
|
64
51
|
}
|
|
65
52
|
}
|
|
66
53
|
} else if ((0, _isNullOrUndefined.default)(callback)) {
|
|
@@ -72,8 +59,6 @@ class Event {
|
|
|
72
59
|
}
|
|
73
60
|
|
|
74
61
|
emit(event) {
|
|
75
|
-
var _context;
|
|
76
|
-
|
|
77
62
|
for (var _len = arguments.length, args = new Array(_len > 1 ? _len - 1 : 0), _key = 1; _key < _len; _key++) {
|
|
78
63
|
args[_key - 1] = arguments[_key];
|
|
79
64
|
}
|
|
@@ -82,7 +67,8 @@ class Event {
|
|
|
82
67
|
return false;
|
|
83
68
|
}
|
|
84
69
|
|
|
85
|
-
|
|
70
|
+
this._eventMap.get(event).forEach(callback => callback(...args));
|
|
71
|
+
|
|
86
72
|
return true;
|
|
87
73
|
}
|
|
88
74
|
|