dtable-ui-component 6.0.24 → 6.0.25
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/lib/ActionSheet/index.js +194 -0
- package/lib/ActionSheet/style/index.css +365 -0
- package/lib/ActivityIndicator/index.css +108 -0
- package/lib/ActivityIndicator/index.js +76 -0
- package/lib/Badge/index.css +96 -0
- package/lib/Badge/index.js +65 -0
- package/lib/DateEditor/mb-date-editor-popover/index.js +3 -3
- package/lib/DatePicker/index.js +120 -0
- package/lib/DatePicker/locale/en_US.js +14 -0
- package/lib/DatePicker/locale/ru_RU.js +14 -0
- package/lib/DatePicker/locale/sv_SE.js +14 -0
- package/lib/DatePicker/locale/zh_CN.js +14 -0
- package/lib/DatePicker/style/index.css +290 -0
- package/lib/DatePicker/utils.js +36 -0
- package/lib/Drawer/index.css +142 -0
- package/lib/Drawer/index.js +21 -0
- package/lib/Icon/index.css +50 -0
- package/lib/Icon/index.js +34 -0
- package/lib/Icon/load-sprite.js +56 -0
- package/lib/InputItem/custom-input.js +321 -0
- package/lib/InputItem/custom-keyboard.js +162 -0
- package/lib/InputItem/index.js +388 -0
- package/lib/InputItem/input.js +45 -0
- package/lib/InputItem/locale/en_US.js +12 -0
- package/lib/InputItem/locale/ru_RU.js +12 -0
- package/lib/InputItem/locale/sv_SE.js +12 -0
- package/lib/InputItem/locale/zh_CN.js +12 -0
- package/lib/InputItem/portal.js +23 -0
- package/lib/InputItem/style/index.css +512 -0
- package/lib/List/index.css +381 -0
- package/lib/List/index.js +41 -0
- package/lib/List/list-item.js +169 -0
- package/lib/Modal/alert.js +82 -0
- package/lib/Modal/index.js +15 -0
- package/lib/Modal/modal.js +118 -0
- package/lib/Modal/operation.js +77 -0
- package/lib/Modal/prompt.js +207 -0
- package/lib/Picker/AbstractPicker.js +190 -0
- package/lib/Picker/index.js +28 -0
- package/lib/Picker/locale/en_US.js +12 -0
- package/lib/Picker/locale/ru_RU.js +12 -0
- package/lib/Picker/locale/sv_SE.js +12 -0
- package/lib/Picker/locale/zh_CN.js +12 -0
- package/lib/Picker/popupProps.js +12 -0
- package/lib/Picker/style/index.css +141 -0
- package/lib/Popover/index.js +62 -0
- package/lib/Popover/item.js +55 -0
- package/lib/Popover/style/index.css +229 -0
- package/lib/Progress/index.css +22 -0
- package/lib/Progress/index.js +65 -0
- package/lib/Radio/Radio.js +47 -0
- package/lib/Radio/RadioItem.js +57 -0
- package/lib/Radio/index.css +90 -0
- package/lib/Radio/index.js +12 -0
- package/lib/TabBar/Tab.js +76 -0
- package/lib/TabBar/index.css +138 -0
- package/lib/TabBar/index.js +128 -0
- package/lib/Tabs/index.css +443 -0
- package/lib/Tabs/index.js +38 -0
- package/lib/TextareaItem/index.css +231 -0
- package/lib/TextareaItem/index.js +231 -0
- package/lib/Toast/index.css +65 -0
- package/lib/Toast/index.js +131 -0
- package/lib/_util/class.js +34 -0
- package/lib/_util/closest.js +17 -0
- package/lib/_util/exenv.js +8 -0
- package/lib/_util/getDataAttr.js +15 -0
- package/lib/_util/getLocale.js +42 -0
- package/lib/index.js +106 -1
- package/package.json +12 -3
|
@@ -0,0 +1,321 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
var _interopRequireWildcard = require("@babel/runtime/helpers/interopRequireWildcard").default;
|
|
4
|
+
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault").default;
|
|
5
|
+
Object.defineProperty(exports, "__esModule", {
|
|
6
|
+
value: true
|
|
7
|
+
});
|
|
8
|
+
exports.default = void 0;
|
|
9
|
+
var _classnames = _interopRequireDefault(require("classnames"));
|
|
10
|
+
var React = _interopRequireWildcard(require("react"));
|
|
11
|
+
var ReactDOM = _interopRequireWildcard(require("react-dom"));
|
|
12
|
+
var _class = require("../_util/class");
|
|
13
|
+
var _exenv = require("../_util/exenv");
|
|
14
|
+
var _customKeyboard = _interopRequireDefault(require("./custom-keyboard"));
|
|
15
|
+
var _portal = _interopRequireDefault(require("./portal"));
|
|
16
|
+
let customNumberKeyboard = null;
|
|
17
|
+
const IS_REACT_16 = !!ReactDOM.createPortal;
|
|
18
|
+
function getBodyScrollTop() {
|
|
19
|
+
const el = document.scrollingElement || document.documentElement;
|
|
20
|
+
return el && el.scrollTop || 0;
|
|
21
|
+
}
|
|
22
|
+
function setBodyScrollTop(scrollTop) {
|
|
23
|
+
const el = document.scrollingElement || document.documentElement;
|
|
24
|
+
el.scrollTop = scrollTop;
|
|
25
|
+
}
|
|
26
|
+
class NumberInput extends React.Component {
|
|
27
|
+
constructor(props) {
|
|
28
|
+
super(props);
|
|
29
|
+
this.onChange = value => {
|
|
30
|
+
if (!('value' in this.props)) {
|
|
31
|
+
this.setState({
|
|
32
|
+
value: value.target.value
|
|
33
|
+
});
|
|
34
|
+
}
|
|
35
|
+
this.props.onChange(value);
|
|
36
|
+
};
|
|
37
|
+
this.onConfirm = value => {
|
|
38
|
+
this.props.onVirtualKeyboardConfirm(value);
|
|
39
|
+
};
|
|
40
|
+
this.addBlurListener = () => {
|
|
41
|
+
document.addEventListener('touchend', this.doBlur, false);
|
|
42
|
+
};
|
|
43
|
+
this.removeBlurListener = () => {
|
|
44
|
+
document.removeEventListener('touchend', this.doBlur, false);
|
|
45
|
+
};
|
|
46
|
+
this.saveRef = el => {
|
|
47
|
+
if (IS_REACT_16 && el) {
|
|
48
|
+
customNumberKeyboard = el;
|
|
49
|
+
}
|
|
50
|
+
};
|
|
51
|
+
this.doBlur = ev => {
|
|
52
|
+
const {
|
|
53
|
+
value
|
|
54
|
+
} = this.state;
|
|
55
|
+
if (ev.target !== this.inputRef) {
|
|
56
|
+
this.onInputBlur(value);
|
|
57
|
+
}
|
|
58
|
+
};
|
|
59
|
+
this.unLinkInput = () => {
|
|
60
|
+
if (customNumberKeyboard && customNumberKeyboard.antmKeyboard && customNumberKeyboard.linkedInput && customNumberKeyboard.linkedInput === this) {
|
|
61
|
+
customNumberKeyboard.linkedInput = null;
|
|
62
|
+
if (this.props.autoAdjustHeight) {
|
|
63
|
+
this.getContainer().style.height = '0';
|
|
64
|
+
}
|
|
65
|
+
(0, _class.addClass)(customNumberKeyboard.antmKeyboard, "".concat(this.props.keyboardPrefixCls, "-wrapper-hide"));
|
|
66
|
+
}
|
|
67
|
+
// for unmount
|
|
68
|
+
this.removeBlurListener();
|
|
69
|
+
};
|
|
70
|
+
this.onInputBlur = value => {
|
|
71
|
+
if (IS_REACT_16) {
|
|
72
|
+
this.keyBoard = null;
|
|
73
|
+
}
|
|
74
|
+
const {
|
|
75
|
+
focus
|
|
76
|
+
} = this.state;
|
|
77
|
+
if (focus) {
|
|
78
|
+
this.setState({
|
|
79
|
+
focus: false
|
|
80
|
+
});
|
|
81
|
+
this.props.onBlur(value);
|
|
82
|
+
setTimeout(() => {
|
|
83
|
+
this.unLinkInput();
|
|
84
|
+
}, 50);
|
|
85
|
+
}
|
|
86
|
+
};
|
|
87
|
+
this.onInputFocus = () => {
|
|
88
|
+
const {
|
|
89
|
+
value
|
|
90
|
+
} = this.state;
|
|
91
|
+
this.props.onFocus(value);
|
|
92
|
+
this.setState({
|
|
93
|
+
focus: true
|
|
94
|
+
}, () => {
|
|
95
|
+
if (customNumberKeyboard) {
|
|
96
|
+
customNumberKeyboard.linkedInput = this;
|
|
97
|
+
if (customNumberKeyboard.antmKeyboard) {
|
|
98
|
+
if (this.props.autoAdjustHeight) {
|
|
99
|
+
const keyBoardHeight = customNumberKeyboard.antmKeyboard.offsetHeight;
|
|
100
|
+
this.getContainer().style.height = "".concat(keyBoardHeight, "px");
|
|
101
|
+
if (this.inputRef) {
|
|
102
|
+
const {
|
|
103
|
+
bottom
|
|
104
|
+
} = this.inputRef.getBoundingClientRect();
|
|
105
|
+
const clientHeight = window.innerHeight;
|
|
106
|
+
// 计算输入框距离视窗的底部距离
|
|
107
|
+
const distance = clientHeight - bottom;
|
|
108
|
+
if (distance < keyBoardHeight) {
|
|
109
|
+
setBodyScrollTop(getBodyScrollTop() + keyBoardHeight - distance);
|
|
110
|
+
}
|
|
111
|
+
}
|
|
112
|
+
}
|
|
113
|
+
(0, _class.removeClass)(customNumberKeyboard.antmKeyboard, "".concat(this.props.keyboardPrefixCls, "-wrapper-hide"));
|
|
114
|
+
}
|
|
115
|
+
customNumberKeyboard.confirmDisabled = value === '';
|
|
116
|
+
if (customNumberKeyboard.confirmKeyboardItem) {
|
|
117
|
+
if (value === '') {
|
|
118
|
+
(0, _class.addClass)(customNumberKeyboard.confirmKeyboardItem, "".concat(this.props.keyboardPrefixCls, "-item-disabled"));
|
|
119
|
+
} else {
|
|
120
|
+
(0, _class.removeClass)(customNumberKeyboard.confirmKeyboardItem, "".concat(this.props.keyboardPrefixCls, "-item-disabled"));
|
|
121
|
+
}
|
|
122
|
+
}
|
|
123
|
+
}
|
|
124
|
+
});
|
|
125
|
+
};
|
|
126
|
+
this.onKeyboardClick = KeyboardItemValue => {
|
|
127
|
+
const {
|
|
128
|
+
maxLength
|
|
129
|
+
} = this.props;
|
|
130
|
+
const {
|
|
131
|
+
value
|
|
132
|
+
} = this.state;
|
|
133
|
+
// tslint:disable-next-line:no-this-assignment
|
|
134
|
+
const {
|
|
135
|
+
onChange
|
|
136
|
+
} = this;
|
|
137
|
+
let valueAfterChange;
|
|
138
|
+
// 删除键
|
|
139
|
+
if (KeyboardItemValue === 'delete') {
|
|
140
|
+
valueAfterChange = value.substring(0, value.length - 1);
|
|
141
|
+
onChange({
|
|
142
|
+
target: {
|
|
143
|
+
value: valueAfterChange
|
|
144
|
+
}
|
|
145
|
+
});
|
|
146
|
+
// 确认键
|
|
147
|
+
} else if (KeyboardItemValue === 'confirm') {
|
|
148
|
+
valueAfterChange = value;
|
|
149
|
+
onChange({
|
|
150
|
+
target: {
|
|
151
|
+
value: valueAfterChange
|
|
152
|
+
}
|
|
153
|
+
});
|
|
154
|
+
this.onInputBlur(value);
|
|
155
|
+
this.onConfirm(value);
|
|
156
|
+
// 收起键
|
|
157
|
+
} else if (KeyboardItemValue === 'hide') {
|
|
158
|
+
valueAfterChange = value;
|
|
159
|
+
this.onInputBlur(valueAfterChange);
|
|
160
|
+
} else {
|
|
161
|
+
if (maxLength !== undefined && +maxLength >= 0 && (value + KeyboardItemValue).length > maxLength) {
|
|
162
|
+
valueAfterChange = (value + KeyboardItemValue).substr(0, maxLength);
|
|
163
|
+
onChange({
|
|
164
|
+
target: {
|
|
165
|
+
value: valueAfterChange
|
|
166
|
+
}
|
|
167
|
+
});
|
|
168
|
+
} else {
|
|
169
|
+
valueAfterChange = value + KeyboardItemValue;
|
|
170
|
+
onChange({
|
|
171
|
+
target: {
|
|
172
|
+
value: valueAfterChange
|
|
173
|
+
}
|
|
174
|
+
});
|
|
175
|
+
}
|
|
176
|
+
}
|
|
177
|
+
if (customNumberKeyboard) {
|
|
178
|
+
customNumberKeyboard.confirmDisabled = valueAfterChange === '';
|
|
179
|
+
if (customNumberKeyboard.confirmKeyboardItem) {
|
|
180
|
+
if (valueAfterChange === '') {
|
|
181
|
+
(0, _class.addClass)(customNumberKeyboard.confirmKeyboardItem, "".concat(this.props.keyboardPrefixCls, "-item-disabled"));
|
|
182
|
+
} else {
|
|
183
|
+
(0, _class.removeClass)(customNumberKeyboard.confirmKeyboardItem, "".concat(this.props.keyboardPrefixCls, "-item-disabled"));
|
|
184
|
+
}
|
|
185
|
+
}
|
|
186
|
+
}
|
|
187
|
+
};
|
|
188
|
+
this.onFakeInputClick = () => {
|
|
189
|
+
this.focus();
|
|
190
|
+
};
|
|
191
|
+
this.focus = () => {
|
|
192
|
+
// this focus may invocked by users page button click, so this click may trigger blurEventListener at the same time
|
|
193
|
+
this.renderCustomKeyboard();
|
|
194
|
+
this.removeBlurListener();
|
|
195
|
+
const {
|
|
196
|
+
focus
|
|
197
|
+
} = this.state;
|
|
198
|
+
if (!focus) {
|
|
199
|
+
this.onInputFocus();
|
|
200
|
+
}
|
|
201
|
+
setTimeout(() => {
|
|
202
|
+
this.addBlurListener();
|
|
203
|
+
}, 50);
|
|
204
|
+
};
|
|
205
|
+
this.state = {
|
|
206
|
+
focus: false,
|
|
207
|
+
value: props.value || ''
|
|
208
|
+
};
|
|
209
|
+
}
|
|
210
|
+
componentWillReceiveProps(nextProps) {
|
|
211
|
+
if ('value' in nextProps) {
|
|
212
|
+
this.setState({
|
|
213
|
+
value: nextProps.value
|
|
214
|
+
});
|
|
215
|
+
}
|
|
216
|
+
}
|
|
217
|
+
componentWillUnmount() {
|
|
218
|
+
// focus:true unmount 不能触发 blur
|
|
219
|
+
if (this.state.focus) {
|
|
220
|
+
this.props.onBlur(this.state.value);
|
|
221
|
+
}
|
|
222
|
+
this.unLinkInput();
|
|
223
|
+
}
|
|
224
|
+
getComponent() {
|
|
225
|
+
const {
|
|
226
|
+
confirmLabel,
|
|
227
|
+
backspaceLabel,
|
|
228
|
+
cancelKeyboardLabel,
|
|
229
|
+
keyboardPrefixCls,
|
|
230
|
+
moneyKeyboardWrapProps,
|
|
231
|
+
moneyKeyboardHeader,
|
|
232
|
+
disabledKeys
|
|
233
|
+
} = this.props;
|
|
234
|
+
return /*#__PURE__*/React.createElement(_customKeyboard.default, {
|
|
235
|
+
ref: this.saveRef,
|
|
236
|
+
onClick: this.onKeyboardClick,
|
|
237
|
+
prefixCls: keyboardPrefixCls,
|
|
238
|
+
confirmLabel: confirmLabel,
|
|
239
|
+
backspaceLabel: backspaceLabel,
|
|
240
|
+
cancelKeyboardLabel: cancelKeyboardLabel,
|
|
241
|
+
wrapProps: moneyKeyboardWrapProps,
|
|
242
|
+
header: moneyKeyboardHeader,
|
|
243
|
+
disabledKeys: disabledKeys
|
|
244
|
+
});
|
|
245
|
+
}
|
|
246
|
+
getContainer() {
|
|
247
|
+
const {
|
|
248
|
+
keyboardPrefixCls
|
|
249
|
+
} = this.props;
|
|
250
|
+
let container = document.querySelector("#".concat(keyboardPrefixCls, "-container"));
|
|
251
|
+
if (!container) {
|
|
252
|
+
container = document.createElement('div');
|
|
253
|
+
container.setAttribute('id', "".concat(keyboardPrefixCls, "-container"));
|
|
254
|
+
document.body.appendChild(container);
|
|
255
|
+
}
|
|
256
|
+
this.container = container;
|
|
257
|
+
return this.container;
|
|
258
|
+
}
|
|
259
|
+
renderCustomKeyboard() {
|
|
260
|
+
if (IS_REACT_16) {
|
|
261
|
+
this.keyBoard = /*#__PURE__*/React.createElement(_portal.default, {
|
|
262
|
+
getContainer: () => this.getContainer()
|
|
263
|
+
}, this.getComponent());
|
|
264
|
+
} else {
|
|
265
|
+
customNumberKeyboard = ReactDOM.unstable_renderSubtreeIntoContainer(this, this.getComponent(), this.getContainer());
|
|
266
|
+
}
|
|
267
|
+
}
|
|
268
|
+
renderPortal() {
|
|
269
|
+
if (!IS_REACT_16 || !_exenv.canUseDOM) {
|
|
270
|
+
return null;
|
|
271
|
+
}
|
|
272
|
+
return this.keyBoard;
|
|
273
|
+
}
|
|
274
|
+
render() {
|
|
275
|
+
const {
|
|
276
|
+
placeholder,
|
|
277
|
+
disabled,
|
|
278
|
+
editable,
|
|
279
|
+
moneyKeyboardAlign
|
|
280
|
+
} = this.props;
|
|
281
|
+
const {
|
|
282
|
+
focus,
|
|
283
|
+
value
|
|
284
|
+
} = this.state;
|
|
285
|
+
const preventKeyboard = disabled || !editable;
|
|
286
|
+
const fakeInputCls = (0, _classnames.default)('fake-input', {
|
|
287
|
+
focus,
|
|
288
|
+
'fake-input-disabled': disabled
|
|
289
|
+
});
|
|
290
|
+
const fakeInputContainerCls = (0, _classnames.default)('fake-input-container', {
|
|
291
|
+
'fake-input-container-left': moneyKeyboardAlign === 'left'
|
|
292
|
+
});
|
|
293
|
+
return /*#__PURE__*/React.createElement("div", {
|
|
294
|
+
className: fakeInputContainerCls
|
|
295
|
+
}, value === '' &&
|
|
296
|
+
/*#__PURE__*/
|
|
297
|
+
// tslint:disable-next-line:jsx-no-multiline-js
|
|
298
|
+
React.createElement("div", {
|
|
299
|
+
className: "fake-input-placeholder"
|
|
300
|
+
}, placeholder), /*#__PURE__*/React.createElement("div", {
|
|
301
|
+
role: "textbox",
|
|
302
|
+
"aria-label": value || placeholder,
|
|
303
|
+
className: fakeInputCls,
|
|
304
|
+
ref: el => this.inputRef = el,
|
|
305
|
+
onClick: preventKeyboard ? () => {} : this.onFakeInputClick
|
|
306
|
+
}, value), this.renderPortal());
|
|
307
|
+
}
|
|
308
|
+
}
|
|
309
|
+
NumberInput.defaultProps = {
|
|
310
|
+
onChange: () => {},
|
|
311
|
+
onFocus: () => {},
|
|
312
|
+
onBlur: () => {},
|
|
313
|
+
onVirtualKeyboardConfirm: () => {},
|
|
314
|
+
placeholder: '',
|
|
315
|
+
disabled: false,
|
|
316
|
+
editable: true,
|
|
317
|
+
prefixCls: 'am-input',
|
|
318
|
+
keyboardPrefixCls: 'am-number-keyboard',
|
|
319
|
+
autoAdjustHeight: false
|
|
320
|
+
};
|
|
321
|
+
var _default = exports.default = NumberInput;
|
|
@@ -0,0 +1,162 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
var _interopRequireWildcard = require("@babel/runtime/helpers/interopRequireWildcard").default;
|
|
4
|
+
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault").default;
|
|
5
|
+
Object.defineProperty(exports, "__esModule", {
|
|
6
|
+
value: true
|
|
7
|
+
});
|
|
8
|
+
exports.default = exports.KeyboardItem = void 0;
|
|
9
|
+
var _classnames = _interopRequireDefault(require("classnames"));
|
|
10
|
+
var React = _interopRequireWildcard(require("react"));
|
|
11
|
+
var _rmcFeedback = _interopRequireDefault(require("rmc-feedback"));
|
|
12
|
+
var _exenv = require("../_util/exenv");
|
|
13
|
+
/**
|
|
14
|
+
* determines whether an array includes a certain value among its entries, returning true or false as appropriate.
|
|
15
|
+
* @param {array} arr The array to search in
|
|
16
|
+
* @param {any} item The value to search for
|
|
17
|
+
*/
|
|
18
|
+
function includes(arr, item) {
|
|
19
|
+
if (!arr || !arr.length || !item) {
|
|
20
|
+
return false;
|
|
21
|
+
}
|
|
22
|
+
for (let i = 0, len = arr.length; i < len; i++) {
|
|
23
|
+
if (arr[i] === item) {
|
|
24
|
+
return true;
|
|
25
|
+
}
|
|
26
|
+
}
|
|
27
|
+
return false;
|
|
28
|
+
}
|
|
29
|
+
class KeyboardItem extends React.Component {
|
|
30
|
+
render() {
|
|
31
|
+
const {
|
|
32
|
+
prefixCls,
|
|
33
|
+
onClick,
|
|
34
|
+
className,
|
|
35
|
+
disabled,
|
|
36
|
+
children,
|
|
37
|
+
tdRef,
|
|
38
|
+
label,
|
|
39
|
+
iconOnly,
|
|
40
|
+
...restProps
|
|
41
|
+
} = this.props;
|
|
42
|
+
let value = children;
|
|
43
|
+
if (className === 'keyboard-delete') {
|
|
44
|
+
value = 'delete';
|
|
45
|
+
} else if (className === 'keyboard-hide') {
|
|
46
|
+
value = 'hide';
|
|
47
|
+
} else if (className === 'keyboard-confirm') {
|
|
48
|
+
value = 'confirm';
|
|
49
|
+
}
|
|
50
|
+
const extraCls = {
|
|
51
|
+
["".concat(prefixCls, "-item-disabled")]: disabled
|
|
52
|
+
};
|
|
53
|
+
const wrapCls = (0, _classnames.default)("".concat(prefixCls, "-item"), className, extraCls);
|
|
54
|
+
return /*#__PURE__*/React.createElement(_rmcFeedback.default, {
|
|
55
|
+
disabled: disabled,
|
|
56
|
+
activeClassName: "".concat(prefixCls, "-item-active")
|
|
57
|
+
}, /*#__PURE__*/React.createElement("td", Object.assign({
|
|
58
|
+
ref: tdRef
|
|
59
|
+
// tslint:disable-next-line:jsx-no-multiline-js
|
|
60
|
+
,
|
|
61
|
+
onTouchEnd: e => {
|
|
62
|
+
onClick(e, value);
|
|
63
|
+
},
|
|
64
|
+
className: wrapCls
|
|
65
|
+
}, restProps), children, iconOnly && /*#__PURE__*/React.createElement("i", {
|
|
66
|
+
className: "sr-only"
|
|
67
|
+
}, label)));
|
|
68
|
+
}
|
|
69
|
+
}
|
|
70
|
+
exports.KeyboardItem = KeyboardItem;
|
|
71
|
+
KeyboardItem.defaultProps = {
|
|
72
|
+
prefixCls: 'am-number-keyboard',
|
|
73
|
+
onClick: () => {},
|
|
74
|
+
disabled: false
|
|
75
|
+
};
|
|
76
|
+
class CustomKeyboard extends React.Component {
|
|
77
|
+
constructor() {
|
|
78
|
+
var _this;
|
|
79
|
+
super(...arguments);
|
|
80
|
+
_this = this;
|
|
81
|
+
this.onKeyboardClick = function (e) {
|
|
82
|
+
let value = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : '';
|
|
83
|
+
e.nativeEvent.stopImmediatePropagation();
|
|
84
|
+
if (_this.props.disabledKeys && includes(_this.props.disabledKeys, value)) {
|
|
85
|
+
return null;
|
|
86
|
+
}
|
|
87
|
+
if (value === 'confirm' && _this.confirmDisabled) {
|
|
88
|
+
return null;
|
|
89
|
+
} else {
|
|
90
|
+
if (_this.linkedInput) {
|
|
91
|
+
_this.linkedInput.onKeyboardClick(value);
|
|
92
|
+
}
|
|
93
|
+
}
|
|
94
|
+
};
|
|
95
|
+
this.renderKeyboardItem = (item, index) => {
|
|
96
|
+
let disabled = false;
|
|
97
|
+
if (this.props.disabledKeys && includes(this.props.disabledKeys, item)) {
|
|
98
|
+
disabled = true;
|
|
99
|
+
}
|
|
100
|
+
return /*#__PURE__*/React.createElement(KeyboardItem, {
|
|
101
|
+
onClick: this.onKeyboardClick,
|
|
102
|
+
key: "item-".concat(item, "-").concat(index),
|
|
103
|
+
disabled: disabled
|
|
104
|
+
}, item);
|
|
105
|
+
};
|
|
106
|
+
}
|
|
107
|
+
render() {
|
|
108
|
+
const {
|
|
109
|
+
prefixCls,
|
|
110
|
+
confirmLabel,
|
|
111
|
+
backspaceLabel,
|
|
112
|
+
cancelKeyboardLabel,
|
|
113
|
+
wrapProps,
|
|
114
|
+
header
|
|
115
|
+
} = this.props;
|
|
116
|
+
const wrapperCls = (0, _classnames.default)("".concat(prefixCls, "-wrapper"), "".concat(prefixCls, "-wrapper-hide"));
|
|
117
|
+
return /*#__PURE__*/React.createElement("div", Object.assign({
|
|
118
|
+
className: wrapperCls,
|
|
119
|
+
ref: el => this.antmKeyboard = el
|
|
120
|
+
}, wrapProps), header && /*#__PURE__*/React.cloneElement(header, {
|
|
121
|
+
onClick: this.onKeyboardClick
|
|
122
|
+
}), /*#__PURE__*/React.createElement("table", null, /*#__PURE__*/React.createElement("tbody", null, /*#__PURE__*/React.createElement("tr", null, ['1', '2', '3'].map((item, index) =>
|
|
123
|
+
// tslint:disable-next-line:jsx-no-multiline-js
|
|
124
|
+
this.renderKeyboardItem(item, index)), /*#__PURE__*/React.createElement(KeyboardItem, Object.assign({
|
|
125
|
+
className: "keyboard-delete",
|
|
126
|
+
rowSpan: 2,
|
|
127
|
+
onClick: this.onKeyboardClick
|
|
128
|
+
}, this.getAriaAttr(backspaceLabel)))), /*#__PURE__*/React.createElement("tr", null, ['4', '5', '6'].map((item, index) =>
|
|
129
|
+
// tslint:disable-next-line:jsx-no-multiline-js
|
|
130
|
+
this.renderKeyboardItem(item, index))), /*#__PURE__*/React.createElement("tr", null, ['7', '8', '9'].map((item, index) =>
|
|
131
|
+
// tslint:disable-next-line:jsx-no-multiline-js
|
|
132
|
+
this.renderKeyboardItem(item, index)), /*#__PURE__*/React.createElement(KeyboardItem, {
|
|
133
|
+
className: "keyboard-confirm",
|
|
134
|
+
rowSpan: 2,
|
|
135
|
+
onClick: this.onKeyboardClick,
|
|
136
|
+
tdRef: el => this.confirmKeyboardItem = el
|
|
137
|
+
}, confirmLabel)), /*#__PURE__*/React.createElement("tr", null, ['.', '0'].map((item, index) =>
|
|
138
|
+
// tslint:disable-next-line:jsx-no-multiline-js
|
|
139
|
+
this.renderKeyboardItem(item, index)), /*#__PURE__*/React.createElement(KeyboardItem, Object.assign({
|
|
140
|
+
className: "keyboard-hide",
|
|
141
|
+
onClick: this.onKeyboardClick
|
|
142
|
+
}, this.getAriaAttr(cancelKeyboardLabel)))))));
|
|
143
|
+
}
|
|
144
|
+
getAriaAttr(label) {
|
|
145
|
+
if (_exenv.IS_IOS) {
|
|
146
|
+
return {
|
|
147
|
+
label,
|
|
148
|
+
iconOnly: true
|
|
149
|
+
};
|
|
150
|
+
} else {
|
|
151
|
+
return {
|
|
152
|
+
role: 'button',
|
|
153
|
+
'aria-label': label
|
|
154
|
+
};
|
|
155
|
+
}
|
|
156
|
+
}
|
|
157
|
+
}
|
|
158
|
+
CustomKeyboard.defaultProps = {
|
|
159
|
+
prefixCls: 'am-number-keyboard',
|
|
160
|
+
disabledKeys: null
|
|
161
|
+
};
|
|
162
|
+
var _default = exports.default = CustomKeyboard;
|