iglooform 2.5.54 → 2.5.56

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 (122) hide show
  1. package/.dumi/tmp/core/EmptyRoute.tsx +9 -0
  2. package/.dumi/tmp/core/defineApp.ts +17 -0
  3. package/.dumi/tmp/core/exportStaticRuntimePlugin.ts +11 -0
  4. package/.dumi/tmp/core/helmet.ts +10 -0
  5. package/.dumi/tmp/core/helmetContext.ts +4 -0
  6. package/.dumi/tmp/core/history.ts +66 -0
  7. package/.dumi/tmp/core/historyIntelli.ts +132 -0
  8. package/.dumi/tmp/core/plugin.ts +60 -0
  9. package/.dumi/tmp/core/pluginConfig.ts +292 -0
  10. package/.dumi/tmp/core/pluginConfigJoi.d.ts +55 -0
  11. package/.dumi/tmp/core/polyfill.ts +201 -0
  12. package/.dumi/tmp/core/route.tsx +50 -0
  13. package/.dumi/tmp/core/terminal.ts +37 -0
  14. package/.dumi/tmp/dumi/exports.ts +5 -0
  15. package/.dumi/tmp/dumi/locales/config.ts +95 -0
  16. package/.dumi/tmp/dumi/locales/runtime.tsx +43 -0
  17. package/.dumi/tmp/dumi/meta/atoms.ts +4 -0
  18. package/.dumi/tmp/dumi/meta/index.ts +255 -0
  19. package/.dumi/tmp/dumi/meta/runtime.ts +31 -0
  20. package/.dumi/tmp/dumi/meta/tabs.ts +5 -0
  21. package/.dumi/tmp/dumi/theme/ContextWrapper.tsx +48 -0
  22. package/.dumi/tmp/dumi/theme/builtins/API.ts +4 -0
  23. package/.dumi/tmp/dumi/theme/builtins/Badge.ts +4 -0
  24. package/.dumi/tmp/dumi/theme/builtins/Container.ts +4 -0
  25. package/.dumi/tmp/dumi/theme/builtins/Previewer.ts +4 -0
  26. package/.dumi/tmp/dumi/theme/builtins/SourceCode.ts +4 -0
  27. package/.dumi/tmp/dumi/theme/builtins/Table.ts +4 -0
  28. package/.dumi/tmp/dumi/theme/builtins/Tree.ts +4 -0
  29. package/.dumi/tmp/dumi/theme/layouts/DocLayout.ts +4 -0
  30. package/.dumi/tmp/dumi/theme/loading.tsx +25 -0
  31. package/.dumi/tmp/dumi/theme/nprogress.css +59 -0
  32. package/.dumi/tmp/dumi/theme/slots/ColorSwitch.ts +4 -0
  33. package/.dumi/tmp/dumi/theme/slots/Content.ts +4 -0
  34. package/.dumi/tmp/dumi/theme/slots/ContentFooter.ts +4 -0
  35. package/.dumi/tmp/dumi/theme/slots/ContentTabs.ts +4 -0
  36. package/.dumi/tmp/dumi/theme/slots/Features.ts +4 -0
  37. package/.dumi/tmp/dumi/theme/slots/Footer.ts +4 -0
  38. package/.dumi/tmp/dumi/theme/slots/Header.ts +4 -0
  39. package/.dumi/tmp/dumi/theme/slots/HeaderExtra.ts +4 -0
  40. package/.dumi/tmp/dumi/theme/slots/Hero.ts +4 -0
  41. package/.dumi/tmp/dumi/theme/slots/HeroTitle.ts +4 -0
  42. package/.dumi/tmp/dumi/theme/slots/LangSwitch.ts +4 -0
  43. package/.dumi/tmp/dumi/theme/slots/Logo.ts +4 -0
  44. package/.dumi/tmp/dumi/theme/slots/Navbar.ts +4 -0
  45. package/.dumi/tmp/dumi/theme/slots/NavbarExtra.ts +4 -0
  46. package/.dumi/tmp/dumi/theme/slots/NotFound.ts +4 -0
  47. package/.dumi/tmp/dumi/theme/slots/PreviewerActions.ts +4 -0
  48. package/.dumi/tmp/dumi/theme/slots/PreviewerActionsExtra.ts +4 -0
  49. package/.dumi/tmp/dumi/theme/slots/RtlSwitch.ts +4 -0
  50. package/.dumi/tmp/dumi/theme/slots/SearchBar.ts +5 -0
  51. package/.dumi/tmp/dumi/theme/slots/SearchResult.ts +4 -0
  52. package/.dumi/tmp/dumi/theme/slots/Sidebar.ts +4 -0
  53. package/.dumi/tmp/dumi/theme/slots/SocialIcon.ts +4 -0
  54. package/.dumi/tmp/dumi/theme/slots/Toc.ts +4 -0
  55. package/.dumi/tmp/exports.ts +18 -0
  56. package/.dumi/tmp/plugin-antd/runtime.tsx +65 -0
  57. package/.dumi/tmp/plugin-antd/runtimeConfig.d.ts +6 -0
  58. package/.dumi/tmp/plugin-antd/types.d.ts +14 -0
  59. package/.dumi/tmp/plugin-html2sketch/index.ts +35 -0
  60. package/.dumi/tmp/testBrowser.tsx +90 -0
  61. package/.dumi/tmp/umi.ts +108 -0
  62. package/es/form/elements.js +3 -1
  63. package/es/form/index.js +12 -2
  64. package/es/form-context.d.ts +2 -1
  65. package/es/form-context.js +2 -1
  66. package/es/hooks/index.d.ts +1 -0
  67. package/es/hooks/index.js +1 -0
  68. package/es/hooks/ocr/index.d.ts +3 -0
  69. package/es/hooks/ocr/index.js +25 -0
  70. package/es/hooks/ocr/micro-blink.d.ts +3 -0
  71. package/es/hooks/ocr/micro-blink.js +231 -0
  72. package/es/input/input-date.js +40 -28
  73. package/es/input/phone-number.d.ts +1 -1
  74. package/es/input/phone-number.js +38 -15
  75. package/es/locale/en-US/messages.json +3 -0
  76. package/es/locale/id-ID/messages.json +3 -0
  77. package/es/locale/th-TH/messages.json +3 -0
  78. package/es/locale/vi-VN/messages.json +3 -0
  79. package/es/locale/zh-CN/messages.json +3 -0
  80. package/es/locale/zh-TW/messages.json +3 -0
  81. package/es/ocr/index.d.ts +15 -0
  82. package/es/ocr/index.js +38 -0
  83. package/es/ocr/micro-blink/index.d.ts +8 -0
  84. package/es/ocr/micro-blink/index.js +189 -0
  85. package/es/ocr/micro-blink/style/index.d.ts +1 -0
  86. package/es/ocr/micro-blink/style/index.js +1 -0
  87. package/es/ocr/micro-blink/style/index.less +30 -0
  88. package/es/types.d.ts +12 -0
  89. package/es/upload/index.js +46 -22
  90. package/es/upload-photo/index.js +24 -4
  91. package/es/utils/form-utils.js +1 -1
  92. package/lib/form/elements.js +4 -1
  93. package/lib/form/index.js +13 -2
  94. package/lib/form-context.d.ts +2 -1
  95. package/lib/form-context.js +2 -1
  96. package/lib/hooks/index.d.ts +1 -0
  97. package/lib/hooks/index.js +1 -0
  98. package/lib/hooks/ocr/index.d.ts +3 -0
  99. package/lib/hooks/ocr/index.js +36 -0
  100. package/lib/hooks/ocr/micro-blink.d.ts +3 -0
  101. package/lib/hooks/ocr/micro-blink.js +251 -0
  102. package/lib/input/input-date.js +40 -28
  103. package/lib/input/phone-number.d.ts +1 -1
  104. package/lib/input/phone-number.js +42 -17
  105. package/lib/locale/en-US/messages.json +3 -0
  106. package/lib/locale/id-ID/messages.json +3 -0
  107. package/lib/locale/th-TH/messages.json +3 -0
  108. package/lib/locale/vi-VN/messages.json +3 -0
  109. package/lib/locale/zh-CN/messages.json +3 -0
  110. package/lib/locale/zh-TW/messages.json +3 -0
  111. package/lib/ocr/index.d.ts +15 -0
  112. package/lib/ocr/index.js +49 -0
  113. package/lib/ocr/micro-blink/index.d.ts +8 -0
  114. package/lib/ocr/micro-blink/index.js +218 -0
  115. package/lib/ocr/micro-blink/style/index.d.ts +1 -0
  116. package/lib/ocr/micro-blink/style/index.js +3 -0
  117. package/lib/ocr/micro-blink/style/index.less +30 -0
  118. package/lib/types.d.ts +12 -0
  119. package/lib/upload/index.js +45 -22
  120. package/lib/upload-photo/index.js +23 -4
  121. package/lib/utils/form-utils.js +1 -1
  122. package/package.json +2 -1
@@ -0,0 +1,189 @@
1
+ import "antd/es/upload/style";
2
+ import _Upload from "antd/es/upload";
3
+
4
+ function asyncGeneratorStep(gen, resolve, reject, _next, _throw, key, arg) { try { var info = gen[key](arg); var value = info.value; } catch (error) { reject(error); return; } if (info.done) { resolve(value); } else { Promise.resolve(value).then(_next, _throw); } }
5
+
6
+ function _asyncToGenerator(fn) { return function () { var self = this, args = arguments; return new Promise(function (resolve, reject) { var gen = fn.apply(self, args); function _next(value) { asyncGeneratorStep(gen, resolve, reject, _next, _throw, "next", value); } function _throw(err) { asyncGeneratorStep(gen, resolve, reject, _next, _throw, "throw", err); } _next(undefined); }); }; }
7
+
8
+ import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
9
+ import { useContext } from 'react';
10
+ import { UploadOutlined } from 'iglooicon';
11
+ import { colors } from 'iglootheme';
12
+ import invariant from 'invariant';
13
+ import * as lodash from 'lodash';
14
+ import moment from 'moment';
15
+ import fromContext from '../../form-context';
16
+ import Typography from '../../typography';
17
+ import { LocaleContext } from '../../locale';
18
+ import message from '../../global-message';
19
+ import './style';
20
+
21
+ function getOcrDate(result, format) {
22
+ var successfullyParsed = lodash.get(result, ['dateOfBirth', 'successfullyParsed']);
23
+
24
+ if (successfullyParsed) {
25
+ var year = lodash.get(result, ['dateOfBirth', 'year']);
26
+ var month = lodash.get(result, ['dateOfBirth', 'month']);
27
+ var day = lodash.get(result, ['dateOfBirth', 'day']);
28
+ var date = new Date("".concat(year, "-").concat(month, "-").concat(day));
29
+ return format ? moment(date).format(format) : moment(date);
30
+ }
31
+
32
+ return undefined;
33
+ }
34
+
35
+ var MicroBlink = function MicroBlink(props) {
36
+ var outputMap = props.outputMap,
37
+ disabled = props.disabled;
38
+ var Dragger = _Upload.Dragger;
39
+
40
+ var _useContext = useContext(fromContext),
41
+ ocrHooks = _useContext.ocrHooks,
42
+ form = _useContext.form;
43
+
44
+ var _useContext2 = useContext(LocaleContext),
45
+ formatMessage = _useContext2.formatMessage;
46
+
47
+ var _ref = ocrHooks || {},
48
+ microBlink = _ref.microBlink;
49
+
50
+ var _ref2 = microBlink || {},
51
+ recognize = _ref2.recognize;
52
+
53
+ invariant(Boolean(microBlink) && Boolean(recognize), 'Must Config Micro Blink licenseKey');
54
+
55
+ var onUpload = /*#__PURE__*/function () {
56
+ var _ref3 = _asyncToGenerator( /*#__PURE__*/regeneratorRuntime.mark(function _callee(file) {
57
+ var microBlinkResult, state, formSet;
58
+ return regeneratorRuntime.wrap(function _callee$(_context) {
59
+ while (1) {
60
+ switch (_context.prev = _context.next) {
61
+ case 0:
62
+ if (!recognize) {
63
+ _context.next = 15;
64
+ break;
65
+ }
66
+
67
+ _context.next = 3;
68
+ return recognize(file);
69
+
70
+ case 3:
71
+ microBlinkResult = _context.sent;
72
+
73
+ if (microBlinkResult) {
74
+ _context.next = 6;
75
+ break;
76
+ }
77
+
78
+ return _context.abrupt("return");
79
+
80
+ case 6:
81
+ state = microBlinkResult.state;
82
+ _context.t0 = state;
83
+ _context.next = _context.t0 === 0 ? 10 : 12;
84
+ break;
85
+
86
+ case 10:
87
+ message.error(formatMessage({
88
+ id: 'Nothing has been recognized.'
89
+ }));
90
+ return _context.abrupt("return");
91
+
92
+ case 12:
93
+ return _context.abrupt("break", 13);
94
+
95
+ case 13:
96
+ formSet = (outputMap || []).reduce(function (pre, cur) {
97
+ var field = cur.field,
98
+ source = cur.source,
99
+ format = cur.format,
100
+ formatType = cur.formatType;
101
+
102
+ switch (formatType) {
103
+ case 'date':
104
+ pre.push({
105
+ name: field,
106
+ value: getOcrDate(microBlinkResult, format),
107
+ errors: []
108
+ });
109
+ break;
110
+
111
+ default:
112
+ pre.push({
113
+ name: field,
114
+ value: lodash.get(microBlinkResult || {}, source),
115
+ errors: []
116
+ });
117
+ break;
118
+ }
119
+
120
+ return pre;
121
+ }, []);
122
+ form === null || form === void 0 ? void 0 : form.setFields(formSet);
123
+
124
+ case 15:
125
+ case "end":
126
+ return _context.stop();
127
+ }
128
+ }
129
+ }, _callee);
130
+ }));
131
+
132
+ return function onUpload(_x) {
133
+ return _ref3.apply(this, arguments);
134
+ };
135
+ }();
136
+
137
+ return _jsx("div", {
138
+ className: 'igloo-micro-blink',
139
+ children: _jsx(Dragger, {
140
+ action: function action(file) {
141
+ onUpload(file);
142
+ return '';
143
+ },
144
+ showUploadList: false,
145
+ className: "igloo-upload-box",
146
+ customRequest: function customRequest() {},
147
+ //@ts-ignore
148
+ disabled: disabled,
149
+ multiple: true,
150
+ children: _jsxs("div", {
151
+ className: "igloo-upload-box-center",
152
+ children: [_jsx(UploadOutlined, {
153
+ style: {
154
+ marginRight: 16,
155
+ fontSize: 24,
156
+ color: '#666666'
157
+ }
158
+ }), _jsxs("span", {
159
+ className: "igloo-upload-placeholder",
160
+ children: [_jsx(Typography, {
161
+ level: "body1",
162
+ children: formatMessage({
163
+ id: 'Drag and drop a file here'
164
+ })
165
+ }), _jsx(Typography, {
166
+ level: "body1",
167
+ style: {
168
+ marginLeft: 4
169
+ },
170
+ children: formatMessage({
171
+ id: 'or'
172
+ })
173
+ }), _jsx(Typography, {
174
+ level: "body1",
175
+ style: {
176
+ color: colors.purpleMain,
177
+ marginLeft: 4
178
+ },
179
+ children: formatMessage({
180
+ id: 'browse'
181
+ })
182
+ })]
183
+ })]
184
+ })
185
+ })
186
+ });
187
+ };
188
+
189
+ export default MicroBlink;
@@ -0,0 +1 @@
1
+ import './index.less';
@@ -0,0 +1 @@
1
+ import './index.less';
@@ -0,0 +1,30 @@
1
+ .igloo-micro-blink {
2
+ .igloo-upload-box {
3
+ &:hover {
4
+ border-color: #d9d9d9 !important;
5
+ }
6
+
7
+ & > .ant-upload {
8
+ background: #ffffff !important;
9
+
10
+ .ant-upload-btn {
11
+ padding: 24px 24px;
12
+ }
13
+ }
14
+
15
+ .igloo-upload-box-center {
16
+ display: flex;
17
+ align-items: center;
18
+ justify-content: center;
19
+ white-space: nowrap;
20
+
21
+ .igloo-upload-placeholder {
22
+ white-space: pre-wrap;
23
+
24
+ .igloo-upload-box-center-upload-icon {
25
+ margin-right: 16px;
26
+ }
27
+ }
28
+ }
29
+ }
30
+ }
package/es/types.d.ts CHANGED
@@ -4,8 +4,19 @@ import { ReactNode } from 'react';
4
4
  import { NamePath } from 'rc-field-form/lib/interface';
5
5
  import { CheckboxOptionType } from 'antd/es/checkbox';
6
6
  import { SelectProps } from 'antd/es/select';
7
+ import { BlinkIdSingleSideRecognizerResult } from '@microblink/blinkid-in-browser-sdk';
7
8
  export { Rule } from 'rc-field-form/lib/interface';
8
9
  export declare type FormItemName = NamePath;
10
+ export interface OCRHooks {
11
+ microBlink?: {
12
+ recognize: ((file: File) => Promise<BlinkIdSingleSideRecognizerResult | null>) | null;
13
+ };
14
+ }
15
+ export interface OCRConfig {
16
+ microBlink?: {
17
+ licenseKey: string;
18
+ };
19
+ }
9
20
  export interface FormBasicConfig {
10
21
  className?: string;
11
22
  config: FormItemConfig;
@@ -31,6 +42,7 @@ export interface FormBasicConfig {
31
42
  validationRule?: string;
32
43
  getRuleValidationApi?: string;
33
44
  stepDirection?: 'vertical' | 'horizontal';
45
+ ocr?: OCRConfig;
34
46
  }
35
47
  export declare type FormItemAssert = {
36
48
  field: NamePath;
@@ -54,6 +54,7 @@ import { LocaleContext } from '../locale';
54
54
  import Preview from '../upload-preview/media';
55
55
  import { classifyType } from '../utils/tools';
56
56
  import FormContext from '../form-context';
57
+ import { staticFormatMessage } from '../locale';
57
58
  var Dragger = _Upload.Dragger;
58
59
 
59
60
  var IglooUpload = function IglooUpload(props) {
@@ -64,11 +65,16 @@ var IglooUpload = function IglooUpload(props) {
64
65
  var _useContext = useContext(FormContext),
65
66
  uploadApi = _useContext.uploadApi;
66
67
 
68
+ var _useContext2 = useContext(LocaleContext),
69
+ formatMessage = _useContext2.formatMessage;
70
+
71
+ var staticMessage = formatMessage({
72
+ id: 'File Uploading'
73
+ });
67
74
  invariant(typeof props.handleUpload === 'function' || uploadApi, '"handleUpload" should be a function. Or uploadApi should be set at Form/FreeForm');
68
75
  invariant(!uploadApi || props.bizKey, '"bizKey" should be set if Upload is used with uploadApi');
69
76
 
70
- var _props$value = props.value,
71
- value = _props$value === void 0 ? [] : _props$value,
77
+ var value = props.value,
72
78
  limit = props.limit,
73
79
  limitErrorMessage = props.limitErrorMessage,
74
80
  descriptions = props.descriptions,
@@ -119,21 +125,28 @@ var IglooUpload = function IglooUpload(props) {
119
125
  placeholder = props.placeholder,
120
126
  rest = _objectWithoutProperties(props, _excluded);
121
127
 
122
- var _useState = useState(value.map(function (url, index) {
123
- return {
124
- url: url,
125
- dataUrl: url,
126
- status: 'success',
127
- type: '',
128
- name: "File".concat(index + 1),
129
- size: 0,
130
- uid: index
131
- };
132
- })),
128
+ var _useState = useState([]),
133
129
  _useState2 = _slicedToArray(_useState, 2),
134
130
  files = _useState2[0],
135
131
  setFiles = _useState2[1];
136
132
 
133
+ useEffect(function () {
134
+ if (Array.isArray(value) && value.length && files.length === 0) {
135
+ var _files = (value || []).map(function (url, index) {
136
+ return {
137
+ url: url,
138
+ dataUrl: url,
139
+ status: 'success',
140
+ type: '',
141
+ name: "File".concat(index + 1),
142
+ size: 0,
143
+ uid: index
144
+ };
145
+ });
146
+
147
+ setFiles(_files);
148
+ }
149
+ }, [value]);
137
150
  useEffect(function () {
138
151
  var removeLimitMsg = function removeLimitMsg(e) {
139
152
  if (!(files === null || files === void 0 ? void 0 : files.length)) {
@@ -157,10 +170,6 @@ var IglooUpload = function IglooUpload(props) {
157
170
  return;
158
171
  }
159
172
  });
160
-
161
- var _useContext2 = useContext(LocaleContext),
162
- formatMessage = _useContext2.formatMessage;
163
-
164
173
  useEffect(function () {
165
174
  return function () {
166
175
  dataUrlRef.current.forEach(function (dataUrl) {
@@ -169,9 +178,20 @@ var IglooUpload = function IglooUpload(props) {
169
178
  };
170
179
  }, []);
171
180
  useEffect(function () {
172
- if (!(value === null || value === void 0 ? void 0 : value.length) && !files.length) return;
181
+ if (!value && !files.length) return;
173
182
 
174
183
  if (files.length) {
184
+ var hasProcessing = files.find(function (f) {
185
+ return f.status === 'progress';
186
+ });
187
+
188
+ if (hasProcessing) {
189
+ onChange && onChange({
190
+ status: 'processing'
191
+ });
192
+ return;
193
+ }
194
+
175
195
  var urls = files.map(function (f) {
176
196
  var status = f.status,
177
197
  name = f.name,
@@ -184,13 +204,11 @@ var IglooUpload = function IglooUpload(props) {
184
204
  };
185
205
  }
186
206
 
187
- if (f.url || f.dataUrl) {
188
- return f.url || f.dataUrl;
189
- }
207
+ return f.url;
190
208
  });
191
209
  onChange && onChange(urls);
192
210
  } else {
193
- onChange && onChange([]);
211
+ onChange && onChange(undefined);
194
212
  }
195
213
  }, [files]);
196
214
  invariant(limit === undefined || limit > 0, "\"limit\" should be a pasitive number.");
@@ -607,6 +625,12 @@ var FileList = function FileList(_ref6) {
607
625
  };
608
626
 
609
627
  function checkFileList(value) {
628
+ if ((value === null || value === void 0 ? void 0 : value.status) === 'processing') {
629
+ return Promise.reject(staticFormatMessage({
630
+ id: 'File Uploading'
631
+ }));
632
+ }
633
+
610
634
  if (!value) {
611
635
  return Promise.resolve();
612
636
  }
@@ -58,6 +58,7 @@ import Preview from '../upload-preview/media';
58
58
  import { classifyType } from '../utils/tools';
59
59
  import MediaItem from './media';
60
60
  import FormContext from '../form-context';
61
+ import { staticFormatMessage } from '../locale';
61
62
  var useBreakpoint = _Grid.useBreakpoint;
62
63
  var prefix = 'igloo-upload-photo';
63
64
 
@@ -199,6 +200,10 @@ var UploadPhoto = function UploadPhoto(props) {
199
200
  var _useBreakpoint = useBreakpoint(),
200
201
  md = _useBreakpoint.md;
201
202
 
203
+ var staticMessage = formatMessage({
204
+ id: 'Photo Uploading'
205
+ });
206
+
202
207
  var mapFilesFromValue = function mapFilesFromValue(urls) {
203
208
  var _files = [];
204
209
  Promise.all(urls.map( /*#__PURE__*/function () {
@@ -250,6 +255,17 @@ var UploadPhoto = function UploadPhoto(props) {
250
255
  if (!value && !files.length) return;
251
256
 
252
257
  if (files.length) {
258
+ var hasProcessing = files.find(function (f) {
259
+ return f.status === 'progress';
260
+ });
261
+
262
+ if (hasProcessing) {
263
+ onChange && onChange({
264
+ status: 'processing'
265
+ });
266
+ return;
267
+ }
268
+
253
269
  var urls = files.map(function (f) {
254
270
  var status = f.status,
255
271
  name = f.name,
@@ -262,13 +278,11 @@ var UploadPhoto = function UploadPhoto(props) {
262
278
  };
263
279
  }
264
280
 
265
- if (f.url || f.dataUrl) {
266
- return f.url || f.dataUrl;
267
- }
281
+ return f.url;
268
282
  });
269
283
  onChange && onChange(urls);
270
284
  } else {
271
- onChange && onChange([]);
285
+ onChange && onChange(undefined);
272
286
  }
273
287
  }, [files]);
274
288
  var uploadId = useMemo(function () {
@@ -806,6 +820,12 @@ var UploadPhoto = function UploadPhoto(props) {
806
820
  };
807
821
 
808
822
  function checkFileList(value) {
823
+ if ((value === null || value === void 0 ? void 0 : value.status) === 'processing') {
824
+ return Promise.reject(staticFormatMessage({
825
+ id: 'Photo Uploading'
826
+ }));
827
+ }
828
+
809
829
  if (!value) {
810
830
  return Promise.resolve();
811
831
  }
@@ -210,7 +210,7 @@ export var calcFormItemProps = function calcFormItemProps(config, extraProps, fo
210
210
  shouldRenderCode = config.shouldRenderCode,
211
211
  rest = _objectWithoutProperties(config, _excluded);
212
212
 
213
- invariant(nameProp !== undefined || type === 'Divider' || type === 'Section' || type === 'Typography' || !type, "name property is required for form item config (type: ".concat(type, ")"));
213
+ invariant(nameProp !== undefined || type === 'Divider' || type === 'Section' || type === 'Typography' || type === 'OCR' || !type, "name property is required for form item config (type: ".concat(type, ")"));
214
214
  invariant(!previewFormater || typeof previewFormater === 'function', 'previewFormater property should be a function');
215
215
  invariant(!shouldRender || typeof shouldRender === 'function', 'shouldRender property should be a function');
216
216
 
@@ -37,6 +37,8 @@ var _typography = _interopRequireDefault(require("../typography"));
37
37
 
38
38
  var _searchBox = _interopRequireDefault(require("../search-box"));
39
39
 
40
+ var _ocr = _interopRequireDefault(require("../ocr"));
41
+
40
42
  function _getRequireWildcardCache(nodeInterop) { if (typeof WeakMap !== "function") return null; var cacheBabelInterop = new WeakMap(); var cacheNodeInterop = new WeakMap(); return (_getRequireWildcardCache = function _getRequireWildcardCache(nodeInterop) { return nodeInterop ? cacheNodeInterop : cacheBabelInterop; })(nodeInterop); }
41
43
 
42
44
  function _interopRequireWildcard(obj, nodeInterop) { if (!nodeInterop && obj && obj.__esModule) { return obj; } if (obj === null || _typeof(obj) !== "object" && typeof obj !== "function") { return { default: obj }; } var cache = _getRequireWildcardCache(nodeInterop); if (cache && cache.has(obj)) { return cache.get(obj); } var newObj = {}; var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var key in obj) { if (key !== "default" && Object.prototype.hasOwnProperty.call(obj, key)) { var desc = hasPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : null; if (desc && (desc.get || desc.set)) { Object.defineProperty(newObj, key, desc); } else { newObj[key] = obj[key]; } } } newObj.default = obj; if (cache) { cache.set(obj, newObj); } return newObj; }
@@ -75,7 +77,8 @@ var elementMap = {
75
77
  Confirmation: _confirmation.default,
76
78
  ExpiryDate: _input.ExpiryDate,
77
79
  Typography: _typography.default,
78
- SearchBox: _searchBox.default
80
+ SearchBox: _searchBox.default,
81
+ OCR: _ocr.default
79
82
  };
80
83
 
81
84
  var Unknown = function Unknown() {
package/lib/form/index.js CHANGED
@@ -37,6 +37,8 @@ var _locale = require("../locale");
37
37
 
38
38
  var _formUtils = require("./../utils/form-utils");
39
39
 
40
+ var _ocr = _interopRequireDefault(require("../hooks/ocr"));
41
+
40
42
  var _excluded = ["validateMessages"];
41
43
 
42
44
  function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
@@ -91,7 +93,8 @@ var IglooForm = function IglooForm(props, ref) {
91
93
  selectDatasourceApi = props.selectDatasourceApi,
92
94
  getRuleValidationApi = props.getRuleValidationApi,
93
95
  _props$stepDirection = props.stepDirection,
94
- stepDirection = _props$stepDirection === void 0 ? 'vertical' : _props$stepDirection;
96
+ stepDirection = _props$stepDirection === void 0 ? 'vertical' : _props$stepDirection,
97
+ ocr = props.ocr;
95
98
 
96
99
  var _Form$useForm = _form.default.useForm(),
97
100
  _Form$useForm2 = _slicedToArray(_Form$useForm, 1),
@@ -119,6 +122,13 @@ var IglooForm = function IglooForm(props, ref) {
119
122
  currentLang = _useContext.currentLang;
120
123
 
121
124
  var validationRule = props.validationRule || config.validationRule;
125
+ var createHooks = (0, _ocr.default)();
126
+ var ocrHooks = undefined;
127
+
128
+ if (ocr) {
129
+ ocrHooks = createHooks(ocr);
130
+ }
131
+
122
132
  (0, _invariant.default)(type, "Contianer type should be one of ['Pages', 'Page', 'Steps', 'Login']");
123
133
  (0, _invariant.default)(!validationRule || getRuleValidationApi, 'Please provide getRuleValidationApi in Form props');
124
134
 
@@ -302,7 +312,8 @@ var IglooForm = function IglooForm(props, ref) {
302
312
  uploadApi: uploadApi,
303
313
  selectDatasourceApi: selectDatasourceApi,
304
314
  getRuleValidationApi: getRuleValidationApi,
305
- handleValuesChange: handleValuesChange
315
+ handleValuesChange: handleValuesChange,
316
+ ocrHooks: ocrHooks
306
317
  }, locales),
307
318
  children: (0, _jsxRuntime.jsxs)(_form.default, {
308
319
  form: form,
@@ -1,6 +1,6 @@
1
1
  import React from 'react';
2
2
  import { FormInstance } from 'antd/es/form';
3
- import { FormItemName } from '@/types';
3
+ import { FormItemName, OCRHooks } from './types';
4
4
  declare const _default: React.Context<{
5
5
  form?: FormInstance<any> | undefined;
6
6
  onCancel?(): void;
@@ -19,5 +19,6 @@ declare const _default: React.Context<{
19
19
  selectDatasourceApi?: string | undefined;
20
20
  getRuleValidationApi?: string | undefined;
21
21
  handleValuesChange(changedFields: any): any;
22
+ ocrHooks?: OCRHooks | undefined;
22
23
  }>;
23
24
  export default _default;
@@ -14,7 +14,8 @@ var _default = /*#__PURE__*/_react.default.createContext({
14
14
  return window;
15
15
  },
16
16
  registerDependencies: function registerDependencies() {},
17
- handleValuesChange: function handleValuesChange() {}
17
+ handleValuesChange: function handleValuesChange() {},
18
+ ocrHooks: {}
18
19
  });
19
20
 
20
21
  exports.default = _default;
@@ -0,0 +1 @@
1
+
@@ -0,0 +1 @@
1
+ "use strict";
@@ -0,0 +1,3 @@
1
+ import { OCRConfig, OCRHooks } from '../../types';
2
+ declare const useOCR: () => (config: OCRConfig) => OCRHooks;
3
+ export default useOCR;
@@ -0,0 +1,36 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ exports.default = void 0;
7
+
8
+ var _invariant = _interopRequireDefault(require("invariant"));
9
+
10
+ var _microBlink = _interopRequireDefault(require("./micro-blink"));
11
+
12
+ function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
13
+
14
+ var useOCR = function useOCR() {
15
+ var createRecognize = (0, _microBlink.default)();
16
+ return function (config) {
17
+ var microBlink = config.microBlink;
18
+
19
+ var _ref = microBlink || {},
20
+ licenseKey = _ref.licenseKey;
21
+
22
+ var hooks = {};
23
+ (0, _invariant.default)(Boolean(microBlink) === Boolean(licenseKey), 'Must Config licenseKey of Micro Blink');
24
+
25
+ if (microBlink && licenseKey) {
26
+ hooks['microBlink'] = {
27
+ recognize: createRecognize(licenseKey)
28
+ };
29
+ }
30
+
31
+ return hooks;
32
+ };
33
+ };
34
+
35
+ var _default = useOCR;
36
+ exports.default = _default;
@@ -0,0 +1,3 @@
1
+ import * as BlinkIDSDK from '@microblink/blinkid-in-browser-sdk';
2
+ declare const useMicroBlink: () => (licenseKey: string) => (file: File) => Promise<BlinkIDSDK.BlinkIdSingleSideRecognizerResult | null>;
3
+ export default useMicroBlink;