@lvce-editor/activity-bar-worker 1.6.0 → 1.8.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.
@@ -963,9 +963,10 @@ const create$1 = (id, uri, x, y, width, height, args, parentUid, platform = 0) =
963
963
  y: 0,
964
964
  sideBarVisible: false,
965
965
  activityBarItems: [],
966
- selectedIndex: -1
966
+ selectedIndex: -1,
967
+ itemHeight: 48
967
968
  };
968
- set$3(state.uid, state, state);
969
+ set$3(id, state, state);
969
970
  return state;
970
971
  };
971
972
 
@@ -1054,11 +1055,15 @@ const focusNone = state => {
1054
1055
  return focusIndex(state, -1);
1055
1056
  };
1056
1057
 
1057
- const Button$1 = 'button';
1058
+ const Button$2 = 'button';
1058
1059
  const None = 'none';
1059
1060
  const Tab$1 = 'tab';
1060
1061
  const ToolBar = 'toolbar';
1061
1062
 
1063
+ const Button$1 = 'event.button';
1064
+ const ClientX = 'event.clientX';
1065
+ const ClientY = 'event.clientY';
1066
+
1062
1067
  const Enter = 3;
1063
1068
  const Space = 9;
1064
1069
  const PageUp = 10;
@@ -1122,10 +1127,24 @@ const handleBlur = state => {
1122
1127
  };
1123
1128
  };
1124
1129
 
1130
+ const getIndexFromPosition = (y, eventX, eventY, itemHeight, itemCount) => {
1131
+ const relativeY = eventY - y;
1132
+ const index = Math.floor(relativeY / itemHeight);
1133
+ if (index < 0 || index >= itemCount) {
1134
+ return -1;
1135
+ }
1136
+ return index;
1137
+ };
1138
+
1125
1139
  const show = async (x, y, id, ...args) => {
1126
1140
  // TODO
1127
1141
  };
1128
1142
 
1143
+ const handleClickAdditionalViews = async (state, x, y, viewletId) => {
1144
+ await show();
1145
+ return state;
1146
+ };
1147
+
1129
1148
  const rpcs = Object.create(null);
1130
1149
  const set$2 = (id, rpc) => {
1131
1150
  rpcs[id] = rpc;
@@ -1518,14 +1537,6 @@ const {
1518
1537
  invoke
1519
1538
  } = RendererWorker;
1520
1539
 
1521
- const handleClickSettings = async (state, x, y, viewletId) => {
1522
- await show();
1523
- return state;
1524
- };
1525
- const handleClickAdditionalViews = async (state, x, y, viewletId) => {
1526
- await show();
1527
- return state;
1528
- };
1529
1540
  const handleClickOther = async (state, x, y, viewletId) => {
1530
1541
  // TODO ask renderer worker asynchronously if sidebar is visible
1531
1542
 
@@ -1546,10 +1557,19 @@ const handleClickOther = async (state, x, y, viewletId) => {
1546
1557
  }
1547
1558
  return state;
1548
1559
  };
1549
- const handleClick = async (state, button, index, x, y) => {
1560
+
1561
+ const handleClickSettings = async (state, x, y, viewletId) => {
1562
+ await show();
1563
+ return state;
1564
+ };
1565
+
1566
+ const handleClickIndex = async (state, button, index, x, y) => {
1550
1567
  if (button !== LeftClick) {
1551
1568
  return state;
1552
1569
  }
1570
+ if (index === -1) {
1571
+ return state;
1572
+ }
1553
1573
  const {
1554
1574
  activityBarItems
1555
1575
  } = state;
@@ -1565,6 +1585,21 @@ const handleClick = async (state, button, index, x, y) => {
1565
1585
  }
1566
1586
  };
1567
1587
 
1588
+ const handleClick = async (state, button, eventX, eventY) => {
1589
+ const {
1590
+ activityBarItems,
1591
+ itemHeight,
1592
+ y
1593
+ } = state;
1594
+ const index = getIndexFromPosition(y, eventX, eventY, itemHeight, activityBarItems.length);
1595
+ return handleClickIndex(state, button, index, eventX, eventY);
1596
+ };
1597
+
1598
+ const handleContextMenu = async (state, button, x, y) => {
1599
+ await show();
1600
+ return state;
1601
+ };
1602
+
1568
1603
  const handleResize = state => {
1569
1604
  return state;
1570
1605
  };
@@ -1697,7 +1732,8 @@ const loadContent = async (state, savedState) => {
1697
1732
  const items = getActivityBarItems();
1698
1733
  return {
1699
1734
  ...state,
1700
- activityBarItems: items
1735
+ activityBarItems: items,
1736
+ sideBarVisible: true
1701
1737
  };
1702
1738
  };
1703
1739
 
@@ -1763,7 +1799,7 @@ const createActivityBarItem = item => {
1763
1799
  const isSelected = flags & Selected;
1764
1800
  const isFocused = flags & Focused;
1765
1801
  const isProgress = flags & Progress;
1766
- const role = isTab ? Tab$1 : Button$1;
1802
+ const role = isTab ? Tab$1 : Button$2;
1767
1803
  const ariaSelected = getAriaSelected(isTab, isSelected);
1768
1804
  const marginTop = flags & MarginTop;
1769
1805
  let className = ActivityBarItem;
@@ -1832,11 +1868,12 @@ const getVirtualDom = visibleItems => {
1832
1868
  return dom;
1833
1869
  };
1834
1870
 
1871
+ const className = mergeClassNames(Viewlet, ActivityBar$1);
1835
1872
  const getActivityBarVirtualDom = visibleItems => {
1836
1873
  return [{
1837
1874
  type: Div,
1838
1875
  id: ActivityBar,
1839
- className: mergeClassNames(Viewlet, ActivityBar$1),
1876
+ className,
1840
1877
  role: ToolBar,
1841
1878
  ariaRoleDescription: activityBar(),
1842
1879
  ariaOrientation: Vertical,
@@ -1896,7 +1933,21 @@ const render2 = (uid, diffResult) => {
1896
1933
  };
1897
1934
 
1898
1935
  const renderEventListeners = () => {
1899
- return [];
1936
+ return [{
1937
+ name: HandleBlur,
1938
+ params: ['handleBlur']
1939
+ }, {
1940
+ name: HandleFocus,
1941
+ params: ['handleFocus']
1942
+ }, {
1943
+ name: HandleContextMenu,
1944
+ params: ['handleContextMenu', Button$1, ClientX, ClientY]
1945
+ }, {
1946
+ name: HandleMouseDown,
1947
+ params: ['handleClick', Button$1, ClientX, ClientY],
1948
+ preventDefault: true,
1949
+ stopPropagation: true
1950
+ }];
1900
1951
  };
1901
1952
 
1902
1953
  const saveState = state => {
@@ -1922,6 +1973,8 @@ const commandMap = {
1922
1973
  'ActivityBar.handleBlur': wrapCommand(handleBlur),
1923
1974
  'ActivityBar.handleResize': wrapCommand(handleResize),
1924
1975
  'ActivityBar.handleClick': wrapCommand(handleClick),
1976
+ 'ActivityBar.handleContextMenu': wrapCommand(handleContextMenu),
1977
+ 'ActivityBar.handleClickIndex': wrapCommand(handleClickIndex),
1925
1978
  'ActivityBar.handleSideBarViewletChange': wrapCommand(handleSideBarViewletChange),
1926
1979
  'ActivityBar.loadContent': wrapCommand(loadContent),
1927
1980
  'ActivityBar.render2': render2,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@lvce-editor/activity-bar-worker",
3
- "version": "1.6.0",
3
+ "version": "1.8.0",
4
4
  "description": "Explorer Worker",
5
5
  "repository": {
6
6
  "type": "git",