@autobest-ui/components 1.1.8 → 1.1.9
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/esm/index.d.ts +2 -2
- package/esm/input-number/index.d.ts +30 -17
- package/esm/input-number/index.js +116 -36
- package/esm/table/body/BodyRow.d.ts +2 -2
- package/esm/table/body/index.d.ts +2 -2
- package/esm/table/body/index.js +6 -6
- package/esm/table/header/HeaderCell.d.ts +2 -2
- package/esm/table/header/HeaderRow.d.ts +2 -2
- package/esm/table/index.d.ts +4 -4
- package/esm/table/index.js +3 -3
- package/esm/table/interface.d.ts +9 -3
- package/lib/index.d.ts +2 -2
- package/lib/input-number/index.d.ts +30 -17
- package/lib/input-number/index.js +116 -36
- package/lib/table/body/BodyRow.d.ts +2 -2
- package/lib/table/body/index.d.ts +2 -2
- package/lib/table/body/index.js +6 -6
- package/lib/table/header/HeaderCell.d.ts +2 -2
- package/lib/table/header/HeaderRow.d.ts +2 -2
- package/lib/table/index.d.ts +4 -4
- package/lib/table/index.js +3 -3
- package/lib/table/interface.d.ts +9 -3
- package/package.json +2 -2
package/esm/index.d.ts
CHANGED
|
@@ -43,8 +43,8 @@ export type { ScriptAttributes, ScriptProps } from './script';
|
|
|
43
43
|
export { default as Script } from './script';
|
|
44
44
|
export type { MessageProps } from './message';
|
|
45
45
|
export { default as Message } from './message';
|
|
46
|
-
export type { TableProps,
|
|
47
|
-
export type {
|
|
46
|
+
export type { TableProps, TableRowSelectionInfo } from './table';
|
|
47
|
+
export type { TableColumnInfo, TableColumnOnRenderReturnObjectInfo } from './table/interface';
|
|
48
48
|
export { default as Table } from './table';
|
|
49
49
|
export type { DatePickerProps } from './date-picker';
|
|
50
50
|
export { default as DatePicker } from './date-picker';
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import React from 'react';
|
|
2
|
-
import { AddListenerEventHandler } from '@autobest-ui/utils';
|
|
3
|
-
interface
|
|
2
|
+
import { debounce, AddListenerEventHandler } from '@autobest-ui/utils';
|
|
3
|
+
interface OnChangeHandler {
|
|
4
4
|
(value: string, name?: string): void;
|
|
5
5
|
}
|
|
6
6
|
interface ChangeEvent {
|
|
@@ -12,7 +12,7 @@ export interface InputNumberProps extends Omit<React.InputHTMLAttributes<any>, '
|
|
|
12
12
|
/**
|
|
13
13
|
* 值修改后的回调函数,用于修改value属性
|
|
14
14
|
*/
|
|
15
|
-
onChange:
|
|
15
|
+
onChange: OnChangeHandler;
|
|
16
16
|
/**
|
|
17
17
|
* input样式
|
|
18
18
|
*/
|
|
@@ -30,7 +30,8 @@ export interface InputNumberProps extends Omit<React.InputHTMLAttributes<any>, '
|
|
|
30
30
|
*/
|
|
31
31
|
max?: number;
|
|
32
32
|
/**
|
|
33
|
-
*
|
|
33
|
+
* 打包值,向上取整,不赋值或者赋值为0表示不做取整操作
|
|
34
|
+
* 注:packMultiple不允许传小数
|
|
34
35
|
*/
|
|
35
36
|
packMultiple?: number;
|
|
36
37
|
/**
|
|
@@ -38,9 +39,13 @@ export interface InputNumberProps extends Omit<React.InputHTMLAttributes<any>, '
|
|
|
38
39
|
*/
|
|
39
40
|
disabled?: boolean;
|
|
40
41
|
/**
|
|
41
|
-
*
|
|
42
|
+
* 可输入的小数位数,0或没有值表示只能输入整数
|
|
42
43
|
*/
|
|
43
|
-
|
|
44
|
+
digital?: number;
|
|
45
|
+
/**
|
|
46
|
+
* 为true则自动补全小数位数
|
|
47
|
+
*/
|
|
48
|
+
padDigital?: boolean;
|
|
44
49
|
/**
|
|
45
50
|
* 输入框默认字符大小
|
|
46
51
|
*/
|
|
@@ -56,11 +61,11 @@ export interface InputNumberProps extends Omit<React.InputHTMLAttributes<any>, '
|
|
|
56
61
|
/**
|
|
57
62
|
* packMultiple 有值时,判断前的回调函数
|
|
58
63
|
*/
|
|
59
|
-
onChangePackMultipleBefore?:
|
|
64
|
+
onChangePackMultipleBefore?: OnChangeHandler;
|
|
60
65
|
/**
|
|
61
66
|
* packMultiple 有值时,判断后的回调函数
|
|
62
67
|
*/
|
|
63
|
-
onChangePackMultipleAfter?:
|
|
68
|
+
onChangePackMultipleAfter?: OnChangeHandler;
|
|
64
69
|
/**
|
|
65
70
|
* 是否需要显示增加按钮
|
|
66
71
|
*/
|
|
@@ -70,10 +75,6 @@ interface InputNumberStates {
|
|
|
70
75
|
enter: boolean;
|
|
71
76
|
focus: boolean;
|
|
72
77
|
}
|
|
73
|
-
interface DebounceRef {
|
|
74
|
-
(value: string): void;
|
|
75
|
-
cancel: () => void;
|
|
76
|
-
}
|
|
77
78
|
interface LocationInfo {
|
|
78
79
|
left: number;
|
|
79
80
|
top: number;
|
|
@@ -86,13 +87,15 @@ declare class InputNumber extends React.Component<InputNumberProps, InputNumberS
|
|
|
86
87
|
name: string;
|
|
87
88
|
size: number;
|
|
88
89
|
disabled: boolean;
|
|
89
|
-
|
|
90
|
+
digital: number;
|
|
91
|
+
padDigital: boolean;
|
|
90
92
|
delay: number;
|
|
91
93
|
visibleButton: boolean;
|
|
92
94
|
};
|
|
93
95
|
constructor(props: InputNumberProps);
|
|
94
96
|
currentRef: React.RefObject<HTMLLabelElement>;
|
|
95
|
-
|
|
97
|
+
changePackMultipleValueDebounce: ReturnType<typeof debounce>;
|
|
98
|
+
padDigitalDebounce: ReturnType<typeof debounce>;
|
|
96
99
|
addLocationInfo: LocationInfo;
|
|
97
100
|
subLocationInfo: LocationInfo;
|
|
98
101
|
mouseUpHandler: AddListenerEventHandler;
|
|
@@ -120,10 +123,20 @@ declare class InputNumber extends React.Component<InputNumberProps, InputNumberS
|
|
|
120
123
|
isInside: (ev: React.MouseEvent<Element, MouseEvent>, locationInfo: LocationInfo) => boolean;
|
|
121
124
|
getLocationInfo: () => void;
|
|
122
125
|
getCurrentValue: (value: string) => number;
|
|
126
|
+
getPadDigitalValue: (value: string) => string;
|
|
123
127
|
onChangePackMultipleValue: (value: string) => void;
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
128
|
+
onPadDigital: (value: any) => void;
|
|
129
|
+
getPadDigitalDebounce: () => {
|
|
130
|
+
(...arg: any[]): void;
|
|
131
|
+
cancel(): void;
|
|
132
|
+
};
|
|
133
|
+
getChangePackMultipleValueDebounce: () => {
|
|
134
|
+
(...arg: any[]): void;
|
|
135
|
+
cancel(): void;
|
|
136
|
+
};
|
|
137
|
+
callback: (value: string, ignoreDelay?: any) => void;
|
|
138
|
+
onValueChange: (ev: ChangeEvent, ignoreDelay?: any) => void;
|
|
139
|
+
getValueCalculate: (value: number, offset: number) => number;
|
|
127
140
|
onAdd: () => void;
|
|
128
141
|
onSub: () => void;
|
|
129
142
|
renderButton: () => JSX.Element;
|
|
@@ -43,7 +43,7 @@ var __assign = this && this.__assign || function () {
|
|
|
43
43
|
import React from 'react';
|
|
44
44
|
import classNames from 'classnames';
|
|
45
45
|
import { isBlank, debounce, getOffsetAndSize, addEventListener } from '@autobest-ui/utils';
|
|
46
|
-
var cls = 'ab-input-number';
|
|
46
|
+
var cls = 'ab-input-number'; // TODO: 重构组件
|
|
47
47
|
|
|
48
48
|
var InputNumber =
|
|
49
49
|
/** @class */
|
|
@@ -305,6 +305,19 @@ function (_super) {
|
|
|
305
305
|
return ceilNumber;
|
|
306
306
|
};
|
|
307
307
|
|
|
308
|
+
_this.getPadDigitalValue = function (value) {
|
|
309
|
+
var _a = _this.props,
|
|
310
|
+
digital = _a.digital,
|
|
311
|
+
padDigital = _a.padDigital;
|
|
312
|
+
|
|
313
|
+
if (!padDigital || isBlank(value) || !digital) {
|
|
314
|
+
return value;
|
|
315
|
+
}
|
|
316
|
+
|
|
317
|
+
var resultArr = value.split('.');
|
|
318
|
+
return resultArr[0] + "." + (resultArr[1] || '').padEnd(digital, '0');
|
|
319
|
+
};
|
|
320
|
+
|
|
308
321
|
_this.onChangePackMultipleValue = function (value) {
|
|
309
322
|
var currentValue = _this.getCurrentValue(value).toString();
|
|
310
323
|
|
|
@@ -319,60 +332,97 @@ function (_super) {
|
|
|
319
332
|
}
|
|
320
333
|
};
|
|
321
334
|
|
|
322
|
-
_this.
|
|
323
|
-
|
|
324
|
-
|
|
335
|
+
_this.onPadDigital = function (value) {
|
|
336
|
+
var currentValue = _this.getPadDigitalValue(value);
|
|
337
|
+
|
|
338
|
+
var _a = _this.props,
|
|
339
|
+
onChange = _a.onChange,
|
|
340
|
+
name = _a.name;
|
|
341
|
+
|
|
342
|
+
if (value !== currentValue) {
|
|
343
|
+
onChange(currentValue, name);
|
|
325
344
|
}
|
|
345
|
+
};
|
|
346
|
+
|
|
347
|
+
_this.getPadDigitalDebounce = function () {
|
|
348
|
+
if (_this.padDigitalDebounce) {
|
|
349
|
+
return _this.padDigitalDebounce;
|
|
350
|
+
}
|
|
351
|
+
|
|
352
|
+
_this.padDigitalDebounce = debounce(_this.onPadDigital, _this.props.delay);
|
|
353
|
+
return _this.padDigitalDebounce;
|
|
354
|
+
};
|
|
326
355
|
|
|
327
|
-
|
|
328
|
-
|
|
356
|
+
_this.getChangePackMultipleValueDebounce = function () {
|
|
357
|
+
if (_this.changePackMultipleValueDebounce) {
|
|
358
|
+
return _this.changePackMultipleValueDebounce;
|
|
359
|
+
}
|
|
360
|
+
|
|
361
|
+
_this.changePackMultipleValueDebounce = debounce(_this.onChangePackMultipleValue, _this.props.delay);
|
|
362
|
+
return _this.changePackMultipleValueDebounce;
|
|
329
363
|
};
|
|
330
364
|
|
|
331
|
-
_this.callback = function (value) {
|
|
365
|
+
_this.callback = function (value, ignoreDelay) {
|
|
332
366
|
var _a = _this.props,
|
|
333
367
|
name = _a.name,
|
|
334
368
|
onChange = _a.onChange,
|
|
335
|
-
onChangePackMultipleBefore = _a.onChangePackMultipleBefore
|
|
336
|
-
|
|
369
|
+
onChangePackMultipleBefore = _a.onChangePackMultipleBefore,
|
|
370
|
+
packMultiple = _a.packMultiple,
|
|
371
|
+
padDigital = _a.padDigital;
|
|
337
372
|
|
|
338
|
-
if (onChange) {
|
|
373
|
+
if (onChange && value !== _this.props.value) {
|
|
339
374
|
onChange(value, name);
|
|
340
375
|
}
|
|
341
376
|
|
|
342
|
-
|
|
343
|
-
|
|
344
|
-
if (!isBlank(packMultiple) && !isBlank(value) && valueNumber % packMultiple !== 0) {
|
|
377
|
+
if (packMultiple && !isBlank(value) && parseFloat(value) % packMultiple !== 0) {
|
|
345
378
|
if (onChangePackMultipleBefore) {
|
|
346
379
|
onChangePackMultipleBefore(value, name);
|
|
347
380
|
}
|
|
348
381
|
|
|
349
|
-
|
|
382
|
+
if (ignoreDelay) {
|
|
383
|
+
_this.onChangePackMultipleValue(value);
|
|
384
|
+
} else {
|
|
385
|
+
_this.getChangePackMultipleValueDebounce()(value);
|
|
386
|
+
}
|
|
387
|
+
|
|
388
|
+
return;
|
|
389
|
+
}
|
|
390
|
+
|
|
391
|
+
if (padDigital) {
|
|
392
|
+
if (ignoreDelay) {
|
|
393
|
+
_this.onPadDigital(value);
|
|
394
|
+
|
|
395
|
+
return;
|
|
396
|
+
}
|
|
397
|
+
|
|
398
|
+
_this.getPadDigitalDebounce()(value);
|
|
350
399
|
}
|
|
351
400
|
};
|
|
352
401
|
|
|
353
|
-
_this.onValueChange = function (ev) {
|
|
354
|
-
if (_this.
|
|
355
|
-
_this.
|
|
402
|
+
_this.onValueChange = function (ev, ignoreDelay) {
|
|
403
|
+
if (_this.changePackMultipleValueDebounce) {
|
|
404
|
+
_this.changePackMultipleValueDebounce.cancel();
|
|
356
405
|
}
|
|
357
406
|
|
|
358
407
|
var _a = _this.props,
|
|
359
408
|
min = _a.min,
|
|
360
409
|
max = _a.max,
|
|
361
|
-
|
|
410
|
+
digital = _a.digital,
|
|
362
411
|
value = _a.value;
|
|
363
|
-
var currentValue = ev.target.value.toString();
|
|
412
|
+
var currentValue = ev.target.value.toString(); // 输入为空
|
|
364
413
|
|
|
365
414
|
if (isBlank(currentValue)) {
|
|
366
|
-
_this.callback('');
|
|
415
|
+
_this.callback('', ignoreDelay);
|
|
367
416
|
|
|
368
417
|
return;
|
|
369
418
|
}
|
|
370
419
|
|
|
371
|
-
var preValue = value.toString();
|
|
420
|
+
var preValue = value.toString(); // 输入的不是数字格式
|
|
421
|
+
|
|
372
422
|
var reg = /^-$|(^(-?\d+)(\.\d*)?)$/;
|
|
373
423
|
|
|
374
424
|
if (!reg.test(currentValue)) {
|
|
375
|
-
_this.callback(preValue);
|
|
425
|
+
_this.callback(preValue, ignoreDelay);
|
|
376
426
|
|
|
377
427
|
return;
|
|
378
428
|
} // 0开头后面直接是数字,没有点如:011, 这是不合法的
|
|
@@ -381,41 +431,59 @@ function (_super) {
|
|
|
381
431
|
var zeroReg = /^0\d+$/;
|
|
382
432
|
|
|
383
433
|
if (zeroReg.test(currentValue)) {
|
|
384
|
-
_this.callback(preValue);
|
|
434
|
+
_this.callback(preValue, ignoreDelay);
|
|
385
435
|
|
|
386
436
|
return;
|
|
437
|
+
} // 小数位数限制
|
|
438
|
+
|
|
439
|
+
|
|
440
|
+
if (digital) {
|
|
441
|
+
currentValue = new RegExp("[^.]+([.](\\d{0," + digital + "}))?").exec(currentValue)[0].toString();
|
|
387
442
|
}
|
|
388
443
|
|
|
389
444
|
var valueNumber = parseFloat(currentValue);
|
|
390
445
|
|
|
391
446
|
if (!isBlank(min)) {
|
|
392
447
|
if (min > valueNumber) {
|
|
393
|
-
_this.callback(preValue);
|
|
448
|
+
_this.callback(preValue, ignoreDelay);
|
|
394
449
|
|
|
395
450
|
return;
|
|
396
451
|
} // 如果min>= 0, 将阻止输入-
|
|
397
452
|
|
|
398
453
|
|
|
399
454
|
if (min >= 0 && currentValue.indexOf('-') > -1) {
|
|
400
|
-
_this.callback('');
|
|
455
|
+
_this.callback('', ignoreDelay);
|
|
401
456
|
|
|
402
457
|
return;
|
|
403
458
|
}
|
|
404
459
|
}
|
|
405
460
|
|
|
406
461
|
if (!isBlank(max) && max < valueNumber) {
|
|
407
|
-
_this.callback(preValue);
|
|
462
|
+
_this.callback(preValue, ignoreDelay);
|
|
408
463
|
|
|
409
464
|
return;
|
|
410
465
|
}
|
|
411
466
|
|
|
412
|
-
if (
|
|
413
|
-
_this.callback(preValue);
|
|
467
|
+
if (!digital && currentValue.indexOf('.') > -1) {
|
|
468
|
+
_this.callback(preValue, ignoreDelay);
|
|
414
469
|
|
|
415
470
|
return;
|
|
416
471
|
}
|
|
417
472
|
|
|
418
|
-
_this.callback(currentValue);
|
|
473
|
+
_this.callback(currentValue, ignoreDelay);
|
|
474
|
+
};
|
|
475
|
+
|
|
476
|
+
_this.getValueCalculate = function (value, offset) {
|
|
477
|
+
var valueStr = value.toString();
|
|
478
|
+
var offsetStr = offset.toString();
|
|
479
|
+
|
|
480
|
+
if (valueStr.indexOf('.') < 0 && offsetStr.indexOf('.') < 0) {
|
|
481
|
+
return value + offset;
|
|
482
|
+
}
|
|
483
|
+
|
|
484
|
+
var digital = _this.props.digital;
|
|
485
|
+
var powValue = Math.pow(10, digital);
|
|
486
|
+
return Math.round((value + offset) * powValue) / powValue;
|
|
419
487
|
};
|
|
420
488
|
|
|
421
489
|
_this.onAdd = function () {
|
|
@@ -426,7 +494,7 @@ function (_super) {
|
|
|
426
494
|
|
|
427
495
|
var ev = {
|
|
428
496
|
target: {
|
|
429
|
-
value: (
|
|
497
|
+
value: _this.getPadDigitalValue(_this.getValueCalculate(Number(value), step).toString())
|
|
430
498
|
}
|
|
431
499
|
};
|
|
432
500
|
|
|
@@ -440,7 +508,7 @@ function (_super) {
|
|
|
440
508
|
var step = packMultiple || 1;
|
|
441
509
|
var ev = {
|
|
442
510
|
target: {
|
|
443
|
-
value: (
|
|
511
|
+
value: _this.getPadDigitalValue(_this.getValueCalculate(Number(value), step * -1).toString())
|
|
444
512
|
}
|
|
445
513
|
};
|
|
446
514
|
|
|
@@ -473,6 +541,11 @@ function (_super) {
|
|
|
473
541
|
|
|
474
542
|
InputNumber.prototype.componentDidMount = function () {
|
|
475
543
|
this.addMouseMoveListener();
|
|
544
|
+
this.onValueChange({
|
|
545
|
+
target: {
|
|
546
|
+
value: this.props.value
|
|
547
|
+
}
|
|
548
|
+
}, true);
|
|
476
549
|
};
|
|
477
550
|
|
|
478
551
|
InputNumber.prototype.componentWillUnmount = function () {
|
|
@@ -486,9 +559,14 @@ function (_super) {
|
|
|
486
559
|
this.mouseMoveHandler = null;
|
|
487
560
|
}
|
|
488
561
|
|
|
489
|
-
if (this.
|
|
490
|
-
this.
|
|
491
|
-
this.
|
|
562
|
+
if (this.padDigitalDebounce) {
|
|
563
|
+
this.padDigitalDebounce.cancel();
|
|
564
|
+
this.padDigitalDebounce = null;
|
|
565
|
+
}
|
|
566
|
+
|
|
567
|
+
if (this.changePackMultipleValueDebounce) {
|
|
568
|
+
this.changePackMultipleValueDebounce.cancel();
|
|
569
|
+
this.changePackMultipleValueDebounce = null;
|
|
492
570
|
}
|
|
493
571
|
};
|
|
494
572
|
|
|
@@ -497,7 +575,8 @@ function (_super) {
|
|
|
497
575
|
|
|
498
576
|
delete copyProps.onChangePackMultipleBefore;
|
|
499
577
|
delete copyProps.onChangePackMultipleAfter;
|
|
500
|
-
delete copyProps.
|
|
578
|
+
delete copyProps.digital;
|
|
579
|
+
delete copyProps.padDigital;
|
|
501
580
|
delete copyProps.packMultiple;
|
|
502
581
|
delete copyProps.visibleButton;
|
|
503
582
|
delete copyProps.onChange;
|
|
@@ -539,7 +618,8 @@ function (_super) {
|
|
|
539
618
|
name: '',
|
|
540
619
|
size: 3,
|
|
541
620
|
disabled: false,
|
|
542
|
-
|
|
621
|
+
digital: 0,
|
|
622
|
+
padDigital: false,
|
|
543
623
|
delay: 1000,
|
|
544
624
|
visibleButton: false
|
|
545
625
|
};
|
|
@@ -1,11 +1,11 @@
|
|
|
1
1
|
import React from 'react';
|
|
2
|
-
import {
|
|
2
|
+
import { TableColumnInfo } from '../interface';
|
|
3
3
|
export interface BodyRowProps<T> {
|
|
4
4
|
className?: string;
|
|
5
5
|
prefixCls: string;
|
|
6
6
|
rowData: T;
|
|
7
7
|
index: number;
|
|
8
|
-
columns:
|
|
8
|
+
columns: TableColumnInfo<T>[];
|
|
9
9
|
indent: number;
|
|
10
10
|
CheckCell: React.ReactElement;
|
|
11
11
|
isExpand?: boolean;
|
|
@@ -1,12 +1,12 @@
|
|
|
1
1
|
import React, { ReactText } from 'react';
|
|
2
2
|
import { BodyRowProps } from './BodyRow';
|
|
3
3
|
import { BodyCheckIconProps, BodyRowSelectionInfo } from './CheckIcon';
|
|
4
|
-
import {
|
|
4
|
+
import { TableColumnOnRenderReturnObjectInfo } from '../interface';
|
|
5
5
|
/**
|
|
6
6
|
* 可展开子列表
|
|
7
7
|
*/
|
|
8
8
|
export interface TableExpandableInfo<T> {
|
|
9
|
-
expandedRowRender: (rowData: T, index: number) => React.ReactNode | React.ReactNode[] |
|
|
9
|
+
expandedRowRender: (rowData: T, index: number) => React.ReactNode | React.ReactNode[] | TableColumnOnRenderReturnObjectInfo;
|
|
10
10
|
}
|
|
11
11
|
export interface BodyProps<T> extends Pick<BodyRowProps<T>, 'prefixCls' | 'columns'>, Pick<BodyCheckIconProps<T>, 'selectedRowKeys'> {
|
|
12
12
|
/**
|
package/esm/table/body/index.js
CHANGED
|
@@ -35,14 +35,14 @@ function Body(_a) {
|
|
|
35
35
|
CheckCell: CheckCell,
|
|
36
36
|
indent: 0
|
|
37
37
|
}));
|
|
38
|
-
var expandedRowKey = rowKey + " expanded";
|
|
39
|
-
var expandedColumns = [{
|
|
40
|
-
title: null,
|
|
41
|
-
key: expandedRowKey,
|
|
42
|
-
onRender: expandedRowRenderer
|
|
43
|
-
}];
|
|
44
38
|
|
|
45
39
|
if (expandable) {
|
|
40
|
+
var expandedRowKey = rowKey + " expanded";
|
|
41
|
+
var expandedColumns = [{
|
|
42
|
+
title: null,
|
|
43
|
+
key: expandedRowKey,
|
|
44
|
+
onRender: expandedRowRenderer
|
|
45
|
+
}];
|
|
46
46
|
rows.push(React.createElement(BodyRow, {
|
|
47
47
|
key: expandedRowKey,
|
|
48
48
|
className: prefixCls + "-expand-row",
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import React from 'react';
|
|
2
|
-
import {
|
|
3
|
-
export interface HeaderCellProps<T> extends
|
|
2
|
+
import { TableColumnInfo } from '../interface';
|
|
3
|
+
export interface HeaderCellProps<T> extends TableColumnInfo<T> {
|
|
4
4
|
prefixCls: string;
|
|
5
5
|
isSort: boolean;
|
|
6
6
|
isSortedDescending?: boolean;
|
|
@@ -1,9 +1,9 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { TableColumnInfo } from '../interface';
|
|
2
2
|
import { HeaderCellProps } from './HeaderCell';
|
|
3
3
|
import { HeaderRowSelectionInfo } from './CheckIcon';
|
|
4
4
|
export interface HeaderRowProps<T> extends Pick<HeaderCellProps<T>, 'sortName' | 'isSortedDescending' | 'sortIcon'> {
|
|
5
5
|
prefixCls: string;
|
|
6
|
-
columns:
|
|
6
|
+
columns: TableColumnInfo<T>[];
|
|
7
7
|
/**
|
|
8
8
|
* 点击表头触发的排序函数
|
|
9
9
|
* @param isSortedDescending
|
package/esm/table/index.d.ts
CHANGED
|
@@ -1,11 +1,11 @@
|
|
|
1
1
|
import React, { ReactText } from 'react';
|
|
2
2
|
import { AddListenerEventHandler } from '@autobest-ui/utils';
|
|
3
|
-
import {
|
|
3
|
+
import { TableColumnInfo } from './interface';
|
|
4
4
|
import { HeaderRowProps } from './header/HeaderRow';
|
|
5
5
|
import { BodyProps } from './body';
|
|
6
6
|
import { HeaderRowSelectionInfo } from './header/CheckIcon';
|
|
7
7
|
import { BodyRowSelectionInfo } from './body/CheckIcon';
|
|
8
|
-
export interface
|
|
8
|
+
export interface TableRowSelectionInfo<T> extends Partial<Pick<HeaderRowSelectionInfo, 'selectAllVisible' | 'onSelectAll'>>, Partial<Pick<BodyRowSelectionInfo<T>, 'checkIcon'>> {
|
|
9
9
|
defaultSelectedRowKeys?: ReactText[];
|
|
10
10
|
getDisabled?: (dataRow: any, selectedRowKeys: ReactText[], selectedRows: T[]) => boolean;
|
|
11
11
|
onSelect?: (checked: boolean, rowData: T, selectedRows: T[]) => void;
|
|
@@ -21,7 +21,7 @@ export interface TableProps<T> extends Pick<HeaderRowProps<T>, 'sortName' | 'sor
|
|
|
21
21
|
* 定义每一列数据的格式
|
|
22
22
|
* 具体类型见Column
|
|
23
23
|
*/
|
|
24
|
-
columns:
|
|
24
|
+
columns: TableColumnInfo<T>[];
|
|
25
25
|
/**
|
|
26
26
|
* 获取单条记录的唯一主键; 若是string类型,则取当前行数据中对应名称的属性值; 若是函数,则传入当前行数据,获取rowKey值;这也是勾选功能匹配时所用的key值
|
|
27
27
|
*/
|
|
@@ -41,7 +41,7 @@ export interface TableProps<T> extends Pick<HeaderRowProps<T>, 'sortName' | 'sor
|
|
|
41
41
|
/**
|
|
42
42
|
* 表格行是否可勾选,详见RowSelection
|
|
43
43
|
*/
|
|
44
|
-
rowSelection?:
|
|
44
|
+
rowSelection?: TableRowSelectionInfo<T>;
|
|
45
45
|
/**
|
|
46
46
|
* 默认勾选项数组, 以primaryKey取值
|
|
47
47
|
*/
|
package/esm/table/index.js
CHANGED
|
@@ -74,9 +74,9 @@ function (_super) {
|
|
|
74
74
|
return {
|
|
75
75
|
selectedRowKeys: [],
|
|
76
76
|
selectedRows: [],
|
|
77
|
-
rowSelection: __assign(__assign({}, prevState.rowSelection), {
|
|
77
|
+
rowSelection: prevState.rowSelection ? __assign(__assign({}, prevState.rowSelection), {
|
|
78
78
|
selectAllChecked: false
|
|
79
|
-
})
|
|
79
|
+
}) : null
|
|
80
80
|
};
|
|
81
81
|
});
|
|
82
82
|
};
|
|
@@ -243,7 +243,7 @@ function (_super) {
|
|
|
243
243
|
};
|
|
244
244
|
|
|
245
245
|
_this.getRowSelection = function () {
|
|
246
|
-
if (!('rowSelection' in _this.props)) {
|
|
246
|
+
if (!('rowSelection' in _this.props) || !_this.props.rowSelection) {
|
|
247
247
|
return null;
|
|
248
248
|
}
|
|
249
249
|
|
package/esm/table/interface.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import React from 'react';
|
|
2
|
-
export interface
|
|
2
|
+
export interface TableColumnOnRenderReturnObjectInfo {
|
|
3
3
|
children: React.ReactNode | React.ReactNode[];
|
|
4
4
|
props: {
|
|
5
5
|
className?: string;
|
|
@@ -7,7 +7,7 @@ export interface ColumnOnRenderReturnObjectInfo {
|
|
|
7
7
|
colSpan?: number;
|
|
8
8
|
};
|
|
9
9
|
}
|
|
10
|
-
export interface
|
|
10
|
+
export interface TableColumnInfo<T> {
|
|
11
11
|
title: React.ReactNode | React.ReactNode[];
|
|
12
12
|
key: string;
|
|
13
13
|
dataIndex?: string;
|
|
@@ -18,5 +18,11 @@ export interface Column<T> {
|
|
|
18
18
|
width?: string | number;
|
|
19
19
|
className?: string;
|
|
20
20
|
colSpan?: number;
|
|
21
|
-
|
|
21
|
+
/**
|
|
22
|
+
* 渲染单元格内容的方法,不传则默认用dataIndex去取当前行对应属性值;入参分别为当前行数据,行索引, 列索引
|
|
23
|
+
* @param rowData
|
|
24
|
+
* @param rowIndex
|
|
25
|
+
* @param colIndex
|
|
26
|
+
*/
|
|
27
|
+
onRender?: (rowData: T, rowIndex: number, colIndex: number) => React.ReactNode | React.ReactNode[] | TableColumnOnRenderReturnObjectInfo;
|
|
22
28
|
}
|
package/lib/index.d.ts
CHANGED
|
@@ -43,8 +43,8 @@ export type { ScriptAttributes, ScriptProps } from './script';
|
|
|
43
43
|
export { default as Script } from './script';
|
|
44
44
|
export type { MessageProps } from './message';
|
|
45
45
|
export { default as Message } from './message';
|
|
46
|
-
export type { TableProps,
|
|
47
|
-
export type {
|
|
46
|
+
export type { TableProps, TableRowSelectionInfo } from './table';
|
|
47
|
+
export type { TableColumnInfo, TableColumnOnRenderReturnObjectInfo } from './table/interface';
|
|
48
48
|
export { default as Table } from './table';
|
|
49
49
|
export type { DatePickerProps } from './date-picker';
|
|
50
50
|
export { default as DatePicker } from './date-picker';
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import React from 'react';
|
|
2
|
-
import { AddListenerEventHandler } from '@autobest-ui/utils';
|
|
3
|
-
interface
|
|
2
|
+
import { debounce, AddListenerEventHandler } from '@autobest-ui/utils';
|
|
3
|
+
interface OnChangeHandler {
|
|
4
4
|
(value: string, name?: string): void;
|
|
5
5
|
}
|
|
6
6
|
interface ChangeEvent {
|
|
@@ -12,7 +12,7 @@ export interface InputNumberProps extends Omit<React.InputHTMLAttributes<any>, '
|
|
|
12
12
|
/**
|
|
13
13
|
* 值修改后的回调函数,用于修改value属性
|
|
14
14
|
*/
|
|
15
|
-
onChange:
|
|
15
|
+
onChange: OnChangeHandler;
|
|
16
16
|
/**
|
|
17
17
|
* input样式
|
|
18
18
|
*/
|
|
@@ -30,7 +30,8 @@ export interface InputNumberProps extends Omit<React.InputHTMLAttributes<any>, '
|
|
|
30
30
|
*/
|
|
31
31
|
max?: number;
|
|
32
32
|
/**
|
|
33
|
-
*
|
|
33
|
+
* 打包值,向上取整,不赋值或者赋值为0表示不做取整操作
|
|
34
|
+
* 注:packMultiple不允许传小数
|
|
34
35
|
*/
|
|
35
36
|
packMultiple?: number;
|
|
36
37
|
/**
|
|
@@ -38,9 +39,13 @@ export interface InputNumberProps extends Omit<React.InputHTMLAttributes<any>, '
|
|
|
38
39
|
*/
|
|
39
40
|
disabled?: boolean;
|
|
40
41
|
/**
|
|
41
|
-
*
|
|
42
|
+
* 可输入的小数位数,0或没有值表示只能输入整数
|
|
42
43
|
*/
|
|
43
|
-
|
|
44
|
+
digital?: number;
|
|
45
|
+
/**
|
|
46
|
+
* 为true则自动补全小数位数
|
|
47
|
+
*/
|
|
48
|
+
padDigital?: boolean;
|
|
44
49
|
/**
|
|
45
50
|
* 输入框默认字符大小
|
|
46
51
|
*/
|
|
@@ -56,11 +61,11 @@ export interface InputNumberProps extends Omit<React.InputHTMLAttributes<any>, '
|
|
|
56
61
|
/**
|
|
57
62
|
* packMultiple 有值时,判断前的回调函数
|
|
58
63
|
*/
|
|
59
|
-
onChangePackMultipleBefore?:
|
|
64
|
+
onChangePackMultipleBefore?: OnChangeHandler;
|
|
60
65
|
/**
|
|
61
66
|
* packMultiple 有值时,判断后的回调函数
|
|
62
67
|
*/
|
|
63
|
-
onChangePackMultipleAfter?:
|
|
68
|
+
onChangePackMultipleAfter?: OnChangeHandler;
|
|
64
69
|
/**
|
|
65
70
|
* 是否需要显示增加按钮
|
|
66
71
|
*/
|
|
@@ -70,10 +75,6 @@ interface InputNumberStates {
|
|
|
70
75
|
enter: boolean;
|
|
71
76
|
focus: boolean;
|
|
72
77
|
}
|
|
73
|
-
interface DebounceRef {
|
|
74
|
-
(value: string): void;
|
|
75
|
-
cancel: () => void;
|
|
76
|
-
}
|
|
77
78
|
interface LocationInfo {
|
|
78
79
|
left: number;
|
|
79
80
|
top: number;
|
|
@@ -86,13 +87,15 @@ declare class InputNumber extends React.Component<InputNumberProps, InputNumberS
|
|
|
86
87
|
name: string;
|
|
87
88
|
size: number;
|
|
88
89
|
disabled: boolean;
|
|
89
|
-
|
|
90
|
+
digital: number;
|
|
91
|
+
padDigital: boolean;
|
|
90
92
|
delay: number;
|
|
91
93
|
visibleButton: boolean;
|
|
92
94
|
};
|
|
93
95
|
constructor(props: InputNumberProps);
|
|
94
96
|
currentRef: React.RefObject<HTMLLabelElement>;
|
|
95
|
-
|
|
97
|
+
changePackMultipleValueDebounce: ReturnType<typeof debounce>;
|
|
98
|
+
padDigitalDebounce: ReturnType<typeof debounce>;
|
|
96
99
|
addLocationInfo: LocationInfo;
|
|
97
100
|
subLocationInfo: LocationInfo;
|
|
98
101
|
mouseUpHandler: AddListenerEventHandler;
|
|
@@ -120,10 +123,20 @@ declare class InputNumber extends React.Component<InputNumberProps, InputNumberS
|
|
|
120
123
|
isInside: (ev: React.MouseEvent<Element, MouseEvent>, locationInfo: LocationInfo) => boolean;
|
|
121
124
|
getLocationInfo: () => void;
|
|
122
125
|
getCurrentValue: (value: string) => number;
|
|
126
|
+
getPadDigitalValue: (value: string) => string;
|
|
123
127
|
onChangePackMultipleValue: (value: string) => void;
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
128
|
+
onPadDigital: (value: any) => void;
|
|
129
|
+
getPadDigitalDebounce: () => {
|
|
130
|
+
(...arg: any[]): void;
|
|
131
|
+
cancel(): void;
|
|
132
|
+
};
|
|
133
|
+
getChangePackMultipleValueDebounce: () => {
|
|
134
|
+
(...arg: any[]): void;
|
|
135
|
+
cancel(): void;
|
|
136
|
+
};
|
|
137
|
+
callback: (value: string, ignoreDelay?: any) => void;
|
|
138
|
+
onValueChange: (ev: ChangeEvent, ignoreDelay?: any) => void;
|
|
139
|
+
getValueCalculate: (value: number, offset: number) => number;
|
|
127
140
|
onAdd: () => void;
|
|
128
141
|
onSub: () => void;
|
|
129
142
|
renderButton: () => JSX.Element;
|
|
@@ -55,7 +55,7 @@ var __assign = void 0 && (void 0).__assign || function () {
|
|
|
55
55
|
return __assign.apply(this, arguments);
|
|
56
56
|
};
|
|
57
57
|
|
|
58
|
-
var cls = 'ab-input-number';
|
|
58
|
+
var cls = 'ab-input-number'; // TODO: 重构组件
|
|
59
59
|
|
|
60
60
|
var InputNumber =
|
|
61
61
|
/** @class */
|
|
@@ -317,6 +317,19 @@ function (_super) {
|
|
|
317
317
|
return ceilNumber;
|
|
318
318
|
};
|
|
319
319
|
|
|
320
|
+
_this.getPadDigitalValue = function (value) {
|
|
321
|
+
var _a = _this.props,
|
|
322
|
+
digital = _a.digital,
|
|
323
|
+
padDigital = _a.padDigital;
|
|
324
|
+
|
|
325
|
+
if (!padDigital || (0, _utils.isBlank)(value) || !digital) {
|
|
326
|
+
return value;
|
|
327
|
+
}
|
|
328
|
+
|
|
329
|
+
var resultArr = value.split('.');
|
|
330
|
+
return resultArr[0] + "." + (resultArr[1] || '').padEnd(digital, '0');
|
|
331
|
+
};
|
|
332
|
+
|
|
320
333
|
_this.onChangePackMultipleValue = function (value) {
|
|
321
334
|
var currentValue = _this.getCurrentValue(value).toString();
|
|
322
335
|
|
|
@@ -331,60 +344,97 @@ function (_super) {
|
|
|
331
344
|
}
|
|
332
345
|
};
|
|
333
346
|
|
|
334
|
-
_this.
|
|
335
|
-
|
|
336
|
-
|
|
347
|
+
_this.onPadDigital = function (value) {
|
|
348
|
+
var currentValue = _this.getPadDigitalValue(value);
|
|
349
|
+
|
|
350
|
+
var _a = _this.props,
|
|
351
|
+
onChange = _a.onChange,
|
|
352
|
+
name = _a.name;
|
|
353
|
+
|
|
354
|
+
if (value !== currentValue) {
|
|
355
|
+
onChange(currentValue, name);
|
|
337
356
|
}
|
|
357
|
+
};
|
|
358
|
+
|
|
359
|
+
_this.getPadDigitalDebounce = function () {
|
|
360
|
+
if (_this.padDigitalDebounce) {
|
|
361
|
+
return _this.padDigitalDebounce;
|
|
362
|
+
}
|
|
363
|
+
|
|
364
|
+
_this.padDigitalDebounce = (0, _utils.debounce)(_this.onPadDigital, _this.props.delay);
|
|
365
|
+
return _this.padDigitalDebounce;
|
|
366
|
+
};
|
|
338
367
|
|
|
339
|
-
|
|
340
|
-
|
|
368
|
+
_this.getChangePackMultipleValueDebounce = function () {
|
|
369
|
+
if (_this.changePackMultipleValueDebounce) {
|
|
370
|
+
return _this.changePackMultipleValueDebounce;
|
|
371
|
+
}
|
|
372
|
+
|
|
373
|
+
_this.changePackMultipleValueDebounce = (0, _utils.debounce)(_this.onChangePackMultipleValue, _this.props.delay);
|
|
374
|
+
return _this.changePackMultipleValueDebounce;
|
|
341
375
|
};
|
|
342
376
|
|
|
343
|
-
_this.callback = function (value) {
|
|
377
|
+
_this.callback = function (value, ignoreDelay) {
|
|
344
378
|
var _a = _this.props,
|
|
345
379
|
name = _a.name,
|
|
346
380
|
onChange = _a.onChange,
|
|
347
|
-
onChangePackMultipleBefore = _a.onChangePackMultipleBefore
|
|
348
|
-
|
|
381
|
+
onChangePackMultipleBefore = _a.onChangePackMultipleBefore,
|
|
382
|
+
packMultiple = _a.packMultiple,
|
|
383
|
+
padDigital = _a.padDigital;
|
|
349
384
|
|
|
350
|
-
if (onChange) {
|
|
385
|
+
if (onChange && value !== _this.props.value) {
|
|
351
386
|
onChange(value, name);
|
|
352
387
|
}
|
|
353
388
|
|
|
354
|
-
|
|
355
|
-
|
|
356
|
-
if (!(0, _utils.isBlank)(packMultiple) && !(0, _utils.isBlank)(value) && valueNumber % packMultiple !== 0) {
|
|
389
|
+
if (packMultiple && !(0, _utils.isBlank)(value) && parseFloat(value) % packMultiple !== 0) {
|
|
357
390
|
if (onChangePackMultipleBefore) {
|
|
358
391
|
onChangePackMultipleBefore(value, name);
|
|
359
392
|
}
|
|
360
393
|
|
|
361
|
-
|
|
394
|
+
if (ignoreDelay) {
|
|
395
|
+
_this.onChangePackMultipleValue(value);
|
|
396
|
+
} else {
|
|
397
|
+
_this.getChangePackMultipleValueDebounce()(value);
|
|
398
|
+
}
|
|
399
|
+
|
|
400
|
+
return;
|
|
401
|
+
}
|
|
402
|
+
|
|
403
|
+
if (padDigital) {
|
|
404
|
+
if (ignoreDelay) {
|
|
405
|
+
_this.onPadDigital(value);
|
|
406
|
+
|
|
407
|
+
return;
|
|
408
|
+
}
|
|
409
|
+
|
|
410
|
+
_this.getPadDigitalDebounce()(value);
|
|
362
411
|
}
|
|
363
412
|
};
|
|
364
413
|
|
|
365
|
-
_this.onValueChange = function (ev) {
|
|
366
|
-
if (_this.
|
|
367
|
-
_this.
|
|
414
|
+
_this.onValueChange = function (ev, ignoreDelay) {
|
|
415
|
+
if (_this.changePackMultipleValueDebounce) {
|
|
416
|
+
_this.changePackMultipleValueDebounce.cancel();
|
|
368
417
|
}
|
|
369
418
|
|
|
370
419
|
var _a = _this.props,
|
|
371
420
|
min = _a.min,
|
|
372
421
|
max = _a.max,
|
|
373
|
-
|
|
422
|
+
digital = _a.digital,
|
|
374
423
|
value = _a.value;
|
|
375
|
-
var currentValue = ev.target.value.toString();
|
|
424
|
+
var currentValue = ev.target.value.toString(); // 输入为空
|
|
376
425
|
|
|
377
426
|
if ((0, _utils.isBlank)(currentValue)) {
|
|
378
|
-
_this.callback('');
|
|
427
|
+
_this.callback('', ignoreDelay);
|
|
379
428
|
|
|
380
429
|
return;
|
|
381
430
|
}
|
|
382
431
|
|
|
383
|
-
var preValue = value.toString();
|
|
432
|
+
var preValue = value.toString(); // 输入的不是数字格式
|
|
433
|
+
|
|
384
434
|
var reg = /^-$|(^(-?\d+)(\.\d*)?)$/;
|
|
385
435
|
|
|
386
436
|
if (!reg.test(currentValue)) {
|
|
387
|
-
_this.callback(preValue);
|
|
437
|
+
_this.callback(preValue, ignoreDelay);
|
|
388
438
|
|
|
389
439
|
return;
|
|
390
440
|
} // 0开头后面直接是数字,没有点如:011, 这是不合法的
|
|
@@ -393,41 +443,59 @@ function (_super) {
|
|
|
393
443
|
var zeroReg = /^0\d+$/;
|
|
394
444
|
|
|
395
445
|
if (zeroReg.test(currentValue)) {
|
|
396
|
-
_this.callback(preValue);
|
|
446
|
+
_this.callback(preValue, ignoreDelay);
|
|
397
447
|
|
|
398
448
|
return;
|
|
449
|
+
} // 小数位数限制
|
|
450
|
+
|
|
451
|
+
|
|
452
|
+
if (digital) {
|
|
453
|
+
currentValue = new RegExp("[^.]+([.](\\d{0," + digital + "}))?").exec(currentValue)[0].toString();
|
|
399
454
|
}
|
|
400
455
|
|
|
401
456
|
var valueNumber = parseFloat(currentValue);
|
|
402
457
|
|
|
403
458
|
if (!(0, _utils.isBlank)(min)) {
|
|
404
459
|
if (min > valueNumber) {
|
|
405
|
-
_this.callback(preValue);
|
|
460
|
+
_this.callback(preValue, ignoreDelay);
|
|
406
461
|
|
|
407
462
|
return;
|
|
408
463
|
} // 如果min>= 0, 将阻止输入-
|
|
409
464
|
|
|
410
465
|
|
|
411
466
|
if (min >= 0 && currentValue.indexOf('-') > -1) {
|
|
412
|
-
_this.callback('');
|
|
467
|
+
_this.callback('', ignoreDelay);
|
|
413
468
|
|
|
414
469
|
return;
|
|
415
470
|
}
|
|
416
471
|
}
|
|
417
472
|
|
|
418
473
|
if (!(0, _utils.isBlank)(max) && max < valueNumber) {
|
|
419
|
-
_this.callback(preValue);
|
|
474
|
+
_this.callback(preValue, ignoreDelay);
|
|
420
475
|
|
|
421
476
|
return;
|
|
422
477
|
}
|
|
423
478
|
|
|
424
|
-
if (
|
|
425
|
-
_this.callback(preValue);
|
|
479
|
+
if (!digital && currentValue.indexOf('.') > -1) {
|
|
480
|
+
_this.callback(preValue, ignoreDelay);
|
|
426
481
|
|
|
427
482
|
return;
|
|
428
483
|
}
|
|
429
484
|
|
|
430
|
-
_this.callback(currentValue);
|
|
485
|
+
_this.callback(currentValue, ignoreDelay);
|
|
486
|
+
};
|
|
487
|
+
|
|
488
|
+
_this.getValueCalculate = function (value, offset) {
|
|
489
|
+
var valueStr = value.toString();
|
|
490
|
+
var offsetStr = offset.toString();
|
|
491
|
+
|
|
492
|
+
if (valueStr.indexOf('.') < 0 && offsetStr.indexOf('.') < 0) {
|
|
493
|
+
return value + offset;
|
|
494
|
+
}
|
|
495
|
+
|
|
496
|
+
var digital = _this.props.digital;
|
|
497
|
+
var powValue = Math.pow(10, digital);
|
|
498
|
+
return Math.round((value + offset) * powValue) / powValue;
|
|
431
499
|
};
|
|
432
500
|
|
|
433
501
|
_this.onAdd = function () {
|
|
@@ -438,7 +506,7 @@ function (_super) {
|
|
|
438
506
|
|
|
439
507
|
var ev = {
|
|
440
508
|
target: {
|
|
441
|
-
value: (
|
|
509
|
+
value: _this.getPadDigitalValue(_this.getValueCalculate(Number(value), step).toString())
|
|
442
510
|
}
|
|
443
511
|
};
|
|
444
512
|
|
|
@@ -452,7 +520,7 @@ function (_super) {
|
|
|
452
520
|
var step = packMultiple || 1;
|
|
453
521
|
var ev = {
|
|
454
522
|
target: {
|
|
455
|
-
value: (
|
|
523
|
+
value: _this.getPadDigitalValue(_this.getValueCalculate(Number(value), step * -1).toString())
|
|
456
524
|
}
|
|
457
525
|
};
|
|
458
526
|
|
|
@@ -485,6 +553,11 @@ function (_super) {
|
|
|
485
553
|
|
|
486
554
|
InputNumber.prototype.componentDidMount = function () {
|
|
487
555
|
this.addMouseMoveListener();
|
|
556
|
+
this.onValueChange({
|
|
557
|
+
target: {
|
|
558
|
+
value: this.props.value
|
|
559
|
+
}
|
|
560
|
+
}, true);
|
|
488
561
|
};
|
|
489
562
|
|
|
490
563
|
InputNumber.prototype.componentWillUnmount = function () {
|
|
@@ -498,9 +571,14 @@ function (_super) {
|
|
|
498
571
|
this.mouseMoveHandler = null;
|
|
499
572
|
}
|
|
500
573
|
|
|
501
|
-
if (this.
|
|
502
|
-
this.
|
|
503
|
-
this.
|
|
574
|
+
if (this.padDigitalDebounce) {
|
|
575
|
+
this.padDigitalDebounce.cancel();
|
|
576
|
+
this.padDigitalDebounce = null;
|
|
577
|
+
}
|
|
578
|
+
|
|
579
|
+
if (this.changePackMultipleValueDebounce) {
|
|
580
|
+
this.changePackMultipleValueDebounce.cancel();
|
|
581
|
+
this.changePackMultipleValueDebounce = null;
|
|
504
582
|
}
|
|
505
583
|
};
|
|
506
584
|
|
|
@@ -509,7 +587,8 @@ function (_super) {
|
|
|
509
587
|
|
|
510
588
|
delete copyProps.onChangePackMultipleBefore;
|
|
511
589
|
delete copyProps.onChangePackMultipleAfter;
|
|
512
|
-
delete copyProps.
|
|
590
|
+
delete copyProps.digital;
|
|
591
|
+
delete copyProps.padDigital;
|
|
513
592
|
delete copyProps.packMultiple;
|
|
514
593
|
delete copyProps.visibleButton;
|
|
515
594
|
delete copyProps.onChange;
|
|
@@ -551,7 +630,8 @@ function (_super) {
|
|
|
551
630
|
name: '',
|
|
552
631
|
size: 3,
|
|
553
632
|
disabled: false,
|
|
554
|
-
|
|
633
|
+
digital: 0,
|
|
634
|
+
padDigital: false,
|
|
555
635
|
delay: 1000,
|
|
556
636
|
visibleButton: false
|
|
557
637
|
};
|
|
@@ -1,11 +1,11 @@
|
|
|
1
1
|
import React from 'react';
|
|
2
|
-
import {
|
|
2
|
+
import { TableColumnInfo } from '../interface';
|
|
3
3
|
export interface BodyRowProps<T> {
|
|
4
4
|
className?: string;
|
|
5
5
|
prefixCls: string;
|
|
6
6
|
rowData: T;
|
|
7
7
|
index: number;
|
|
8
|
-
columns:
|
|
8
|
+
columns: TableColumnInfo<T>[];
|
|
9
9
|
indent: number;
|
|
10
10
|
CheckCell: React.ReactElement;
|
|
11
11
|
isExpand?: boolean;
|
|
@@ -1,12 +1,12 @@
|
|
|
1
1
|
import React, { ReactText } from 'react';
|
|
2
2
|
import { BodyRowProps } from './BodyRow';
|
|
3
3
|
import { BodyCheckIconProps, BodyRowSelectionInfo } from './CheckIcon';
|
|
4
|
-
import {
|
|
4
|
+
import { TableColumnOnRenderReturnObjectInfo } from '../interface';
|
|
5
5
|
/**
|
|
6
6
|
* 可展开子列表
|
|
7
7
|
*/
|
|
8
8
|
export interface TableExpandableInfo<T> {
|
|
9
|
-
expandedRowRender: (rowData: T, index: number) => React.ReactNode | React.ReactNode[] |
|
|
9
|
+
expandedRowRender: (rowData: T, index: number) => React.ReactNode | React.ReactNode[] | TableColumnOnRenderReturnObjectInfo;
|
|
10
10
|
}
|
|
11
11
|
export interface BodyProps<T> extends Pick<BodyRowProps<T>, 'prefixCls' | 'columns'>, Pick<BodyCheckIconProps<T>, 'selectedRowKeys'> {
|
|
12
12
|
/**
|
package/lib/table/body/index.js
CHANGED
|
@@ -46,14 +46,14 @@ function Body(_a) {
|
|
|
46
46
|
CheckCell: CheckCell,
|
|
47
47
|
indent: 0
|
|
48
48
|
}));
|
|
49
|
-
var expandedRowKey = rowKey + " expanded";
|
|
50
|
-
var expandedColumns = [{
|
|
51
|
-
title: null,
|
|
52
|
-
key: expandedRowKey,
|
|
53
|
-
onRender: expandedRowRenderer
|
|
54
|
-
}];
|
|
55
49
|
|
|
56
50
|
if (expandable) {
|
|
51
|
+
var expandedRowKey = rowKey + " expanded";
|
|
52
|
+
var expandedColumns = [{
|
|
53
|
+
title: null,
|
|
54
|
+
key: expandedRowKey,
|
|
55
|
+
onRender: expandedRowRenderer
|
|
56
|
+
}];
|
|
57
57
|
rows.push(_react.default.createElement(_BodyRow.default, {
|
|
58
58
|
key: expandedRowKey,
|
|
59
59
|
className: prefixCls + "-expand-row",
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import React from 'react';
|
|
2
|
-
import {
|
|
3
|
-
export interface HeaderCellProps<T> extends
|
|
2
|
+
import { TableColumnInfo } from '../interface';
|
|
3
|
+
export interface HeaderCellProps<T> extends TableColumnInfo<T> {
|
|
4
4
|
prefixCls: string;
|
|
5
5
|
isSort: boolean;
|
|
6
6
|
isSortedDescending?: boolean;
|
|
@@ -1,9 +1,9 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { TableColumnInfo } from '../interface';
|
|
2
2
|
import { HeaderCellProps } from './HeaderCell';
|
|
3
3
|
import { HeaderRowSelectionInfo } from './CheckIcon';
|
|
4
4
|
export interface HeaderRowProps<T> extends Pick<HeaderCellProps<T>, 'sortName' | 'isSortedDescending' | 'sortIcon'> {
|
|
5
5
|
prefixCls: string;
|
|
6
|
-
columns:
|
|
6
|
+
columns: TableColumnInfo<T>[];
|
|
7
7
|
/**
|
|
8
8
|
* 点击表头触发的排序函数
|
|
9
9
|
* @param isSortedDescending
|
package/lib/table/index.d.ts
CHANGED
|
@@ -1,11 +1,11 @@
|
|
|
1
1
|
import React, { ReactText } from 'react';
|
|
2
2
|
import { AddListenerEventHandler } from '@autobest-ui/utils';
|
|
3
|
-
import {
|
|
3
|
+
import { TableColumnInfo } from './interface';
|
|
4
4
|
import { HeaderRowProps } from './header/HeaderRow';
|
|
5
5
|
import { BodyProps } from './body';
|
|
6
6
|
import { HeaderRowSelectionInfo } from './header/CheckIcon';
|
|
7
7
|
import { BodyRowSelectionInfo } from './body/CheckIcon';
|
|
8
|
-
export interface
|
|
8
|
+
export interface TableRowSelectionInfo<T> extends Partial<Pick<HeaderRowSelectionInfo, 'selectAllVisible' | 'onSelectAll'>>, Partial<Pick<BodyRowSelectionInfo<T>, 'checkIcon'>> {
|
|
9
9
|
defaultSelectedRowKeys?: ReactText[];
|
|
10
10
|
getDisabled?: (dataRow: any, selectedRowKeys: ReactText[], selectedRows: T[]) => boolean;
|
|
11
11
|
onSelect?: (checked: boolean, rowData: T, selectedRows: T[]) => void;
|
|
@@ -21,7 +21,7 @@ export interface TableProps<T> extends Pick<HeaderRowProps<T>, 'sortName' | 'sor
|
|
|
21
21
|
* 定义每一列数据的格式
|
|
22
22
|
* 具体类型见Column
|
|
23
23
|
*/
|
|
24
|
-
columns:
|
|
24
|
+
columns: TableColumnInfo<T>[];
|
|
25
25
|
/**
|
|
26
26
|
* 获取单条记录的唯一主键; 若是string类型,则取当前行数据中对应名称的属性值; 若是函数,则传入当前行数据,获取rowKey值;这也是勾选功能匹配时所用的key值
|
|
27
27
|
*/
|
|
@@ -41,7 +41,7 @@ export interface TableProps<T> extends Pick<HeaderRowProps<T>, 'sortName' | 'sor
|
|
|
41
41
|
/**
|
|
42
42
|
* 表格行是否可勾选,详见RowSelection
|
|
43
43
|
*/
|
|
44
|
-
rowSelection?:
|
|
44
|
+
rowSelection?: TableRowSelectionInfo<T>;
|
|
45
45
|
/**
|
|
46
46
|
* 默认勾选项数组, 以primaryKey取值
|
|
47
47
|
*/
|
package/lib/table/index.js
CHANGED
|
@@ -88,9 +88,9 @@ function (_super) {
|
|
|
88
88
|
return {
|
|
89
89
|
selectedRowKeys: [],
|
|
90
90
|
selectedRows: [],
|
|
91
|
-
rowSelection: __assign(__assign({}, prevState.rowSelection), {
|
|
91
|
+
rowSelection: prevState.rowSelection ? __assign(__assign({}, prevState.rowSelection), {
|
|
92
92
|
selectAllChecked: false
|
|
93
|
-
})
|
|
93
|
+
}) : null
|
|
94
94
|
};
|
|
95
95
|
});
|
|
96
96
|
};
|
|
@@ -257,7 +257,7 @@ function (_super) {
|
|
|
257
257
|
};
|
|
258
258
|
|
|
259
259
|
_this.getRowSelection = function () {
|
|
260
|
-
if (!('rowSelection' in _this.props)) {
|
|
260
|
+
if (!('rowSelection' in _this.props) || !_this.props.rowSelection) {
|
|
261
261
|
return null;
|
|
262
262
|
}
|
|
263
263
|
|
package/lib/table/interface.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import React from 'react';
|
|
2
|
-
export interface
|
|
2
|
+
export interface TableColumnOnRenderReturnObjectInfo {
|
|
3
3
|
children: React.ReactNode | React.ReactNode[];
|
|
4
4
|
props: {
|
|
5
5
|
className?: string;
|
|
@@ -7,7 +7,7 @@ export interface ColumnOnRenderReturnObjectInfo {
|
|
|
7
7
|
colSpan?: number;
|
|
8
8
|
};
|
|
9
9
|
}
|
|
10
|
-
export interface
|
|
10
|
+
export interface TableColumnInfo<T> {
|
|
11
11
|
title: React.ReactNode | React.ReactNode[];
|
|
12
12
|
key: string;
|
|
13
13
|
dataIndex?: string;
|
|
@@ -18,5 +18,11 @@ export interface Column<T> {
|
|
|
18
18
|
width?: string | number;
|
|
19
19
|
className?: string;
|
|
20
20
|
colSpan?: number;
|
|
21
|
-
|
|
21
|
+
/**
|
|
22
|
+
* 渲染单元格内容的方法,不传则默认用dataIndex去取当前行对应属性值;入参分别为当前行数据,行索引, 列索引
|
|
23
|
+
* @param rowData
|
|
24
|
+
* @param rowIndex
|
|
25
|
+
* @param colIndex
|
|
26
|
+
*/
|
|
27
|
+
onRender?: (rowData: T, rowIndex: number, colIndex: number) => React.ReactNode | React.ReactNode[] | TableColumnOnRenderReturnObjectInfo;
|
|
22
28
|
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@autobest-ui/components",
|
|
3
|
-
"version": "1.1.
|
|
3
|
+
"version": "1.1.9",
|
|
4
4
|
"private": false,
|
|
5
5
|
"description": "components common ui for React",
|
|
6
6
|
"main": "lib/index.js",
|
|
@@ -46,5 +46,5 @@
|
|
|
46
46
|
"react": ">=16.8.6",
|
|
47
47
|
"react-transition-group": ">=4.2.2"
|
|
48
48
|
},
|
|
49
|
-
"gitHead": "
|
|
49
|
+
"gitHead": "b2116ba6608e80a8aa7c1fbfe12d3be7e7cae998"
|
|
50
50
|
}
|