iglooform 3.0.2 → 3.0.3
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/.dumi/tmp/core/defineApp.ts +1 -1
- package/.dumi/tmp/core/helmet.ts +1 -1
- package/.dumi/tmp/core/history.ts +1 -1
- package/.dumi/tmp/core/historyIntelli.ts +1 -1
- package/.dumi/tmp/core/plugin.ts +2 -2
- package/.dumi/tmp/core/polyfill.ts +197 -197
- package/.dumi/tmp/core/route.tsx +33 -33
- package/.dumi/tmp/dumi/exports.ts +1 -1
- package/.dumi/tmp/dumi/locales/runtime.tsx +2 -2
- package/.dumi/tmp/dumi/meta/index.ts +33 -33
- package/.dumi/tmp/dumi/meta/runtime.ts +1 -1
- package/.dumi/tmp/dumi/theme/ContextWrapper.tsx +2 -2
- package/.dumi/tmp/dumi/theme/builtins/API.ts +1 -1
- package/.dumi/tmp/dumi/theme/builtins/Badge.ts +1 -1
- package/.dumi/tmp/dumi/theme/builtins/Container.ts +1 -1
- package/.dumi/tmp/dumi/theme/builtins/Previewer.ts +1 -1
- package/.dumi/tmp/dumi/theme/builtins/SourceCode.ts +1 -1
- package/.dumi/tmp/dumi/theme/builtins/Table.ts +1 -1
- package/.dumi/tmp/dumi/theme/builtins/Tree.ts +1 -1
- package/.dumi/tmp/dumi/theme/layouts/DocLayout.ts +1 -1
- package/.dumi/tmp/dumi/theme/loading.tsx +1 -1
- package/.dumi/tmp/dumi/theme/slots/ColorSwitch.ts +1 -1
- package/.dumi/tmp/dumi/theme/slots/Content.ts +1 -1
- package/.dumi/tmp/dumi/theme/slots/ContentFooter.ts +1 -1
- package/.dumi/tmp/dumi/theme/slots/ContentTabs.ts +1 -1
- package/.dumi/tmp/dumi/theme/slots/Features.ts +1 -1
- package/.dumi/tmp/dumi/theme/slots/Footer.ts +1 -1
- package/.dumi/tmp/dumi/theme/slots/Header.ts +1 -1
- package/.dumi/tmp/dumi/theme/slots/HeaderExtra.ts +1 -1
- package/.dumi/tmp/dumi/theme/slots/Hero.ts +1 -1
- package/.dumi/tmp/dumi/theme/slots/HeroTitle.ts +1 -1
- package/.dumi/tmp/dumi/theme/slots/LangSwitch.ts +1 -1
- package/.dumi/tmp/dumi/theme/slots/Logo.ts +1 -1
- package/.dumi/tmp/dumi/theme/slots/Navbar.ts +1 -1
- package/.dumi/tmp/dumi/theme/slots/NavbarExtra.ts +1 -1
- package/.dumi/tmp/dumi/theme/slots/NotFound.ts +1 -1
- package/.dumi/tmp/dumi/theme/slots/PreviewerActions.ts +1 -1
- package/.dumi/tmp/dumi/theme/slots/PreviewerActionsExtra.ts +1 -1
- package/.dumi/tmp/dumi/theme/slots/RtlSwitch.ts +1 -1
- package/.dumi/tmp/dumi/theme/slots/SearchBar.ts +2 -2
- package/.dumi/tmp/dumi/theme/slots/SearchResult.ts +1 -1
- package/.dumi/tmp/dumi/theme/slots/Sidebar.ts +1 -1
- package/.dumi/tmp/dumi/theme/slots/SocialIcon.ts +1 -1
- package/.dumi/tmp/dumi/theme/slots/Toc.ts +1 -1
- package/.dumi/tmp/exports.ts +5 -5
- package/.dumi/tmp/testBrowser.tsx +3 -3
- package/.dumi/tmp/umi.ts +4 -4
- package/es/admin-amount/style/index.d.ts +0 -0
- package/es/babel-plugin-import-option.d.ts +7 -0
- package/es/back-top/index.d.ts +5 -0
- package/es/input/style/amount/index.d.ts +2 -0
- package/es/input/style/index.d.ts +2 -0
- package/es/input/style/input-date/index.d.ts +2 -0
- package/es/input/style/otp/index.d.ts +2 -0
- package/es/input/style/phone-number/index.d.ts +2 -0
- package/es/input/style/text-area/index.d.ts +2 -0
- package/es/locale/en-US/messages.json +2 -1
- package/es/locale/id-ID/messages.json +2 -1
- package/es/locale/locale-provider.d.ts +11 -0
- package/es/locale/th-TH/messages.json +2 -1
- package/es/locale/vi-VN/messages.json +2 -1
- package/es/locale/zh-CN/messages.json +2 -1
- package/es/locale/zh-TW/messages.json +2 -1
- package/es/login-page/index.d.ts +7 -0
- package/es/message/style/index.d.ts +1 -0
- package/es/ocr/micro-blink/style/index.d.ts +1 -0
- package/es/platform/platform-card/index.d.ts +12 -0
- package/es/platform/switch-platform/index.d.ts +12 -0
- package/es/tabs/index.d.ts +15 -0
- package/es/upload/index.js +43 -20
- package/es/upload-photo/index.js +20 -4
- package/es/utils/useAsyncEffect.d.ts +3 -0
- package/lib/admin-amount/style/index.d.ts +0 -0
- package/lib/babel-plugin-import-option.d.ts +7 -0
- package/lib/back-top/index.d.ts +5 -0
- package/lib/input/style/amount/index.d.ts +2 -0
- package/lib/input/style/index.d.ts +2 -0
- package/lib/input/style/input-date/index.d.ts +2 -0
- package/lib/input/style/otp/index.d.ts +2 -0
- package/lib/input/style/phone-number/index.d.ts +2 -0
- package/lib/input/style/text-area/index.d.ts +2 -0
- package/lib/locale/en-US/messages.json +2 -1
- package/lib/locale/id-ID/messages.json +2 -1
- package/lib/locale/locale-provider.d.ts +11 -0
- package/lib/locale/th-TH/messages.json +2 -1
- package/lib/locale/vi-VN/messages.json +2 -1
- package/lib/locale/zh-CN/messages.json +2 -1
- package/lib/locale/zh-TW/messages.json +2 -1
- package/lib/login-page/index.d.ts +7 -0
- package/lib/message/style/index.d.ts +1 -0
- package/lib/ocr/micro-blink/style/index.d.ts +1 -0
- package/lib/platform/platform-card/index.d.ts +12 -0
- package/lib/platform/switch-platform/index.d.ts +12 -0
- package/lib/tabs/index.d.ts +15 -0
- package/lib/upload/index.js +42 -20
- package/lib/upload-photo/index.js +19 -4
- package/lib/utils/useAsyncEffect.d.ts +3 -0
- package/package.json +1 -1
package/lib/upload/index.js
CHANGED
|
@@ -50,10 +50,14 @@ var IglooUpload = function IglooUpload(props) {
|
|
|
50
50
|
var dataUrlRef = (0, _react.useRef)([]);
|
|
51
51
|
var _useContext = (0, _react.useContext)(_formContext.default),
|
|
52
52
|
uploadApi = _useContext.uploadApi;
|
|
53
|
+
var _useContext2 = (0, _react.useContext)(_locale.LocaleContext),
|
|
54
|
+
formatMessage = _useContext2.formatMessage;
|
|
55
|
+
var staticMessage = formatMessage({
|
|
56
|
+
id: 'File Uploading'
|
|
57
|
+
});
|
|
53
58
|
(0, _invariant.default)(typeof props.handleUpload === 'function' || uploadApi, '"handleUpload" should be a function. Or uploadApi should be set at Form/FreeForm');
|
|
54
59
|
(0, _invariant.default)(!uploadApi || props.bizKey, '"bizKey" should be set if Upload is used with uploadApi');
|
|
55
|
-
var
|
|
56
|
-
value = _props$value === void 0 ? [] : _props$value,
|
|
60
|
+
var value = props.value,
|
|
57
61
|
limit = props.limit,
|
|
58
62
|
limitErrorMessage = props.limitErrorMessage,
|
|
59
63
|
descriptions = props.descriptions,
|
|
@@ -97,17 +101,7 @@ var IglooUpload = function IglooUpload(props) {
|
|
|
97
101
|
containerRef = props.containerRef,
|
|
98
102
|
placeholder = props.placeholder,
|
|
99
103
|
rest = _objectWithoutProperties(props, _excluded);
|
|
100
|
-
var _useState = (0, _react.useState)(
|
|
101
|
-
return {
|
|
102
|
-
url: url,
|
|
103
|
-
dataUrl: url,
|
|
104
|
-
status: 'success',
|
|
105
|
-
type: '',
|
|
106
|
-
name: "File".concat(index + 1),
|
|
107
|
-
size: 0,
|
|
108
|
-
uid: index
|
|
109
|
-
};
|
|
110
|
-
})),
|
|
104
|
+
var _useState = (0, _react.useState)([]),
|
|
111
105
|
_useState2 = _slicedToArray(_useState, 2),
|
|
112
106
|
files = _useState2[0],
|
|
113
107
|
setFiles = _useState2[1];
|
|
@@ -132,8 +126,24 @@ var IglooUpload = function IglooUpload(props) {
|
|
|
132
126
|
return;
|
|
133
127
|
}
|
|
134
128
|
});
|
|
135
|
-
|
|
136
|
-
|
|
129
|
+
|
|
130
|
+
// 有初始值的处理 (不是初始化)
|
|
131
|
+
(0, _react.useEffect)(function () {
|
|
132
|
+
if (Array.isArray(value) && value.length && files.length === 0) {
|
|
133
|
+
var _files = (value || []).map(function (url, index) {
|
|
134
|
+
return {
|
|
135
|
+
url: url,
|
|
136
|
+
dataUrl: url,
|
|
137
|
+
status: 'success',
|
|
138
|
+
type: '',
|
|
139
|
+
name: "File".concat(index + 1),
|
|
140
|
+
size: 0,
|
|
141
|
+
uid: index
|
|
142
|
+
};
|
|
143
|
+
});
|
|
144
|
+
setFiles(_files);
|
|
145
|
+
}
|
|
146
|
+
}, [value]);
|
|
137
147
|
(0, _react.useEffect)(function () {
|
|
138
148
|
return function () {
|
|
139
149
|
dataUrlRef.current.forEach(function (dataUrl) {
|
|
@@ -142,8 +152,17 @@ var IglooUpload = function IglooUpload(props) {
|
|
|
142
152
|
};
|
|
143
153
|
}, []);
|
|
144
154
|
(0, _react.useEffect)(function () {
|
|
145
|
-
if (!
|
|
155
|
+
if (!value && !files.length) return;
|
|
146
156
|
if (files.length) {
|
|
157
|
+
var hasProcessing = files.find(function (f) {
|
|
158
|
+
return f.status === 'progress';
|
|
159
|
+
});
|
|
160
|
+
if (hasProcessing) {
|
|
161
|
+
onChange && onChange({
|
|
162
|
+
status: 'processing'
|
|
163
|
+
});
|
|
164
|
+
return;
|
|
165
|
+
}
|
|
147
166
|
var urls = files.map(function (f) {
|
|
148
167
|
var status = f.status,
|
|
149
168
|
name = f.name,
|
|
@@ -154,13 +173,11 @@ var IglooUpload = function IglooUpload(props) {
|
|
|
154
173
|
errorMsg: errorMsg
|
|
155
174
|
};
|
|
156
175
|
}
|
|
157
|
-
|
|
158
|
-
return f.url || f.dataUrl;
|
|
159
|
-
}
|
|
176
|
+
return f.url;
|
|
160
177
|
});
|
|
161
178
|
onChange && onChange(urls);
|
|
162
179
|
} else {
|
|
163
|
-
onChange && onChange(
|
|
180
|
+
onChange && onChange(undefined);
|
|
164
181
|
}
|
|
165
182
|
}, [files]);
|
|
166
183
|
(0, _invariant.default)(limit === undefined || limit > 0, "\"limit\" should be a pasitive number.");
|
|
@@ -534,6 +551,11 @@ var FileList = function FileList(_ref6) {
|
|
|
534
551
|
return /*#__PURE__*/_reactDom.default.createPortal(children, containerRef.current);
|
|
535
552
|
};
|
|
536
553
|
function checkFileList(value) {
|
|
554
|
+
if ((value === null || value === void 0 ? void 0 : value.status) === 'processing') {
|
|
555
|
+
return Promise.reject((0, _locale.staticFormatMessage)({
|
|
556
|
+
id: 'File Uploading'
|
|
557
|
+
}));
|
|
558
|
+
}
|
|
537
559
|
if (!value) {
|
|
538
560
|
return Promise.resolve();
|
|
539
561
|
}
|
|
@@ -155,6 +155,9 @@ var UploadPhoto = function UploadPhoto(props) {
|
|
|
155
155
|
setMasks = _useState6[1];
|
|
156
156
|
var _useBreakpoint = useBreakpoint(),
|
|
157
157
|
md = _useBreakpoint.md;
|
|
158
|
+
var staticMessage = formatMessage({
|
|
159
|
+
id: 'Photo Uploading'
|
|
160
|
+
});
|
|
158
161
|
var mapFilesFromValue = function mapFilesFromValue(urls) {
|
|
159
162
|
var _files = [];
|
|
160
163
|
Promise.all(urls.map( /*#__PURE__*/function () {
|
|
@@ -199,6 +202,15 @@ var UploadPhoto = function UploadPhoto(props) {
|
|
|
199
202
|
(0, _react.useEffect)(function () {
|
|
200
203
|
if (!value && !files.length) return;
|
|
201
204
|
if (files.length) {
|
|
205
|
+
var hasProcessing = files.find(function (f) {
|
|
206
|
+
return f.status === 'progress';
|
|
207
|
+
});
|
|
208
|
+
if (hasProcessing) {
|
|
209
|
+
onChange && onChange({
|
|
210
|
+
status: 'processing'
|
|
211
|
+
});
|
|
212
|
+
return;
|
|
213
|
+
}
|
|
202
214
|
var urls = files.map(function (f) {
|
|
203
215
|
var status = f.status,
|
|
204
216
|
name = f.name,
|
|
@@ -209,13 +221,11 @@ var UploadPhoto = function UploadPhoto(props) {
|
|
|
209
221
|
errorMsg: errorMsg
|
|
210
222
|
};
|
|
211
223
|
}
|
|
212
|
-
|
|
213
|
-
return f.url || f.dataUrl;
|
|
214
|
-
}
|
|
224
|
+
return f.url;
|
|
215
225
|
});
|
|
216
226
|
onChange && onChange(urls);
|
|
217
227
|
} else {
|
|
218
|
-
onChange && onChange(
|
|
228
|
+
onChange && onChange(undefined);
|
|
219
229
|
}
|
|
220
230
|
}, [files]);
|
|
221
231
|
var uploadId = (0, _react.useMemo)(function () {
|
|
@@ -687,6 +697,11 @@ var UploadPhoto = function UploadPhoto(props) {
|
|
|
687
697
|
});
|
|
688
698
|
};
|
|
689
699
|
function checkFileList(value) {
|
|
700
|
+
if ((value === null || value === void 0 ? void 0 : value.status) === 'processing') {
|
|
701
|
+
return Promise.reject((0, _locale.staticFormatMessage)({
|
|
702
|
+
id: 'Photo Uploading'
|
|
703
|
+
}));
|
|
704
|
+
}
|
|
690
705
|
if (!value) {
|
|
691
706
|
return Promise.resolve();
|
|
692
707
|
}
|