iglooform 2.4.13 → 2.4.17
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/example/index.js +3 -0
- package/es/input/credit-card.js +24 -10
- package/es/input/expiry-date.js +26 -22
- package/es/input/input-date.js +18 -24
- package/es/input/phone-number.js +5 -3
- package/es/locale/locale-provider.js +6 -2
- package/es/locale/zh-TW/messages.json +76 -0
- package/es/locale/zh-TW.d.ts +2 -0
- package/es/locale/zh-TW.js +3 -0
- package/lib/example/index.js +3 -0
- package/lib/input/credit-card.js +24 -10
- package/lib/input/expiry-date.js +26 -22
- package/lib/input/input-date.js +18 -24
- package/lib/input/phone-number.js +4 -2
- package/lib/locale/locale-provider.js +8 -2
- package/lib/locale/zh-TW/messages.json +76 -0
- package/lib/locale/zh-TW.d.ts +2 -0
- package/lib/locale/zh-TW.js +11 -0
- package/package.json +1 -1
package/es/example/index.js
CHANGED
package/es/input/credit-card.js
CHANGED
|
@@ -88,6 +88,7 @@ var IglooCredit = function IglooCredit(props) {
|
|
|
88
88
|
_props$cardConfig = props.cardConfig,
|
|
89
89
|
cardConfig = _props$cardConfig === void 0 ? [] : _props$cardConfig,
|
|
90
90
|
formChangeProps = props.onChange,
|
|
91
|
+
setFieldError = props.setFieldError,
|
|
91
92
|
value = props.value;
|
|
92
93
|
|
|
93
94
|
var _useState = useState(''),
|
|
@@ -147,30 +148,43 @@ var IglooCredit = function IglooCredit(props) {
|
|
|
147
148
|
function handleOnChange(value, cardRules, formOnChange) {
|
|
148
149
|
var pureNumInput = value.replace(/[^0-9]/gi, '');
|
|
149
150
|
|
|
150
|
-
if (pureNumInput.length === formValue.length &&
|
|
151
|
+
if (pureNumInput.length === formValue.length && value[value.length - 1] === '') {
|
|
151
152
|
// 删除了空格,得删除一个数字
|
|
152
153
|
pureNumInput = pureNumInput.substring(0, pureNumInput.length - 1);
|
|
153
154
|
}
|
|
154
155
|
|
|
155
156
|
setFormValue(pureNumInput);
|
|
156
|
-
formOnChange && formOnChange(pureNumInput); // 未必是16位
|
|
157
|
-
// if (pureNumInput.length === 17) {
|
|
158
|
-
// return
|
|
159
|
-
// }
|
|
160
|
-
|
|
161
157
|
judgeCardType(pureNumInput, cardRules);
|
|
162
|
-
setSeparateValue(separatePureNum(pureNumInput));
|
|
163
|
-
|
|
158
|
+
setSeparateValue(separatePureNum(pureNumInput)); // 空值校验
|
|
159
|
+
|
|
160
|
+
if (!pureNumInput) {
|
|
161
|
+
formOnChange && formOnChange(pureNumInput);
|
|
162
|
+
return;
|
|
163
|
+
}
|
|
164
|
+
|
|
165
|
+
for (var i = 0; i < cardRules.length; i++) {
|
|
166
|
+
var reg = cardRules[i].reg;
|
|
167
|
+
var regObj = new RegExp(reg);
|
|
164
168
|
|
|
169
|
+
if (regObj.test(pureNumInput)) {
|
|
170
|
+
formOnChange && formOnChange(pureNumInput);
|
|
171
|
+
return;
|
|
172
|
+
}
|
|
173
|
+
}
|
|
174
|
+
|
|
175
|
+
setFieldError && setFieldError(formatMessage({
|
|
176
|
+
id: 'Credit card must be {typeNames} or {finalName}',
|
|
177
|
+
values: getErrorMessage(cardRules)
|
|
178
|
+
}));
|
|
179
|
+
}
|
|
165
180
|
|
|
166
181
|
useEffect(function () {
|
|
167
182
|
if (value) {
|
|
168
183
|
handleOnChange(value, [].concat(_toConsumableArray(cardConfig), defaultCheck), formChangeProps);
|
|
169
184
|
}
|
|
170
|
-
}, []);
|
|
185
|
+
}, [value]);
|
|
171
186
|
return _jsx(_Input, _objectSpread(_objectSpread({}, omit(props, [].concat(_toConsumableArray(formMethods), ['cardConfig']))), {}, {
|
|
172
187
|
suffix: cardIcon,
|
|
173
|
-
// type="number"
|
|
174
188
|
className: classnames(className, 'igloo-input', 'igloo-input-credit-card'),
|
|
175
189
|
value: inputSeparate,
|
|
176
190
|
onChange: function onChange(e) {
|
package/es/input/expiry-date.js
CHANGED
|
@@ -67,8 +67,12 @@ var IglooExpiryDate = function IglooExpiryDate(props) {
|
|
|
67
67
|
var onChangeProps = props.onChange,
|
|
68
68
|
setFieldError = props.setFieldError,
|
|
69
69
|
_props$value = props.value,
|
|
70
|
-
value = _props$value === void 0 ? {
|
|
71
|
-
|
|
70
|
+
value = _props$value === void 0 ? {
|
|
71
|
+
year: undefined,
|
|
72
|
+
month: undefined
|
|
73
|
+
} : _props$value,
|
|
74
|
+
disabled = props.disabled,
|
|
75
|
+
check = props.check;
|
|
72
76
|
|
|
73
77
|
var _useState = useState(false),
|
|
74
78
|
_useState2 = _slicedToArray(_useState, 2),
|
|
@@ -80,11 +84,6 @@ var IglooExpiryDate = function IglooExpiryDate(props) {
|
|
|
80
84
|
var secondInput = useRef(null);
|
|
81
85
|
var formatDeleteSpace = dateFormater.replace(/\s+/g, '');
|
|
82
86
|
|
|
83
|
-
var _useState3 = useState(false),
|
|
84
|
-
_useState4 = _slicedToArray(_useState3, 2),
|
|
85
|
-
everInputAll = _useState4[0],
|
|
86
|
-
setEverInputAll = _useState4[1];
|
|
87
|
-
|
|
88
87
|
var _dealFormat = dealFormat(formatDeleteSpace),
|
|
89
88
|
_dealFormat2 = _slicedToArray(_dealFormat, 2),
|
|
90
89
|
timeInputArr = _dealFormat2[0],
|
|
@@ -95,29 +94,34 @@ var IglooExpiryDate = function IglooExpiryDate(props) {
|
|
|
95
94
|
|
|
96
95
|
var inputValueRef = useRef({});
|
|
97
96
|
|
|
98
|
-
var
|
|
99
|
-
|
|
100
|
-
inputValue =
|
|
101
|
-
setInput =
|
|
97
|
+
var _useState3 = useState({}),
|
|
98
|
+
_useState4 = _slicedToArray(_useState3, 2),
|
|
99
|
+
inputValue = _useState4[0],
|
|
100
|
+
setInput = _useState4[1];
|
|
102
101
|
|
|
103
102
|
useEffect(function () {
|
|
104
103
|
if (!value) return;
|
|
105
104
|
setInput(value);
|
|
106
105
|
inputValueRef.current = value;
|
|
107
|
-
}, []);
|
|
106
|
+
}, [value.year, value.month]);
|
|
108
107
|
useEffect(function () {
|
|
108
|
+
if (JSON.stringify(inputValue) === '{}') return;
|
|
109
109
|
var _inputValueRef$curren = inputValueRef.current,
|
|
110
110
|
year = _inputValueRef$curren.year,
|
|
111
|
-
month = _inputValueRef$curren.month;
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
111
|
+
month = _inputValueRef$curren.month;
|
|
112
|
+
var value = {
|
|
113
|
+
year: year,
|
|
114
|
+
month: month
|
|
115
|
+
};
|
|
116
|
+
var userCheck = check ? check(value) : true;
|
|
117
|
+
var compCheck = year && month ? year.length === 2 && month.length === 2 && Number(month) <= 12 : false;
|
|
118
|
+
|
|
119
|
+
if (userCheck && compCheck) {
|
|
120
|
+
onChangeProps && onChangeProps(value);
|
|
121
|
+
} else {
|
|
122
|
+
setFieldError && setFieldError(formatMessage({
|
|
123
|
+
id: 'Please enter a valid date.'
|
|
124
|
+
}));
|
|
121
125
|
}
|
|
122
126
|
}, [inputValue]);
|
|
123
127
|
|
package/es/input/input-date.js
CHANGED
|
@@ -30,7 +30,7 @@ import { LocaleContext } from '../locale';
|
|
|
30
30
|
import classnames from 'classnames';
|
|
31
31
|
import moment from 'moment';
|
|
32
32
|
import './style/index';
|
|
33
|
-
var
|
|
33
|
+
var dateFormat = 'DD / MM / YYYY'; // momentjs format中能出现的合法字符
|
|
34
34
|
|
|
35
35
|
var momentLetterArr = ['A', 'a', 'd', 'D', 'H', 'h', 'm', 'M', 'Q', 's', 'w', 'X', 'Y', ' ']; // 对于每一个input的输入做一个简单的时间限制
|
|
36
36
|
|
|
@@ -72,7 +72,7 @@ var getTextWidth = function getTextWidth(str) {
|
|
|
72
72
|
var IglooInputDate = function IglooInputDate(props) {
|
|
73
73
|
// format除去空格
|
|
74
74
|
var _props$format = props.format,
|
|
75
|
-
format = _props$format === void 0 ?
|
|
75
|
+
format = _props$format === void 0 ? dateFormat : _props$format,
|
|
76
76
|
onChangeProps = props.onChange,
|
|
77
77
|
setFieldError = props.setFieldError,
|
|
78
78
|
disabled = props.disabled,
|
|
@@ -94,11 +94,6 @@ var IglooInputDate = function IglooInputDate(props) {
|
|
|
94
94
|
inputValue = _useState4[0],
|
|
95
95
|
setInput = _useState4[1];
|
|
96
96
|
|
|
97
|
-
var _useState5 = useState(false),
|
|
98
|
-
_useState6 = _slicedToArray(_useState5, 2),
|
|
99
|
-
everInputAll = _useState6[0],
|
|
100
|
-
setEverInputAll = _useState6[1];
|
|
101
|
-
|
|
102
97
|
var formatDeleteSpace = format.replace(/\s+/g, '');
|
|
103
98
|
|
|
104
99
|
var _dealFormat = dealFormat(formatDeleteSpace),
|
|
@@ -110,24 +105,23 @@ var IglooInputDate = function IglooInputDate(props) {
|
|
|
110
105
|
formatMessage = _useContext.formatMessage;
|
|
111
106
|
|
|
112
107
|
useEffect(function () {
|
|
113
|
-
var _dealFormat3 = dealFormat(formatDeleteSpace),
|
|
114
|
-
_dealFormat4 = _slicedToArray(_dealFormat3, 2),
|
|
115
|
-
_ = _dealFormat4[0],
|
|
116
|
-
delimiter = _dealFormat4[1];
|
|
117
|
-
|
|
118
108
|
if (!value) return;
|
|
119
|
-
var init = value.
|
|
109
|
+
var init = value.split(delimiter);
|
|
120
110
|
setInput(init);
|
|
121
111
|
inputValueRef.current = init;
|
|
122
|
-
}, []);
|
|
112
|
+
}, [value]);
|
|
123
113
|
useEffect(function () {
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
var
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
if (
|
|
130
|
-
onChangeProps && onChangeProps(
|
|
114
|
+
if (!inputValue.length) return;
|
|
115
|
+
var currentInput = inputValueRef.current.join(delimiter);
|
|
116
|
+
var available = moment(currentInput.replace(/\s+/g, ''), formatDeleteSpace, true).isValid();
|
|
117
|
+
var value = moment(currentInput, formatDeleteSpace).format(format);
|
|
118
|
+
|
|
119
|
+
if (available) {
|
|
120
|
+
onChangeProps && onChangeProps(value);
|
|
121
|
+
} else {
|
|
122
|
+
setFieldError && setFieldError(formatMessage({
|
|
123
|
+
id: 'Please enter a valid date.'
|
|
124
|
+
}));
|
|
131
125
|
}
|
|
132
126
|
}, [inputValue]);
|
|
133
127
|
|
|
@@ -214,7 +208,7 @@ var IglooInputDate = function IglooInputDate(props) {
|
|
|
214
208
|
className: "igloo-input-date-picker-input",
|
|
215
209
|
placeholder: item,
|
|
216
210
|
ref: ref,
|
|
217
|
-
value: inputValue[index],
|
|
211
|
+
value: (inputValue[index] || '').replace(/\s+/g, ''),
|
|
218
212
|
onBlur: function onBlur(e) {
|
|
219
213
|
return autoZero(e.target.value, inputValueRef.current, index, item);
|
|
220
214
|
},
|
|
@@ -239,7 +233,7 @@ var IglooInputDate = function IglooInputDate(props) {
|
|
|
239
233
|
ref: ref,
|
|
240
234
|
bordered: false,
|
|
241
235
|
maxLength: item.length,
|
|
242
|
-
value: inputValue[index],
|
|
236
|
+
value: (inputValue[index] || '').replace(/\s+/g, ''),
|
|
243
237
|
onBlur: function onBlur(e) {
|
|
244
238
|
return autoZero(e.target.value, inputValueRef.current, index, item);
|
|
245
239
|
},
|
|
@@ -275,7 +269,7 @@ function checkTime(value, format) {
|
|
|
275
269
|
|
|
276
270
|
IglooInputDate.formItemPropsHandler = function (config) {
|
|
277
271
|
var _config$format = config.format,
|
|
278
|
-
format = _config$format === void 0 ?
|
|
272
|
+
format = _config$format === void 0 ? dateFormat : _config$format;
|
|
279
273
|
return {
|
|
280
274
|
rules: [{
|
|
281
275
|
validator: function validator(_, value) {
|
package/es/input/phone-number.js
CHANGED
|
@@ -14,7 +14,7 @@ function _iterableToArrayLimit(arr, i) { var _i = arr == null ? null : typeof Sy
|
|
|
14
14
|
function _arrayWithHoles(arr) { if (Array.isArray(arr)) return arr; }
|
|
15
15
|
|
|
16
16
|
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
17
|
-
import { useState, useContext } from 'react';
|
|
17
|
+
import { useState, useContext, useEffect } from 'react';
|
|
18
18
|
import classnames from 'classnames';
|
|
19
19
|
import invariant from 'invariant';
|
|
20
20
|
import Select from '../select';
|
|
@@ -28,7 +28,6 @@ var PhoneNumber = function PhoneNumber(_ref) {
|
|
|
28
28
|
disabled = _ref.disabled,
|
|
29
29
|
value = _ref.value,
|
|
30
30
|
formChangeProps = _ref.onChange,
|
|
31
|
-
setFieldValue = _ref.setFieldValue,
|
|
32
31
|
style = _ref.style;
|
|
33
32
|
|
|
34
33
|
var _useContext = useContext(LocaleContext),
|
|
@@ -50,6 +49,9 @@ var PhoneNumber = function PhoneNumber(_ref) {
|
|
|
50
49
|
number = _useState4[0],
|
|
51
50
|
setNumber = _useState4[1];
|
|
52
51
|
|
|
52
|
+
useEffect(function () {
|
|
53
|
+
setNumber(value ? value.phoneNumber : undefined);
|
|
54
|
+
}, [value]);
|
|
53
55
|
var leftPart = Array.isArray(areaCode) ? _jsx(Select, {
|
|
54
56
|
disabled: disabled,
|
|
55
57
|
onChange: function onChange(e) {
|
|
@@ -78,7 +80,7 @@ var PhoneNumber = function PhoneNumber(_ref) {
|
|
|
78
80
|
}, className),
|
|
79
81
|
children: [leftPart, _jsx(_Input, {
|
|
80
82
|
type: "tel",
|
|
81
|
-
|
|
83
|
+
value: number,
|
|
82
84
|
onChange: function onChange(e) {
|
|
83
85
|
setNumber(e.target.value);
|
|
84
86
|
formChangeProps(e.target.value ? {
|
|
@@ -15,11 +15,13 @@ import zh from './zh-CN';
|
|
|
15
15
|
import id from './id-ID';
|
|
16
16
|
import vi from './vi-VN';
|
|
17
17
|
import th from './th-TH';
|
|
18
|
+
import zhTW from './zh-TW';
|
|
18
19
|
import antdId from 'antd/es/locale/id_ID';
|
|
19
20
|
import antdEn from 'antd/es/locale/en_US';
|
|
20
21
|
import antdZh from 'antd/es/locale/zh_CN';
|
|
21
22
|
import antdVi from 'antd/es/locale/vi_VN';
|
|
22
23
|
import antdTH from 'antd/es/locale/th_TH';
|
|
24
|
+
import antdZhTw from 'antd/es/locale/zh_TW';
|
|
23
25
|
import antdDefault from 'antd/es/locale/default';
|
|
24
26
|
import { staticLang } from './format-message';
|
|
25
27
|
export var locales = {
|
|
@@ -27,14 +29,16 @@ export var locales = {
|
|
|
27
29
|
'id-ID': id,
|
|
28
30
|
'zh-CN': zh,
|
|
29
31
|
'vi-VN': vi,
|
|
30
|
-
'th-TH': th
|
|
32
|
+
'th-TH': th,
|
|
33
|
+
'zh-TW': zhTW
|
|
31
34
|
};
|
|
32
35
|
var antdLocale = {
|
|
33
36
|
'en-US': _objectSpread(_objectSpread({}, antdDefault), antdEn),
|
|
34
37
|
'id-ID': _objectSpread(_objectSpread({}, antdDefault), antdId),
|
|
35
38
|
'zh-CN': _objectSpread(_objectSpread({}, antdDefault), antdZh),
|
|
36
39
|
'vi-VN': _objectSpread(_objectSpread({}, antdDefault), antdVi),
|
|
37
|
-
'th-TH': _objectSpread(_objectSpread({}, antdDefault), antdTH)
|
|
40
|
+
'th-TH': _objectSpread(_objectSpread({}, antdDefault), antdTH),
|
|
41
|
+
'zh-TW': _objectSpread(_objectSpread({}, antdDefault), antdZhTw)
|
|
38
42
|
};
|
|
39
43
|
|
|
40
44
|
var LocaleProvider = function LocaleProvider(_ref) {
|
|
@@ -0,0 +1,76 @@
|
|
|
1
|
+
{
|
|
2
|
+
"1 file attached.": "附加1個文件。",
|
|
3
|
+
"1 file imported.": "導入1文件。",
|
|
4
|
+
"1 file in progress...": "1文件正在進行中......",
|
|
5
|
+
"Accept": "接受",
|
|
6
|
+
"Action": "行動",
|
|
7
|
+
"Add": "添加",
|
|
8
|
+
"Apply": "申請",
|
|
9
|
+
"Apply Columns": "申請專欄",
|
|
10
|
+
"Cancel": "取消",
|
|
11
|
+
"Clear All": "清除所有",
|
|
12
|
+
"Click to cancel sorting": "點擊取消排序",
|
|
13
|
+
"Click to sort ascending": "點擊排序升序",
|
|
14
|
+
"Click to sort descending": "點擊排序降序",
|
|
15
|
+
"Close Result Panel": "關閉結果面板",
|
|
16
|
+
"Continue": "繼續",
|
|
17
|
+
"Credit card must be {typeNames} or {finalName}": "信用卡必須是{typeNames}或{finalName}",
|
|
18
|
+
"Custom": "習慣",
|
|
19
|
+
"Customize Columns": "自定義列",
|
|
20
|
+
"Data Importing Queue": "數據導入隊列",
|
|
21
|
+
"Data Processed": "數據已處理",
|
|
22
|
+
"Data Processing...": "數據處理中。。。",
|
|
23
|
+
"Date": "日期",
|
|
24
|
+
"Drag and drop a file here": "拖放文件至此",
|
|
25
|
+
"Edit": "編輯",
|
|
26
|
+
"Error Report": "錯誤報告",
|
|
27
|
+
"Filter": "篩選",
|
|
28
|
+
"I declare that the statements I have described above are true. I further declare that the loss occured was accidental, without planning or consensus with other parties.": "我聲明我上面描述的陳述是真的。我進一步宣布發生損失是偶然的,沒有規劃或與其他方的共識。",
|
|
29
|
+
"Import": "導入",
|
|
30
|
+
"It is recommended to select no more than {colMax} metrics to ensure the default visibility of each column input.": "建議選擇不超過{colMax}指標以確保每個列輸入的默認可見性。",
|
|
31
|
+
"Last 7 Days": "過去7天",
|
|
32
|
+
"Last Day": "過去1天",
|
|
33
|
+
"Last Month": "上個月",
|
|
34
|
+
"Log in": "登錄",
|
|
35
|
+
"Next": "下一個",
|
|
36
|
+
"No preview for this file. Only support image, video or PDF file.": "不支持預覽此文件。只支持圖像,視頻或PDF文件。",
|
|
37
|
+
"Numbers only, please omit \" \" or \"-\".": "只有數字,請省略“”或“ - ”。",
|
|
38
|
+
"OK": "好",
|
|
39
|
+
"Once you’re happy with the above, and you’ve checked the declaration, please go ahead and submit your claim.": "一旦您對上述內容感到滿意,您已檢查聲明,請繼續並提交您的索賠。",
|
|
40
|
+
"Optional": "可選項",
|
|
41
|
+
"Please enter a valid date.": "請輸入有效的日期。",
|
|
42
|
+
"Please enter a valid time.": "請輸入有效的時間。",
|
|
43
|
+
"Please select": "請選擇",
|
|
44
|
+
"Please select a file type": "請選擇文件類型",
|
|
45
|
+
"Please take a moment to review what you’ve told us above.": "請花點時間查看您在上面提供給我們的內容。",
|
|
46
|
+
"Previous": "以前的",
|
|
47
|
+
"Processing": "處理中",
|
|
48
|
+
"Processing progress cannot be updated at the moment. Don’t worry! All your file data are still in progress.": "此刻無法更新處理進度。別擔心!您的所有文件數據仍在進行中。",
|
|
49
|
+
"Quantity of files should be less than {limit}": "文件的數量應小於{limit}",
|
|
50
|
+
"Reject": "拒絕",
|
|
51
|
+
"Remove": "消除",
|
|
52
|
+
"Resend OTP": "重新發送OTP.",
|
|
53
|
+
"Resend in": "重新發送",
|
|
54
|
+
"Reset All Filters": "重置所有過濾器",
|
|
55
|
+
"Result": "結果",
|
|
56
|
+
"Result: Success {success_num}; Error {fail_num}": "結果:成功{success_num};錯誤{fail_num}",
|
|
57
|
+
"Rows per page": "每頁行數",
|
|
58
|
+
"Select All": "全選",
|
|
59
|
+
"Send OTP": "發送OTP.",
|
|
60
|
+
"Submit": "提交",
|
|
61
|
+
"The file type is not supported.": "不支持文件類型。",
|
|
62
|
+
"This Month": "本月",
|
|
63
|
+
"Unselect All": "全部取消選擇",
|
|
64
|
+
"Uploading": "上傳",
|
|
65
|
+
"We support CSV or XLSX files (less than 20M each).": "我們支持CSV或XLSX文件(小於20M)。",
|
|
66
|
+
"Yes, Close": "是的,關閉",
|
|
67
|
+
"browse": "瀏覽",
|
|
68
|
+
"or": "或者",
|
|
69
|
+
"{beginIndex}-{endIndex} of {total}": "{beginIndex} - {endIndex} 從 {total}",
|
|
70
|
+
"{canInputNum} characters left": "{canInputNum}剩餘字符",
|
|
71
|
+
"{canInputNum} characters over": "{canInputNum}超出字符",
|
|
72
|
+
"{count} files attached.": "{count}附加文件。",
|
|
73
|
+
"{currentStep} of {allSteps}": "{allSteps}的{currentStep}",
|
|
74
|
+
"{doneNumber} files imported.": "{doneNumber}導入的文件。",
|
|
75
|
+
"{processingNumber} files in progress...": "{processingNumber}正在進行的文件。。。"
|
|
76
|
+
}
|
package/lib/example/index.js
CHANGED
package/lib/input/credit-card.js
CHANGED
|
@@ -103,6 +103,7 @@ var IglooCredit = function IglooCredit(props) {
|
|
|
103
103
|
_props$cardConfig = props.cardConfig,
|
|
104
104
|
cardConfig = _props$cardConfig === void 0 ? [] : _props$cardConfig,
|
|
105
105
|
formChangeProps = props.onChange,
|
|
106
|
+
setFieldError = props.setFieldError,
|
|
106
107
|
value = props.value;
|
|
107
108
|
|
|
108
109
|
var _useState = (0, _react.useState)(''),
|
|
@@ -162,30 +163,43 @@ var IglooCredit = function IglooCredit(props) {
|
|
|
162
163
|
function handleOnChange(value, cardRules, formOnChange) {
|
|
163
164
|
var pureNumInput = value.replace(/[^0-9]/gi, '');
|
|
164
165
|
|
|
165
|
-
if (pureNumInput.length === formValue.length &&
|
|
166
|
+
if (pureNumInput.length === formValue.length && value[value.length - 1] === '') {
|
|
166
167
|
// 删除了空格,得删除一个数字
|
|
167
168
|
pureNumInput = pureNumInput.substring(0, pureNumInput.length - 1);
|
|
168
169
|
}
|
|
169
170
|
|
|
170
171
|
setFormValue(pureNumInput);
|
|
171
|
-
formOnChange && formOnChange(pureNumInput); // 未必是16位
|
|
172
|
-
// if (pureNumInput.length === 17) {
|
|
173
|
-
// return
|
|
174
|
-
// }
|
|
175
|
-
|
|
176
172
|
judgeCardType(pureNumInput, cardRules);
|
|
177
|
-
setSeparateValue(separatePureNum(pureNumInput));
|
|
178
|
-
|
|
173
|
+
setSeparateValue(separatePureNum(pureNumInput)); // 空值校验
|
|
174
|
+
|
|
175
|
+
if (!pureNumInput) {
|
|
176
|
+
formOnChange && formOnChange(pureNumInput);
|
|
177
|
+
return;
|
|
178
|
+
}
|
|
179
|
+
|
|
180
|
+
for (var i = 0; i < cardRules.length; i++) {
|
|
181
|
+
var reg = cardRules[i].reg;
|
|
182
|
+
var regObj = new RegExp(reg);
|
|
179
183
|
|
|
184
|
+
if (regObj.test(pureNumInput)) {
|
|
185
|
+
formOnChange && formOnChange(pureNumInput);
|
|
186
|
+
return;
|
|
187
|
+
}
|
|
188
|
+
}
|
|
189
|
+
|
|
190
|
+
setFieldError && setFieldError(formatMessage({
|
|
191
|
+
id: 'Credit card must be {typeNames} or {finalName}',
|
|
192
|
+
values: getErrorMessage(cardRules)
|
|
193
|
+
}));
|
|
194
|
+
}
|
|
180
195
|
|
|
181
196
|
(0, _react.useEffect)(function () {
|
|
182
197
|
if (value) {
|
|
183
198
|
handleOnChange(value, [].concat(_toConsumableArray(cardConfig), defaultCheck), formChangeProps);
|
|
184
199
|
}
|
|
185
|
-
}, []);
|
|
200
|
+
}, [value]);
|
|
186
201
|
return (0, _jsxRuntime.jsx)(_input.default, _objectSpread(_objectSpread({}, (0, _omit.default)(props, [].concat(_toConsumableArray(_formMethods.default), ['cardConfig']))), {}, {
|
|
187
202
|
suffix: cardIcon,
|
|
188
|
-
// type="number"
|
|
189
203
|
className: (0, _classnames.default)(className, 'igloo-input', 'igloo-input-credit-card'),
|
|
190
204
|
value: inputSeparate,
|
|
191
205
|
onChange: function onChange(e) {
|
package/lib/input/expiry-date.js
CHANGED
|
@@ -83,8 +83,12 @@ var IglooExpiryDate = function IglooExpiryDate(props) {
|
|
|
83
83
|
var onChangeProps = props.onChange,
|
|
84
84
|
setFieldError = props.setFieldError,
|
|
85
85
|
_props$value = props.value,
|
|
86
|
-
value = _props$value === void 0 ? {
|
|
87
|
-
|
|
86
|
+
value = _props$value === void 0 ? {
|
|
87
|
+
year: undefined,
|
|
88
|
+
month: undefined
|
|
89
|
+
} : _props$value,
|
|
90
|
+
disabled = props.disabled,
|
|
91
|
+
check = props.check;
|
|
88
92
|
|
|
89
93
|
var _useState = (0, _react.useState)(false),
|
|
90
94
|
_useState2 = _slicedToArray(_useState, 2),
|
|
@@ -96,11 +100,6 @@ var IglooExpiryDate = function IglooExpiryDate(props) {
|
|
|
96
100
|
var secondInput = (0, _react.useRef)(null);
|
|
97
101
|
var formatDeleteSpace = dateFormater.replace(/\s+/g, '');
|
|
98
102
|
|
|
99
|
-
var _useState3 = (0, _react.useState)(false),
|
|
100
|
-
_useState4 = _slicedToArray(_useState3, 2),
|
|
101
|
-
everInputAll = _useState4[0],
|
|
102
|
-
setEverInputAll = _useState4[1];
|
|
103
|
-
|
|
104
103
|
var _dealFormat = dealFormat(formatDeleteSpace),
|
|
105
104
|
_dealFormat2 = _slicedToArray(_dealFormat, 2),
|
|
106
105
|
timeInputArr = _dealFormat2[0],
|
|
@@ -111,29 +110,34 @@ var IglooExpiryDate = function IglooExpiryDate(props) {
|
|
|
111
110
|
|
|
112
111
|
var inputValueRef = (0, _react.useRef)({});
|
|
113
112
|
|
|
114
|
-
var
|
|
115
|
-
|
|
116
|
-
inputValue =
|
|
117
|
-
setInput =
|
|
113
|
+
var _useState3 = (0, _react.useState)({}),
|
|
114
|
+
_useState4 = _slicedToArray(_useState3, 2),
|
|
115
|
+
inputValue = _useState4[0],
|
|
116
|
+
setInput = _useState4[1];
|
|
118
117
|
|
|
119
118
|
(0, _react.useEffect)(function () {
|
|
120
119
|
if (!value) return;
|
|
121
120
|
setInput(value);
|
|
122
121
|
inputValueRef.current = value;
|
|
123
|
-
}, []);
|
|
122
|
+
}, [value.year, value.month]);
|
|
124
123
|
(0, _react.useEffect)(function () {
|
|
124
|
+
if (JSON.stringify(inputValue) === '{}') return;
|
|
125
125
|
var _inputValueRef$curren = inputValueRef.current,
|
|
126
126
|
year = _inputValueRef$curren.year,
|
|
127
|
-
month = _inputValueRef$curren.month;
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
127
|
+
month = _inputValueRef$curren.month;
|
|
128
|
+
var value = {
|
|
129
|
+
year: year,
|
|
130
|
+
month: month
|
|
131
|
+
};
|
|
132
|
+
var userCheck = check ? check(value) : true;
|
|
133
|
+
var compCheck = year && month ? year.length === 2 && month.length === 2 && Number(month) <= 12 : false;
|
|
134
|
+
|
|
135
|
+
if (userCheck && compCheck) {
|
|
136
|
+
onChangeProps && onChangeProps(value);
|
|
137
|
+
} else {
|
|
138
|
+
setFieldError && setFieldError(formatMessage({
|
|
139
|
+
id: 'Please enter a valid date.'
|
|
140
|
+
}));
|
|
137
141
|
}
|
|
138
142
|
}, [inputValue]);
|
|
139
143
|
|
package/lib/input/input-date.js
CHANGED
|
@@ -47,7 +47,7 @@ function _iterableToArrayLimit(arr, i) { var _i = arr == null ? null : typeof Sy
|
|
|
47
47
|
|
|
48
48
|
function _arrayWithHoles(arr) { if (Array.isArray(arr)) return arr; }
|
|
49
49
|
|
|
50
|
-
var
|
|
50
|
+
var dateFormat = 'DD / MM / YYYY'; // momentjs format中能出现的合法字符
|
|
51
51
|
|
|
52
52
|
var momentLetterArr = ['A', 'a', 'd', 'D', 'H', 'h', 'm', 'M', 'Q', 's', 'w', 'X', 'Y', ' ']; // 对于每一个input的输入做一个简单的时间限制
|
|
53
53
|
|
|
@@ -89,7 +89,7 @@ var getTextWidth = function getTextWidth(str) {
|
|
|
89
89
|
var IglooInputDate = function IglooInputDate(props) {
|
|
90
90
|
// format除去空格
|
|
91
91
|
var _props$format = props.format,
|
|
92
|
-
format = _props$format === void 0 ?
|
|
92
|
+
format = _props$format === void 0 ? dateFormat : _props$format,
|
|
93
93
|
onChangeProps = props.onChange,
|
|
94
94
|
setFieldError = props.setFieldError,
|
|
95
95
|
disabled = props.disabled,
|
|
@@ -111,11 +111,6 @@ var IglooInputDate = function IglooInputDate(props) {
|
|
|
111
111
|
inputValue = _useState4[0],
|
|
112
112
|
setInput = _useState4[1];
|
|
113
113
|
|
|
114
|
-
var _useState5 = (0, _react.useState)(false),
|
|
115
|
-
_useState6 = _slicedToArray(_useState5, 2),
|
|
116
|
-
everInputAll = _useState6[0],
|
|
117
|
-
setEverInputAll = _useState6[1];
|
|
118
|
-
|
|
119
114
|
var formatDeleteSpace = format.replace(/\s+/g, '');
|
|
120
115
|
|
|
121
116
|
var _dealFormat = dealFormat(formatDeleteSpace),
|
|
@@ -127,24 +122,23 @@ var IglooInputDate = function IglooInputDate(props) {
|
|
|
127
122
|
formatMessage = _useContext.formatMessage;
|
|
128
123
|
|
|
129
124
|
(0, _react.useEffect)(function () {
|
|
130
|
-
var _dealFormat3 = dealFormat(formatDeleteSpace),
|
|
131
|
-
_dealFormat4 = _slicedToArray(_dealFormat3, 2),
|
|
132
|
-
_ = _dealFormat4[0],
|
|
133
|
-
delimiter = _dealFormat4[1];
|
|
134
|
-
|
|
135
125
|
if (!value) return;
|
|
136
|
-
var init = value.
|
|
126
|
+
var init = value.split(delimiter);
|
|
137
127
|
setInput(init);
|
|
138
128
|
inputValueRef.current = init;
|
|
139
|
-
}, []);
|
|
129
|
+
}, [value]);
|
|
140
130
|
(0, _react.useEffect)(function () {
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
var
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
if (
|
|
147
|
-
onChangeProps && onChangeProps(
|
|
131
|
+
if (!inputValue.length) return;
|
|
132
|
+
var currentInput = inputValueRef.current.join(delimiter);
|
|
133
|
+
var available = (0, _moment.default)(currentInput.replace(/\s+/g, ''), formatDeleteSpace, true).isValid();
|
|
134
|
+
var value = (0, _moment.default)(currentInput, formatDeleteSpace).format(format);
|
|
135
|
+
|
|
136
|
+
if (available) {
|
|
137
|
+
onChangeProps && onChangeProps(value);
|
|
138
|
+
} else {
|
|
139
|
+
setFieldError && setFieldError(formatMessage({
|
|
140
|
+
id: 'Please enter a valid date.'
|
|
141
|
+
}));
|
|
148
142
|
}
|
|
149
143
|
}, [inputValue]);
|
|
150
144
|
|
|
@@ -231,7 +225,7 @@ var IglooInputDate = function IglooInputDate(props) {
|
|
|
231
225
|
className: "igloo-input-date-picker-input",
|
|
232
226
|
placeholder: item,
|
|
233
227
|
ref: ref,
|
|
234
|
-
value: inputValue[index],
|
|
228
|
+
value: (inputValue[index] || '').replace(/\s+/g, ''),
|
|
235
229
|
onBlur: function onBlur(e) {
|
|
236
230
|
return autoZero(e.target.value, inputValueRef.current, index, item);
|
|
237
231
|
},
|
|
@@ -256,7 +250,7 @@ var IglooInputDate = function IglooInputDate(props) {
|
|
|
256
250
|
ref: ref,
|
|
257
251
|
bordered: false,
|
|
258
252
|
maxLength: item.length,
|
|
259
|
-
value: inputValue[index],
|
|
253
|
+
value: (inputValue[index] || '').replace(/\s+/g, ''),
|
|
260
254
|
onBlur: function onBlur(e) {
|
|
261
255
|
return autoZero(e.target.value, inputValueRef.current, index, item);
|
|
262
256
|
},
|
|
@@ -292,7 +286,7 @@ function checkTime(value, format) {
|
|
|
292
286
|
|
|
293
287
|
IglooInputDate.formItemPropsHandler = function (config) {
|
|
294
288
|
var _config$format = config.format,
|
|
295
|
-
format = _config$format === void 0 ?
|
|
289
|
+
format = _config$format === void 0 ? dateFormat : _config$format;
|
|
296
290
|
return {
|
|
297
291
|
rules: [{
|
|
298
292
|
validator: function validator(_, value) {
|
|
@@ -44,7 +44,6 @@ var PhoneNumber = function PhoneNumber(_ref) {
|
|
|
44
44
|
disabled = _ref.disabled,
|
|
45
45
|
value = _ref.value,
|
|
46
46
|
formChangeProps = _ref.onChange,
|
|
47
|
-
setFieldValue = _ref.setFieldValue,
|
|
48
47
|
style = _ref.style;
|
|
49
48
|
|
|
50
49
|
var _useContext = (0, _react.useContext)(_locale.LocaleContext),
|
|
@@ -66,6 +65,9 @@ var PhoneNumber = function PhoneNumber(_ref) {
|
|
|
66
65
|
number = _useState4[0],
|
|
67
66
|
setNumber = _useState4[1];
|
|
68
67
|
|
|
68
|
+
(0, _react.useEffect)(function () {
|
|
69
|
+
setNumber(value ? value.phoneNumber : undefined);
|
|
70
|
+
}, [value]);
|
|
69
71
|
var leftPart = Array.isArray(areaCode) ? (0, _jsxRuntime.jsx)(_select.default, {
|
|
70
72
|
disabled: disabled,
|
|
71
73
|
onChange: function onChange(e) {
|
|
@@ -94,7 +96,7 @@ var PhoneNumber = function PhoneNumber(_ref) {
|
|
|
94
96
|
}, className),
|
|
95
97
|
children: [leftPart, (0, _jsxRuntime.jsx)(_input.default, {
|
|
96
98
|
type: "tel",
|
|
97
|
-
|
|
99
|
+
value: number,
|
|
98
100
|
onChange: function onChange(e) {
|
|
99
101
|
setNumber(e.target.value);
|
|
100
102
|
formChangeProps(e.target.value ? {
|
|
@@ -25,6 +25,8 @@ var _viVN = _interopRequireDefault(require("./vi-VN"));
|
|
|
25
25
|
|
|
26
26
|
var _thTH = _interopRequireDefault(require("./th-TH"));
|
|
27
27
|
|
|
28
|
+
var _zhTW = _interopRequireDefault(require("./zh-TW"));
|
|
29
|
+
|
|
28
30
|
var _id_ID = _interopRequireDefault(require("antd/es/locale/id_ID"));
|
|
29
31
|
|
|
30
32
|
var _en_US = _interopRequireDefault(require("antd/es/locale/en_US"));
|
|
@@ -35,6 +37,8 @@ var _vi_VN = _interopRequireDefault(require("antd/es/locale/vi_VN"));
|
|
|
35
37
|
|
|
36
38
|
var _th_TH = _interopRequireDefault(require("antd/es/locale/th_TH"));
|
|
37
39
|
|
|
40
|
+
var _zh_TW = _interopRequireDefault(require("antd/es/locale/zh_TW"));
|
|
41
|
+
|
|
38
42
|
var _default2 = _interopRequireDefault(require("antd/es/locale/default"));
|
|
39
43
|
|
|
40
44
|
var _formatMessage = require("./format-message");
|
|
@@ -52,7 +56,8 @@ var locales = {
|
|
|
52
56
|
'id-ID': _idID.default,
|
|
53
57
|
'zh-CN': _zhCN.default,
|
|
54
58
|
'vi-VN': _viVN.default,
|
|
55
|
-
'th-TH': _thTH.default
|
|
59
|
+
'th-TH': _thTH.default,
|
|
60
|
+
'zh-TW': _zhTW.default
|
|
56
61
|
};
|
|
57
62
|
exports.locales = locales;
|
|
58
63
|
var antdLocale = {
|
|
@@ -60,7 +65,8 @@ var antdLocale = {
|
|
|
60
65
|
'id-ID': _objectSpread(_objectSpread({}, _default2.default), _id_ID.default),
|
|
61
66
|
'zh-CN': _objectSpread(_objectSpread({}, _default2.default), _zh_CN.default),
|
|
62
67
|
'vi-VN': _objectSpread(_objectSpread({}, _default2.default), _vi_VN.default),
|
|
63
|
-
'th-TH': _objectSpread(_objectSpread({}, _default2.default), _th_TH.default)
|
|
68
|
+
'th-TH': _objectSpread(_objectSpread({}, _default2.default), _th_TH.default),
|
|
69
|
+
'zh-TW': _objectSpread(_objectSpread({}, _default2.default), _zh_TW.default)
|
|
64
70
|
};
|
|
65
71
|
|
|
66
72
|
var LocaleProvider = function LocaleProvider(_ref) {
|
|
@@ -0,0 +1,76 @@
|
|
|
1
|
+
{
|
|
2
|
+
"1 file attached.": "附加1個文件。",
|
|
3
|
+
"1 file imported.": "導入1文件。",
|
|
4
|
+
"1 file in progress...": "1文件正在進行中......",
|
|
5
|
+
"Accept": "接受",
|
|
6
|
+
"Action": "行動",
|
|
7
|
+
"Add": "添加",
|
|
8
|
+
"Apply": "申請",
|
|
9
|
+
"Apply Columns": "申請專欄",
|
|
10
|
+
"Cancel": "取消",
|
|
11
|
+
"Clear All": "清除所有",
|
|
12
|
+
"Click to cancel sorting": "點擊取消排序",
|
|
13
|
+
"Click to sort ascending": "點擊排序升序",
|
|
14
|
+
"Click to sort descending": "點擊排序降序",
|
|
15
|
+
"Close Result Panel": "關閉結果面板",
|
|
16
|
+
"Continue": "繼續",
|
|
17
|
+
"Credit card must be {typeNames} or {finalName}": "信用卡必須是{typeNames}或{finalName}",
|
|
18
|
+
"Custom": "習慣",
|
|
19
|
+
"Customize Columns": "自定義列",
|
|
20
|
+
"Data Importing Queue": "數據導入隊列",
|
|
21
|
+
"Data Processed": "數據已處理",
|
|
22
|
+
"Data Processing...": "數據處理中。。。",
|
|
23
|
+
"Date": "日期",
|
|
24
|
+
"Drag and drop a file here": "拖放文件至此",
|
|
25
|
+
"Edit": "編輯",
|
|
26
|
+
"Error Report": "錯誤報告",
|
|
27
|
+
"Filter": "篩選",
|
|
28
|
+
"I declare that the statements I have described above are true. I further declare that the loss occured was accidental, without planning or consensus with other parties.": "我聲明我上面描述的陳述是真的。我進一步宣布發生損失是偶然的,沒有規劃或與其他方的共識。",
|
|
29
|
+
"Import": "導入",
|
|
30
|
+
"It is recommended to select no more than {colMax} metrics to ensure the default visibility of each column input.": "建議選擇不超過{colMax}指標以確保每個列輸入的默認可見性。",
|
|
31
|
+
"Last 7 Days": "過去7天",
|
|
32
|
+
"Last Day": "過去1天",
|
|
33
|
+
"Last Month": "上個月",
|
|
34
|
+
"Log in": "登錄",
|
|
35
|
+
"Next": "下一個",
|
|
36
|
+
"No preview for this file. Only support image, video or PDF file.": "不支持預覽此文件。只支持圖像,視頻或PDF文件。",
|
|
37
|
+
"Numbers only, please omit \" \" or \"-\".": "只有數字,請省略“”或“ - ”。",
|
|
38
|
+
"OK": "好",
|
|
39
|
+
"Once you’re happy with the above, and you’ve checked the declaration, please go ahead and submit your claim.": "一旦您對上述內容感到滿意,您已檢查聲明,請繼續並提交您的索賠。",
|
|
40
|
+
"Optional": "可選項",
|
|
41
|
+
"Please enter a valid date.": "請輸入有效的日期。",
|
|
42
|
+
"Please enter a valid time.": "請輸入有效的時間。",
|
|
43
|
+
"Please select": "請選擇",
|
|
44
|
+
"Please select a file type": "請選擇文件類型",
|
|
45
|
+
"Please take a moment to review what you’ve told us above.": "請花點時間查看您在上面提供給我們的內容。",
|
|
46
|
+
"Previous": "以前的",
|
|
47
|
+
"Processing": "處理中",
|
|
48
|
+
"Processing progress cannot be updated at the moment. Don’t worry! All your file data are still in progress.": "此刻無法更新處理進度。別擔心!您的所有文件數據仍在進行中。",
|
|
49
|
+
"Quantity of files should be less than {limit}": "文件的數量應小於{limit}",
|
|
50
|
+
"Reject": "拒絕",
|
|
51
|
+
"Remove": "消除",
|
|
52
|
+
"Resend OTP": "重新發送OTP.",
|
|
53
|
+
"Resend in": "重新發送",
|
|
54
|
+
"Reset All Filters": "重置所有過濾器",
|
|
55
|
+
"Result": "結果",
|
|
56
|
+
"Result: Success {success_num}; Error {fail_num}": "結果:成功{success_num};錯誤{fail_num}",
|
|
57
|
+
"Rows per page": "每頁行數",
|
|
58
|
+
"Select All": "全選",
|
|
59
|
+
"Send OTP": "發送OTP.",
|
|
60
|
+
"Submit": "提交",
|
|
61
|
+
"The file type is not supported.": "不支持文件類型。",
|
|
62
|
+
"This Month": "本月",
|
|
63
|
+
"Unselect All": "全部取消選擇",
|
|
64
|
+
"Uploading": "上傳",
|
|
65
|
+
"We support CSV or XLSX files (less than 20M each).": "我們支持CSV或XLSX文件(小於20M)。",
|
|
66
|
+
"Yes, Close": "是的,關閉",
|
|
67
|
+
"browse": "瀏覽",
|
|
68
|
+
"or": "或者",
|
|
69
|
+
"{beginIndex}-{endIndex} of {total}": "{beginIndex} - {endIndex} 從 {total}",
|
|
70
|
+
"{canInputNum} characters left": "{canInputNum}剩餘字符",
|
|
71
|
+
"{canInputNum} characters over": "{canInputNum}超出字符",
|
|
72
|
+
"{count} files attached.": "{count}附加文件。",
|
|
73
|
+
"{currentStep} of {allSteps}": "{allSteps}的{currentStep}",
|
|
74
|
+
"{doneNumber} files imported.": "{doneNumber}導入的文件。",
|
|
75
|
+
"{processingNumber} files in progress...": "{processingNumber}正在進行的文件。。。"
|
|
76
|
+
}
|