@lvce-editor/activity-bar-worker 1.18.0 → 1.22.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 +88 -39
- package/package.json +1 -1
|
@@ -1040,7 +1040,7 @@ const isEqual$1 = (oldState, newState) => {
|
|
|
1040
1040
|
};
|
|
1041
1041
|
|
|
1042
1042
|
const isEqual = (oldState, newState) => {
|
|
1043
|
-
return oldState.focusedIndex === newState.focusedIndex && oldState.activityBarItems === newState.activityBarItems;
|
|
1043
|
+
return oldState.focusedIndex === newState.focusedIndex && oldState.activityBarItems === newState.activityBarItems && oldState.updateProgress === newState.updateProgress && oldState.updateState === newState.updateState;
|
|
1044
1044
|
};
|
|
1045
1045
|
|
|
1046
1046
|
const RenderItems = 4;
|
|
@@ -1296,6 +1296,31 @@ const handleSideBarViewletChange = (state, id, ...args) => {
|
|
|
1296
1296
|
};
|
|
1297
1297
|
};
|
|
1298
1298
|
|
|
1299
|
+
const getNewItems = (items, state) => {
|
|
1300
|
+
return items.map(item => {
|
|
1301
|
+
if (item.id === 'Settings' && state === 1) {
|
|
1302
|
+
return {
|
|
1303
|
+
...item,
|
|
1304
|
+
badgeIcon: 'clock',
|
|
1305
|
+
flags: item.flags | Progress
|
|
1306
|
+
};
|
|
1307
|
+
}
|
|
1308
|
+
return item;
|
|
1309
|
+
});
|
|
1310
|
+
};
|
|
1311
|
+
const handleUpdateStateChange = async (state, config) => {
|
|
1312
|
+
const {
|
|
1313
|
+
activityBarItems
|
|
1314
|
+
} = state;
|
|
1315
|
+
const newItems = getNewItems(activityBarItems, config.state);
|
|
1316
|
+
return {
|
|
1317
|
+
...state,
|
|
1318
|
+
updateState: config.state,
|
|
1319
|
+
updateProgress: config.progress,
|
|
1320
|
+
activityBarItems: newItems
|
|
1321
|
+
};
|
|
1322
|
+
};
|
|
1323
|
+
|
|
1299
1324
|
const emptyObject = {};
|
|
1300
1325
|
const RE_PLACEHOLDER = /\{(PH\d+)\}/g;
|
|
1301
1326
|
const i18nString = (key, placeholders = emptyObject) => {
|
|
@@ -1441,12 +1466,14 @@ const ActivityBar$1 = 'ActivityBar';
|
|
|
1441
1466
|
const ActivityBarItem = 'ActivityBarItem';
|
|
1442
1467
|
const ActivityBarItemNested = 'ActivityBarItemNested';
|
|
1443
1468
|
const ActivityBarItemSelected = 'ActivityBarItemSelected';
|
|
1444
|
-
const
|
|
1469
|
+
const ActivityBarItemBadge = 'ActivityBarItemBadge';
|
|
1445
1470
|
const BadgeContent = 'BadgeContent';
|
|
1446
1471
|
const FocusOutline = 'FocusOutline';
|
|
1447
1472
|
const Icon = 'Icon';
|
|
1448
1473
|
const MarginTopAuto = 'MarginTopAuto';
|
|
1449
1474
|
const Viewlet = 'Viewlet';
|
|
1475
|
+
const MaskIconProgress = 'MaskIconProgress';
|
|
1476
|
+
const ActivityBarBadgeIcon = 'ActivityBarBadgeIcon';
|
|
1450
1477
|
|
|
1451
1478
|
const HandleBlur = 1;
|
|
1452
1479
|
const HandleContextMenu = 2;
|
|
@@ -1455,6 +1482,29 @@ const HandleMouseDown = 4;
|
|
|
1455
1482
|
|
|
1456
1483
|
const ActivityBar = 'ActivityBar';
|
|
1457
1484
|
|
|
1485
|
+
const getAriaSelected = (isTab, isSelected) => {
|
|
1486
|
+
if (!isTab) {
|
|
1487
|
+
return undefined;
|
|
1488
|
+
}
|
|
1489
|
+
return Boolean(isSelected);
|
|
1490
|
+
};
|
|
1491
|
+
|
|
1492
|
+
const getBadgeVirtualDom = () => {
|
|
1493
|
+
return [{
|
|
1494
|
+
type: Div,
|
|
1495
|
+
className: ActivityBarItemBadge,
|
|
1496
|
+
childCount: 1
|
|
1497
|
+
}, {
|
|
1498
|
+
type: Div,
|
|
1499
|
+
className: BadgeContent,
|
|
1500
|
+
childCount: 1
|
|
1501
|
+
}, {
|
|
1502
|
+
type: Div,
|
|
1503
|
+
className: mergeClassNames(Icon, ActivityBarBadgeIcon, MaskIconProgress),
|
|
1504
|
+
childCount: 0
|
|
1505
|
+
}];
|
|
1506
|
+
};
|
|
1507
|
+
|
|
1458
1508
|
const getClassName = (isFocused, marginTop, isSelected) => {
|
|
1459
1509
|
const classNames = [ActivityBarItem];
|
|
1460
1510
|
if (isFocused) {
|
|
@@ -1469,6 +1519,36 @@ const getClassName = (isFocused, marginTop, isSelected) => {
|
|
|
1469
1519
|
return mergeClassNames(...classNames);
|
|
1470
1520
|
};
|
|
1471
1521
|
|
|
1522
|
+
const getActivityBarItemInProgressDom = item => {
|
|
1523
|
+
const {
|
|
1524
|
+
flags,
|
|
1525
|
+
title,
|
|
1526
|
+
icon
|
|
1527
|
+
} = item;
|
|
1528
|
+
const isTab = flags & Tab;
|
|
1529
|
+
const isSelected = flags & Selected;
|
|
1530
|
+
const isFocused = flags & Focused;
|
|
1531
|
+
const role = isTab ? Tab$1 : Button$2;
|
|
1532
|
+
const ariaSelected = getAriaSelected(isTab, isSelected);
|
|
1533
|
+
const marginTop = flags & MarginTop;
|
|
1534
|
+
let className = getClassName(isFocused, marginTop, isSelected);
|
|
1535
|
+
className += ' ' + ActivityBarItemNested;
|
|
1536
|
+
return [{
|
|
1537
|
+
type: Div,
|
|
1538
|
+
className,
|
|
1539
|
+
ariaLabel: '',
|
|
1540
|
+
title,
|
|
1541
|
+
role,
|
|
1542
|
+
ariaSelected,
|
|
1543
|
+
childCount: 2
|
|
1544
|
+
}, {
|
|
1545
|
+
type: Div,
|
|
1546
|
+
className: mergeClassNames(Icon, `MaskIcon${icon}`),
|
|
1547
|
+
role: None,
|
|
1548
|
+
childCount: 0
|
|
1549
|
+
}, ...getBadgeVirtualDom()];
|
|
1550
|
+
};
|
|
1551
|
+
|
|
1472
1552
|
const getIconVirtualDom = (icon, type = Div) => {
|
|
1473
1553
|
return {
|
|
1474
1554
|
type,
|
|
@@ -1478,13 +1558,7 @@ const getIconVirtualDom = (icon, type = Div) => {
|
|
|
1478
1558
|
};
|
|
1479
1559
|
};
|
|
1480
1560
|
|
|
1481
|
-
const
|
|
1482
|
-
if (!isTab) {
|
|
1483
|
-
return undefined;
|
|
1484
|
-
}
|
|
1485
|
-
return Boolean(isSelected);
|
|
1486
|
-
};
|
|
1487
|
-
const createActivityBarItem = item => {
|
|
1561
|
+
const getActivityBarItemVirtualDom = item => {
|
|
1488
1562
|
const {
|
|
1489
1563
|
flags,
|
|
1490
1564
|
title,
|
|
@@ -1497,7 +1571,7 @@ const createActivityBarItem = item => {
|
|
|
1497
1571
|
const role = isTab ? Tab$1 : Button$2;
|
|
1498
1572
|
const ariaSelected = getAriaSelected(isTab, isSelected);
|
|
1499
1573
|
const marginTop = flags & MarginTop;
|
|
1500
|
-
|
|
1574
|
+
const className = getClassName(isFocused, marginTop, isSelected);
|
|
1501
1575
|
if (isSelected) {
|
|
1502
1576
|
return [{
|
|
1503
1577
|
type: Div,
|
|
@@ -1512,34 +1586,7 @@ const createActivityBarItem = item => {
|
|
|
1512
1586
|
|
|
1513
1587
|
// TODO support progress on selected activity bar item
|
|
1514
1588
|
if (isProgress) {
|
|
1515
|
-
|
|
1516
|
-
return [{
|
|
1517
|
-
type: Div,
|
|
1518
|
-
className,
|
|
1519
|
-
ariaLabel: '',
|
|
1520
|
-
title,
|
|
1521
|
-
role,
|
|
1522
|
-
ariaSelected,
|
|
1523
|
-
childCount: 2
|
|
1524
|
-
}, {
|
|
1525
|
-
type: Div,
|
|
1526
|
-
className: Icon,
|
|
1527
|
-
role: None,
|
|
1528
|
-
childCount: 0,
|
|
1529
|
-
maskImage: icon
|
|
1530
|
-
}, {
|
|
1531
|
-
type: Div,
|
|
1532
|
-
className: Badge,
|
|
1533
|
-
childCount: 1
|
|
1534
|
-
}, {
|
|
1535
|
-
type: Div,
|
|
1536
|
-
className: BadgeContent,
|
|
1537
|
-
childCount: 1
|
|
1538
|
-
}, {
|
|
1539
|
-
type: Div,
|
|
1540
|
-
className: Icon,
|
|
1541
|
-
maskImage: 'Progress'
|
|
1542
|
-
}];
|
|
1589
|
+
return getActivityBarItemInProgressDom(item);
|
|
1543
1590
|
}
|
|
1544
1591
|
return [{
|
|
1545
1592
|
type: Div,
|
|
@@ -1551,8 +1598,9 @@ const createActivityBarItem = item => {
|
|
|
1551
1598
|
childCount: 0
|
|
1552
1599
|
}];
|
|
1553
1600
|
};
|
|
1601
|
+
|
|
1554
1602
|
const getVirtualDom = visibleItems => {
|
|
1555
|
-
const dom = visibleItems.flatMap(
|
|
1603
|
+
const dom = visibleItems.flatMap(getActivityBarItemVirtualDom);
|
|
1556
1604
|
return dom;
|
|
1557
1605
|
};
|
|
1558
1606
|
|
|
@@ -1670,6 +1718,7 @@ const commandMap = {
|
|
|
1670
1718
|
'ActivityBar.focusFirst': wrapCommand(focusFirst),
|
|
1671
1719
|
'ActivityBar.focusIndex': wrapCommand(focusIndex),
|
|
1672
1720
|
'ActivityBar.focusLast': wrapCommand(focusLast),
|
|
1721
|
+
'ActivityBar.handleUpdateStateChange': wrapCommand(handleUpdateStateChange),
|
|
1673
1722
|
'ActivityBar.focusNext': wrapCommand(focusNext),
|
|
1674
1723
|
'ActivityBar.focusNone': wrapCommand(focusNone),
|
|
1675
1724
|
'ActivityBar.getCommandIds': getCommandIds,
|