iglooform 3.0.0-alpha.8 → 3.0.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/.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/.vscode/settings.json +3 -0
- package/es/card-detail/card-page.d.ts +2 -2
- package/es/card-detail/card.d.ts +2 -2
- package/es/filter/index.js +4 -0
- package/es/form/elements.js +3 -1
- package/es/form/hsteps/index.js +8 -11
- package/es/form/index.js +11 -3
- package/es/form/steps/index.js +8 -11
- package/es/form-context.d.ts +3 -2
- package/es/form-context.js +2 -1
- package/es/free-form/index.js +10 -2
- package/es/free-form/steps/index.js +8 -11
- package/es/hooks/ocr/index.d.ts +3 -0
- package/es/hooks/ocr/index.js +17 -0
- package/es/hooks/ocr/micro-blink.d.ts +6 -0
- package/es/hooks/ocr/micro-blink.js +207 -0
- package/es/index.d.ts +1 -0
- package/es/index.js +1 -0
- package/es/input/phone-number.js +1 -1
- package/es/locale/en-US/messages.json +4 -0
- package/es/locale/id-ID/messages.json +4 -0
- package/es/locale/th-TH/messages.json +4 -0
- package/es/locale/vi-VN/messages.json +4 -0
- package/es/locale/zh-CN/messages.json +4 -0
- package/es/locale/zh-TW/messages.json +4 -0
- package/es/ocr/index.d.ts +15 -0
- package/es/ocr/index.js +29 -0
- package/es/ocr/micro-blink/index.d.ts +8 -0
- package/es/ocr/micro-blink/index.js +166 -0
- package/es/ocr/micro-blink/style/index.js +1 -0
- package/es/ocr/micro-blink/style/index.less +30 -0
- package/es/types.d.ts +21 -1
- package/es/utils/form-utils.js +1 -1
- package/es/utils/useAsyncEffect.js +66 -0
- package/lib/card-detail/card-page.d.ts +2 -2
- package/lib/card-detail/card.d.ts +2 -2
- package/lib/filter/index.js +4 -0
- package/lib/form/elements.js +3 -1
- package/lib/form/hsteps/index.js +8 -11
- package/lib/form/index.js +11 -5
- package/lib/form/steps/index.js +8 -11
- package/lib/form-context.d.ts +3 -2
- package/lib/form-context.js +2 -1
- package/lib/free-form/index.js +10 -2
- package/lib/free-form/steps/index.js +8 -11
- package/lib/hooks/ocr/index.d.ts +3 -0
- package/lib/hooks/ocr/index.js +25 -0
- package/lib/hooks/ocr/micro-blink.d.ts +6 -0
- package/lib/hooks/ocr/micro-blink.js +217 -0
- package/lib/index.d.ts +1 -0
- package/lib/index.js +7 -0
- package/lib/input/phone-number.js +1 -1
- package/lib/locale/en-US/messages.json +4 -0
- package/lib/locale/id-ID/messages.json +4 -0
- package/lib/locale/th-TH/messages.json +4 -0
- package/lib/locale/vi-VN/messages.json +4 -0
- package/lib/locale/zh-CN/messages.json +4 -0
- package/lib/locale/zh-TW/messages.json +4 -0
- package/lib/ocr/index.d.ts +15 -0
- package/lib/ocr/index.js +37 -0
- package/lib/ocr/micro-blink/index.d.ts +8 -0
- package/lib/ocr/micro-blink/index.js +175 -0
- package/lib/ocr/micro-blink/style/index.js +3 -0
- package/lib/ocr/micro-blink/style/index.less +30 -0
- package/lib/types.d.ts +21 -1
- package/lib/utils/form-utils.js +1 -1
- package/lib/utils/useAsyncEffect.js +73 -0
- package/package.json +2 -1
- package/es/admin-amount/style/index.d.ts +0 -0
- package/es/babel-plugin-import-option.d.ts +0 -7
- package/es/back-top/index.d.ts +0 -5
- package/es/input/style/amount/index.d.ts +0 -2
- package/es/input/style/index.d.ts +0 -2
- package/es/input/style/input-date/index.d.ts +0 -2
- package/es/input/style/otp/index.d.ts +0 -2
- package/es/input/style/phone-number/index.d.ts +0 -2
- package/es/input/style/text-area/index.d.ts +0 -2
- package/es/locale/locale-provider.d.ts +0 -11
- package/es/login-page/index.d.ts +0 -7
- package/es/message/style/index.d.ts +0 -1
- package/es/platform/platform-card/index.d.ts +0 -12
- package/es/platform/switch-platform/index.d.ts +0 -12
- package/es/tabs/index.d.ts +0 -15
- package/lib/admin-amount/style/index.d.ts +0 -0
- package/lib/babel-plugin-import-option.d.ts +0 -7
- package/lib/back-top/index.d.ts +0 -5
- package/lib/input/style/amount/index.d.ts +0 -2
- package/lib/input/style/index.d.ts +0 -2
- package/lib/input/style/input-date/index.d.ts +0 -2
- package/lib/input/style/otp/index.d.ts +0 -2
- package/lib/input/style/phone-number/index.d.ts +0 -2
- package/lib/input/style/text-area/index.d.ts +0 -2
- package/lib/locale/locale-provider.d.ts +0 -11
- package/lib/login-page/index.d.ts +0 -7
- package/lib/message/style/index.d.ts +0 -1
- package/lib/platform/platform-card/index.d.ts +0 -12
- package/lib/platform/switch-platform/index.d.ts +0 -12
- package/lib/tabs/index.d.ts +0 -15
package/es/filter/index.js
CHANGED
|
@@ -667,6 +667,10 @@ var FilterComponent = function FilterComponent(props) {
|
|
|
667
667
|
})
|
|
668
668
|
})
|
|
669
669
|
}), /*#__PURE__*/_jsx(Button, {
|
|
670
|
+
style: {
|
|
671
|
+
display: 'flex',
|
|
672
|
+
alignItems: 'center'
|
|
673
|
+
},
|
|
670
674
|
onClick: function onClick() {
|
|
671
675
|
setDropVisible(false);
|
|
672
676
|
setShowSearchInputDefault(false);
|
package/es/form/elements.js
CHANGED
|
@@ -14,6 +14,7 @@ import RenderElement from "./render";
|
|
|
14
14
|
import Typography from "../typography";
|
|
15
15
|
import SearchBox from "../search-box";
|
|
16
16
|
import formContext from "../form-context";
|
|
17
|
+
import OCR from "../ocr";
|
|
17
18
|
var elementMap = {
|
|
18
19
|
Input: Input,
|
|
19
20
|
PhoneNumber: PhoneNumber,
|
|
@@ -46,7 +47,8 @@ var elementMap = {
|
|
|
46
47
|
Confirmation: Confirmation,
|
|
47
48
|
ExpiryDate: ExpiryDate,
|
|
48
49
|
Typography: Typography,
|
|
49
|
-
SearchBox: SearchBox
|
|
50
|
+
SearchBox: SearchBox,
|
|
51
|
+
OCR: OCR
|
|
50
52
|
};
|
|
51
53
|
var Unknown = function Unknown() {
|
|
52
54
|
return 'Unknown Form Item';
|
package/es/form/hsteps/index.js
CHANGED
|
@@ -52,14 +52,11 @@ var HSteps = function HSteps(_ref) {
|
|
|
52
52
|
_useState2 = _slicedToArray(_useState, 2),
|
|
53
53
|
current = _useState2[0],
|
|
54
54
|
setCurrent = _useState2[1];
|
|
55
|
-
|
|
55
|
+
// const [last, setLast] = useState(0);
|
|
56
|
+
var _useState3 = useState(false),
|
|
56
57
|
_useState4 = _slicedToArray(_useState3, 2),
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
var _useState5 = useState(false),
|
|
60
|
-
_useState6 = _slicedToArray(_useState5, 2),
|
|
61
|
-
shouldScroll = _useState6[0],
|
|
62
|
-
setShouldScroll = _useState6[1];
|
|
58
|
+
shouldScroll = _useState4[0],
|
|
59
|
+
setShouldScroll = _useState4[1];
|
|
63
60
|
var _useReducer = useReducer(function (r) {
|
|
64
61
|
return r + 1;
|
|
65
62
|
}, 0),
|
|
@@ -203,10 +200,10 @@ var HSteps = function HSteps(_ref) {
|
|
|
203
200
|
_context.t2 = _context["catch"](31);
|
|
204
201
|
return _context.abrupt("return");
|
|
205
202
|
case 42:
|
|
206
|
-
setCurrent(
|
|
207
|
-
setLast(0);
|
|
203
|
+
setCurrent(current + 1);
|
|
204
|
+
// setLast(0);
|
|
208
205
|
setShouldScroll(true);
|
|
209
|
-
case
|
|
206
|
+
case 44:
|
|
210
207
|
case "end":
|
|
211
208
|
return _context.stop();
|
|
212
209
|
}
|
|
@@ -217,7 +214,7 @@ var HSteps = function HSteps(_ref) {
|
|
|
217
214
|
};
|
|
218
215
|
}();
|
|
219
216
|
var handleEdit = function handleEdit(index) {
|
|
220
|
-
setLast(current);
|
|
217
|
+
// setLast(current);
|
|
221
218
|
setCurrent(index);
|
|
222
219
|
setShouldScroll(false);
|
|
223
220
|
typeof onEdit === 'function' && onEdit(index);
|
package/es/form/index.js
CHANGED
|
@@ -16,7 +16,7 @@ function _unsupportedIterableToArray(o, minLen) { if (!o) return; if (typeof o =
|
|
|
16
16
|
function _arrayLikeToArray(arr, len) { if (len == null || len > arr.length) len = arr.length; for (var i = 0, arr2 = new Array(len); i < len; i++) arr2[i] = arr[i]; return arr2; }
|
|
17
17
|
function _iterableToArrayLimit(arr, i) { var _i = null == arr ? null : "undefined" != typeof Symbol && arr[Symbol.iterator] || arr["@@iterator"]; if (null != _i) { var _s, _e, _x, _r, _arr = [], _n = !0, _d = !1; try { if (_x = (_i = _i.call(arr)).next, 0 === i) { if (Object(_i) !== _i) return; _n = !1; } else for (; !(_n = (_s = _x.call(_i)).done) && (_arr.push(_s.value), _arr.length !== i); _n = !0); } catch (err) { _d = !0, _e = err; } finally { try { if (!_n && null != _i.return && (_r = _i.return(), Object(_r) !== _r)) return; } finally { if (_d) throw _e; } } return _arr; } }
|
|
18
18
|
function _arrayWithHoles(arr) { if (Array.isArray(arr)) return arr; }
|
|
19
|
-
import
|
|
19
|
+
import { useState, useImperativeHandle, forwardRef, useRef, useContext } from 'react';
|
|
20
20
|
import { Form } from 'antd';
|
|
21
21
|
import Pages from "./pages";
|
|
22
22
|
import Page from "./page";
|
|
@@ -30,6 +30,7 @@ import classNames from 'classnames';
|
|
|
30
30
|
import invariant from 'invariant';
|
|
31
31
|
import { LocaleContext } from "../locale";
|
|
32
32
|
import { getRuleValidation } from "./../utils/form-utils";
|
|
33
|
+
import useOCR from "../hooks/ocr";
|
|
33
34
|
import { jsx as _jsx } from "react/jsx-runtime";
|
|
34
35
|
import { jsxs as _jsxs } from "react/jsx-runtime";
|
|
35
36
|
var IglooForm = function IglooForm(props, ref) {
|
|
@@ -58,7 +59,8 @@ var IglooForm = function IglooForm(props, ref) {
|
|
|
58
59
|
_props$stepDirection = props.stepDirection,
|
|
59
60
|
stepDirection = _props$stepDirection === void 0 ? 'vertical' : _props$stepDirection,
|
|
60
61
|
_props$customizeCompo = props.customizeComponents,
|
|
61
|
-
customizeComponents = _props$customizeCompo === void 0 ? {} : _props$customizeCompo
|
|
62
|
+
customizeComponents = _props$customizeCompo === void 0 ? {} : _props$customizeCompo,
|
|
63
|
+
ocr = props.ocr;
|
|
62
64
|
var _Form$useForm = Form.useForm(),
|
|
63
65
|
_Form$useForm2 = _slicedToArray(_Form$useForm, 1),
|
|
64
66
|
innerForm = _Form$useForm2[0];
|
|
@@ -78,6 +80,11 @@ var IglooForm = function IglooForm(props, ref) {
|
|
|
78
80
|
var _useContext = useContext(LocaleContext),
|
|
79
81
|
currentLang = _useContext.currentLang;
|
|
80
82
|
var validationRule = props.validationRule || config.validationRule;
|
|
83
|
+
var createHooks = useOCR();
|
|
84
|
+
var ocrHooks = undefined;
|
|
85
|
+
if (ocr) {
|
|
86
|
+
ocrHooks = createHooks(ocr);
|
|
87
|
+
}
|
|
81
88
|
invariant(type, "Contianer type should be one of ['Pages', 'Page', 'Steps', 'Login']");
|
|
82
89
|
invariant(!validationRule || getRuleValidationApi, 'Please provide getRuleValidationApi in Form props');
|
|
83
90
|
var validateMessages = localesProp.validateMessages,
|
|
@@ -225,7 +232,8 @@ var IglooForm = function IglooForm(props, ref) {
|
|
|
225
232
|
selectDatasourceApi: selectDatasourceApi,
|
|
226
233
|
getRuleValidationApi: getRuleValidationApi,
|
|
227
234
|
handleValuesChange: handleValuesChange,
|
|
228
|
-
customizeComponents: customizeComponents
|
|
235
|
+
customizeComponents: customizeComponents,
|
|
236
|
+
ocrHooks: ocrHooks
|
|
229
237
|
}, locales),
|
|
230
238
|
children: /*#__PURE__*/_jsxs(Form, {
|
|
231
239
|
form: form,
|
package/es/form/steps/index.js
CHANGED
|
@@ -35,14 +35,11 @@ var Steps = function Steps(_ref) {
|
|
|
35
35
|
_useState2 = _slicedToArray(_useState, 2),
|
|
36
36
|
current = _useState2[0],
|
|
37
37
|
setCurrent = _useState2[1];
|
|
38
|
-
|
|
38
|
+
// const [last, setLast] = useState(0);
|
|
39
|
+
var _useState3 = useState(false),
|
|
39
40
|
_useState4 = _slicedToArray(_useState3, 2),
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
var _useState5 = useState(false),
|
|
43
|
-
_useState6 = _slicedToArray(_useState5, 2),
|
|
44
|
-
shouldScroll = _useState6[0],
|
|
45
|
-
setShouldScroll = _useState6[1];
|
|
41
|
+
shouldScroll = _useState4[0],
|
|
42
|
+
setShouldScroll = _useState4[1];
|
|
46
43
|
var _useReducer = useReducer(function (r) {
|
|
47
44
|
return r + 1;
|
|
48
45
|
}, 0),
|
|
@@ -165,10 +162,10 @@ var Steps = function Steps(_ref) {
|
|
|
165
162
|
_context.t2 = _context["catch"](29);
|
|
166
163
|
return _context.abrupt("return");
|
|
167
164
|
case 40:
|
|
168
|
-
setCurrent(
|
|
169
|
-
setLast(0);
|
|
165
|
+
setCurrent(current + 1);
|
|
166
|
+
// setLast(0);
|
|
170
167
|
setShouldScroll(true);
|
|
171
|
-
case
|
|
168
|
+
case 42:
|
|
172
169
|
case "end":
|
|
173
170
|
return _context.stop();
|
|
174
171
|
}
|
|
@@ -179,7 +176,7 @@ var Steps = function Steps(_ref) {
|
|
|
179
176
|
};
|
|
180
177
|
}();
|
|
181
178
|
var handleEdit = function handleEdit(index) {
|
|
182
|
-
setLast(current);
|
|
179
|
+
// setLast(current);
|
|
183
180
|
setCurrent(index);
|
|
184
181
|
setShouldScroll(false);
|
|
185
182
|
typeof onEdit === 'function' && onEdit(index);
|
package/es/form-context.d.ts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import React from 'react';
|
|
2
2
|
import { FormInstance } from 'antd/es/form';
|
|
3
|
-
import { FC, FormItemName } from './types';
|
|
3
|
+
import { FC, FormItemName, OCRHooks } from './types';
|
|
4
4
|
declare const _default: React.Context<{
|
|
5
5
|
form?: FormInstance<any> | undefined;
|
|
6
6
|
onCancel?(): void;
|
|
@@ -15,12 +15,13 @@ declare const _default: React.Context<{
|
|
|
15
15
|
showSubmitButton?: boolean | undefined;
|
|
16
16
|
getScrollContainer: () => HTMLElement | Window | null;
|
|
17
17
|
registerDependencies: (name: FormItemName | FormItemName[], updater: Function) => void;
|
|
18
|
+
handleValuesChange(changedFields: any): any;
|
|
18
19
|
uploadApi?: string | undefined;
|
|
19
20
|
selectDatasourceApi?: string | undefined;
|
|
20
21
|
getRuleValidationApi?: string | undefined;
|
|
21
|
-
handleValuesChange(changedFields: any): any;
|
|
22
22
|
customizeComponents?: {
|
|
23
23
|
[name: string]: FC<{}>;
|
|
24
24
|
} | undefined;
|
|
25
|
+
ocrHooks?: OCRHooks | undefined;
|
|
25
26
|
}>;
|
|
26
27
|
export default _default;
|
package/es/form-context.js
CHANGED
package/es/free-form/index.js
CHANGED
|
@@ -23,6 +23,7 @@ import messages from "./messages";
|
|
|
23
23
|
import "./style";
|
|
24
24
|
import invariant from 'invariant';
|
|
25
25
|
import classNames from 'classnames';
|
|
26
|
+
import useOCR from "../hooks/ocr";
|
|
26
27
|
import { LocaleContext } from "../locale";
|
|
27
28
|
import { getRuleValidation } from "./../utils/form-utils";
|
|
28
29
|
import { jsx as _jsx } from "react/jsx-runtime";
|
|
@@ -49,7 +50,8 @@ var FreeForm = function FreeForm(props) {
|
|
|
49
50
|
uploadApi = props.uploadApi,
|
|
50
51
|
selectDatasourceApi = props.selectDatasourceApi,
|
|
51
52
|
validationRule = props.validationRule,
|
|
52
|
-
getRuleValidationApi = props.getRuleValidationApi
|
|
53
|
+
getRuleValidationApi = props.getRuleValidationApi,
|
|
54
|
+
ocr = props.ocr;
|
|
53
55
|
var _Form$useForm = Form.useForm(),
|
|
54
56
|
_Form$useForm2 = _slicedToArray(_Form$useForm, 1),
|
|
55
57
|
innerForm = _Form$useForm2[0];
|
|
@@ -67,6 +69,11 @@ var FreeForm = function FreeForm(props) {
|
|
|
67
69
|
callFirstModified = _useState6[1];
|
|
68
70
|
var _useContext = useContext(LocaleContext),
|
|
69
71
|
currentLang = _useContext.currentLang;
|
|
72
|
+
var createHooks = useOCR();
|
|
73
|
+
var ocrHooks = undefined;
|
|
74
|
+
if (ocr) {
|
|
75
|
+
ocrHooks = createHooks(ocr);
|
|
76
|
+
}
|
|
70
77
|
invariant(!validationRule || getRuleValidationApi, 'Please provide getRuleValidationApi in Form props');
|
|
71
78
|
var validateMessages = localesProp.validateMessages,
|
|
72
79
|
locales = _objectWithoutProperties(localesProp, _excluded);
|
|
@@ -185,7 +192,8 @@ var FreeForm = function FreeForm(props) {
|
|
|
185
192
|
uploadApi: uploadApi,
|
|
186
193
|
selectDatasourceApi: selectDatasourceApi,
|
|
187
194
|
getRuleValidationApi: getRuleValidationApi,
|
|
188
|
-
handleValuesChange: handleValuesChange
|
|
195
|
+
handleValuesChange: handleValuesChange,
|
|
196
|
+
ocrHooks: ocrHooks
|
|
189
197
|
}, locales),
|
|
190
198
|
children: /*#__PURE__*/_jsx(Form, {
|
|
191
199
|
form: form,
|
|
@@ -29,14 +29,11 @@ var Steps = function Steps(_ref) {
|
|
|
29
29
|
_useState2 = _slicedToArray(_useState, 2),
|
|
30
30
|
current = _useState2[0],
|
|
31
31
|
setCurrent = _useState2[1];
|
|
32
|
-
|
|
32
|
+
// const [last, setLast] = useState(0);
|
|
33
|
+
var _useState3 = useState(false),
|
|
33
34
|
_useState4 = _slicedToArray(_useState3, 2),
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
var _useState5 = useState(false),
|
|
37
|
-
_useState6 = _slicedToArray(_useState5, 2),
|
|
38
|
-
shouldScroll = _useState6[0],
|
|
39
|
-
setShouldScroll = _useState6[1];
|
|
35
|
+
shouldScroll = _useState4[0],
|
|
36
|
+
setShouldScroll = _useState4[1];
|
|
40
37
|
useEffect(function () {
|
|
41
38
|
if (currentStep === undefined || currentStep === current) return;
|
|
42
39
|
setCurrent(currentStep);
|
|
@@ -46,10 +43,10 @@ var Steps = function Steps(_ref) {
|
|
|
46
43
|
return _regeneratorRuntime().wrap(function _callee$(_context) {
|
|
47
44
|
while (1) switch (_context.prev = _context.next) {
|
|
48
45
|
case 0:
|
|
49
|
-
setCurrent(
|
|
50
|
-
setLast(0);
|
|
46
|
+
setCurrent(current + 1);
|
|
47
|
+
// setLast(0);
|
|
51
48
|
setShouldScroll(true);
|
|
52
|
-
case
|
|
49
|
+
case 2:
|
|
53
50
|
case "end":
|
|
54
51
|
return _context.stop();
|
|
55
52
|
}
|
|
@@ -60,7 +57,7 @@ var Steps = function Steps(_ref) {
|
|
|
60
57
|
};
|
|
61
58
|
}();
|
|
62
59
|
var handleEdit = function handleEdit(index) {
|
|
63
|
-
setLast(current);
|
|
60
|
+
// setLast(current);
|
|
64
61
|
setCurrent(index);
|
|
65
62
|
setShouldScroll(false);
|
|
66
63
|
typeof onEdit === 'function' && onEdit(index);
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import invariant from 'invariant';
|
|
2
|
+
import useMicroBlink from "./micro-blink";
|
|
3
|
+
var useOCR = function useOCR() {
|
|
4
|
+
var createRecognize = useMicroBlink();
|
|
5
|
+
return function (config) {
|
|
6
|
+
var microBlink = config.microBlink;
|
|
7
|
+
var _ref = microBlink || {},
|
|
8
|
+
licenseKey = _ref.licenseKey;
|
|
9
|
+
var hooks = {};
|
|
10
|
+
invariant(Boolean(microBlink) === Boolean(licenseKey), 'Must Config licenseKey of Micro Blink');
|
|
11
|
+
if (microBlink && licenseKey) {
|
|
12
|
+
hooks['microBlink'] = createRecognize(licenseKey);
|
|
13
|
+
}
|
|
14
|
+
return hooks;
|
|
15
|
+
};
|
|
16
|
+
};
|
|
17
|
+
export default useOCR;
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
import * as BlinkIDSDK from '@microblink/blinkid-in-browser-sdk';
|
|
2
|
+
declare const useMicroBlink: () => (licenseKey: string) => {
|
|
3
|
+
recognize: (file: File) => Promise<BlinkIDSDK.BlinkIdSingleSideRecognizerResult | null>;
|
|
4
|
+
loading: boolean;
|
|
5
|
+
};
|
|
6
|
+
export default useMicroBlink;
|
|
@@ -0,0 +1,207 @@
|
|
|
1
|
+
function _typeof(obj) { "@babel/helpers - typeof"; return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function (obj) { return typeof obj; } : function (obj) { return obj && "function" == typeof Symbol && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }, _typeof(obj); }
|
|
2
|
+
function _regeneratorRuntime() { "use strict"; /*! regenerator-runtime -- Copyright (c) 2014-present, Facebook, Inc. -- license (MIT): https://github.com/facebook/regenerator/blob/main/LICENSE */ _regeneratorRuntime = function _regeneratorRuntime() { return exports; }; var exports = {}, Op = Object.prototype, hasOwn = Op.hasOwnProperty, defineProperty = Object.defineProperty || function (obj, key, desc) { obj[key] = desc.value; }, $Symbol = "function" == typeof Symbol ? Symbol : {}, iteratorSymbol = $Symbol.iterator || "@@iterator", asyncIteratorSymbol = $Symbol.asyncIterator || "@@asyncIterator", toStringTagSymbol = $Symbol.toStringTag || "@@toStringTag"; function define(obj, key, value) { return Object.defineProperty(obj, key, { value: value, enumerable: !0, configurable: !0, writable: !0 }), obj[key]; } try { define({}, ""); } catch (err) { define = function define(obj, key, value) { return obj[key] = value; }; } function wrap(innerFn, outerFn, self, tryLocsList) { var protoGenerator = outerFn && outerFn.prototype instanceof Generator ? outerFn : Generator, generator = Object.create(protoGenerator.prototype), context = new Context(tryLocsList || []); return defineProperty(generator, "_invoke", { value: makeInvokeMethod(innerFn, self, context) }), generator; } function tryCatch(fn, obj, arg) { try { return { type: "normal", arg: fn.call(obj, arg) }; } catch (err) { return { type: "throw", arg: err }; } } exports.wrap = wrap; var ContinueSentinel = {}; function Generator() {} function GeneratorFunction() {} function GeneratorFunctionPrototype() {} var IteratorPrototype = {}; define(IteratorPrototype, iteratorSymbol, function () { return this; }); var getProto = Object.getPrototypeOf, NativeIteratorPrototype = getProto && getProto(getProto(values([]))); NativeIteratorPrototype && NativeIteratorPrototype !== Op && hasOwn.call(NativeIteratorPrototype, iteratorSymbol) && (IteratorPrototype = NativeIteratorPrototype); var Gp = GeneratorFunctionPrototype.prototype = Generator.prototype = Object.create(IteratorPrototype); function defineIteratorMethods(prototype) { ["next", "throw", "return"].forEach(function (method) { define(prototype, method, function (arg) { return this._invoke(method, arg); }); }); } function AsyncIterator(generator, PromiseImpl) { function invoke(method, arg, resolve, reject) { var record = tryCatch(generator[method], generator, arg); if ("throw" !== record.type) { var result = record.arg, value = result.value; return value && "object" == _typeof(value) && hasOwn.call(value, "__await") ? PromiseImpl.resolve(value.__await).then(function (value) { invoke("next", value, resolve, reject); }, function (err) { invoke("throw", err, resolve, reject); }) : PromiseImpl.resolve(value).then(function (unwrapped) { result.value = unwrapped, resolve(result); }, function (error) { return invoke("throw", error, resolve, reject); }); } reject(record.arg); } var previousPromise; defineProperty(this, "_invoke", { value: function value(method, arg) { function callInvokeWithMethodAndArg() { return new PromiseImpl(function (resolve, reject) { invoke(method, arg, resolve, reject); }); } return previousPromise = previousPromise ? previousPromise.then(callInvokeWithMethodAndArg, callInvokeWithMethodAndArg) : callInvokeWithMethodAndArg(); } }); } function makeInvokeMethod(innerFn, self, context) { var state = "suspendedStart"; return function (method, arg) { if ("executing" === state) throw new Error("Generator is already running"); if ("completed" === state) { if ("throw" === method) throw arg; return doneResult(); } for (context.method = method, context.arg = arg;;) { var delegate = context.delegate; if (delegate) { var delegateResult = maybeInvokeDelegate(delegate, context); if (delegateResult) { if (delegateResult === ContinueSentinel) continue; return delegateResult; } } if ("next" === context.method) context.sent = context._sent = context.arg;else if ("throw" === context.method) { if ("suspendedStart" === state) throw state = "completed", context.arg; context.dispatchException(context.arg); } else "return" === context.method && context.abrupt("return", context.arg); state = "executing"; var record = tryCatch(innerFn, self, context); if ("normal" === record.type) { if (state = context.done ? "completed" : "suspendedYield", record.arg === ContinueSentinel) continue; return { value: record.arg, done: context.done }; } "throw" === record.type && (state = "completed", context.method = "throw", context.arg = record.arg); } }; } function maybeInvokeDelegate(delegate, context) { var methodName = context.method, method = delegate.iterator[methodName]; if (undefined === method) return context.delegate = null, "throw" === methodName && delegate.iterator.return && (context.method = "return", context.arg = undefined, maybeInvokeDelegate(delegate, context), "throw" === context.method) || "return" !== methodName && (context.method = "throw", context.arg = new TypeError("The iterator does not provide a '" + methodName + "' method")), ContinueSentinel; var record = tryCatch(method, delegate.iterator, context.arg); if ("throw" === record.type) return context.method = "throw", context.arg = record.arg, context.delegate = null, ContinueSentinel; var info = record.arg; return info ? info.done ? (context[delegate.resultName] = info.value, context.next = delegate.nextLoc, "return" !== context.method && (context.method = "next", context.arg = undefined), context.delegate = null, ContinueSentinel) : info : (context.method = "throw", context.arg = new TypeError("iterator result is not an object"), context.delegate = null, ContinueSentinel); } function pushTryEntry(locs) { var entry = { tryLoc: locs[0] }; 1 in locs && (entry.catchLoc = locs[1]), 2 in locs && (entry.finallyLoc = locs[2], entry.afterLoc = locs[3]), this.tryEntries.push(entry); } function resetTryEntry(entry) { var record = entry.completion || {}; record.type = "normal", delete record.arg, entry.completion = record; } function Context(tryLocsList) { this.tryEntries = [{ tryLoc: "root" }], tryLocsList.forEach(pushTryEntry, this), this.reset(!0); } function values(iterable) { if (iterable) { var iteratorMethod = iterable[iteratorSymbol]; if (iteratorMethod) return iteratorMethod.call(iterable); if ("function" == typeof iterable.next) return iterable; if (!isNaN(iterable.length)) { var i = -1, next = function next() { for (; ++i < iterable.length;) if (hasOwn.call(iterable, i)) return next.value = iterable[i], next.done = !1, next; return next.value = undefined, next.done = !0, next; }; return next.next = next; } } return { next: doneResult }; } function doneResult() { return { value: undefined, done: !0 }; } return GeneratorFunction.prototype = GeneratorFunctionPrototype, defineProperty(Gp, "constructor", { value: GeneratorFunctionPrototype, configurable: !0 }), defineProperty(GeneratorFunctionPrototype, "constructor", { value: GeneratorFunction, configurable: !0 }), GeneratorFunction.displayName = define(GeneratorFunctionPrototype, toStringTagSymbol, "GeneratorFunction"), exports.isGeneratorFunction = function (genFun) { var ctor = "function" == typeof genFun && genFun.constructor; return !!ctor && (ctor === GeneratorFunction || "GeneratorFunction" === (ctor.displayName || ctor.name)); }, exports.mark = function (genFun) { return Object.setPrototypeOf ? Object.setPrototypeOf(genFun, GeneratorFunctionPrototype) : (genFun.__proto__ = GeneratorFunctionPrototype, define(genFun, toStringTagSymbol, "GeneratorFunction")), genFun.prototype = Object.create(Gp), genFun; }, exports.awrap = function (arg) { return { __await: arg }; }, defineIteratorMethods(AsyncIterator.prototype), define(AsyncIterator.prototype, asyncIteratorSymbol, function () { return this; }), exports.AsyncIterator = AsyncIterator, exports.async = function (innerFn, outerFn, self, tryLocsList, PromiseImpl) { void 0 === PromiseImpl && (PromiseImpl = Promise); var iter = new AsyncIterator(wrap(innerFn, outerFn, self, tryLocsList), PromiseImpl); return exports.isGeneratorFunction(outerFn) ? iter : iter.next().then(function (result) { return result.done ? result.value : iter.next(); }); }, defineIteratorMethods(Gp), define(Gp, toStringTagSymbol, "Generator"), define(Gp, iteratorSymbol, function () { return this; }), define(Gp, "toString", function () { return "[object Generator]"; }), exports.keys = function (val) { var object = Object(val), keys = []; for (var key in object) keys.push(key); return keys.reverse(), function next() { for (; keys.length;) { var key = keys.pop(); if (key in object) return next.value = key, next.done = !1, next; } return next.done = !0, next; }; }, exports.values = values, Context.prototype = { constructor: Context, reset: function reset(skipTempReset) { if (this.prev = 0, this.next = 0, this.sent = this._sent = undefined, this.done = !1, this.delegate = null, this.method = "next", this.arg = undefined, this.tryEntries.forEach(resetTryEntry), !skipTempReset) for (var name in this) "t" === name.charAt(0) && hasOwn.call(this, name) && !isNaN(+name.slice(1)) && (this[name] = undefined); }, stop: function stop() { this.done = !0; var rootRecord = this.tryEntries[0].completion; if ("throw" === rootRecord.type) throw rootRecord.arg; return this.rval; }, dispatchException: function dispatchException(exception) { if (this.done) throw exception; var context = this; function handle(loc, caught) { return record.type = "throw", record.arg = exception, context.next = loc, caught && (context.method = "next", context.arg = undefined), !!caught; } for (var i = this.tryEntries.length - 1; i >= 0; --i) { var entry = this.tryEntries[i], record = entry.completion; if ("root" === entry.tryLoc) return handle("end"); if (entry.tryLoc <= this.prev) { var hasCatch = hasOwn.call(entry, "catchLoc"), hasFinally = hasOwn.call(entry, "finallyLoc"); if (hasCatch && hasFinally) { if (this.prev < entry.catchLoc) return handle(entry.catchLoc, !0); if (this.prev < entry.finallyLoc) return handle(entry.finallyLoc); } else if (hasCatch) { if (this.prev < entry.catchLoc) return handle(entry.catchLoc, !0); } else { if (!hasFinally) throw new Error("try statement without catch or finally"); if (this.prev < entry.finallyLoc) return handle(entry.finallyLoc); } } } }, abrupt: function abrupt(type, arg) { for (var i = this.tryEntries.length - 1; i >= 0; --i) { var entry = this.tryEntries[i]; if (entry.tryLoc <= this.prev && hasOwn.call(entry, "finallyLoc") && this.prev < entry.finallyLoc) { var finallyEntry = entry; break; } } finallyEntry && ("break" === type || "continue" === type) && finallyEntry.tryLoc <= arg && arg <= finallyEntry.finallyLoc && (finallyEntry = null); var record = finallyEntry ? finallyEntry.completion : {}; return record.type = type, record.arg = arg, finallyEntry ? (this.method = "next", this.next = finallyEntry.finallyLoc, ContinueSentinel) : this.complete(record); }, complete: function complete(record, afterLoc) { if ("throw" === record.type) throw record.arg; return "break" === record.type || "continue" === record.type ? this.next = record.arg : "return" === record.type ? (this.rval = this.arg = record.arg, this.method = "return", this.next = "end") : "normal" === record.type && afterLoc && (this.next = afterLoc), ContinueSentinel; }, finish: function finish(finallyLoc) { for (var i = this.tryEntries.length - 1; i >= 0; --i) { var entry = this.tryEntries[i]; if (entry.finallyLoc === finallyLoc) return this.complete(entry.completion, entry.afterLoc), resetTryEntry(entry), ContinueSentinel; } }, catch: function _catch(tryLoc) { for (var i = this.tryEntries.length - 1; i >= 0; --i) { var entry = this.tryEntries[i]; if (entry.tryLoc === tryLoc) { var record = entry.completion; if ("throw" === record.type) { var thrown = record.arg; resetTryEntry(entry); } return thrown; } } throw new Error("illegal catch attempt"); }, delegateYield: function delegateYield(iterable, resultName, nextLoc) { return this.delegate = { iterator: values(iterable), resultName: resultName, nextLoc: nextLoc }, "next" === this.method && (this.arg = undefined), ContinueSentinel; } }, exports; }
|
|
3
|
+
function _slicedToArray(arr, i) { return _arrayWithHoles(arr) || _iterableToArrayLimit(arr, i) || _unsupportedIterableToArray(arr, i) || _nonIterableRest(); }
|
|
4
|
+
function _nonIterableRest() { throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); }
|
|
5
|
+
function _unsupportedIterableToArray(o, minLen) { if (!o) return; if (typeof o === "string") return _arrayLikeToArray(o, minLen); var n = Object.prototype.toString.call(o).slice(8, -1); if (n === "Object" && o.constructor) n = o.constructor.name; if (n === "Map" || n === "Set") return Array.from(o); if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _arrayLikeToArray(o, minLen); }
|
|
6
|
+
function _arrayLikeToArray(arr, len) { if (len == null || len > arr.length) len = arr.length; for (var i = 0, arr2 = new Array(len); i < len; i++) arr2[i] = arr[i]; return arr2; }
|
|
7
|
+
function _iterableToArrayLimit(arr, i) { var _i = null == arr ? null : "undefined" != typeof Symbol && arr[Symbol.iterator] || arr["@@iterator"]; if (null != _i) { var _s, _e, _x, _r, _arr = [], _n = !0, _d = !1; try { if (_x = (_i = _i.call(arr)).next, 0 === i) { if (Object(_i) !== _i) return; _n = !1; } else for (; !(_n = (_s = _x.call(_i)).done) && (_arr.push(_s.value), _arr.length !== i); _n = !0); } catch (err) { _d = !0, _e = err; } finally { try { if (!_n && null != _i.return && (_r = _i.return(), Object(_r) !== _r)) return; } finally { if (_d) throw _e; } } return _arr; } }
|
|
8
|
+
function _arrayWithHoles(arr) { if (Array.isArray(arr)) return arr; }
|
|
9
|
+
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); } }
|
|
10
|
+
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); }); }; }
|
|
11
|
+
import { useState, useCallback, useContext } from 'react';
|
|
12
|
+
import * as BlinkIDSDK from '@microblink/blinkid-in-browser-sdk';
|
|
13
|
+
import { LocaleContext } from "../../locale";
|
|
14
|
+
import message from "../../message";
|
|
15
|
+
var MICRO_BLINK_SERVICE_PATH = 'https://static.iglooinsure.com/microblink/in-browser';
|
|
16
|
+
function getWorkerLocation(_x) {
|
|
17
|
+
return _getWorkerLocation.apply(this, arguments);
|
|
18
|
+
}
|
|
19
|
+
function _getWorkerLocation() {
|
|
20
|
+
_getWorkerLocation = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee5(path) {
|
|
21
|
+
return _regeneratorRuntime().wrap(function _callee5$(_context5) {
|
|
22
|
+
while (1) switch (_context5.prev = _context5.next) {
|
|
23
|
+
case 0:
|
|
24
|
+
return _context5.abrupt("return", new Promise(function (resolve) {
|
|
25
|
+
window.fetch(path).then(function (response) {
|
|
26
|
+
return response.text();
|
|
27
|
+
}).then(function (data) {
|
|
28
|
+
var blob = new Blob([data], {
|
|
29
|
+
type: 'application/javascript'
|
|
30
|
+
});
|
|
31
|
+
var url = URL.createObjectURL(blob);
|
|
32
|
+
resolve(url);
|
|
33
|
+
});
|
|
34
|
+
}));
|
|
35
|
+
case 1:
|
|
36
|
+
case "end":
|
|
37
|
+
return _context5.stop();
|
|
38
|
+
}
|
|
39
|
+
}, _callee5);
|
|
40
|
+
}));
|
|
41
|
+
return _getWorkerLocation.apply(this, arguments);
|
|
42
|
+
}
|
|
43
|
+
var useMicroBlink = function useMicroBlink() {
|
|
44
|
+
var _useContext = useContext(LocaleContext),
|
|
45
|
+
formatMessage = _useContext.formatMessage;
|
|
46
|
+
var _useState = useState(false),
|
|
47
|
+
_useState2 = _slicedToArray(_useState, 2),
|
|
48
|
+
initLoading = _useState2[0],
|
|
49
|
+
setInitLoading = _useState2[1];
|
|
50
|
+
var _useState3 = useState(''),
|
|
51
|
+
_useState4 = _slicedToArray(_useState3, 2),
|
|
52
|
+
currentKey = _useState4[0],
|
|
53
|
+
setCurrentKey = _useState4[1];
|
|
54
|
+
var _useState5 = useState(null),
|
|
55
|
+
_useState6 = _slicedToArray(_useState5, 2),
|
|
56
|
+
recognizer = _useState6[0],
|
|
57
|
+
setRecognizer = _useState6[1];
|
|
58
|
+
var _useState7 = useState(null),
|
|
59
|
+
_useState8 = _slicedToArray(_useState7, 2),
|
|
60
|
+
recognizerRunner = _useState8[0],
|
|
61
|
+
setRecognizerRunner = _useState8[1];
|
|
62
|
+
var initSdk = /*#__PURE__*/function () {
|
|
63
|
+
var _ref = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee2(licenseKey) {
|
|
64
|
+
var loadSettings;
|
|
65
|
+
return _regeneratorRuntime().wrap(function _callee2$(_context2) {
|
|
66
|
+
while (1) switch (_context2.prev = _context2.next) {
|
|
67
|
+
case 0:
|
|
68
|
+
if (!BlinkIDSDK.isBrowserSupported()) {
|
|
69
|
+
_context2.next = 10;
|
|
70
|
+
break;
|
|
71
|
+
}
|
|
72
|
+
setInitLoading(true);
|
|
73
|
+
loadSettings = new BlinkIDSDK.WasmSDKLoadSettings(licenseKey);
|
|
74
|
+
loadSettings.engineLocation = MICRO_BLINK_SERVICE_PATH;
|
|
75
|
+
_context2.next = 6;
|
|
76
|
+
return getWorkerLocation("".concat(MICRO_BLINK_SERVICE_PATH, "/BlinkIDWasmSDK.worker.min.js"));
|
|
77
|
+
case 6:
|
|
78
|
+
loadSettings.workerLocation = _context2.sent;
|
|
79
|
+
BlinkIDSDK.loadWasmModule(loadSettings).then( /*#__PURE__*/function () {
|
|
80
|
+
var _ref2 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee(wasmSDK) {
|
|
81
|
+
var recognizer, recognizerRunner;
|
|
82
|
+
return _regeneratorRuntime().wrap(function _callee$(_context) {
|
|
83
|
+
while (1) switch (_context.prev = _context.next) {
|
|
84
|
+
case 0:
|
|
85
|
+
_context.next = 2;
|
|
86
|
+
return BlinkIDSDK.createBlinkIdSingleSideRecognizer(wasmSDK);
|
|
87
|
+
case 2:
|
|
88
|
+
recognizer = _context.sent;
|
|
89
|
+
_context.next = 5;
|
|
90
|
+
return BlinkIDSDK.createRecognizerRunner(wasmSDK, [recognizer], false);
|
|
91
|
+
case 5:
|
|
92
|
+
recognizerRunner = _context.sent;
|
|
93
|
+
setRecognizer(recognizer);
|
|
94
|
+
setRecognizerRunner(recognizerRunner);
|
|
95
|
+
setInitLoading(false);
|
|
96
|
+
case 9:
|
|
97
|
+
case "end":
|
|
98
|
+
return _context.stop();
|
|
99
|
+
}
|
|
100
|
+
}, _callee);
|
|
101
|
+
}));
|
|
102
|
+
return function (_x3) {
|
|
103
|
+
return _ref2.apply(this, arguments);
|
|
104
|
+
};
|
|
105
|
+
}(), function (error) {
|
|
106
|
+
setInitLoading(false);
|
|
107
|
+
message.error(formatMessage({
|
|
108
|
+
id: 'Error during the initialization of the SDK! {error}',
|
|
109
|
+
values: {
|
|
110
|
+
error: error.message || error
|
|
111
|
+
}
|
|
112
|
+
}));
|
|
113
|
+
});
|
|
114
|
+
_context2.next = 11;
|
|
115
|
+
break;
|
|
116
|
+
case 10:
|
|
117
|
+
message.error(formatMessage({
|
|
118
|
+
id: 'This browser is not supported by the SDK!'
|
|
119
|
+
}));
|
|
120
|
+
case 11:
|
|
121
|
+
case "end":
|
|
122
|
+
return _context2.stop();
|
|
123
|
+
}
|
|
124
|
+
}, _callee2);
|
|
125
|
+
}));
|
|
126
|
+
return function initSdk(_x2) {
|
|
127
|
+
return _ref.apply(this, arguments);
|
|
128
|
+
};
|
|
129
|
+
}();
|
|
130
|
+
var recognize = useCallback(function () {
|
|
131
|
+
if (recognizer && recognizerRunner) {
|
|
132
|
+
return /*#__PURE__*/function () {
|
|
133
|
+
var _ref3 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee3(file) {
|
|
134
|
+
var ele, frame, processResult, recognitionResult;
|
|
135
|
+
return _regeneratorRuntime().wrap(function _callee3$(_context3) {
|
|
136
|
+
while (1) switch (_context3.prev = _context3.next) {
|
|
137
|
+
case 0:
|
|
138
|
+
ele = document.createElement('img');
|
|
139
|
+
ele.src = URL.createObjectURL(file);
|
|
140
|
+
_context3.next = 4;
|
|
141
|
+
return ele.decode();
|
|
142
|
+
case 4:
|
|
143
|
+
frame = BlinkIDSDK.captureFrame(ele);
|
|
144
|
+
_context3.next = 7;
|
|
145
|
+
return recognizerRunner.processImage(frame);
|
|
146
|
+
case 7:
|
|
147
|
+
processResult = _context3.sent;
|
|
148
|
+
if (!(processResult !== BlinkIDSDK.RecognizerResultState.Empty)) {
|
|
149
|
+
_context3.next = 15;
|
|
150
|
+
break;
|
|
151
|
+
}
|
|
152
|
+
_context3.next = 11;
|
|
153
|
+
return recognizer.getResult();
|
|
154
|
+
case 11:
|
|
155
|
+
recognitionResult = _context3.sent;
|
|
156
|
+
return _context3.abrupt("return", recognitionResult);
|
|
157
|
+
case 15:
|
|
158
|
+
message.error(formatMessage({
|
|
159
|
+
id: 'Recognition was not successful!'
|
|
160
|
+
}));
|
|
161
|
+
return _context3.abrupt("return", null);
|
|
162
|
+
case 17:
|
|
163
|
+
case "end":
|
|
164
|
+
return _context3.stop();
|
|
165
|
+
}
|
|
166
|
+
}, _callee3);
|
|
167
|
+
}));
|
|
168
|
+
return function (_x4) {
|
|
169
|
+
return _ref3.apply(this, arguments);
|
|
170
|
+
};
|
|
171
|
+
}();
|
|
172
|
+
} else {
|
|
173
|
+
return /*#__PURE__*/function () {
|
|
174
|
+
var _ref4 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee4(file) {
|
|
175
|
+
return _regeneratorRuntime().wrap(function _callee4$(_context4) {
|
|
176
|
+
while (1) switch (_context4.prev = _context4.next) {
|
|
177
|
+
case 0:
|
|
178
|
+
return _context4.abrupt("return", null);
|
|
179
|
+
case 1:
|
|
180
|
+
case "end":
|
|
181
|
+
return _context4.stop();
|
|
182
|
+
}
|
|
183
|
+
}, _callee4);
|
|
184
|
+
}));
|
|
185
|
+
return function (_x5) {
|
|
186
|
+
return _ref4.apply(this, arguments);
|
|
187
|
+
};
|
|
188
|
+
}();
|
|
189
|
+
}
|
|
190
|
+
}, [recognizer, recognizerRunner]);
|
|
191
|
+
var dealRepeatSendRequest = function dealRepeatSendRequest(licenseKey) {
|
|
192
|
+
if (currentKey !== '' && currentKey === licenseKey) {
|
|
193
|
+
return;
|
|
194
|
+
} else {
|
|
195
|
+
setCurrentKey(licenseKey);
|
|
196
|
+
initSdk(licenseKey);
|
|
197
|
+
}
|
|
198
|
+
};
|
|
199
|
+
return function (licenseKey) {
|
|
200
|
+
dealRepeatSendRequest(licenseKey);
|
|
201
|
+
return {
|
|
202
|
+
recognize: recognize(),
|
|
203
|
+
loading: initLoading
|
|
204
|
+
};
|
|
205
|
+
};
|
|
206
|
+
};
|
|
207
|
+
export default useMicroBlink;
|
package/es/index.d.ts
CHANGED
|
@@ -2,6 +2,7 @@ export { default as Form } from './form';
|
|
|
2
2
|
export { default as Button, GreenButton, YellowButton, RedButton, } from './button';
|
|
3
3
|
export { default as DatePicker, IglooBuddhistDatePicker as BuddhistDatePicker, IglooRangePicker as RangePicker, IglooWeekPicker as WeekPicker, IglooMonthPicker as MonthPicker, } from './date-picker';
|
|
4
4
|
export { default as Input, PhoneNumber, Amount, Password, Email, InputNumber, TextArea, InputDate, CreditCard, ExpiryDate, InputId, } from './input';
|
|
5
|
+
export { default as OCR } from './ocr';
|
|
5
6
|
export { default as Select, TimeSelect, AttachedSelect } from './select';
|
|
6
7
|
export { default as Radio, RadioGroup, RadioGroupWithOther } from './radio';
|
|
7
8
|
export { default as Upload } from './upload';
|
package/es/index.js
CHANGED
|
@@ -2,6 +2,7 @@ export { default as Form } from "./form";
|
|
|
2
2
|
export { default as Button, GreenButton, YellowButton, RedButton } from "./button";
|
|
3
3
|
export { default as DatePicker, IglooBuddhistDatePicker as BuddhistDatePicker, IglooRangePicker as RangePicker, IglooWeekPicker as WeekPicker, IglooMonthPicker as MonthPicker } from "./date-picker";
|
|
4
4
|
export { default as Input, PhoneNumber, Amount, Password, Email, InputNumber, TextArea, InputDate, CreditCard, ExpiryDate, InputId } from "./input";
|
|
5
|
+
export { default as OCR } from "./ocr";
|
|
5
6
|
export { default as Select, TimeSelect, AttachedSelect } from "./select";
|
|
6
7
|
export { default as Radio, RadioGroup, RadioGroupWithOther } from "./radio";
|
|
7
8
|
export { default as Upload } from "./upload";
|
package/es/input/phone-number.js
CHANGED
|
@@ -27,6 +27,7 @@
|
|
|
27
27
|
"Encrypted PDF": "Encrypted PDF",
|
|
28
28
|
"Enter the password to open this PDF file.": "Enter the password to open this PDF file.",
|
|
29
29
|
"Error Report": "Error Report",
|
|
30
|
+
"Error during the initialization of the SDK! {error}": "Error during the initialization of the SDK! {error}",
|
|
30
31
|
"Failed to load PDF file.": "Failed to load PDF file.",
|
|
31
32
|
"Filter": "Filter",
|
|
32
33
|
"I agree to the Igloo": "I agree to the Igloo",
|
|
@@ -42,6 +43,7 @@
|
|
|
42
43
|
"Log in": "Log in",
|
|
43
44
|
"Next": "Next",
|
|
44
45
|
"No preview for this file. Only support image, video or PDF file.": "No preview for this file. Only support image, video or PDF file.",
|
|
46
|
+
"Nothing has been recognized.": "Nothing has been recognized.",
|
|
45
47
|
"Numbers only, please omit \" \" or \"-\".": "Numbers only, please omit \" \" or \"-\".",
|
|
46
48
|
"OK": "OK",
|
|
47
49
|
"Ok": "Ok",
|
|
@@ -62,6 +64,7 @@
|
|
|
62
64
|
"Processing": "Processing",
|
|
63
65
|
"Processing progress cannot be updated at the moment. Don’t worry! All your file data are still in progress.": "Processing progress cannot be updated at the moment. Don’t worry! All your file data are still in progress.",
|
|
64
66
|
"Quantity of files should be less than {limit}": "Quantity of files should be less than {limit}",
|
|
67
|
+
"Recognition was not successful!": "Recognition was not successful!",
|
|
65
68
|
"Reject": "Reject",
|
|
66
69
|
"Remove": "Remove",
|
|
67
70
|
"Resend OTP": "Resend OTP",
|
|
@@ -80,6 +83,7 @@
|
|
|
80
83
|
"The file type is not supported.": "The file type is not supported.",
|
|
81
84
|
"There are no options available currently": "There are no options available currently",
|
|
82
85
|
"This Month": "This Month",
|
|
86
|
+
"This browser is not supported by the SDK!": "This browser is not supported by the SDK!",
|
|
83
87
|
"This is an encrypted file, click to enter password.": "This is an encrypted file, click to enter password.",
|
|
84
88
|
"Unselect All": "Unselect All",
|
|
85
89
|
"Uploading": "Uploading",
|
|
@@ -27,6 +27,7 @@
|
|
|
27
27
|
"Encrypted PDF": "PDF terenkripsi",
|
|
28
28
|
"Enter the password to open this PDF file.": "Masukkan kata sandi untuk membuka file PDF ini.",
|
|
29
29
|
"Error Report": "Laporan Kesalahan",
|
|
30
|
+
"Error during the initialization of the SDK! {error}": "",
|
|
30
31
|
"Failed to load PDF file.": "Gagal memuat file PDF.",
|
|
31
32
|
"Filter": "Saring",
|
|
32
33
|
"I agree to the Igloo": "Saya setuju dengan Igloo",
|
|
@@ -42,6 +43,7 @@
|
|
|
42
43
|
"Log in": "Masuk",
|
|
43
44
|
"Next": "Selanjutnya",
|
|
44
45
|
"No preview for this file. Only support image, video or PDF file.": "Tidak ada pratinjau untuk file ini. Hanya mendukung file gambar, video atau PDF.",
|
|
46
|
+
"Nothing has been recognized.": "",
|
|
45
47
|
"Numbers only, please omit \" \" or \"-\".": "Angka saja, harap hilangkan \" \" atau \"-\".",
|
|
46
48
|
"OK": "oke",
|
|
47
49
|
"Ok": "oke",
|
|
@@ -62,6 +64,7 @@
|
|
|
62
64
|
"Processing": "Sedang diproses",
|
|
63
65
|
"Processing progress cannot be updated at the moment. Don’t worry! All your file data are still in progress.": "Perkembangan terkait proses belum dapat diperbarui saat ini. Jangan khawatir! Semua data Anda masih dalam proses .",
|
|
64
66
|
"Quantity of files should be less than {limit}": "Jumlah dokumen tidak bisa lebih dari {limit}",
|
|
67
|
+
"Recognition was not successful!": "",
|
|
65
68
|
"Reject": "Menolak",
|
|
66
69
|
"Remove": "Menghapus",
|
|
67
70
|
"Resend OTP": "Kirim ulang OTP",
|
|
@@ -80,6 +83,7 @@
|
|
|
80
83
|
"The file type is not supported.": "Jenis file tidak didukung.",
|
|
81
84
|
"There are no options available currently": "Tidak ada opsi yang tersedia saat ini",
|
|
82
85
|
"This Month": "Bulan ini",
|
|
86
|
+
"This browser is not supported by the SDK!": "",
|
|
83
87
|
"This is an encrypted file, click to enter password.": "Ini adalah file terenkripsi, klik untuk memasukkan kata sandi.",
|
|
84
88
|
"Unselect All": "Batalkan semua",
|
|
85
89
|
"Uploading": "Mengunggah",
|