@lvce-editor/activity-bar-worker 1.26.0 → 1.28.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/activityBarWorkerMain.js +50 -21
- package/package.json +1 -1
|
@@ -1025,17 +1025,15 @@ const create = (id, uri, x, y, width, height, args, parentUid, platform = 0) =>
|
|
|
1025
1025
|
itemHeight: 48,
|
|
1026
1026
|
updateState: '',
|
|
1027
1027
|
updateProgress: 0,
|
|
1028
|
-
filteredItems: []
|
|
1028
|
+
filteredItems: [],
|
|
1029
|
+
numberOfVisibleItems: 0
|
|
1029
1030
|
};
|
|
1030
1031
|
set(id, state, state);
|
|
1031
1032
|
return state;
|
|
1032
1033
|
};
|
|
1033
1034
|
|
|
1034
1035
|
const isEqual$2 = (oldState, newState) => {
|
|
1035
|
-
|
|
1036
|
-
// maybe only when items change, and even then not
|
|
1037
|
-
// always, but only when it affects the css
|
|
1038
|
-
return false;
|
|
1036
|
+
return oldState.itemHeight === newState.itemHeight;
|
|
1039
1037
|
};
|
|
1040
1038
|
|
|
1041
1039
|
const isEqual$1 = (oldState, newState) => {
|
|
@@ -1043,7 +1041,7 @@ const isEqual$1 = (oldState, newState) => {
|
|
|
1043
1041
|
};
|
|
1044
1042
|
|
|
1045
1043
|
const isEqual = (oldState, newState) => {
|
|
1046
|
-
return oldState.
|
|
1044
|
+
return oldState.activityBarItems === newState.activityBarItems && oldState.filteredItems === newState.filteredItems && oldState.focusedIndex === newState.focusedIndex && oldState.updateProgress === newState.updateProgress && oldState.updateState === newState.updateState;
|
|
1047
1045
|
};
|
|
1048
1046
|
|
|
1049
1047
|
const RenderItems = 4;
|
|
@@ -1146,10 +1144,30 @@ const handleBlur = state => {
|
|
|
1146
1144
|
};
|
|
1147
1145
|
};
|
|
1148
1146
|
|
|
1149
|
-
const getIndexFromPosition = (y, eventX, eventY, itemHeight, itemCount) => {
|
|
1147
|
+
const getIndexFromPosition = (y, eventX, eventY, itemHeight, itemCount, height) => {
|
|
1148
|
+
if (itemCount === 0) {
|
|
1149
|
+
return -1;
|
|
1150
|
+
}
|
|
1151
|
+
// If there's only one item, treat it as a top item (not Settings at bottom)
|
|
1152
|
+
if (itemCount === 1) {
|
|
1153
|
+
const relativeY = eventY - y;
|
|
1154
|
+
const index = Math.floor(relativeY / itemHeight);
|
|
1155
|
+
if (index < 0 || index >= itemCount) {
|
|
1156
|
+
return -1;
|
|
1157
|
+
}
|
|
1158
|
+
return index;
|
|
1159
|
+
}
|
|
1160
|
+
// Settings is always at the bottom (last item) when there are multiple items
|
|
1161
|
+
const settingsBottomY = y + height;
|
|
1162
|
+
const settingsTopY = settingsBottomY - itemHeight;
|
|
1163
|
+
// Check if click is in the Settings area (bottom)
|
|
1164
|
+
if (eventY >= settingsTopY && eventY < settingsBottomY) {
|
|
1165
|
+
return itemCount - 1;
|
|
1166
|
+
}
|
|
1167
|
+
// Otherwise, calculate index from top items
|
|
1150
1168
|
const relativeY = eventY - y;
|
|
1151
1169
|
const index = Math.floor(relativeY / itemHeight);
|
|
1152
|
-
if (index < 0 || index >= itemCount) {
|
|
1170
|
+
if (index < 0 || index >= itemCount - 1) {
|
|
1153
1171
|
return -1;
|
|
1154
1172
|
}
|
|
1155
1173
|
return index;
|
|
@@ -1206,9 +1224,9 @@ const handleClickIndex = async (state, button, index, x, y) => {
|
|
|
1206
1224
|
return state;
|
|
1207
1225
|
}
|
|
1208
1226
|
const {
|
|
1209
|
-
|
|
1227
|
+
filteredItems
|
|
1210
1228
|
} = state;
|
|
1211
|
-
const item =
|
|
1229
|
+
const item = filteredItems[index];
|
|
1212
1230
|
const viewletId = item.id;
|
|
1213
1231
|
switch (viewletId) {
|
|
1214
1232
|
case 'Settings':
|
|
@@ -1222,11 +1240,12 @@ const handleClickIndex = async (state, button, index, x, y) => {
|
|
|
1222
1240
|
|
|
1223
1241
|
const handleClick = async (state, button, eventX, eventY) => {
|
|
1224
1242
|
const {
|
|
1225
|
-
|
|
1243
|
+
filteredItems,
|
|
1226
1244
|
itemHeight,
|
|
1227
|
-
y
|
|
1245
|
+
y,
|
|
1246
|
+
height
|
|
1228
1247
|
} = state;
|
|
1229
|
-
const index = getIndexFromPosition(y, eventX, eventY, itemHeight,
|
|
1248
|
+
const index = getIndexFromPosition(y, eventX, eventY, itemHeight, filteredItems.length, height);
|
|
1230
1249
|
return handleClickIndex(state, button, index, eventX, eventY);
|
|
1231
1250
|
};
|
|
1232
1251
|
|
|
@@ -1385,15 +1404,19 @@ const markSelected = (items, selectedIndex) => {
|
|
|
1385
1404
|
|
|
1386
1405
|
const handleSideBarViewletChange = (state, id, ...args) => {
|
|
1387
1406
|
const {
|
|
1388
|
-
activityBarItems
|
|
1407
|
+
activityBarItems,
|
|
1408
|
+
height,
|
|
1409
|
+
itemHeight
|
|
1389
1410
|
} = state;
|
|
1390
1411
|
const index = findIndex(activityBarItems, id);
|
|
1391
1412
|
const newActivityBarItems = markSelected(activityBarItems, index);
|
|
1413
|
+
const filteredItems = getFilteredActivityBarItems(newActivityBarItems, height, itemHeight);
|
|
1392
1414
|
return {
|
|
1393
1415
|
...state,
|
|
1394
1416
|
selectedIndex: index,
|
|
1395
1417
|
currentViewletId: id,
|
|
1396
1418
|
activityBarItems: newActivityBarItems,
|
|
1419
|
+
filteredItems,
|
|
1397
1420
|
sideBarVisible: true
|
|
1398
1421
|
};
|
|
1399
1422
|
};
|
|
@@ -1425,14 +1448,14 @@ const getNewItems = (items, state) => {
|
|
|
1425
1448
|
};
|
|
1426
1449
|
const handleUpdateStateChange = async (state, config) => {
|
|
1427
1450
|
const {
|
|
1428
|
-
|
|
1451
|
+
filteredItems
|
|
1429
1452
|
} = state;
|
|
1430
|
-
const newItems = getNewItems(
|
|
1453
|
+
const newItems = getNewItems(filteredItems, config.state);
|
|
1431
1454
|
return {
|
|
1432
1455
|
...state,
|
|
1433
1456
|
updateState: config.state,
|
|
1434
1457
|
updateProgress: config.progress,
|
|
1435
|
-
|
|
1458
|
+
filteredItems: newItems
|
|
1436
1459
|
};
|
|
1437
1460
|
};
|
|
1438
1461
|
|
|
@@ -1487,15 +1510,21 @@ const getActivityBarItems = () => {
|
|
|
1487
1510
|
};
|
|
1488
1511
|
|
|
1489
1512
|
const loadContent = async (state, savedState) => {
|
|
1513
|
+
const {
|
|
1514
|
+
itemHeight,
|
|
1515
|
+
height
|
|
1516
|
+
} = state;
|
|
1490
1517
|
const items = getActivityBarItems();
|
|
1491
1518
|
const explorerIndex = 0;
|
|
1492
1519
|
const itemsWithSelected = markSelected(items, explorerIndex);
|
|
1520
|
+
const filteredItems = getFilteredActivityBarItems(itemsWithSelected, height, itemHeight);
|
|
1493
1521
|
return {
|
|
1494
1522
|
...state,
|
|
1495
1523
|
activityBarItems: itemsWithSelected,
|
|
1496
|
-
sideBarVisible: true,
|
|
1497
1524
|
currentViewletId: Explorer,
|
|
1498
|
-
|
|
1525
|
+
filteredItems,
|
|
1526
|
+
selectedIndex: explorerIndex,
|
|
1527
|
+
sideBarVisible: true
|
|
1499
1528
|
};
|
|
1500
1529
|
};
|
|
1501
1530
|
|
|
@@ -1742,9 +1771,9 @@ const getActivityBarVirtualDom = visibleItems => {
|
|
|
1742
1771
|
const renderItems = (oldState, newState) => {
|
|
1743
1772
|
const {
|
|
1744
1773
|
uid,
|
|
1745
|
-
|
|
1774
|
+
filteredItems
|
|
1746
1775
|
} = newState;
|
|
1747
|
-
const dom = getActivityBarVirtualDom(
|
|
1776
|
+
const dom = getActivityBarVirtualDom(filteredItems);
|
|
1748
1777
|
return [SetDom2, uid, dom];
|
|
1749
1778
|
};
|
|
1750
1779
|
|