@qn-pandora/pandora-component 4.4.6 → 5.0.1
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/components/InputNumberWithUnit/index.d.ts +1 -0
- package/es/components/InputNumberWithUnit/index.js +3 -3
- package/es/components/Table/ResizableTitle/index.js +34 -5
- package/es/components/Table/ResizableTitle/style.css +4 -3
- package/es/components/Table/ResizableTitle/style.less +2 -3
- package/es/components/Table/index.d.ts +7 -1
- package/es/components/Table/index.js +28 -16
- package/es/index.css +7389 -7388
- package/es/index.less +15 -15
- package/lib/components/InputNumberWithUnit/index.d.ts +1 -0
- package/lib/components/InputNumberWithUnit/index.js +3 -3
- package/lib/components/Table/ResizableTitle/index.js +53 -5
- package/lib/components/Table/ResizableTitle/style.css +4 -3
- package/lib/components/Table/ResizableTitle/style.less +2 -3
- package/lib/components/Table/index.d.ts +7 -1
- package/lib/components/Table/index.js +28 -16
- package/lib/index.css +2861 -2860
- package/lib/index.less +12 -12
- package/package.json +3 -3
package/es/index.less
CHANGED
@@ -1,36 +1,36 @@
|
|
1
1
|
@import './style/mixin.less';
|
2
2
|
@import './style/theme.less';
|
3
|
-
@import './components/AutoComplete/style.less';
|
4
|
-
@import './components/Button/style.less';
|
5
3
|
@import './components/Breadcrumb/style.less';
|
4
|
+
@import './components/AutoComplete/style.less';
|
6
5
|
@import './components/Card/style.less';
|
7
|
-
@import './components/
|
6
|
+
@import './components/Button/style.less';
|
8
7
|
@import './components/CheckTransformList/style.less';
|
8
|
+
@import './components/Checkbox/style.less';
|
9
9
|
@import './components/Collapse/style.less';
|
10
10
|
@import './components/CheckboxList/style.less';
|
11
11
|
@import './components/CollapsiblePanel/style.less';
|
12
|
-
@import './components/DateTimePicker/style.less';
|
13
12
|
@import './components/Descriptions/style.less';
|
13
|
+
@import './components/DateTimePicker/style.less';
|
14
14
|
@import './components/Drawer/style.less';
|
15
|
-
@import './components/Input/style.less';
|
16
15
|
@import './components/FileResumable/style.less';
|
16
|
+
@import './components/Input/style.less';
|
17
17
|
@import './components/KeyValuePair/style.less';
|
18
18
|
@import './components/Menu/style.less';
|
19
19
|
@import './components/Modal/style.less';
|
20
20
|
@import './components/NameExplainTooltip/style.less';
|
21
|
-
@import './components/NameLimiter/style.less';
|
22
21
|
@import './components/OptionList/style.less';
|
23
22
|
@import './components/RadioGroup/style.less';
|
24
23
|
@import './components/RangeInput/style.less';
|
25
|
-
@import './components/RemarkName/style.less';
|
26
24
|
@import './components/Selector/style.less';
|
25
|
+
@import './components/RemarkName/style.less';
|
27
26
|
@import './components/Spin/style.less';
|
28
|
-
@import './components/
|
27
|
+
@import './components/NameLimiter/style.less';
|
29
28
|
@import './components/Table/style.less';
|
30
|
-
@import './components/
|
29
|
+
@import './components/Steps/style.less';
|
31
30
|
@import './components/TagList/style.less';
|
32
|
-
@import './components/
|
31
|
+
@import './components/Tabs/style.less';
|
33
32
|
@import './components/Timeline/style.less';
|
33
|
+
@import './components/TreeSelector/style.less';
|
34
34
|
@import './components/Transfer/style.less';
|
35
35
|
@import './components/Card/RowExtra/style.less';
|
36
36
|
@import './components/Card/SearchInput/style.less';
|
@@ -41,14 +41,14 @@
|
|
41
41
|
@import './components/OptionList/InlineOptionList/style.less';
|
42
42
|
@import './components/OptionList/OptionItem/style.less';
|
43
43
|
@import './components/OptionList/PopoverOptionList/style.less';
|
44
|
-
@import './components/Steps/ControlButton/style.less';
|
45
|
-
@import './components/Table/ColumnTag/style.less';
|
46
44
|
@import './components/Table/ColumnSetting/style.less';
|
45
|
+
@import './components/Table/ColumnTag/style.less';
|
47
46
|
@import './components/Table/ResizableTitle/style.less';
|
48
|
-
@import './components/TagList/Tag/style.less';
|
49
47
|
@import './components/TagList/TagSwitch/style.less';
|
50
|
-
@import './components/
|
51
|
-
@import './components/
|
48
|
+
@import './components/TagList/Tag/style.less';
|
49
|
+
@import './components/Steps/ControlButton/style.less';
|
52
50
|
@import './components/Transfer/ListBody/style.less';
|
51
|
+
@import './components/Transfer/List/style.less';
|
52
|
+
@import './components/Timeline/TimelineItem/style.less';
|
53
53
|
@import './components/DateTimePicker/Collapse/Panel/style.less';
|
54
54
|
@import './components/DateTimePicker/BaseMobile/Absolute/style.less';
|
@@ -50,7 +50,7 @@ var getUnit = function (value) {
|
|
50
50
|
return (value === null || value === void 0 ? void 0 : value.replace(/\d+/, '')) || '';
|
51
51
|
};
|
52
52
|
function InputNumberWithUnit(props) {
|
53
|
-
var value = props.value, onChange = props.onChange, onNumberChange = props.onNumberChange, onUnitChange = props.onUnitChange, className = props.className, unitClassName = props.unitClassName, placeholder = props.placeholder, unitOptions = props.unitOptions, _a = props.unitWidth, unitWidth = _a === void 0 ? 86 : _a, min = props.min, max = props.max;
|
53
|
+
var value = props.value, onChange = props.onChange, onNumberChange = props.onNumberChange, onUnitChange = props.onUnitChange, className = props.className, unitClassName = props.unitClassName, placeholder = props.placeholder, unitOptions = props.unitOptions, _a = props.unitWidth, unitWidth = _a === void 0 ? 86 : _a, min = props.min, max = props.max, readOnly = props.readOnly;
|
54
54
|
var _b = __read(react_1.useState(), 2), num = _b[0], setNum = _b[1];
|
55
55
|
var _c = __read(react_1.useState(), 2), unit = _c[0], setUnit = _c[1];
|
56
56
|
var controlled = Object.hasOwnProperty.call(props, 'value');
|
@@ -74,7 +74,7 @@ function InputNumberWithUnit(props) {
|
|
74
74
|
}
|
75
75
|
onUnitChange === null || onUnitChange === void 0 ? void 0 : onUnitChange(unit);
|
76
76
|
}, [num, onChange, onUnitChange, controlled, value]);
|
77
|
-
var addonAfterNode = (react_1.default.createElement(Selector_1.default, { options: unitOptions, className: unitClassName, value: controlled ? getUnit(value) : unit, style: { width: unitWidth }, onChange: onSelectorChange }));
|
78
|
-
return (react_1.default.createElement(InputNumber_1.default, { className: style_1.SDK_PREFIX + "-input-number-unit " + className, value: controlled ? getNum(value) : num, onChange: onInputChange, placeholder: placeholder, addonAfter: addonAfterNode, min: min, max: max }));
|
77
|
+
var addonAfterNode = (react_1.default.createElement(Selector_1.default, { options: unitOptions, className: unitClassName, value: controlled ? getUnit(value) : unit, style: { width: unitWidth }, onChange: onSelectorChange, disabled: readOnly }));
|
78
|
+
return (react_1.default.createElement(InputNumber_1.default, { className: style_1.SDK_PREFIX + "-input-number-unit " + className, value: controlled ? getNum(value) : num, onChange: onInputChange, placeholder: placeholder, addonAfter: addonAfterNode, min: min, max: max, disabled: readOnly }));
|
79
79
|
}
|
80
80
|
exports.default = InputNumberWithUnit;
|
@@ -10,6 +10,25 @@ var __assign = (this && this.__assign) || function () {
|
|
10
10
|
};
|
11
11
|
return __assign.apply(this, arguments);
|
12
12
|
};
|
13
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
14
|
+
if (k2 === undefined) k2 = k;
|
15
|
+
Object.defineProperty(o, k2, { enumerable: true, get: function() { return m[k]; } });
|
16
|
+
}) : (function(o, m, k, k2) {
|
17
|
+
if (k2 === undefined) k2 = k;
|
18
|
+
o[k2] = m[k];
|
19
|
+
}));
|
20
|
+
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
21
|
+
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
22
|
+
}) : function(o, v) {
|
23
|
+
o["default"] = v;
|
24
|
+
});
|
25
|
+
var __importStar = (this && this.__importStar) || function (mod) {
|
26
|
+
if (mod && mod.__esModule) return mod;
|
27
|
+
var result = {};
|
28
|
+
if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
|
29
|
+
__setModuleDefault(result, mod);
|
30
|
+
return result;
|
31
|
+
};
|
13
32
|
var __rest = (this && this.__rest) || function (s, e) {
|
14
33
|
var t = {};
|
15
34
|
for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0)
|
@@ -21,25 +40,54 @@ var __rest = (this && this.__rest) || function (s, e) {
|
|
21
40
|
}
|
22
41
|
return t;
|
23
42
|
};
|
43
|
+
var __read = (this && this.__read) || function (o, n) {
|
44
|
+
var m = typeof Symbol === "function" && o[Symbol.iterator];
|
45
|
+
if (!m) return o;
|
46
|
+
var i = m.call(o), r, ar = [], e;
|
47
|
+
try {
|
48
|
+
while ((n === void 0 || n-- > 0) && !(r = i.next()).done) ar.push(r.value);
|
49
|
+
}
|
50
|
+
catch (error) { e = { error: error }; }
|
51
|
+
finally {
|
52
|
+
try {
|
53
|
+
if (r && !r.done && (m = i["return"])) m.call(i);
|
54
|
+
}
|
55
|
+
finally { if (e) throw e.error; }
|
56
|
+
}
|
57
|
+
return ar;
|
58
|
+
};
|
24
59
|
var __importDefault = (this && this.__importDefault) || function (mod) {
|
25
60
|
return (mod && mod.__esModule) ? mod : { "default": mod };
|
26
61
|
};
|
27
62
|
Object.defineProperty(exports, "__esModule", { value: true });
|
28
|
-
var react_1 =
|
63
|
+
var react_1 = __importStar(require("react"));
|
29
64
|
var react_resizable_1 = require("react-resizable");
|
30
65
|
var classnames_1 = __importDefault(require("classnames"));
|
31
66
|
var pandora_component_icons_1 = require("@qn-pandora/pandora-component-icons");
|
32
67
|
var style_1 = require("../../../constants/style");
|
33
68
|
var ResizableTitle = function (props) {
|
34
|
-
var onResize = props.onResize,
|
35
|
-
|
69
|
+
var onResize = props.onResize, propsWidth = props.width, className = props.className, isLastColumn = props.isLastColumn, restProps = __rest(props, ["onResize", "width", "className", "isLastColumn"]);
|
70
|
+
var _a = __read(react_1.useState(propsWidth), 2), width = _a[0], setWidth = _a[1];
|
71
|
+
var contentRef = react_1.useRef(null);
|
72
|
+
react_1.useEffect(function () {
|
73
|
+
// Set the initial width based on content
|
74
|
+
if (!width && contentRef.current) {
|
75
|
+
setWidth(contentRef.current.offsetWidth);
|
76
|
+
}
|
77
|
+
}, [width]);
|
78
|
+
var handleResize = function (event, params) {
|
79
|
+
setWidth(params.size.width);
|
80
|
+
onResize(event, params);
|
81
|
+
};
|
82
|
+
// 最后一列不添加拖拽按钮
|
83
|
+
if (!onResize || isLastColumn) {
|
36
84
|
return (react_1.default.createElement("th", __assign({}, restProps, { className: classnames_1.default(className, style_1.SDK_PREFIX + "-table-resizable-th") })));
|
37
85
|
}
|
38
|
-
return (react_1.default.createElement(react_resizable_1.Resizable, { width: width, height: 0, onResize:
|
86
|
+
return (react_1.default.createElement(react_resizable_1.Resizable, { axis: "x", width: width, className: style_1.SDK_PREFIX + "-table-resizable-Resizable", height: 0, onResize: handleResize, minConstraints: [40, 0], draggableOpts: { enableUserSelectHack: false }, handle: react_1.default.createElement("span", { className: style_1.SDK_PREFIX + "-table-resizable-handle", onClick: function (e) {
|
39
87
|
e.preventDefault();
|
40
88
|
e.stopPropagation();
|
41
89
|
} },
|
42
90
|
react_1.default.createElement(pandora_component_icons_1.Resizable, null)) },
|
43
|
-
react_1.default.createElement("th", __assign({}, restProps, { className: classnames_1.default(className, style_1.SDK_PREFIX + "-table-resizable-th") }))));
|
91
|
+
react_1.default.createElement("th", __assign({}, restProps, { className: classnames_1.default(className, style_1.SDK_PREFIX + "-table-resizable-th"), ref: contentRef }))));
|
44
92
|
};
|
45
93
|
exports.default = ResizableTitle;
|
@@ -1,13 +1,14 @@
|
|
1
|
+
.pandora-sdk-table-resizable-th {
|
2
|
+
width: 100%;
|
3
|
+
}
|
1
4
|
.pandora-sdk-table-resizable-th .pandora-sdk-table-resizable-handle {
|
2
5
|
position: absolute;
|
3
6
|
cursor: col-resize;
|
4
|
-
right:
|
5
|
-
margin-left: 6px;
|
7
|
+
right: 1px;
|
6
8
|
height: 40%;
|
7
9
|
top: 50%;
|
8
10
|
-webkit-transform: translateY(-50%);
|
9
11
|
transform: translateY(-50%);
|
10
|
-
padding: 2px;
|
11
12
|
width: 8px;
|
12
13
|
opacity: 0;
|
13
14
|
-webkit-transition: opacity 0.2s ease-in-out;
|
@@ -1,15 +1,14 @@
|
|
1
1
|
@import '../../../style/theme.less';
|
2
2
|
|
3
3
|
.@{sdk-prefix}-table-resizable-th {
|
4
|
+
width: 100%;
|
4
5
|
.@{sdk-prefix}-table-resizable-handle {
|
5
6
|
position: absolute;
|
6
7
|
cursor: col-resize;
|
7
|
-
right:
|
8
|
-
margin-left: 6px;
|
8
|
+
right: 1px;
|
9
9
|
height: 40%;
|
10
10
|
top: 50%;
|
11
11
|
transform: translateY(-50%);
|
12
|
-
padding: 2px;
|
13
12
|
width: 8px;
|
14
13
|
opacity: 0;
|
15
14
|
transition: opacity 0.2s ease-in-out;
|
@@ -61,6 +61,12 @@ export interface ITableProps<T> extends Omit<TableProps<T>, 'columns'> {
|
|
61
61
|
draggable?: boolean | ETableSettingType;
|
62
62
|
saveSettingKey?: string;
|
63
63
|
onSettingChange?: (fields: ISaveFieldItem[]) => void;
|
64
|
+
/**
|
65
|
+
* 是否需要填充空白列, 默认为true
|
66
|
+
* 如果支持拖拽,在屏幕宽度大于table总的列宽的时候,会把剩余空间平均分到每一列上。那么拖拽一列会导致其他列的宽度都发生变更
|
67
|
+
* 添加一个空白列,宽度auto.可以解决此问题。如果可以接受上述问题,那就无需空白列,needEmptyColumn = false
|
68
|
+
*/
|
69
|
+
needEmptyColumn?: boolean;
|
64
70
|
}
|
65
71
|
/**
|
66
72
|
* pandora2.0风格的表格
|
@@ -108,7 +114,7 @@ declare class Table<T = any> extends React.Component<ITableProps<T>, any> {
|
|
108
114
|
updateSettingFields(columns: Array<IColumnType<T>>, settingFields: ISaveFieldItem[]): void;
|
109
115
|
handleHideColumnsChange(keys: string[]): Promise<void> | undefined;
|
110
116
|
getSortedColumns(): IKeyValues<any>[];
|
111
|
-
transfromColumns(columns: IKeyValues[]): IKeyValues<any>[];
|
117
|
+
transfromColumns(columns: IKeyValues[], needEmptyColumn?: boolean): IKeyValues<any>[];
|
112
118
|
getColumns(): IKeyValues<any>[];
|
113
119
|
getRowKey(row: any, index: number): any;
|
114
120
|
getSortCoulmns(columns: IKeyValues[]): IKeyValues<any>[];
|
@@ -412,8 +412,8 @@ var Table = /** @class */ (function (_super) {
|
|
412
412
|
};
|
413
413
|
// 如果支持拖拽,在屏幕宽度大于table总的列宽的时候,添加一个空白列,宽度auto.
|
414
414
|
// 空白列添加到右固定列的前面
|
415
|
-
Table.prototype.transfromColumns = function (columns) {
|
416
|
-
if (!this.resizable)
|
415
|
+
Table.prototype.transfromColumns = function (columns, needEmptyColumn) {
|
416
|
+
if (!this.resizable || needEmptyColumn === false)
|
417
417
|
return columns;
|
418
418
|
var cols = __spread(columns);
|
419
419
|
var firstFixedRightIndex = cols.findIndex(function (item) { return lodash_1.get(item, 'fixed') === 'right'; });
|
@@ -431,14 +431,14 @@ var Table = /** @class */ (function (_super) {
|
|
431
431
|
return cols;
|
432
432
|
};
|
433
433
|
Table.prototype.getColumns = function () {
|
434
|
-
var _a = this.props, showColumnSetting = _a.showColumnSetting, columnSettingOverlayClass = _a.columnSettingOverlayClass;
|
434
|
+
var _a = this.props, showColumnSetting = _a.showColumnSetting, columnSettingOverlayClass = _a.columnSettingOverlayClass, needEmptyColumn = _a.needEmptyColumn;
|
435
435
|
if (!showColumnSetting) {
|
436
|
-
return this.transfromColumns(this.columns);
|
436
|
+
return this.transfromColumns(this.columns, needEmptyColumn);
|
437
437
|
}
|
438
438
|
// 获取到列设置的options
|
439
439
|
var columnsSettingOptions = this.columnsSettingOptions;
|
440
440
|
var allCols = this.getSortedColumns();
|
441
|
-
this.transfromColumns(allCols);
|
441
|
+
this.transfromColumns(allCols, needEmptyColumn);
|
442
442
|
var length = allCols.length;
|
443
443
|
if (length > 0) {
|
444
444
|
var title = (React.createElement("span", { className: style_1.SDK_PREFIX + "-last-column-title" },
|
@@ -570,6 +570,7 @@ var Table = /** @class */ (function (_super) {
|
|
570
570
|
return noneSelected || disabled;
|
571
571
|
};
|
572
572
|
Table.prototype.handleResize = function (col, size, oldColumn) {
|
573
|
+
console.log('handleResize', col, size);
|
573
574
|
var newColumns = __spread(oldColumn);
|
574
575
|
newColumns.forEach(function (item) {
|
575
576
|
if (lodash_1.get(item, 'dataIndex') === col.dataIndex) {
|
@@ -579,11 +580,18 @@ var Table = /** @class */ (function (_super) {
|
|
579
580
|
var sizeMap = {};
|
580
581
|
var setttingFields = this.settingFields;
|
581
582
|
newColumns.forEach(function (element) {
|
582
|
-
if (element.dataIndex &&
|
583
|
+
if (element.dataIndex &&
|
584
|
+
lodash_1.isNumber(element.width) &&
|
585
|
+
!isNaN(element.width)) {
|
583
586
|
sizeMap[element.dataIndex] = element.width;
|
584
587
|
}
|
585
588
|
});
|
586
589
|
if (this.props.onSettingChange) {
|
590
|
+
setttingFields.forEach(function (field) {
|
591
|
+
if (sizeMap[field.field]) {
|
592
|
+
field.width = sizeMap[field.field];
|
593
|
+
}
|
594
|
+
});
|
587
595
|
this.props.onSettingChange(setttingFields);
|
588
596
|
}
|
589
597
|
else if (this.resizable && this.props.saveSettingKey) {
|
@@ -607,18 +615,22 @@ var Table = /** @class */ (function (_super) {
|
|
607
615
|
return lodash_1.isNumber(width) ? __assign(__assign({}, col), { width: width }) : col;
|
608
616
|
});
|
609
617
|
}
|
610
|
-
var transformColumns = columns === null || columns === void 0 ? void 0 : columns.map(function (it) {
|
618
|
+
var transformColumns = columns === null || columns === void 0 ? void 0 : columns.map(function (it, index) {
|
611
619
|
if (lodash_1.get(it, 'resizable') && _this.resizable) {
|
612
620
|
return __assign(__assign({}, it), { ellipsis: {
|
613
621
|
showTitle: true
|
614
|
-
}, onHeaderCell: function (col) {
|
615
|
-
|
616
|
-
|
617
|
-
|
618
|
-
|
619
|
-
|
620
|
-
|
621
|
-
|
622
|
+
}, onHeaderCell: function (col) {
|
623
|
+
var _a;
|
624
|
+
return ({
|
625
|
+
width: col.width,
|
626
|
+
// !传入newColumn,而不传入column是因为需要拿到有onHeaderCell的值,外面collumn的变化内部监听不到
|
627
|
+
onResize: function (_, _a) {
|
628
|
+
var size = _a.size;
|
629
|
+
_this.handleResize(col, size, transformColumns);
|
630
|
+
},
|
631
|
+
isLastColumn: index === ((_a = (columns || [])) === null || _a === void 0 ? void 0 : _a.length) - 1
|
632
|
+
});
|
633
|
+
} });
|
622
634
|
}
|
623
635
|
return it;
|
624
636
|
});
|
@@ -775,7 +787,7 @@ var Table = /** @class */ (function (_super) {
|
|
775
787
|
__decorate([
|
776
788
|
bind_1.default,
|
777
789
|
__metadata("design:type", Function),
|
778
|
-
__metadata("design:paramtypes", [Array]),
|
790
|
+
__metadata("design:paramtypes", [Array, Boolean]),
|
779
791
|
__metadata("design:returntype", void 0)
|
780
792
|
], Table.prototype, "transfromColumns", null);
|
781
793
|
__decorate([
|