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.
Files changed (98) hide show
  1. package/.dumi/tmp/core/defineApp.ts +1 -1
  2. package/.dumi/tmp/core/helmet.ts +1 -1
  3. package/.dumi/tmp/core/history.ts +1 -1
  4. package/.dumi/tmp/core/historyIntelli.ts +1 -1
  5. package/.dumi/tmp/core/plugin.ts +2 -2
  6. package/.dumi/tmp/core/polyfill.ts +197 -197
  7. package/.dumi/tmp/core/route.tsx +33 -33
  8. package/.dumi/tmp/dumi/exports.ts +1 -1
  9. package/.dumi/tmp/dumi/locales/runtime.tsx +2 -2
  10. package/.dumi/tmp/dumi/meta/index.ts +33 -33
  11. package/.dumi/tmp/dumi/meta/runtime.ts +1 -1
  12. package/.dumi/tmp/dumi/theme/ContextWrapper.tsx +2 -2
  13. package/.dumi/tmp/dumi/theme/builtins/API.ts +1 -1
  14. package/.dumi/tmp/dumi/theme/builtins/Badge.ts +1 -1
  15. package/.dumi/tmp/dumi/theme/builtins/Container.ts +1 -1
  16. package/.dumi/tmp/dumi/theme/builtins/Previewer.ts +1 -1
  17. package/.dumi/tmp/dumi/theme/builtins/SourceCode.ts +1 -1
  18. package/.dumi/tmp/dumi/theme/builtins/Table.ts +1 -1
  19. package/.dumi/tmp/dumi/theme/builtins/Tree.ts +1 -1
  20. package/.dumi/tmp/dumi/theme/layouts/DocLayout.ts +1 -1
  21. package/.dumi/tmp/dumi/theme/loading.tsx +1 -1
  22. package/.dumi/tmp/dumi/theme/slots/ColorSwitch.ts +1 -1
  23. package/.dumi/tmp/dumi/theme/slots/Content.ts +1 -1
  24. package/.dumi/tmp/dumi/theme/slots/ContentFooter.ts +1 -1
  25. package/.dumi/tmp/dumi/theme/slots/ContentTabs.ts +1 -1
  26. package/.dumi/tmp/dumi/theme/slots/Features.ts +1 -1
  27. package/.dumi/tmp/dumi/theme/slots/Footer.ts +1 -1
  28. package/.dumi/tmp/dumi/theme/slots/Header.ts +1 -1
  29. package/.dumi/tmp/dumi/theme/slots/HeaderExtra.ts +1 -1
  30. package/.dumi/tmp/dumi/theme/slots/Hero.ts +1 -1
  31. package/.dumi/tmp/dumi/theme/slots/HeroTitle.ts +1 -1
  32. package/.dumi/tmp/dumi/theme/slots/LangSwitch.ts +1 -1
  33. package/.dumi/tmp/dumi/theme/slots/Logo.ts +1 -1
  34. package/.dumi/tmp/dumi/theme/slots/Navbar.ts +1 -1
  35. package/.dumi/tmp/dumi/theme/slots/NavbarExtra.ts +1 -1
  36. package/.dumi/tmp/dumi/theme/slots/NotFound.ts +1 -1
  37. package/.dumi/tmp/dumi/theme/slots/PreviewerActions.ts +1 -1
  38. package/.dumi/tmp/dumi/theme/slots/PreviewerActionsExtra.ts +1 -1
  39. package/.dumi/tmp/dumi/theme/slots/RtlSwitch.ts +1 -1
  40. package/.dumi/tmp/dumi/theme/slots/SearchBar.ts +2 -2
  41. package/.dumi/tmp/dumi/theme/slots/SearchResult.ts +1 -1
  42. package/.dumi/tmp/dumi/theme/slots/Sidebar.ts +1 -1
  43. package/.dumi/tmp/dumi/theme/slots/SocialIcon.ts +1 -1
  44. package/.dumi/tmp/dumi/theme/slots/Toc.ts +1 -1
  45. package/.dumi/tmp/exports.ts +5 -5
  46. package/.dumi/tmp/testBrowser.tsx +3 -3
  47. package/.dumi/tmp/umi.ts +4 -4
  48. package/es/admin-amount/style/index.d.ts +0 -0
  49. package/es/babel-plugin-import-option.d.ts +7 -0
  50. package/es/back-top/index.d.ts +5 -0
  51. package/es/input/style/amount/index.d.ts +2 -0
  52. package/es/input/style/index.d.ts +2 -0
  53. package/es/input/style/input-date/index.d.ts +2 -0
  54. package/es/input/style/otp/index.d.ts +2 -0
  55. package/es/input/style/phone-number/index.d.ts +2 -0
  56. package/es/input/style/text-area/index.d.ts +2 -0
  57. package/es/locale/en-US/messages.json +2 -1
  58. package/es/locale/id-ID/messages.json +2 -1
  59. package/es/locale/locale-provider.d.ts +11 -0
  60. package/es/locale/th-TH/messages.json +2 -1
  61. package/es/locale/vi-VN/messages.json +2 -1
  62. package/es/locale/zh-CN/messages.json +2 -1
  63. package/es/locale/zh-TW/messages.json +2 -1
  64. package/es/login-page/index.d.ts +7 -0
  65. package/es/message/style/index.d.ts +1 -0
  66. package/es/ocr/micro-blink/style/index.d.ts +1 -0
  67. package/es/platform/platform-card/index.d.ts +12 -0
  68. package/es/platform/switch-platform/index.d.ts +12 -0
  69. package/es/tabs/index.d.ts +15 -0
  70. package/es/upload/index.js +43 -20
  71. package/es/upload-photo/index.js +20 -4
  72. package/es/utils/useAsyncEffect.d.ts +3 -0
  73. package/lib/admin-amount/style/index.d.ts +0 -0
  74. package/lib/babel-plugin-import-option.d.ts +7 -0
  75. package/lib/back-top/index.d.ts +5 -0
  76. package/lib/input/style/amount/index.d.ts +2 -0
  77. package/lib/input/style/index.d.ts +2 -0
  78. package/lib/input/style/input-date/index.d.ts +2 -0
  79. package/lib/input/style/otp/index.d.ts +2 -0
  80. package/lib/input/style/phone-number/index.d.ts +2 -0
  81. package/lib/input/style/text-area/index.d.ts +2 -0
  82. package/lib/locale/en-US/messages.json +2 -1
  83. package/lib/locale/id-ID/messages.json +2 -1
  84. package/lib/locale/locale-provider.d.ts +11 -0
  85. package/lib/locale/th-TH/messages.json +2 -1
  86. package/lib/locale/vi-VN/messages.json +2 -1
  87. package/lib/locale/zh-CN/messages.json +2 -1
  88. package/lib/locale/zh-TW/messages.json +2 -1
  89. package/lib/login-page/index.d.ts +7 -0
  90. package/lib/message/style/index.d.ts +1 -0
  91. package/lib/ocr/micro-blink/style/index.d.ts +1 -0
  92. package/lib/platform/platform-card/index.d.ts +12 -0
  93. package/lib/platform/switch-platform/index.d.ts +12 -0
  94. package/lib/tabs/index.d.ts +15 -0
  95. package/lib/upload/index.js +42 -20
  96. package/lib/upload-photo/index.js +19 -4
  97. package/lib/utils/useAsyncEffect.d.ts +3 -0
  98. package/package.json +1 -1
@@ -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 _props$value = props.value,
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)(value.map(function (url, index) {
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
- var _useContext2 = (0, _react.useContext)(_locale.LocaleContext),
136
- formatMessage = _useContext2.formatMessage;
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 (!(value !== null && value !== void 0 && value.length) && !files.length) return;
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
- if (f.url || f.dataUrl) {
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
- if (f.url || f.dataUrl) {
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
  }
@@ -0,0 +1,3 @@
1
+ import type { DependencyList } from 'react';
2
+ declare function useAsyncEffect(effect: () => AsyncGenerator<void, void, void> | Promise<void>, deps?: DependencyList): void;
3
+ export default useAsyncEffect;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "iglooform",
3
- "version": "3.0.2",
3
+ "version": "3.0.3",
4
4
  "scripts": {
5
5
  "start": "dumi dev",
6
6
  "build-dev": "dumi build",