iglooform 2.5.54 → 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/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/types.d.ts +12 -0
- package/lib/utils/form-utils.js +1 -1
- package/package.json +2 -1
package/es/form/elements.js
CHANGED
|
@@ -13,6 +13,7 @@ import UploadPhoto from '../upload-photo';
|
|
|
13
13
|
import RenderElement from './render';
|
|
14
14
|
import Typography from '../typography';
|
|
15
15
|
import SearchBox from '../search-box';
|
|
16
|
+
import OCR from '../ocr';
|
|
16
17
|
var elementMap = {
|
|
17
18
|
Input: Input,
|
|
18
19
|
PhoneNumber: PhoneNumber,
|
|
@@ -45,7 +46,8 @@ var elementMap = {
|
|
|
45
46
|
Confirmation: Confirmation,
|
|
46
47
|
ExpiryDate: ExpiryDate,
|
|
47
48
|
Typography: Typography,
|
|
48
|
-
SearchBox: SearchBox
|
|
49
|
+
SearchBox: SearchBox,
|
|
50
|
+
OCR: OCR
|
|
49
51
|
};
|
|
50
52
|
|
|
51
53
|
var Unknown = function Unknown() {
|
package/es/form/index.js
CHANGED
|
@@ -42,6 +42,7 @@ import classNames from 'classnames';
|
|
|
42
42
|
import invariant from 'invariant';
|
|
43
43
|
import { LocaleContext } from '../locale';
|
|
44
44
|
import { getRuleValidation } from './../utils/form-utils';
|
|
45
|
+
import useOCR from '../hooks/ocr';
|
|
45
46
|
|
|
46
47
|
var IglooForm = function IglooForm(props, ref) {
|
|
47
48
|
var config = props.config,
|
|
@@ -67,7 +68,8 @@ var IglooForm = function IglooForm(props, ref) {
|
|
|
67
68
|
selectDatasourceApi = props.selectDatasourceApi,
|
|
68
69
|
getRuleValidationApi = props.getRuleValidationApi,
|
|
69
70
|
_props$stepDirection = props.stepDirection,
|
|
70
|
-
stepDirection = _props$stepDirection === void 0 ? 'vertical' : _props$stepDirection
|
|
71
|
+
stepDirection = _props$stepDirection === void 0 ? 'vertical' : _props$stepDirection,
|
|
72
|
+
ocr = props.ocr;
|
|
71
73
|
|
|
72
74
|
var _Form$useForm = _Form.useForm(),
|
|
73
75
|
_Form$useForm2 = _slicedToArray(_Form$useForm, 1),
|
|
@@ -95,6 +97,13 @@ var IglooForm = function IglooForm(props, ref) {
|
|
|
95
97
|
currentLang = _useContext.currentLang;
|
|
96
98
|
|
|
97
99
|
var validationRule = props.validationRule || config.validationRule;
|
|
100
|
+
var createHooks = useOCR();
|
|
101
|
+
var ocrHooks = undefined;
|
|
102
|
+
|
|
103
|
+
if (ocr) {
|
|
104
|
+
ocrHooks = createHooks(ocr);
|
|
105
|
+
}
|
|
106
|
+
|
|
98
107
|
invariant(type, "Contianer type should be one of ['Pages', 'Page', 'Steps', 'Login']");
|
|
99
108
|
invariant(!validationRule || getRuleValidationApi, 'Please provide getRuleValidationApi in Form props');
|
|
100
109
|
|
|
@@ -278,7 +287,8 @@ var IglooForm = function IglooForm(props, ref) {
|
|
|
278
287
|
uploadApi: uploadApi,
|
|
279
288
|
selectDatasourceApi: selectDatasourceApi,
|
|
280
289
|
getRuleValidationApi: getRuleValidationApi,
|
|
281
|
-
handleValuesChange: handleValuesChange
|
|
290
|
+
handleValuesChange: handleValuesChange,
|
|
291
|
+
ocrHooks: ocrHooks
|
|
282
292
|
}, locales),
|
|
283
293
|
children: _jsxs(_Form, {
|
|
284
294
|
form: form,
|
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 { 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/es/form-context.js
CHANGED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
"use strict";
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
import invariant from 'invariant';
|
|
2
|
+
import useMicroBlink from './micro-blink';
|
|
3
|
+
|
|
4
|
+
var useOCR = function useOCR() {
|
|
5
|
+
var createRecognize = useMicroBlink();
|
|
6
|
+
return function (config) {
|
|
7
|
+
var microBlink = config.microBlink;
|
|
8
|
+
|
|
9
|
+
var _ref = microBlink || {},
|
|
10
|
+
licenseKey = _ref.licenseKey;
|
|
11
|
+
|
|
12
|
+
var hooks = {};
|
|
13
|
+
invariant(Boolean(microBlink) === Boolean(licenseKey), 'Must Config licenseKey of Micro Blink');
|
|
14
|
+
|
|
15
|
+
if (microBlink && licenseKey) {
|
|
16
|
+
hooks['microBlink'] = {
|
|
17
|
+
recognize: createRecognize(licenseKey)
|
|
18
|
+
};
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
return hooks;
|
|
22
|
+
};
|
|
23
|
+
};
|
|
24
|
+
|
|
25
|
+
export default useOCR;
|
|
@@ -0,0 +1,231 @@
|
|
|
1
|
+
function _slicedToArray(arr, i) { return _arrayWithHoles(arr) || _iterableToArrayLimit(arr, i) || _unsupportedIterableToArray(arr, i) || _nonIterableRest(); }
|
|
2
|
+
|
|
3
|
+
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."); }
|
|
4
|
+
|
|
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
|
+
|
|
7
|
+
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; }
|
|
8
|
+
|
|
9
|
+
function _iterableToArrayLimit(arr, i) { var _i = arr == null ? null : typeof Symbol !== "undefined" && arr[Symbol.iterator] || arr["@@iterator"]; if (_i == null) return; var _arr = []; var _n = true; var _d = false; var _s, _e; try { for (_i = _i.call(arr); !(_n = (_s = _i.next()).done); _n = true) { _arr.push(_s.value); if (i && _arr.length === i) break; } } catch (err) { _d = true; _e = err; } finally { try { if (!_n && _i["return"] != null) _i["return"](); } finally { if (_d) throw _e; } } return _arr; }
|
|
10
|
+
|
|
11
|
+
function _arrayWithHoles(arr) { if (Array.isArray(arr)) return arr; }
|
|
12
|
+
|
|
13
|
+
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); } }
|
|
14
|
+
|
|
15
|
+
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); }); }; }
|
|
16
|
+
|
|
17
|
+
import { useState, useCallback } from 'react';
|
|
18
|
+
import * as BlinkIDSDK from '@microblink/blinkid-in-browser-sdk';
|
|
19
|
+
import message from '../../global-message';
|
|
20
|
+
var MICRO_BLINK_SERVICE_PATH = 'https://static.iglooinsure.com/microblink/in-browser';
|
|
21
|
+
|
|
22
|
+
function getWorkerLocation(_x) {
|
|
23
|
+
return _getWorkerLocation.apply(this, arguments);
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
function _getWorkerLocation() {
|
|
27
|
+
_getWorkerLocation = _asyncToGenerator( /*#__PURE__*/regeneratorRuntime.mark(function _callee5(path) {
|
|
28
|
+
return regeneratorRuntime.wrap(function _callee5$(_context5) {
|
|
29
|
+
while (1) {
|
|
30
|
+
switch (_context5.prev = _context5.next) {
|
|
31
|
+
case 0:
|
|
32
|
+
return _context5.abrupt("return", new Promise(function (resolve) {
|
|
33
|
+
window.fetch(path).then(function (response) {
|
|
34
|
+
return response.text();
|
|
35
|
+
}).then(function (data) {
|
|
36
|
+
var blob = new Blob([data], {
|
|
37
|
+
type: 'application/javascript'
|
|
38
|
+
});
|
|
39
|
+
var url = URL.createObjectURL(blob);
|
|
40
|
+
resolve(url);
|
|
41
|
+
});
|
|
42
|
+
}));
|
|
43
|
+
|
|
44
|
+
case 1:
|
|
45
|
+
case "end":
|
|
46
|
+
return _context5.stop();
|
|
47
|
+
}
|
|
48
|
+
}
|
|
49
|
+
}, _callee5);
|
|
50
|
+
}));
|
|
51
|
+
return _getWorkerLocation.apply(this, arguments);
|
|
52
|
+
}
|
|
53
|
+
|
|
54
|
+
var useMicroBlink = function useMicroBlink() {
|
|
55
|
+
var _useState = useState(''),
|
|
56
|
+
_useState2 = _slicedToArray(_useState, 2),
|
|
57
|
+
currentKey = _useState2[0],
|
|
58
|
+
setCurrentKey = _useState2[1];
|
|
59
|
+
|
|
60
|
+
var _useState3 = useState(null),
|
|
61
|
+
_useState4 = _slicedToArray(_useState3, 2),
|
|
62
|
+
recognizer = _useState4[0],
|
|
63
|
+
setRecognizer = _useState4[1];
|
|
64
|
+
|
|
65
|
+
var _useState5 = useState(null),
|
|
66
|
+
_useState6 = _slicedToArray(_useState5, 2),
|
|
67
|
+
recognizerRunner = _useState6[0],
|
|
68
|
+
setRecognizerRunner = _useState6[1];
|
|
69
|
+
|
|
70
|
+
var initSdk = /*#__PURE__*/function () {
|
|
71
|
+
var _ref = _asyncToGenerator( /*#__PURE__*/regeneratorRuntime.mark(function _callee2(licenseKey) {
|
|
72
|
+
var loadSettings;
|
|
73
|
+
return regeneratorRuntime.wrap(function _callee2$(_context2) {
|
|
74
|
+
while (1) {
|
|
75
|
+
switch (_context2.prev = _context2.next) {
|
|
76
|
+
case 0:
|
|
77
|
+
if (!BlinkIDSDK.isBrowserSupported()) {
|
|
78
|
+
_context2.next = 9;
|
|
79
|
+
break;
|
|
80
|
+
}
|
|
81
|
+
|
|
82
|
+
loadSettings = new BlinkIDSDK.WasmSDKLoadSettings(licenseKey);
|
|
83
|
+
loadSettings.engineLocation = MICRO_BLINK_SERVICE_PATH;
|
|
84
|
+
_context2.next = 5;
|
|
85
|
+
return getWorkerLocation("".concat(MICRO_BLINK_SERVICE_PATH, "/BlinkIDWasmSDK.worker.min.js"));
|
|
86
|
+
|
|
87
|
+
case 5:
|
|
88
|
+
loadSettings.workerLocation = _context2.sent;
|
|
89
|
+
BlinkIDSDK.loadWasmModule(loadSettings).then( /*#__PURE__*/function () {
|
|
90
|
+
var _ref2 = _asyncToGenerator( /*#__PURE__*/regeneratorRuntime.mark(function _callee(wasmSDK) {
|
|
91
|
+
var recognizer, recognizerRunner;
|
|
92
|
+
return regeneratorRuntime.wrap(function _callee$(_context) {
|
|
93
|
+
while (1) {
|
|
94
|
+
switch (_context.prev = _context.next) {
|
|
95
|
+
case 0:
|
|
96
|
+
_context.next = 2;
|
|
97
|
+
return BlinkIDSDK.createBlinkIdSingleSideRecognizer(wasmSDK);
|
|
98
|
+
|
|
99
|
+
case 2:
|
|
100
|
+
recognizer = _context.sent;
|
|
101
|
+
_context.next = 5;
|
|
102
|
+
return BlinkIDSDK.createRecognizerRunner(wasmSDK, [recognizer], true);
|
|
103
|
+
|
|
104
|
+
case 5:
|
|
105
|
+
recognizerRunner = _context.sent;
|
|
106
|
+
setRecognizer(recognizer);
|
|
107
|
+
setRecognizerRunner(recognizerRunner);
|
|
108
|
+
|
|
109
|
+
case 8:
|
|
110
|
+
case "end":
|
|
111
|
+
return _context.stop();
|
|
112
|
+
}
|
|
113
|
+
}
|
|
114
|
+
}, _callee);
|
|
115
|
+
}));
|
|
116
|
+
|
|
117
|
+
return function (_x3) {
|
|
118
|
+
return _ref2.apply(this, arguments);
|
|
119
|
+
};
|
|
120
|
+
}(), function (error) {
|
|
121
|
+
console.log('Error during the initialization of the SDK!', error);
|
|
122
|
+
});
|
|
123
|
+
_context2.next = 10;
|
|
124
|
+
break;
|
|
125
|
+
|
|
126
|
+
case 9:
|
|
127
|
+
message.error('This browser is not supported by the SDK!');
|
|
128
|
+
|
|
129
|
+
case 10:
|
|
130
|
+
case "end":
|
|
131
|
+
return _context2.stop();
|
|
132
|
+
}
|
|
133
|
+
}
|
|
134
|
+
}, _callee2);
|
|
135
|
+
}));
|
|
136
|
+
|
|
137
|
+
return function initSdk(_x2) {
|
|
138
|
+
return _ref.apply(this, arguments);
|
|
139
|
+
};
|
|
140
|
+
}();
|
|
141
|
+
|
|
142
|
+
var recognize = useCallback(function () {
|
|
143
|
+
if (recognizer && recognizerRunner) {
|
|
144
|
+
return /*#__PURE__*/function () {
|
|
145
|
+
var _ref3 = _asyncToGenerator( /*#__PURE__*/regeneratorRuntime.mark(function _callee3(file) {
|
|
146
|
+
var ele, frame, processResult, recognitionResult;
|
|
147
|
+
return regeneratorRuntime.wrap(function _callee3$(_context3) {
|
|
148
|
+
while (1) {
|
|
149
|
+
switch (_context3.prev = _context3.next) {
|
|
150
|
+
case 0:
|
|
151
|
+
ele = document.createElement('img');
|
|
152
|
+
ele.src = URL.createObjectURL(file);
|
|
153
|
+
_context3.next = 4;
|
|
154
|
+
return ele.decode();
|
|
155
|
+
|
|
156
|
+
case 4:
|
|
157
|
+
frame = BlinkIDSDK.captureFrame(ele);
|
|
158
|
+
_context3.next = 7;
|
|
159
|
+
return recognizerRunner.processImage(frame);
|
|
160
|
+
|
|
161
|
+
case 7:
|
|
162
|
+
processResult = _context3.sent;
|
|
163
|
+
|
|
164
|
+
if (!(processResult !== BlinkIDSDK.RecognizerResultState.Empty)) {
|
|
165
|
+
_context3.next = 15;
|
|
166
|
+
break;
|
|
167
|
+
}
|
|
168
|
+
|
|
169
|
+
_context3.next = 11;
|
|
170
|
+
return recognizer.getResult();
|
|
171
|
+
|
|
172
|
+
case 11:
|
|
173
|
+
recognitionResult = _context3.sent;
|
|
174
|
+
return _context3.abrupt("return", recognitionResult);
|
|
175
|
+
|
|
176
|
+
case 15:
|
|
177
|
+
message.error('Recognition was not successful!');
|
|
178
|
+
return _context3.abrupt("return", null);
|
|
179
|
+
|
|
180
|
+
case 17:
|
|
181
|
+
case "end":
|
|
182
|
+
return _context3.stop();
|
|
183
|
+
}
|
|
184
|
+
}
|
|
185
|
+
}, _callee3);
|
|
186
|
+
}));
|
|
187
|
+
|
|
188
|
+
return function (_x4) {
|
|
189
|
+
return _ref3.apply(this, arguments);
|
|
190
|
+
};
|
|
191
|
+
}();
|
|
192
|
+
} else {
|
|
193
|
+
return /*#__PURE__*/function () {
|
|
194
|
+
var _ref4 = _asyncToGenerator( /*#__PURE__*/regeneratorRuntime.mark(function _callee4(file) {
|
|
195
|
+
return regeneratorRuntime.wrap(function _callee4$(_context4) {
|
|
196
|
+
while (1) {
|
|
197
|
+
switch (_context4.prev = _context4.next) {
|
|
198
|
+
case 0:
|
|
199
|
+
return _context4.abrupt("return", null);
|
|
200
|
+
|
|
201
|
+
case 1:
|
|
202
|
+
case "end":
|
|
203
|
+
return _context4.stop();
|
|
204
|
+
}
|
|
205
|
+
}
|
|
206
|
+
}, _callee4);
|
|
207
|
+
}));
|
|
208
|
+
|
|
209
|
+
return function (_x5) {
|
|
210
|
+
return _ref4.apply(this, arguments);
|
|
211
|
+
};
|
|
212
|
+
}();
|
|
213
|
+
}
|
|
214
|
+
}, [recognizer, recognizerRunner]);
|
|
215
|
+
|
|
216
|
+
var dealRepeatSendRequest = function dealRepeatSendRequest(licenseKey) {
|
|
217
|
+
if (currentKey !== '' && currentKey === licenseKey) {
|
|
218
|
+
return;
|
|
219
|
+
} else {
|
|
220
|
+
setCurrentKey(licenseKey);
|
|
221
|
+
initSdk(licenseKey);
|
|
222
|
+
}
|
|
223
|
+
};
|
|
224
|
+
|
|
225
|
+
return function (licenseKey) {
|
|
226
|
+
dealRepeatSendRequest(licenseKey);
|
|
227
|
+
return recognize();
|
|
228
|
+
};
|
|
229
|
+
};
|
|
230
|
+
|
|
231
|
+
export default useMicroBlink;
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { CSSProperties } from 'react';
|
|
2
2
|
import { FC, IglooComponentProps } from '../types';
|
|
3
|
-
import './style/index';
|
|
3
|
+
import './style/index.less';
|
|
4
4
|
export interface PhoneNumberProps extends IglooComponentProps {
|
|
5
5
|
areaCode?: string | string[];
|
|
6
6
|
phoneNumber?: number;
|
package/es/input/phone-number.js
CHANGED
|
@@ -1,5 +1,10 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
1
|
+
var _excluded = ["areaCode", "phoneNumber", "className", "disabled", "value", "onChange", "style"];
|
|
2
|
+
|
|
3
|
+
function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); enumerableOnly && (symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; })), keys.push.apply(keys, symbols); } return keys; }
|
|
4
|
+
|
|
5
|
+
function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = null != arguments[i] ? arguments[i] : {}; i % 2 ? ownKeys(Object(source), !0).forEach(function (key) { _defineProperty(target, key, source[key]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)) : ownKeys(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } return target; }
|
|
6
|
+
|
|
7
|
+
function _defineProperty(obj, key, value) { if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }
|
|
3
8
|
|
|
4
9
|
function _slicedToArray(arr, i) { return _arrayWithHoles(arr) || _iterableToArrayLimit(arr, i) || _unsupportedIterableToArray(arr, i) || _nonIterableRest(); }
|
|
5
10
|
|
|
@@ -13,13 +18,20 @@ function _iterableToArrayLimit(arr, i) { var _i = arr == null ? null : typeof Sy
|
|
|
13
18
|
|
|
14
19
|
function _arrayWithHoles(arr) { if (Array.isArray(arr)) return arr; }
|
|
15
20
|
|
|
21
|
+
function _objectWithoutProperties(source, excluded) { if (source == null) return {}; var target = _objectWithoutPropertiesLoose(source, excluded); var key, i; if (Object.getOwnPropertySymbols) { var sourceSymbolKeys = Object.getOwnPropertySymbols(source); for (i = 0; i < sourceSymbolKeys.length; i++) { key = sourceSymbolKeys[i]; if (excluded.indexOf(key) >= 0) continue; if (!Object.prototype.propertyIsEnumerable.call(source, key)) continue; target[key] = source[key]; } } return target; }
|
|
22
|
+
|
|
23
|
+
function _objectWithoutPropertiesLoose(source, excluded) { if (source == null) return {}; var target = {}; var sourceKeys = Object.keys(source); var key, i; for (i = 0; i < sourceKeys.length; i++) { key = sourceKeys[i]; if (excluded.indexOf(key) >= 0) continue; target[key] = source[key]; } return target; }
|
|
24
|
+
|
|
16
25
|
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
17
26
|
import { useState, useEffect } from 'react';
|
|
18
27
|
import classnames from 'classnames';
|
|
19
28
|
import invariant from 'invariant';
|
|
29
|
+
import omit from 'omit.js';
|
|
20
30
|
import Select from '../select';
|
|
31
|
+
import formMethods from '../utils/form-methods';
|
|
32
|
+
import Input from './input';
|
|
21
33
|
import { staticFormatMessage as formatMessage } from '../locale';
|
|
22
|
-
import './style/index';
|
|
34
|
+
import './style/index.less';
|
|
23
35
|
|
|
24
36
|
var PhoneNumber = function PhoneNumber(_ref) {
|
|
25
37
|
var areaCode = _ref.areaCode,
|
|
@@ -28,28 +40,35 @@ var PhoneNumber = function PhoneNumber(_ref) {
|
|
|
28
40
|
disabled = _ref.disabled,
|
|
29
41
|
value = _ref.value,
|
|
30
42
|
formChangeProps = _ref.onChange,
|
|
31
|
-
style = _ref.style
|
|
43
|
+
style = _ref.style,
|
|
44
|
+
rest = _objectWithoutProperties(_ref, _excluded);
|
|
45
|
+
|
|
32
46
|
invariant(Array.isArray(areaCode) ? areaCode.length : true, 'areaCode cant be an empty array');
|
|
33
47
|
invariant(areaCode != undefined, 'areaCode must be set');
|
|
34
48
|
|
|
35
|
-
var _useState = useState(Array.isArray(areaCode) ? areaCode[0] : areaCode),
|
|
49
|
+
var _useState = useState((value === null || value === void 0 ? void 0 : value.areaCode) || (Array.isArray(areaCode) ? areaCode[0] : areaCode)),
|
|
36
50
|
_useState2 = _slicedToArray(_useState, 2),
|
|
37
51
|
selectedCode = _useState2[0],
|
|
38
52
|
changeCode = _useState2[1];
|
|
39
53
|
|
|
40
|
-
var _useState3 = useState(value ? value.phoneNumber
|
|
54
|
+
var _useState3 = useState(value === null || value === void 0 ? void 0 : value.phoneNumber),
|
|
41
55
|
_useState4 = _slicedToArray(_useState3, 2),
|
|
42
56
|
number = _useState4[0],
|
|
43
57
|
setNumber = _useState4[1];
|
|
44
58
|
|
|
45
59
|
useEffect(function () {
|
|
46
|
-
|
|
60
|
+
if ((value === null || value === void 0 ? void 0 : value.areaCode) === selectedCode && (value === null || value === void 0 ? void 0 : value.phoneNumber) === number) {
|
|
61
|
+
return;
|
|
62
|
+
}
|
|
63
|
+
|
|
64
|
+
setNumber(value === null || value === void 0 ? void 0 : value.phoneNumber);
|
|
65
|
+
changeCode(value === null || value === void 0 ? void 0 : value.areaCode);
|
|
47
66
|
}, [value]);
|
|
48
67
|
var leftPart = Array.isArray(areaCode) ? _jsx(Select, {
|
|
49
68
|
disabled: disabled,
|
|
50
69
|
onChange: function onChange(e) {
|
|
51
70
|
changeCode(e);
|
|
52
|
-
formChangeProps(number ? {
|
|
71
|
+
formChangeProps(number && e ? {
|
|
53
72
|
areaCode: e,
|
|
54
73
|
phoneNumber: number
|
|
55
74
|
} : undefined);
|
|
@@ -71,9 +90,10 @@ var PhoneNumber = function PhoneNumber(_ref) {
|
|
|
71
90
|
className: classnames('igloo-input-phone', {
|
|
72
91
|
'igloo-input-phone-disabled': disabled
|
|
73
92
|
}, className),
|
|
74
|
-
children: [leftPart, _jsx(
|
|
93
|
+
children: [leftPart, _jsx(Input, _objectSpread({
|
|
75
94
|
type: "tel",
|
|
76
95
|
value: number,
|
|
96
|
+
className: 'igloo-input',
|
|
77
97
|
onChange: function onChange(e) {
|
|
78
98
|
setNumber(e.target.value);
|
|
79
99
|
formChangeProps(e.target.value ? {
|
|
@@ -82,7 +102,7 @@ var PhoneNumber = function PhoneNumber(_ref) {
|
|
|
82
102
|
} : undefined);
|
|
83
103
|
},
|
|
84
104
|
disabled: disabled
|
|
85
|
-
})]
|
|
105
|
+
}, omit(rest, formMethods)))]
|
|
86
106
|
});
|
|
87
107
|
};
|
|
88
108
|
|
|
@@ -93,7 +113,8 @@ PhoneNumber.formItemPropsHandler = function (_ref2) {
|
|
|
93
113
|
maxLength = _ref2.maxLength,
|
|
94
114
|
minLength = _ref2.minLength,
|
|
95
115
|
label = _ref2.label,
|
|
96
|
-
pattern = _ref2.pattern
|
|
116
|
+
pattern = _ref2.pattern,
|
|
117
|
+
initialValue = _ref2.initialValue;
|
|
97
118
|
var rules = [{
|
|
98
119
|
validator: function validator(rule, value) {
|
|
99
120
|
if (!value) return Promise.resolve();
|
|
@@ -181,11 +202,13 @@ PhoneNumber.formItemPropsHandler = function (_ref2) {
|
|
|
181
202
|
});
|
|
182
203
|
}
|
|
183
204
|
|
|
205
|
+
var initialAreaCode = (initialValue === null || initialValue === void 0 ? void 0 : initialValue.areaCode) || (Array.isArray(areaCode) ? areaCode[0] : areaCode);
|
|
206
|
+
var initialPhoneNumber = (initialValue === null || initialValue === void 0 ? void 0 : initialValue.phoneNumber) || phoneNumber;
|
|
184
207
|
return {
|
|
185
|
-
initialValue:
|
|
186
|
-
areaCode:
|
|
187
|
-
phoneNumber:
|
|
188
|
-
}
|
|
208
|
+
initialValue: {
|
|
209
|
+
areaCode: initialAreaCode,
|
|
210
|
+
phoneNumber: initialPhoneNumber
|
|
211
|
+
},
|
|
189
212
|
rules: rules,
|
|
190
213
|
previewFormater: function previewFormater(_ref3) {
|
|
191
214
|
var areaCode = _ref3.areaCode,
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import { FC, IglooComponentProps, FormItemExtraConfig } from '../types';
|
|
2
|
+
export interface OutputMap {
|
|
3
|
+
field: string[];
|
|
4
|
+
source: string[];
|
|
5
|
+
format?: string;
|
|
6
|
+
formatType?: string;
|
|
7
|
+
}
|
|
8
|
+
interface OCRProps extends IglooComponentProps, FormItemExtraConfig {
|
|
9
|
+
ocrConfig: {
|
|
10
|
+
vendor: string;
|
|
11
|
+
outputMap: OutputMap[];
|
|
12
|
+
};
|
|
13
|
+
}
|
|
14
|
+
declare const OCR: FC<OCRProps>;
|
|
15
|
+
export default OCR;
|
package/es/ocr/index.js
ADDED
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
var _excluded = ["ocrConfig"];
|
|
2
|
+
|
|
3
|
+
function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); enumerableOnly && (symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; })), keys.push.apply(keys, symbols); } return keys; }
|
|
4
|
+
|
|
5
|
+
function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = null != arguments[i] ? arguments[i] : {}; i % 2 ? ownKeys(Object(source), !0).forEach(function (key) { _defineProperty(target, key, source[key]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)) : ownKeys(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } return target; }
|
|
6
|
+
|
|
7
|
+
function _defineProperty(obj, key, value) { if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }
|
|
8
|
+
|
|
9
|
+
function _objectWithoutProperties(source, excluded) { if (source == null) return {}; var target = _objectWithoutPropertiesLoose(source, excluded); var key, i; if (Object.getOwnPropertySymbols) { var sourceSymbolKeys = Object.getOwnPropertySymbols(source); for (i = 0; i < sourceSymbolKeys.length; i++) { key = sourceSymbolKeys[i]; if (excluded.indexOf(key) >= 0) continue; if (!Object.prototype.propertyIsEnumerable.call(source, key)) continue; target[key] = source[key]; } } return target; }
|
|
10
|
+
|
|
11
|
+
function _objectWithoutPropertiesLoose(source, excluded) { if (source == null) return {}; var target = {}; var sourceKeys = Object.keys(source); var key, i; for (i = 0; i < sourceKeys.length; i++) { key = sourceKeys[i]; if (excluded.indexOf(key) >= 0) continue; target[key] = source[key]; } return target; }
|
|
12
|
+
|
|
13
|
+
import { jsx as _jsx } from "react/jsx-runtime";
|
|
14
|
+
import MicroBlink from './micro-blink';
|
|
15
|
+
|
|
16
|
+
var OCR = function OCR(props) {
|
|
17
|
+
var ocrConfig = props.ocrConfig,
|
|
18
|
+
rest = _objectWithoutProperties(props, _excluded);
|
|
19
|
+
|
|
20
|
+
var vendor = ocrConfig.vendor,
|
|
21
|
+
outputMap = ocrConfig.outputMap;
|
|
22
|
+
|
|
23
|
+
switch (vendor) {
|
|
24
|
+
case 'microBlink':
|
|
25
|
+
return _jsx(MicroBlink, _objectSpread({
|
|
26
|
+
outputMap: outputMap
|
|
27
|
+
}, rest));
|
|
28
|
+
|
|
29
|
+
default:
|
|
30
|
+
return null;
|
|
31
|
+
}
|
|
32
|
+
};
|
|
33
|
+
|
|
34
|
+
OCR.formItemPropsHandler = function (config) {
|
|
35
|
+
return {};
|
|
36
|
+
};
|
|
37
|
+
|
|
38
|
+
export default OCR;
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import { FC, IglooComponentProps, FormItemExtraConfig } from '../../types';
|
|
2
|
+
import { OutputMap } from '../index';
|
|
3
|
+
import './style';
|
|
4
|
+
interface MicroBlinkProps extends IglooComponentProps, FormItemExtraConfig {
|
|
5
|
+
outputMap: OutputMap[];
|
|
6
|
+
}
|
|
7
|
+
declare const MicroBlink: FC<MicroBlinkProps>;
|
|
8
|
+
export default MicroBlink;
|