@douyinfe/semi-ui 2.54.1 → 2.55.0
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/css/semi.css +40 -40
- package/dist/css/semi.min.css +1 -1
- package/dist/umd/semi-ui.js +111 -93
- 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/_base/base.css +40 -40
- package/lib/cjs/_sortable/index.d.ts +1 -1
- package/lib/cjs/_sortable/index.js +13 -19
- package/lib/cjs/button/splitButtonGroup.d.ts +2 -0
- package/lib/cjs/button/splitButtonGroup.js +29 -3
- package/lib/cjs/descriptions/index.js +19 -2
- package/lib/cjs/descriptions/item.js +1 -1
- package/lib/cjs/navigation/index.d.ts +2 -1
- package/lib/cjs/tabs/index.d.ts +1 -0
- package/lib/cjs/tabs/index.js +31 -54
- package/lib/es/_base/base.css +40 -40
- package/lib/es/_sortable/index.d.ts +1 -1
- package/lib/es/_sortable/index.js +13 -19
- package/lib/es/button/splitButtonGroup.d.ts +2 -0
- package/lib/es/button/splitButtonGroup.js +29 -3
- package/lib/es/descriptions/index.js +17 -2
- package/lib/es/descriptions/item.js +1 -1
- package/lib/es/navigation/index.d.ts +2 -1
- package/lib/es/tabs/index.d.ts +1 -0
- package/lib/es/tabs/index.js +31 -54
- package/package.json +8 -8
package/dist/umd/semi-ui.js
CHANGED
|
@@ -46281,10 +46281,6 @@ function sortable_esm_isAfter(a, b) {
|
|
|
46281
46281
|
|
|
46282
46282
|
|
|
46283
46283
|
const defaultPrefix = 'semi-sortable';
|
|
46284
|
-
const defaultConstraint = {
|
|
46285
|
-
delay: 150,
|
|
46286
|
-
tolerance: 5
|
|
46287
|
-
};
|
|
46288
46284
|
function DefaultContainer(props) {
|
|
46289
46285
|
return /*#__PURE__*/external_root_React_commonjs2_react_commonjs_react_amd_react_default().createElement("div", Object.assign({
|
|
46290
46286
|
style: {
|
|
@@ -46292,6 +46288,9 @@ function DefaultContainer(props) {
|
|
|
46292
46288
|
}
|
|
46293
46289
|
}, props));
|
|
46294
46290
|
}
|
|
46291
|
+
const defaultKeyBoardOptions = {
|
|
46292
|
+
coordinateGetter: sortableKeyboardCoordinates
|
|
46293
|
+
};
|
|
46295
46294
|
function Sortable(_ref) {
|
|
46296
46295
|
let {
|
|
46297
46296
|
items,
|
|
@@ -46299,7 +46298,6 @@ function Sortable(_ref) {
|
|
|
46299
46298
|
adjustScale,
|
|
46300
46299
|
renderItem,
|
|
46301
46300
|
transition,
|
|
46302
|
-
activationConstraint = defaultConstraint,
|
|
46303
46301
|
collisionDetection = closestCenter,
|
|
46304
46302
|
strategy = rectSortingStrategy,
|
|
46305
46303
|
useDragOverlay = true,
|
|
@@ -46308,13 +46306,7 @@ function Sortable(_ref) {
|
|
|
46308
46306
|
prefix = defaultPrefix
|
|
46309
46307
|
} = _ref;
|
|
46310
46308
|
const [activeId, setActiveId] = (0,external_root_React_commonjs2_react_commonjs_react_amd_react_.useState)(null);
|
|
46311
|
-
const sensors = useSensors(useSensor(MouseSensor,
|
|
46312
|
-
activationConstraint
|
|
46313
|
-
}), useSensor(TouchSensor, {
|
|
46314
|
-
activationConstraint
|
|
46315
|
-
}), useSensor(KeyboardSensor, {
|
|
46316
|
-
coordinateGetter: sortableKeyboardCoordinates
|
|
46317
|
-
}));
|
|
46309
|
+
const sensors = useSensors(useSensor(MouseSensor), useSensor(TouchSensor), useSensor(KeyboardSensor, defaultKeyBoardOptions));
|
|
46318
46310
|
const getIndex = (0,external_root_React_commonjs2_react_commonjs_react_amd_react_.useCallback)(id => items.indexOf(id), [items]);
|
|
46319
46311
|
const activeIndex = (0,external_root_React_commonjs2_react_commonjs_react_amd_react_.useMemo)(() => activeId ? getIndex(activeId) : -1, [getIndex, activeId]);
|
|
46320
46312
|
const onDragStart = (0,external_root_React_commonjs2_react_commonjs_react_amd_react_.useCallback)(_ref2 => {
|
|
@@ -46424,13 +46416,15 @@ function SortableItem(_ref4) {
|
|
|
46424
46416
|
[`${prefix}-sortable-item-over`]: isOver,
|
|
46425
46417
|
[`${prefix}-sortable-item-active`]: (active === null || active === void 0 ? void 0 : active.id) === id
|
|
46426
46418
|
});
|
|
46427
|
-
const wrapperStyle =
|
|
46428
|
-
|
|
46429
|
-
|
|
46430
|
-
|
|
46431
|
-
|
|
46432
|
-
|
|
46433
|
-
|
|
46419
|
+
const wrapperStyle = (0,external_root_React_commonjs2_react_commonjs_react_amd_react_.useMemo)(() => {
|
|
46420
|
+
return !isNull_default()(animation) ? {
|
|
46421
|
+
transform: CSS.Transform.toString(Object.assign(Object.assign({}, transform), {
|
|
46422
|
+
scaleX: 1,
|
|
46423
|
+
scaleY: 1
|
|
46424
|
+
})),
|
|
46425
|
+
transition: transition
|
|
46426
|
+
} : undefined;
|
|
46427
|
+
}, [animation, transform, transition]);
|
|
46434
46428
|
return /*#__PURE__*/external_root_React_commonjs2_react_commonjs_react_amd_react_default().createElement("div", Object.assign({
|
|
46435
46429
|
ref: setNodeRef,
|
|
46436
46430
|
style: wrapperStyle,
|
|
@@ -60842,7 +60836,7 @@ class item_Item extends external_root_React_commonjs2_react_commonjs_react_amd_r
|
|
|
60842
60836
|
className: keyCls
|
|
60843
60837
|
}, itemKey)), /*#__PURE__*/external_root_React_commonjs2_react_commonjs_react_amd_react_default().createElement("td", {
|
|
60844
60838
|
className: `${item_prefixCls}-item ${item_prefixCls}-item-td`,
|
|
60845
|
-
colSpan: span
|
|
60839
|
+
colSpan: span ? span * 2 - 1 : 1
|
|
60846
60840
|
}, /*#__PURE__*/external_root_React_commonjs2_react_commonjs_react_amd_react_default().createElement("span", {
|
|
60847
60841
|
className: valCls
|
|
60848
60842
|
}, typeof children === 'function' ? children() : children)));
|
|
@@ -60876,14 +60870,7 @@ class DescriptionsFoundation extends foundation {
|
|
|
60876
60870
|
data,
|
|
60877
60871
|
children
|
|
60878
60872
|
} = this.getProps();
|
|
60879
|
-
|
|
60880
|
-
if (data === null || data === void 0 ? void 0 : data.length) {
|
|
60881
|
-
columns = data || [];
|
|
60882
|
-
} else {
|
|
60883
|
-
columns = (children === null || children === void 0 ? void 0 : children.map(item => Object.assign({
|
|
60884
|
-
value: item.props.children
|
|
60885
|
-
}, item.props))) || [];
|
|
60886
|
-
}
|
|
60873
|
+
const columns = this._adapter.getColumns();
|
|
60887
60874
|
const horizontalList = [];
|
|
60888
60875
|
const curSpan = {
|
|
60889
60876
|
totalSpan: 0,
|
|
@@ -60898,7 +60885,19 @@ class DescriptionsFoundation extends foundation {
|
|
|
60898
60885
|
curSpan.totalSpan = 0;
|
|
60899
60886
|
}
|
|
60900
60887
|
}
|
|
60901
|
-
if (curSpan.itemList.length != 0)
|
|
60888
|
+
if (curSpan.itemList.length != 0) {
|
|
60889
|
+
const lastSpan = curSpan.itemList[curSpan.itemList.length - 1];
|
|
60890
|
+
if (isNaN(lastSpan.span)) {
|
|
60891
|
+
let total = 0;
|
|
60892
|
+
curSpan.itemList.forEach(item => {
|
|
60893
|
+
return total += !isNaN(item.span) ? item.span : 1;
|
|
60894
|
+
});
|
|
60895
|
+
if (total < column) {
|
|
60896
|
+
lastSpan.span = column - total + 1;
|
|
60897
|
+
}
|
|
60898
|
+
}
|
|
60899
|
+
horizontalList.push(curSpan.itemList);
|
|
60900
|
+
}
|
|
60902
60901
|
return horizontalList;
|
|
60903
60902
|
}
|
|
60904
60903
|
}
|
|
@@ -60955,7 +60954,22 @@ class Descriptions extends BaseComponent {
|
|
|
60955
60954
|
this.foundation = new DescriptionsFoundation(this.adapter);
|
|
60956
60955
|
}
|
|
60957
60956
|
get adapter() {
|
|
60958
|
-
return Object.assign({}, super.adapter)
|
|
60957
|
+
return Object.assign(Object.assign({}, super.adapter), {
|
|
60958
|
+
getColumns: () => {
|
|
60959
|
+
var _a, _b;
|
|
60960
|
+
if ((_a = this.props.data) === null || _a === void 0 ? void 0 : _a.length) {
|
|
60961
|
+
return this.props.data;
|
|
60962
|
+
}
|
|
60963
|
+
if (this.props.children) {
|
|
60964
|
+
return (_b = external_root_React_commonjs2_react_commonjs_react_amd_react_default().Children.toArray(this.props.children)) === null || _b === void 0 ? void 0 : _b.map(item => {
|
|
60965
|
+
return /*#__PURE__*/(0,external_root_React_commonjs2_react_commonjs_react_amd_react_.isValidElement)(item) ? Object.assign({
|
|
60966
|
+
value: item.props.children
|
|
60967
|
+
}, item.props) : [];
|
|
60968
|
+
});
|
|
60969
|
+
}
|
|
60970
|
+
return [];
|
|
60971
|
+
}
|
|
60972
|
+
});
|
|
60959
60973
|
}
|
|
60960
60974
|
render() {
|
|
60961
60975
|
const _a = this.props,
|
|
@@ -65997,10 +66011,14 @@ class NavigationFoundation extends foundation {
|
|
|
65997
66011
|
selectedKeys,
|
|
65998
66012
|
mode
|
|
65999
66013
|
} = this.getProps();
|
|
66014
|
+
const {
|
|
66015
|
+
openKeys: stateOpenKeys = []
|
|
66016
|
+
} = this.getStates();
|
|
66000
66017
|
let willOpenKeys = openKeys || defaultOpenKeys || [];
|
|
66001
66018
|
if (!(Array.isArray(defaultOpenKeys) || Array.isArray(openKeys)) && mode === navigation_constants_strings.MODE_VERTICAL && (Array.isArray(defaultSelectedKeys) || Array.isArray(selectedKeys))) {
|
|
66002
66019
|
const currentSelectedKeys = Array.isArray(selectedKeys) ? selectedKeys : defaultSelectedKeys;
|
|
66003
|
-
willOpenKeys = this.getShouldOpenKeys(itemKeysMap, currentSelectedKeys);
|
|
66020
|
+
willOpenKeys = stateOpenKeys.concat(this.getShouldOpenKeys(itemKeysMap, currentSelectedKeys));
|
|
66021
|
+
willOpenKeys = Array.from(new Set(willOpenKeys));
|
|
66004
66022
|
}
|
|
66005
66023
|
return [...willOpenKeys];
|
|
66006
66024
|
}
|
|
@@ -66021,13 +66039,10 @@ class NavigationFoundation extends foundation {
|
|
|
66021
66039
|
return [...willOpenKeySet];
|
|
66022
66040
|
}
|
|
66023
66041
|
destroy() {}
|
|
66024
|
-
selectLevelZeroParentKeys(itemKeysMap) {
|
|
66042
|
+
selectLevelZeroParentKeys(itemKeysMap, itemKeys) {
|
|
66025
66043
|
const _itemKeysMap = isNullOrUndefined(itemKeysMap) ? this.getState('itemKeysMap') : itemKeysMap;
|
|
66026
66044
|
// console.log(itemKeysMap);
|
|
66027
66045
|
const willAddKeys = [];
|
|
66028
|
-
for (var _len2 = arguments.length, itemKeys = new Array(_len2 > 1 ? _len2 - 1 : 0), _key2 = 1; _key2 < _len2; _key2++) {
|
|
66029
|
-
itemKeys[_key2 - 1] = arguments[_key2];
|
|
66030
|
-
}
|
|
66031
66046
|
if (itemKeys.length) {
|
|
66032
66047
|
for (const itemKey of itemKeys) {
|
|
66033
66048
|
if (Array.isArray(_itemKeysMap[itemKey]) && _itemKeysMap[itemKey].length) {
|
|
@@ -76986,16 +77001,42 @@ class SplitButtonGroup extends BaseComponent {
|
|
|
76986
77001
|
constructor() {
|
|
76987
77002
|
super(...arguments);
|
|
76988
77003
|
this.containerRef = /*#__PURE__*/external_root_React_commonjs2_react_commonjs_react_amd_react_default().createRef();
|
|
77004
|
+
this.mutationObserver = null;
|
|
76989
77005
|
}
|
|
76990
77006
|
componentDidMount() {
|
|
76991
|
-
|
|
77007
|
+
const addClassName = () => {
|
|
76992
77008
|
const buttons = this.containerRef.current.querySelectorAll('button');
|
|
76993
77009
|
const firstButton = buttons[0];
|
|
76994
77010
|
const lastButton = buttons[buttons.length - 1];
|
|
76995
|
-
firstButton === null || firstButton === void 0 ? void 0 : firstButton.classList.
|
|
76996
|
-
|
|
77011
|
+
if (!(firstButton === null || firstButton === void 0 ? void 0 : firstButton.classList.contains(`${splitButtonGroup_prefixCls}-first`))) {
|
|
77012
|
+
firstButton === null || firstButton === void 0 ? void 0 : firstButton.classList.add(`${splitButtonGroup_prefixCls}-first`);
|
|
77013
|
+
}
|
|
77014
|
+
if (!(lastButton === null || lastButton === void 0 ? void 0 : lastButton.classList.contains(`${splitButtonGroup_prefixCls}-last`))) {
|
|
77015
|
+
lastButton === null || lastButton === void 0 ? void 0 : lastButton.classList.add(`${splitButtonGroup_prefixCls}-last`);
|
|
77016
|
+
}
|
|
77017
|
+
};
|
|
77018
|
+
if (this.containerRef.current) {
|
|
77019
|
+
addClassName();
|
|
77020
|
+
const mutationObserver = new MutationObserver((mutations, observer) => {
|
|
77021
|
+
for (const mutation of mutations) {
|
|
77022
|
+
if (mutation.type === 'attributes' && mutation.attributeName === 'class' || mutation.type === 'childList' && Array.from(mutation.addedNodes).some(node => node.nodeName === 'BUTTON')) {
|
|
77023
|
+
addClassName();
|
|
77024
|
+
}
|
|
77025
|
+
}
|
|
77026
|
+
});
|
|
77027
|
+
mutationObserver.observe(this.containerRef.current, {
|
|
77028
|
+
attributes: true,
|
|
77029
|
+
childList: true,
|
|
77030
|
+
subtree: true
|
|
77031
|
+
});
|
|
77032
|
+
this.mutationObserver = mutationObserver;
|
|
76997
77033
|
}
|
|
76998
77034
|
}
|
|
77035
|
+
componentWillUnmount() {
|
|
77036
|
+
var _a;
|
|
77037
|
+
super.componentWillUnmount();
|
|
77038
|
+
(_a = this.mutationObserver) === null || _a === void 0 ? void 0 : _a.disconnect();
|
|
77039
|
+
}
|
|
76999
77040
|
render() {
|
|
77000
77041
|
const {
|
|
77001
77042
|
children,
|
|
@@ -79430,7 +79471,7 @@ class TableFoundation extends foundation {
|
|
|
79430
79471
|
}
|
|
79431
79472
|
return true;
|
|
79432
79473
|
} else {
|
|
79433
|
-
const isAllSelected = allKeys.every(rowKey => selectedRowKeysSet.has(rowKey));
|
|
79474
|
+
const isAllSelected = allKeys.length && allKeys.every(rowKey => selectedRowKeysSet.has(rowKey));
|
|
79434
79475
|
return isAllSelected || false;
|
|
79435
79476
|
}
|
|
79436
79477
|
}
|
|
@@ -85207,6 +85248,34 @@ class Tabs extends BaseComponent {
|
|
|
85207
85248
|
current: ref
|
|
85208
85249
|
};
|
|
85209
85250
|
};
|
|
85251
|
+
this.getPanes = () => {
|
|
85252
|
+
const {
|
|
85253
|
+
tabList,
|
|
85254
|
+
children
|
|
85255
|
+
} = this.props;
|
|
85256
|
+
if (Array.isArray(tabList) && tabList.length) {
|
|
85257
|
+
return tabList;
|
|
85258
|
+
}
|
|
85259
|
+
return external_root_React_commonjs2_react_commonjs_react_amd_react_default().Children.map(children, child => {
|
|
85260
|
+
if (child) {
|
|
85261
|
+
const {
|
|
85262
|
+
tab,
|
|
85263
|
+
icon,
|
|
85264
|
+
disabled,
|
|
85265
|
+
itemKey,
|
|
85266
|
+
closable
|
|
85267
|
+
} = child.props;
|
|
85268
|
+
return {
|
|
85269
|
+
tab,
|
|
85270
|
+
icon,
|
|
85271
|
+
disabled,
|
|
85272
|
+
itemKey,
|
|
85273
|
+
closable
|
|
85274
|
+
};
|
|
85275
|
+
}
|
|
85276
|
+
return undefined;
|
|
85277
|
+
});
|
|
85278
|
+
};
|
|
85210
85279
|
this.onTabClick = (activeKey, event) => {
|
|
85211
85280
|
this.foundation.handleTabClick(activeKey, event);
|
|
85212
85281
|
};
|
|
@@ -85245,7 +85314,7 @@ class Tabs extends BaseComponent {
|
|
|
85245
85314
|
this.foundation = new tabs_foundation(this.adapter);
|
|
85246
85315
|
this.state = {
|
|
85247
85316
|
activeKey: this.foundation.getDefaultActiveKey(),
|
|
85248
|
-
panes:
|
|
85317
|
+
panes: this.getPanes(),
|
|
85249
85318
|
prevActiveKey: null,
|
|
85250
85319
|
forceDisableMotion: false
|
|
85251
85320
|
};
|
|
@@ -85255,41 +85324,12 @@ class Tabs extends BaseComponent {
|
|
|
85255
85324
|
get adapter() {
|
|
85256
85325
|
return Object.assign(Object.assign({}, super.adapter), {
|
|
85257
85326
|
collectPane: () => {
|
|
85258
|
-
const
|
|
85259
|
-
tabList,
|
|
85260
|
-
children
|
|
85261
|
-
} = this.props;
|
|
85262
|
-
if (Array.isArray(tabList) && tabList.length) {
|
|
85263
|
-
this.setState({
|
|
85264
|
-
panes: tabList
|
|
85265
|
-
});
|
|
85266
|
-
return;
|
|
85267
|
-
}
|
|
85268
|
-
const panes = external_root_React_commonjs2_react_commonjs_react_amd_react_default().Children.map(children, child => {
|
|
85269
|
-
if (child) {
|
|
85270
|
-
const {
|
|
85271
|
-
tab,
|
|
85272
|
-
icon,
|
|
85273
|
-
disabled,
|
|
85274
|
-
itemKey,
|
|
85275
|
-
closable
|
|
85276
|
-
} = child.props;
|
|
85277
|
-
return {
|
|
85278
|
-
tab,
|
|
85279
|
-
icon,
|
|
85280
|
-
disabled,
|
|
85281
|
-
itemKey,
|
|
85282
|
-
closable
|
|
85283
|
-
};
|
|
85284
|
-
}
|
|
85285
|
-
return undefined;
|
|
85286
|
-
});
|
|
85327
|
+
const panes = this.getPanes();
|
|
85287
85328
|
this.setState({
|
|
85288
85329
|
panes
|
|
85289
85330
|
});
|
|
85290
85331
|
},
|
|
85291
85332
|
collectActiveKey: () => {
|
|
85292
|
-
let panes = [];
|
|
85293
85333
|
const {
|
|
85294
85334
|
tabList,
|
|
85295
85335
|
children,
|
|
@@ -85301,29 +85341,7 @@ class Tabs extends BaseComponent {
|
|
|
85301
85341
|
const {
|
|
85302
85342
|
activeKey
|
|
85303
85343
|
} = this.state;
|
|
85304
|
-
|
|
85305
|
-
panes = tabList;
|
|
85306
|
-
} else {
|
|
85307
|
-
panes = external_root_React_commonjs2_react_commonjs_react_amd_react_default().Children.map(children, child => {
|
|
85308
|
-
if (child) {
|
|
85309
|
-
const {
|
|
85310
|
-
tab,
|
|
85311
|
-
icon,
|
|
85312
|
-
disabled,
|
|
85313
|
-
itemKey,
|
|
85314
|
-
closable
|
|
85315
|
-
} = child.props;
|
|
85316
|
-
return {
|
|
85317
|
-
tab,
|
|
85318
|
-
icon,
|
|
85319
|
-
disabled,
|
|
85320
|
-
itemKey,
|
|
85321
|
-
closable
|
|
85322
|
-
};
|
|
85323
|
-
}
|
|
85324
|
-
return undefined;
|
|
85325
|
-
});
|
|
85326
|
-
}
|
|
85344
|
+
const panes = this.getPanes();
|
|
85327
85345
|
if (panes.findIndex(p => p.itemKey === activeKey) === -1) {
|
|
85328
85346
|
if (panes.length > 0) {
|
|
85329
85347
|
this.setState({
|