iglooform 2.5.53 → 2.5.55
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/es/form/elements.js +3 -1
- package/es/form/index.js +12 -2
- package/es/form-context.d.ts +2 -1
- package/es/form-context.js +2 -1
- package/es/hooks/index.d.ts +1 -0
- package/es/hooks/index.js +1 -0
- package/es/hooks/ocr/index.d.ts +3 -0
- package/es/hooks/ocr/index.js +25 -0
- package/es/hooks/ocr/micro-blink.d.ts +3 -0
- package/es/hooks/ocr/micro-blink.js +231 -0
- package/es/input/phone-number.d.ts +1 -1
- package/es/input/phone-number.js +38 -15
- package/es/ocr/index.d.ts +15 -0
- package/es/ocr/index.js +38 -0
- package/es/ocr/micro-blink/index.d.ts +8 -0
- package/es/ocr/micro-blink/index.js +189 -0
- package/es/ocr/micro-blink/style/index.d.ts +1 -0
- package/es/ocr/micro-blink/style/index.js +1 -0
- package/es/ocr/micro-blink/style/index.less +30 -0
- package/es/platform/platform-card/index.d.ts +1 -0
- package/es/platform/platform-card/index.js +4 -2
- package/es/platform/platform-card/style/index.less +16 -0
- package/es/types.d.ts +12 -0
- package/es/utils/form-utils.js +1 -1
- package/lib/form/elements.js +4 -1
- package/lib/form/index.js +13 -2
- package/lib/form-context.d.ts +2 -1
- package/lib/form-context.js +2 -1
- package/lib/hooks/index.d.ts +1 -0
- package/lib/hooks/index.js +1 -0
- package/lib/hooks/ocr/index.d.ts +3 -0
- package/lib/hooks/ocr/index.js +36 -0
- package/lib/hooks/ocr/micro-blink.d.ts +3 -0
- package/lib/hooks/ocr/micro-blink.js +251 -0
- package/lib/input/phone-number.d.ts +1 -1
- package/lib/input/phone-number.js +42 -17
- package/lib/ocr/index.d.ts +15 -0
- package/lib/ocr/index.js +49 -0
- package/lib/ocr/micro-blink/index.d.ts +8 -0
- package/lib/ocr/micro-blink/index.js +218 -0
- package/lib/ocr/micro-blink/style/index.d.ts +1 -0
- package/lib/ocr/micro-blink/style/index.js +3 -0
- package/lib/ocr/micro-blink/style/index.less +30 -0
- package/lib/platform/platform-card/index.d.ts +1 -0
- package/lib/platform/platform-card/index.js +4 -2
- package/lib/platform/platform-card/style/index.less +16 -0
- package/lib/types.d.ts +12 -0
- package/lib/utils/form-utils.js +1 -1
- package/package.json +2 -1
- package/.idea/iglooform.iml +0 -9
- package/.idea/misc.xml +0 -5
- package/.idea/modules.xml +0 -8
- package/.idea/vcs.xml +0 -6
|
@@ -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
|
+
}
|
|
@@ -23,7 +23,8 @@ var PlatformCard = function PlatformCard(_ref) {
|
|
|
23
23
|
var platform = _ref.platform,
|
|
24
24
|
className = _ref.className,
|
|
25
25
|
style = _ref.style,
|
|
26
|
-
onClick = _ref.onClick
|
|
26
|
+
onClick = _ref.onClick,
|
|
27
|
+
badgeText = _ref.badgeText;
|
|
27
28
|
|
|
28
29
|
var _useState = useState(false),
|
|
29
30
|
_useState2 = _slicedToArray(_useState, 2),
|
|
@@ -33,9 +34,10 @@ var PlatformCard = function PlatformCard(_ref) {
|
|
|
33
34
|
var key = typeof platform === 'string' ? platform : platform.key;
|
|
34
35
|
var name = typeof platform === 'string' ? platform : platform.name;
|
|
35
36
|
return _jsxs("div", {
|
|
36
|
-
className: classnames('igloo-platform', className),
|
|
37
|
+
className: classnames('igloo-platform', className, badgeText && 'igloo-platform-has-badge-text'),
|
|
37
38
|
onClick: onClick,
|
|
38
39
|
style: style,
|
|
40
|
+
"data-badge-text": badgeText,
|
|
39
41
|
children: [showDefault && _jsxs("div", {
|
|
40
42
|
style: {
|
|
41
43
|
textAlign: 'center'
|
|
@@ -19,6 +19,22 @@
|
|
|
19
19
|
border: 3px solid @active-color;
|
|
20
20
|
}
|
|
21
21
|
|
|
22
|
+
&.igloo-platform-has-badge-text {
|
|
23
|
+
position: relative;
|
|
24
|
+
&::before {
|
|
25
|
+
position: absolute;
|
|
26
|
+
right: 0;
|
|
27
|
+
top: 0;
|
|
28
|
+
content: attr(data-badge-text);
|
|
29
|
+
color: @primary-color;
|
|
30
|
+
background-color: @purple-light;
|
|
31
|
+
font-size: 12px;
|
|
32
|
+
padding: 2px 6px;
|
|
33
|
+
border-top-right-radius: 3px;
|
|
34
|
+
border-bottom-left-radius: 3px;
|
|
35
|
+
}
|
|
36
|
+
}
|
|
37
|
+
|
|
22
38
|
.igloo-platform-logo {
|
|
23
39
|
width: 220px;
|
|
24
40
|
height: 120px;
|
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;
|
package/es/utils/form-utils.js
CHANGED
|
@@ -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
|
|
package/lib/form/elements.js
CHANGED
|
@@ -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,
|
package/lib/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 { FormItemName } from '
|
|
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;
|
package/lib/form-context.js
CHANGED
|
@@ -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,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;
|