@douyinfe/semi-ui 2.54.0 → 2.55.0-beta.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/umd/semi-ui.js +69 -90
- 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/_sortable/index.d.ts +1 -1
- package/lib/cjs/_sortable/index.js +13 -19
- package/lib/cjs/navigation/index.d.ts +3 -2
- package/lib/cjs/navigation/index.js +17 -11
- package/lib/cjs/tabs/index.d.ts +1 -0
- package/lib/cjs/tabs/index.js +31 -54
- package/lib/es/_sortable/index.d.ts +1 -1
- package/lib/es/_sortable/index.js +13 -19
- package/lib/es/navigation/index.d.ts +3 -2
- package/lib/es/navigation/index.js +17 -11
- 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,
|
|
@@ -65945,7 +65939,8 @@ class NavigationFoundation extends foundation {
|
|
|
65945
65939
|
items: formattedItems
|
|
65946
65940
|
};
|
|
65947
65941
|
} else {
|
|
65948
|
-
|
|
65942
|
+
// already include parentSelectKeys, set second parameter to false
|
|
65943
|
+
this._adapter.updateSelectedKeys(willSelectedKeys, false);
|
|
65949
65944
|
this._adapter.setItemKeysMap(itemKeysMap);
|
|
65950
65945
|
this._adapter.updateOpenKeys(willOpenKeys);
|
|
65951
65946
|
this._adapter.updateItems(formattedItems);
|
|
@@ -65996,10 +65991,14 @@ class NavigationFoundation extends foundation {
|
|
|
65996
65991
|
selectedKeys,
|
|
65997
65992
|
mode
|
|
65998
65993
|
} = this.getProps();
|
|
65994
|
+
const {
|
|
65995
|
+
openKeys: stateOpenKeys = []
|
|
65996
|
+
} = this.getStates();
|
|
65999
65997
|
let willOpenKeys = openKeys || defaultOpenKeys || [];
|
|
66000
65998
|
if (!(Array.isArray(defaultOpenKeys) || Array.isArray(openKeys)) && mode === navigation_constants_strings.MODE_VERTICAL && (Array.isArray(defaultSelectedKeys) || Array.isArray(selectedKeys))) {
|
|
66001
65999
|
const currentSelectedKeys = Array.isArray(selectedKeys) ? selectedKeys : defaultSelectedKeys;
|
|
66002
|
-
willOpenKeys = this.getShouldOpenKeys(itemKeysMap, currentSelectedKeys);
|
|
66000
|
+
willOpenKeys = stateOpenKeys.concat(this.getShouldOpenKeys(itemKeysMap, currentSelectedKeys));
|
|
66001
|
+
willOpenKeys = Array.from(new Set(willOpenKeys));
|
|
66003
66002
|
}
|
|
66004
66003
|
return [...willOpenKeys];
|
|
66005
66004
|
}
|
|
@@ -66020,13 +66019,10 @@ class NavigationFoundation extends foundation {
|
|
|
66020
66019
|
return [...willOpenKeySet];
|
|
66021
66020
|
}
|
|
66022
66021
|
destroy() {}
|
|
66023
|
-
selectLevelZeroParentKeys(itemKeysMap) {
|
|
66022
|
+
selectLevelZeroParentKeys(itemKeysMap, itemKeys) {
|
|
66024
66023
|
const _itemKeysMap = isNullOrUndefined(itemKeysMap) ? this.getState('itemKeysMap') : itemKeysMap;
|
|
66025
66024
|
// console.log(itemKeysMap);
|
|
66026
66025
|
const willAddKeys = [];
|
|
66027
|
-
for (var _len2 = arguments.length, itemKeys = new Array(_len2 > 1 ? _len2 - 1 : 0), _key2 = 1; _key2 < _len2; _key2++) {
|
|
66028
|
-
itemKeys[_key2 - 1] = arguments[_key2];
|
|
66029
|
-
}
|
|
66030
66026
|
if (itemKeys.length) {
|
|
66031
66027
|
for (const itemKey of itemKeys) {
|
|
66032
66028
|
if (Array.isArray(_itemKeysMap[itemKey]) && _itemKeysMap[itemKey].length) {
|
|
@@ -67192,24 +67188,19 @@ class Nav extends BaseComponent {
|
|
|
67192
67188
|
componentDidMount() {
|
|
67193
67189
|
// override BaseComponent
|
|
67194
67190
|
}
|
|
67195
|
-
componentDidUpdate(prevProps
|
|
67191
|
+
componentDidUpdate(prevProps) {
|
|
67196
67192
|
if (prevProps.items !== this.props.items || prevProps.children !== this.props.children) {
|
|
67197
67193
|
this.foundation.init();
|
|
67198
67194
|
} else {
|
|
67199
67195
|
this.foundation.handleItemsChange(false);
|
|
67200
|
-
const {
|
|
67201
|
-
selectedKeys
|
|
67202
|
-
} = this.state;
|
|
67203
67196
|
if (this.props.selectedKeys && !isEqual_default()(prevProps.selectedKeys, this.props.selectedKeys)) {
|
|
67204
67197
|
this.adapter.updateSelectedKeys(this.props.selectedKeys);
|
|
67198
|
+
const willOpenKeys = this.foundation.getWillOpenKeys(this.state.itemKeysMap);
|
|
67199
|
+
this.adapter.updateOpenKeys(willOpenKeys);
|
|
67205
67200
|
}
|
|
67206
67201
|
if (this.props.openKeys && !isEqual_default()(prevProps.openKeys, this.props.openKeys)) {
|
|
67207
67202
|
this.adapter.updateOpenKeys(this.props.openKeys);
|
|
67208
67203
|
}
|
|
67209
|
-
if (!isEqual_default()(selectedKeys, prevState.selectedKeys)) {
|
|
67210
|
-
const parentSelectKeys = this.foundation.selectLevelZeroParentKeys(null, ...selectedKeys);
|
|
67211
|
-
this.adapter.addSelectedKeys(...parentSelectKeys);
|
|
67212
|
-
}
|
|
67213
67204
|
}
|
|
67214
67205
|
}
|
|
67215
67206
|
get adapter() {
|
|
@@ -67235,9 +67226,20 @@ class Nav extends BaseComponent {
|
|
|
67235
67226
|
}),
|
|
67236
67227
|
addSelectedKeys: createAddKeysFn(this, 'selectedKeys'),
|
|
67237
67228
|
removeSelectedKeys: createRemoveKeysFn(this, 'selectedKeys'),
|
|
67238
|
-
|
|
67239
|
-
|
|
67240
|
-
|
|
67229
|
+
/**
|
|
67230
|
+
* when `includeParentKeys` is `true`, select a nested nav item will select parent nav sub
|
|
67231
|
+
*/
|
|
67232
|
+
updateSelectedKeys: function (selectedKeys) {
|
|
67233
|
+
let includeParentKeys = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : true;
|
|
67234
|
+
let willUpdateSelectedKeys = selectedKeys;
|
|
67235
|
+
if (includeParentKeys) {
|
|
67236
|
+
const parentSelectKeys = _this.foundation.selectLevelZeroParentKeys(null, selectedKeys);
|
|
67237
|
+
willUpdateSelectedKeys = Array.from(new Set(selectedKeys.concat(parentSelectKeys)));
|
|
67238
|
+
}
|
|
67239
|
+
_this.setState({
|
|
67240
|
+
selectedKeys: willUpdateSelectedKeys
|
|
67241
|
+
});
|
|
67242
|
+
},
|
|
67241
67243
|
updateOpenKeys: openKeys => this.setState({
|
|
67242
67244
|
openKeys: [...openKeys]
|
|
67243
67245
|
}),
|
|
@@ -85200,6 +85202,34 @@ class Tabs extends BaseComponent {
|
|
|
85200
85202
|
current: ref
|
|
85201
85203
|
};
|
|
85202
85204
|
};
|
|
85205
|
+
this.getPanes = () => {
|
|
85206
|
+
const {
|
|
85207
|
+
tabList,
|
|
85208
|
+
children
|
|
85209
|
+
} = this.props;
|
|
85210
|
+
if (Array.isArray(tabList) && tabList.length) {
|
|
85211
|
+
return tabList;
|
|
85212
|
+
}
|
|
85213
|
+
return external_root_React_commonjs2_react_commonjs_react_amd_react_default().Children.map(children, child => {
|
|
85214
|
+
if (child) {
|
|
85215
|
+
const {
|
|
85216
|
+
tab,
|
|
85217
|
+
icon,
|
|
85218
|
+
disabled,
|
|
85219
|
+
itemKey,
|
|
85220
|
+
closable
|
|
85221
|
+
} = child.props;
|
|
85222
|
+
return {
|
|
85223
|
+
tab,
|
|
85224
|
+
icon,
|
|
85225
|
+
disabled,
|
|
85226
|
+
itemKey,
|
|
85227
|
+
closable
|
|
85228
|
+
};
|
|
85229
|
+
}
|
|
85230
|
+
return undefined;
|
|
85231
|
+
});
|
|
85232
|
+
};
|
|
85203
85233
|
this.onTabClick = (activeKey, event) => {
|
|
85204
85234
|
this.foundation.handleTabClick(activeKey, event);
|
|
85205
85235
|
};
|
|
@@ -85238,7 +85268,7 @@ class Tabs extends BaseComponent {
|
|
|
85238
85268
|
this.foundation = new tabs_foundation(this.adapter);
|
|
85239
85269
|
this.state = {
|
|
85240
85270
|
activeKey: this.foundation.getDefaultActiveKey(),
|
|
85241
|
-
panes:
|
|
85271
|
+
panes: this.getPanes(),
|
|
85242
85272
|
prevActiveKey: null,
|
|
85243
85273
|
forceDisableMotion: false
|
|
85244
85274
|
};
|
|
@@ -85248,41 +85278,12 @@ class Tabs extends BaseComponent {
|
|
|
85248
85278
|
get adapter() {
|
|
85249
85279
|
return Object.assign(Object.assign({}, super.adapter), {
|
|
85250
85280
|
collectPane: () => {
|
|
85251
|
-
const
|
|
85252
|
-
tabList,
|
|
85253
|
-
children
|
|
85254
|
-
} = this.props;
|
|
85255
|
-
if (Array.isArray(tabList) && tabList.length) {
|
|
85256
|
-
this.setState({
|
|
85257
|
-
panes: tabList
|
|
85258
|
-
});
|
|
85259
|
-
return;
|
|
85260
|
-
}
|
|
85261
|
-
const panes = external_root_React_commonjs2_react_commonjs_react_amd_react_default().Children.map(children, child => {
|
|
85262
|
-
if (child) {
|
|
85263
|
-
const {
|
|
85264
|
-
tab,
|
|
85265
|
-
icon,
|
|
85266
|
-
disabled,
|
|
85267
|
-
itemKey,
|
|
85268
|
-
closable
|
|
85269
|
-
} = child.props;
|
|
85270
|
-
return {
|
|
85271
|
-
tab,
|
|
85272
|
-
icon,
|
|
85273
|
-
disabled,
|
|
85274
|
-
itemKey,
|
|
85275
|
-
closable
|
|
85276
|
-
};
|
|
85277
|
-
}
|
|
85278
|
-
return undefined;
|
|
85279
|
-
});
|
|
85281
|
+
const panes = this.getPanes();
|
|
85280
85282
|
this.setState({
|
|
85281
85283
|
panes
|
|
85282
85284
|
});
|
|
85283
85285
|
},
|
|
85284
85286
|
collectActiveKey: () => {
|
|
85285
|
-
let panes = [];
|
|
85286
85287
|
const {
|
|
85287
85288
|
tabList,
|
|
85288
85289
|
children,
|
|
@@ -85294,29 +85295,7 @@ class Tabs extends BaseComponent {
|
|
|
85294
85295
|
const {
|
|
85295
85296
|
activeKey
|
|
85296
85297
|
} = this.state;
|
|
85297
|
-
|
|
85298
|
-
panes = tabList;
|
|
85299
|
-
} else {
|
|
85300
|
-
panes = external_root_React_commonjs2_react_commonjs_react_amd_react_default().Children.map(children, child => {
|
|
85301
|
-
if (child) {
|
|
85302
|
-
const {
|
|
85303
|
-
tab,
|
|
85304
|
-
icon,
|
|
85305
|
-
disabled,
|
|
85306
|
-
itemKey,
|
|
85307
|
-
closable
|
|
85308
|
-
} = child.props;
|
|
85309
|
-
return {
|
|
85310
|
-
tab,
|
|
85311
|
-
icon,
|
|
85312
|
-
disabled,
|
|
85313
|
-
itemKey,
|
|
85314
|
-
closable
|
|
85315
|
-
};
|
|
85316
|
-
}
|
|
85317
|
-
return undefined;
|
|
85318
|
-
});
|
|
85319
|
-
}
|
|
85298
|
+
const panes = this.getPanes();
|
|
85320
85299
|
if (panes.findIndex(p => p.itemKey === activeKey) === -1) {
|
|
85321
85300
|
if (panes.length > 0) {
|
|
85322
85301
|
this.setState({
|