@douyinfe/semi-ui 2.31.1 → 2.31.2
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/dist/umd/semi-ui.js +45 -10
- package/dist/umd/semi-ui.js.map +1 -1
- package/dist/umd/semi-ui.min.js +1 -1
- package/dist/umd/semi-ui.min.js.map +1 -1
- package/lib/cjs/_utils/index.d.ts +2 -4
- package/lib/cjs/_utils/index.js +5 -5
- package/lib/cjs/navigation/Item.js +4 -2
- package/lib/cjs/navigation/nav-context.d.ts +2 -0
- package/lib/cjs/table/ResizableTable.js +1 -1
- package/lib/cjs/table/utils.d.ts +1 -0
- package/lib/cjs/table/utils.js +31 -1
- package/lib/es/_utils/index.d.ts +2 -4
- package/lib/es/_utils/index.js +5 -5
- package/lib/es/navigation/Item.js +4 -2
- package/lib/es/navigation/nav-context.d.ts +2 -0
- package/lib/es/table/ResizableTable.js +2 -2
- package/lib/es/table/utils.d.ts +1 -0
- package/lib/es/table/utils.js +27 -0
- package/package.json +8 -8
|
@@ -7,11 +7,9 @@ import React from 'react';
|
|
|
7
7
|
*/
|
|
8
8
|
export declare function stopPropagation(e: React.MouseEvent, noImmediate?: boolean): void;
|
|
9
9
|
/**
|
|
10
|
-
*
|
|
11
|
-
* @param {any} value
|
|
12
|
-
* @param {Function} customizer
|
|
13
|
-
* @returns {any}
|
|
14
10
|
* use in Table, Form, Navigation
|
|
11
|
+
*
|
|
12
|
+
* skip clone function and react element
|
|
15
13
|
*/
|
|
16
14
|
export declare function cloneDeep(value: any, customizer?: (value: any) => void): any;
|
|
17
15
|
/**
|
package/lib/cjs/_utils/index.js
CHANGED
|
@@ -47,11 +47,9 @@ function stopPropagation(e, noImmediate) {
|
|
|
47
47
|
}
|
|
48
48
|
}
|
|
49
49
|
/**
|
|
50
|
-
*
|
|
51
|
-
* @param {any} value
|
|
52
|
-
* @param {Function} customizer
|
|
53
|
-
* @returns {any}
|
|
54
50
|
* use in Table, Form, Navigation
|
|
51
|
+
*
|
|
52
|
+
* skip clone function and react element
|
|
55
53
|
*/
|
|
56
54
|
|
|
57
55
|
|
|
@@ -67,7 +65,9 @@ function cloneDeep(value, customizer) {
|
|
|
67
65
|
|
|
68
66
|
if (Object.prototype.toString.call(v) === '[object Error]') {
|
|
69
67
|
return v;
|
|
70
|
-
}
|
|
68
|
+
} // it is tricky
|
|
69
|
+
// when array length beyond max length, array.length will be 0
|
|
70
|
+
|
|
71
71
|
|
|
72
72
|
if (Array.isArray(v) && v.length === 0) {
|
|
73
73
|
const keys = Object.keys(v);
|
|
@@ -53,12 +53,14 @@ class NavItem extends _baseComponent.default {
|
|
|
53
53
|
tooltipHideDelay,
|
|
54
54
|
tooltipShowDelay
|
|
55
55
|
} = this.props;
|
|
56
|
+
const hideDelay = tooltipHideDelay !== null && tooltipHideDelay !== void 0 ? tooltipHideDelay : this.context.tooltipHideDelay;
|
|
57
|
+
const showDelay = tooltipShowDelay !== null && tooltipShowDelay !== void 0 ? tooltipShowDelay : this.context.tooltipShowDelay;
|
|
56
58
|
return /*#__PURE__*/_react.default.createElement(_tooltip.default, {
|
|
57
59
|
content: text,
|
|
58
60
|
position: "right",
|
|
59
61
|
trigger: 'hover',
|
|
60
|
-
mouseEnterDelay:
|
|
61
|
-
mouseLeaveDelay:
|
|
62
|
+
mouseEnterDelay: showDelay,
|
|
63
|
+
mouseLeaveDelay: hideDelay
|
|
62
64
|
}, node);
|
|
63
65
|
};
|
|
64
66
|
|
|
@@ -21,6 +21,8 @@ export interface NavContextType {
|
|
|
21
21
|
canUpdateOpenKeys?: boolean;
|
|
22
22
|
renderWrapper?: NavProps['renderWrapper'];
|
|
23
23
|
getPopupContainer?: DropdownProps['getPopupContainer'];
|
|
24
|
+
tooltipShowDelay?: number;
|
|
25
|
+
tooltipHideDelay?: number;
|
|
24
26
|
}
|
|
25
27
|
declare const NavContext: React.Context<NavContextType>;
|
|
26
28
|
export default NavContext;
|
|
@@ -112,7 +112,7 @@ const ResizableTable = function () {
|
|
|
112
112
|
// If there is a resize value, the width does not use the default value fix#1072
|
|
113
113
|
const _newColumns = (0, _utils.withResizeWidth)(columns, newColumns);
|
|
114
114
|
|
|
115
|
-
setColumns((0,
|
|
115
|
+
setColumns((0, _utils2.mergeColumns)(columns, _newColumns));
|
|
116
116
|
}, [propColumns, props.expandedRowRender, props.hideExpandedColumn, props.rowSelection]);
|
|
117
117
|
const components = (0, _react.useMemo)(() => (0, _merge2.default)({
|
|
118
118
|
header: {
|
package/lib/cjs/table/utils.d.ts
CHANGED
|
@@ -39,4 +39,5 @@ export declare function mergeComponents(components: TableComponents, virtualized
|
|
|
39
39
|
};
|
|
40
40
|
} & TableComponents;
|
|
41
41
|
export declare const logger: Logger;
|
|
42
|
+
export declare function mergeColumns(oldColumns?: any[], newColumns?: any[], keyPropNames?: any[], deep?: boolean): any[];
|
|
42
43
|
export { cloneDeep };
|
package/lib/cjs/table/utils.js
CHANGED
|
@@ -12,8 +12,15 @@ Object.defineProperty(exports, "cloneDeep", {
|
|
|
12
12
|
});
|
|
13
13
|
exports.logger = void 0;
|
|
14
14
|
exports.measureScrollbar = measureScrollbar;
|
|
15
|
+
exports.mergeColumns = mergeColumns;
|
|
15
16
|
exports.mergeComponents = mergeComponents;
|
|
16
17
|
|
|
18
|
+
var _map2 = _interopRequireDefault(require("lodash/map"));
|
|
19
|
+
|
|
20
|
+
var _find2 = _interopRequireDefault(require("lodash/find"));
|
|
21
|
+
|
|
22
|
+
var _clone2 = _interopRequireDefault(require("lodash/clone"));
|
|
23
|
+
|
|
17
24
|
var _merge2 = _interopRequireDefault(require("lodash/merge"));
|
|
18
25
|
|
|
19
26
|
var _Logger = _interopRequireDefault(require("@douyinfe/semi-foundation/lib/cjs/utils/Logger"));
|
|
@@ -22,6 +29,8 @@ var _constants = require("@douyinfe/semi-foundation/lib/cjs/table/constants");
|
|
|
22
29
|
|
|
23
30
|
var _utils = require("../_utils");
|
|
24
31
|
|
|
32
|
+
var _utils2 = require("@douyinfe/semi-foundation/lib/cjs/table/utils");
|
|
33
|
+
|
|
25
34
|
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
26
35
|
|
|
27
36
|
let scrollbarVerticalSize, scrollbarHorizontalSize; // Measure scrollbar width for padding body during modal show/hide
|
|
@@ -130,4 +139,25 @@ function mergeComponents(components, virtualized) {
|
|
|
130
139
|
}
|
|
131
140
|
|
|
132
141
|
const logger = new _Logger.default('[@douyinfe/semi-ui Table]');
|
|
133
|
-
exports.logger = logger;
|
|
142
|
+
exports.logger = logger;
|
|
143
|
+
|
|
144
|
+
function mergeColumns() {
|
|
145
|
+
let oldColumns = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : [];
|
|
146
|
+
let newColumns = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : [];
|
|
147
|
+
let keyPropNames = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : null;
|
|
148
|
+
let deep = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : true;
|
|
149
|
+
const finalColumns = [];
|
|
150
|
+
const clone = deep ? _utils.cloneDeep : _clone2.default;
|
|
151
|
+
(0, _map2.default)(newColumns, newColumn => {
|
|
152
|
+
newColumn = Object.assign({}, newColumn);
|
|
153
|
+
const key = (0, _utils2.getColumnKey)(newColumn, keyPropNames);
|
|
154
|
+
const oldColumn = key != null && (0, _find2.default)(oldColumns, item => (0, _utils2.getColumnKey)(item, keyPropNames) === key);
|
|
155
|
+
|
|
156
|
+
if (oldColumn) {
|
|
157
|
+
finalColumns.push(clone(Object.assign(Object.assign({}, oldColumn), newColumn)));
|
|
158
|
+
} else {
|
|
159
|
+
finalColumns.push(clone(newColumn));
|
|
160
|
+
}
|
|
161
|
+
});
|
|
162
|
+
return finalColumns;
|
|
163
|
+
}
|
package/lib/es/_utils/index.d.ts
CHANGED
|
@@ -7,11 +7,9 @@ import React from 'react';
|
|
|
7
7
|
*/
|
|
8
8
|
export declare function stopPropagation(e: React.MouseEvent, noImmediate?: boolean): void;
|
|
9
9
|
/**
|
|
10
|
-
*
|
|
11
|
-
* @param {any} value
|
|
12
|
-
* @param {Function} customizer
|
|
13
|
-
* @returns {any}
|
|
14
10
|
* use in Table, Form, Navigation
|
|
11
|
+
*
|
|
12
|
+
* skip clone function and react element
|
|
15
13
|
*/
|
|
16
14
|
export declare function cloneDeep(value: any, customizer?: (value: any) => void): any;
|
|
17
15
|
/**
|
package/lib/es/_utils/index.js
CHANGED
|
@@ -26,11 +26,9 @@ export function stopPropagation(e, noImmediate) {
|
|
|
26
26
|
}
|
|
27
27
|
}
|
|
28
28
|
/**
|
|
29
|
-
*
|
|
30
|
-
* @param {any} value
|
|
31
|
-
* @param {Function} customizer
|
|
32
|
-
* @returns {any}
|
|
33
29
|
* use in Table, Form, Navigation
|
|
30
|
+
*
|
|
31
|
+
* skip clone function and react element
|
|
34
32
|
*/
|
|
35
33
|
|
|
36
34
|
export function cloneDeep(value, customizer) {
|
|
@@ -45,7 +43,9 @@ export function cloneDeep(value, customizer) {
|
|
|
45
43
|
|
|
46
44
|
if (Object.prototype.toString.call(v) === '[object Error]') {
|
|
47
45
|
return v;
|
|
48
|
-
}
|
|
46
|
+
} // it is tricky
|
|
47
|
+
// when array length beyond max length, array.length will be 0
|
|
48
|
+
|
|
49
49
|
|
|
50
50
|
if (Array.isArray(v) && v.length === 0) {
|
|
51
51
|
const keys = Object.keys(v);
|
|
@@ -31,12 +31,14 @@ export default class NavItem extends BaseComponent {
|
|
|
31
31
|
tooltipHideDelay,
|
|
32
32
|
tooltipShowDelay
|
|
33
33
|
} = this.props;
|
|
34
|
+
const hideDelay = tooltipHideDelay !== null && tooltipHideDelay !== void 0 ? tooltipHideDelay : this.context.tooltipHideDelay;
|
|
35
|
+
const showDelay = tooltipShowDelay !== null && tooltipShowDelay !== void 0 ? tooltipShowDelay : this.context.tooltipShowDelay;
|
|
34
36
|
return /*#__PURE__*/React.createElement(Tooltip, {
|
|
35
37
|
content: text,
|
|
36
38
|
position: "right",
|
|
37
39
|
trigger: 'hover',
|
|
38
|
-
mouseEnterDelay:
|
|
39
|
-
mouseLeaveDelay:
|
|
40
|
+
mouseEnterDelay: showDelay,
|
|
41
|
+
mouseLeaveDelay: hideDelay
|
|
40
42
|
}, node);
|
|
41
43
|
};
|
|
42
44
|
|
|
@@ -21,6 +21,8 @@ export interface NavContextType {
|
|
|
21
21
|
canUpdateOpenKeys?: boolean;
|
|
22
22
|
renderWrapper?: NavProps['renderWrapper'];
|
|
23
23
|
getPopupContainer?: DropdownProps['getPopupContainer'];
|
|
24
|
+
tooltipShowDelay?: number;
|
|
25
|
+
tooltipHideDelay?: number;
|
|
24
26
|
}
|
|
25
27
|
declare const NavContext: React.Context<NavContextType>;
|
|
26
28
|
export default NavContext;
|
|
@@ -27,9 +27,9 @@ var __rest = this && this.__rest || function (s, e) {
|
|
|
27
27
|
import React, { useState, useEffect, useMemo } from 'react';
|
|
28
28
|
import { addClass, removeClass } from '@douyinfe/semi-foundation/lib/es/utils/classnames';
|
|
29
29
|
import { strings, numbers } from '@douyinfe/semi-foundation/lib/es/table/constants';
|
|
30
|
-
import {
|
|
30
|
+
import { assignColumnKeys, findColumn, withResizeWidth } from '@douyinfe/semi-foundation/lib/es/table/utils';
|
|
31
31
|
import Table from './Table';
|
|
32
|
-
import { cloneDeep } from './utils';
|
|
32
|
+
import { cloneDeep, mergeColumns } from './utils';
|
|
33
33
|
import getColumns from './getColumns';
|
|
34
34
|
import ResizableHeaderCell from './ResizableHeaderCell';
|
|
35
35
|
|
package/lib/es/table/utils.d.ts
CHANGED
|
@@ -39,4 +39,5 @@ export declare function mergeComponents(components: TableComponents, virtualized
|
|
|
39
39
|
};
|
|
40
40
|
} & TableComponents;
|
|
41
41
|
export declare const logger: Logger;
|
|
42
|
+
export declare function mergeColumns(oldColumns?: any[], newColumns?: any[], keyPropNames?: any[], deep?: boolean): any[];
|
|
42
43
|
export { cloneDeep };
|
package/lib/es/table/utils.js
CHANGED
|
@@ -1,7 +1,11 @@
|
|
|
1
|
+
import _map from "lodash/map";
|
|
2
|
+
import _find from "lodash/find";
|
|
3
|
+
import _clone from "lodash/clone";
|
|
1
4
|
import _merge from "lodash/merge";
|
|
2
5
|
import Logger from '@douyinfe/semi-foundation/lib/es/utils/Logger';
|
|
3
6
|
import { numbers } from '@douyinfe/semi-foundation/lib/es/table/constants';
|
|
4
7
|
import { cloneDeep } from '../_utils';
|
|
8
|
+
import { getColumnKey } from '@douyinfe/semi-foundation/lib/es/table/utils';
|
|
5
9
|
let scrollbarVerticalSize, scrollbarHorizontalSize; // Measure scrollbar width for padding body during modal show/hide
|
|
6
10
|
|
|
7
11
|
const scrollbarMeasure = {
|
|
@@ -105,4 +109,27 @@ export function mergeComponents(components, virtualized) {
|
|
|
105
109
|
}, components);
|
|
106
110
|
}
|
|
107
111
|
export const logger = new Logger('[@douyinfe/semi-ui Table]');
|
|
112
|
+
export function mergeColumns() {
|
|
113
|
+
let oldColumns = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : [];
|
|
114
|
+
let newColumns = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : [];
|
|
115
|
+
let keyPropNames = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : null;
|
|
116
|
+
let deep = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : true;
|
|
117
|
+
const finalColumns = [];
|
|
118
|
+
const clone = deep ? cloneDeep : _clone;
|
|
119
|
+
|
|
120
|
+
_map(newColumns, newColumn => {
|
|
121
|
+
newColumn = Object.assign({}, newColumn);
|
|
122
|
+
const key = getColumnKey(newColumn, keyPropNames);
|
|
123
|
+
|
|
124
|
+
const oldColumn = key != null && _find(oldColumns, item => getColumnKey(item, keyPropNames) === key);
|
|
125
|
+
|
|
126
|
+
if (oldColumn) {
|
|
127
|
+
finalColumns.push(clone(Object.assign(Object.assign({}, oldColumn), newColumn)));
|
|
128
|
+
} else {
|
|
129
|
+
finalColumns.push(clone(newColumn));
|
|
130
|
+
}
|
|
131
|
+
});
|
|
132
|
+
|
|
133
|
+
return finalColumns;
|
|
134
|
+
}
|
|
108
135
|
export { cloneDeep };
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@douyinfe/semi-ui",
|
|
3
|
-
"version": "2.31.
|
|
3
|
+
"version": "2.31.2",
|
|
4
4
|
"description": "",
|
|
5
5
|
"main": "lib/cjs/index.js",
|
|
6
6
|
"module": "lib/es/index.js",
|
|
@@ -17,12 +17,12 @@
|
|
|
17
17
|
"lib/*"
|
|
18
18
|
],
|
|
19
19
|
"dependencies": {
|
|
20
|
-
"@douyinfe/semi-animation": "2.31.
|
|
21
|
-
"@douyinfe/semi-animation-react": "2.31.
|
|
22
|
-
"@douyinfe/semi-foundation": "2.31.
|
|
23
|
-
"@douyinfe/semi-icons": "2.31.
|
|
24
|
-
"@douyinfe/semi-illustrations": "2.31.
|
|
25
|
-
"@douyinfe/semi-theme-default": "2.31.
|
|
20
|
+
"@douyinfe/semi-animation": "2.31.2",
|
|
21
|
+
"@douyinfe/semi-animation-react": "2.31.2",
|
|
22
|
+
"@douyinfe/semi-foundation": "2.31.2",
|
|
23
|
+
"@douyinfe/semi-icons": "2.31.2",
|
|
24
|
+
"@douyinfe/semi-illustrations": "2.31.2",
|
|
25
|
+
"@douyinfe/semi-theme-default": "2.31.2",
|
|
26
26
|
"async-validator": "^3.5.0",
|
|
27
27
|
"classnames": "^2.2.6",
|
|
28
28
|
"copy-text-to-clipboard": "^2.1.1",
|
|
@@ -69,7 +69,7 @@
|
|
|
69
69
|
],
|
|
70
70
|
"author": "",
|
|
71
71
|
"license": "MIT",
|
|
72
|
-
"gitHead": "
|
|
72
|
+
"gitHead": "43a8fa54b5c662bad2fbb53603846b5c33f5d8da",
|
|
73
73
|
"devDependencies": {
|
|
74
74
|
"@babel/plugin-proposal-decorators": "^7.15.8",
|
|
75
75
|
"@babel/plugin-transform-runtime": "^7.15.8",
|