@lvce-editor/problems-view 1.3.0 → 1.5.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/problemsViewWorkerMain.js +150 -10
- package/package.json +1 -1
|
@@ -1087,11 +1087,13 @@ const focusIndex = (state, index) => {
|
|
|
1087
1087
|
};
|
|
1088
1088
|
|
|
1089
1089
|
const None = 'none';
|
|
1090
|
+
const ToolBar = 'toolbar';
|
|
1090
1091
|
const Tree$1 = 'tree';
|
|
1091
1092
|
const TreeItem$1 = 'treeitem';
|
|
1092
1093
|
const AriaRoles = {
|
|
1093
1094
|
__proto__: null,
|
|
1094
1095
|
None,
|
|
1096
|
+
ToolBar,
|
|
1095
1097
|
Tree: Tree$1,
|
|
1096
1098
|
TreeItem: TreeItem$1
|
|
1097
1099
|
};
|
|
@@ -1119,7 +1121,7 @@ const KeyCode = {
|
|
|
1119
1121
|
const mergeClassNames = (...classNames) => {
|
|
1120
1122
|
return classNames.filter(Boolean).join(' ');
|
|
1121
1123
|
};
|
|
1122
|
-
const Button = 1;
|
|
1124
|
+
const Button$1 = 1;
|
|
1123
1125
|
const Div = 4;
|
|
1124
1126
|
const Input = 6;
|
|
1125
1127
|
const Span = 8;
|
|
@@ -1129,7 +1131,7 @@ const A = 53;
|
|
|
1129
1131
|
const VirtualDomElements = {
|
|
1130
1132
|
__proto__: null,
|
|
1131
1133
|
A,
|
|
1132
|
-
Button,
|
|
1134
|
+
Button: Button$1,
|
|
1133
1135
|
Div,
|
|
1134
1136
|
Img,
|
|
1135
1137
|
Input,
|
|
@@ -1261,6 +1263,35 @@ const handleArrowRight = state => {
|
|
|
1261
1263
|
};
|
|
1262
1264
|
};
|
|
1263
1265
|
|
|
1266
|
+
const getListIndex = (eventX, eventY, x, y, deltaY, itemHeight) => {
|
|
1267
|
+
const relativeY = eventY - y + deltaY;
|
|
1268
|
+
const index = Math.floor(relativeY / itemHeight);
|
|
1269
|
+
return index;
|
|
1270
|
+
};
|
|
1271
|
+
|
|
1272
|
+
const handleClickAt = (state, eventX, eventY) => {
|
|
1273
|
+
const {
|
|
1274
|
+
problems,
|
|
1275
|
+
x,
|
|
1276
|
+
y,
|
|
1277
|
+
itemHeight
|
|
1278
|
+
} = state;
|
|
1279
|
+
|
|
1280
|
+
// TODO use functional focus rendering
|
|
1281
|
+
// Focus.setFocus(FocusKey.Problems)
|
|
1282
|
+
if (problems.length === 0) {
|
|
1283
|
+
return focusIndex(state, -1);
|
|
1284
|
+
}
|
|
1285
|
+
const index = getListIndex(eventX, eventY, x, y, 0, itemHeight);
|
|
1286
|
+
if (index > problems.length) {
|
|
1287
|
+
return focusIndex(state, -1);
|
|
1288
|
+
}
|
|
1289
|
+
return {
|
|
1290
|
+
...state,
|
|
1291
|
+
focusedIndex: index
|
|
1292
|
+
};
|
|
1293
|
+
};
|
|
1294
|
+
|
|
1264
1295
|
const handleContextMenu = async (state, eventX, eventY) => {
|
|
1265
1296
|
// @ts-ignore
|
|
1266
1297
|
// await ContextMenu.show(eventX, eventY, MenuEntryId.Problems)
|
|
@@ -1304,7 +1335,11 @@ const Message$1 = 'Message';
|
|
|
1304
1335
|
const NoProblemsDetected = 'No problems have been detected in the workspace.';
|
|
1305
1336
|
const NoResultsFoundWithProvidedFilterCriteria = 'No results found with provided filter criteria.';
|
|
1306
1337
|
const ProblemsDetected = 'Some problems have been detected in the workspace.';
|
|
1338
|
+
const ShowingOfItems = 'Showing {PH1} of {PH2} ';
|
|
1307
1339
|
const Source = 'Source';
|
|
1340
|
+
const CollapseAll$1 = 'Collapse All';
|
|
1341
|
+
const ViewAsTable = 'View as Table';
|
|
1342
|
+
const ViewAsList = 'View as List';
|
|
1308
1343
|
|
|
1309
1344
|
const noProblemsDetected = () => {
|
|
1310
1345
|
return i18nString(NoProblemsDetected);
|
|
@@ -1336,12 +1371,27 @@ const file = () => {
|
|
|
1336
1371
|
const filter = () => {
|
|
1337
1372
|
return i18nString(Filter$3);
|
|
1338
1373
|
};
|
|
1374
|
+
const showingOf = (visibleCount, totalCount) => {
|
|
1375
|
+
return i18nString(ShowingOfItems, {
|
|
1376
|
+
PH1: visibleCount,
|
|
1377
|
+
PH2: totalCount
|
|
1378
|
+
});
|
|
1379
|
+
};
|
|
1339
1380
|
const source = () => {
|
|
1340
1381
|
return i18nString(Source);
|
|
1341
1382
|
};
|
|
1342
1383
|
const noResultsFoundWithProvidedFilterCriteria = () => {
|
|
1343
1384
|
return i18nString(NoResultsFoundWithProvidedFilterCriteria);
|
|
1344
1385
|
};
|
|
1386
|
+
const collapseAll = () => {
|
|
1387
|
+
return i18nString(CollapseAll$1);
|
|
1388
|
+
};
|
|
1389
|
+
const viewAsList$1 = () => {
|
|
1390
|
+
return i18nString(ViewAsList);
|
|
1391
|
+
};
|
|
1392
|
+
const viewAsTable$1 = () => {
|
|
1393
|
+
return i18nString(ViewAsTable);
|
|
1394
|
+
};
|
|
1345
1395
|
|
|
1346
1396
|
const getSavedViewMode = savedState => {
|
|
1347
1397
|
if (savedState && typeof savedState.viewMode === 'number') {
|
|
@@ -1383,13 +1433,18 @@ const loadContent = async (state, savedState) => {
|
|
|
1383
1433
|
};
|
|
1384
1434
|
};
|
|
1385
1435
|
|
|
1436
|
+
const Button = 1;
|
|
1437
|
+
const ProblemsFilter = 4;
|
|
1438
|
+
|
|
1386
1439
|
const Chevron = 'Chevron';
|
|
1387
1440
|
const FileIcon = 'FileIcon';
|
|
1388
1441
|
const Filter$2 = 'Filter';
|
|
1442
|
+
const FilterBadge = 'FilterBadge';
|
|
1389
1443
|
const Highlight = 'Highlight';
|
|
1390
1444
|
const IconButton = 'IconButton';
|
|
1391
1445
|
const InputBox = 'InputBox';
|
|
1392
1446
|
const Label = 'Label';
|
|
1447
|
+
const Actions = 'Actions';
|
|
1393
1448
|
const LabelDetail = 'LabelDetail';
|
|
1394
1449
|
const Message = 'Message';
|
|
1395
1450
|
const MessageAction = 'MessageAction';
|
|
@@ -1442,7 +1497,10 @@ const getActionButtonVirtualDom = action => {
|
|
|
1442
1497
|
|
|
1443
1498
|
const Filter$1 = 'filter';
|
|
1444
1499
|
|
|
1500
|
+
const CollapseAll = 'CollapseAll';
|
|
1445
1501
|
const Filter = 'Filter';
|
|
1502
|
+
const ListFlat = 'ListFlat';
|
|
1503
|
+
const ListTree = 'ListTree';
|
|
1446
1504
|
|
|
1447
1505
|
const getProblemsFilterVirtualDom = action => {
|
|
1448
1506
|
// TODO avoid mutation
|
|
@@ -1462,6 +1520,15 @@ const getProblemsFilterVirtualDom = action => {
|
|
|
1462
1520
|
name: Filter$1,
|
|
1463
1521
|
value: action.value
|
|
1464
1522
|
});
|
|
1523
|
+
if (action.badgeText) {
|
|
1524
|
+
// @ts-ignore
|
|
1525
|
+
dom[0].childCount++;
|
|
1526
|
+
dom.push({
|
|
1527
|
+
type: VirtualDomElements.Div,
|
|
1528
|
+
className: FilterBadge,
|
|
1529
|
+
childCount: 1
|
|
1530
|
+
}, text(action.badgeText));
|
|
1531
|
+
}
|
|
1465
1532
|
// @ts-ignore
|
|
1466
1533
|
dom[0].childCount++;
|
|
1467
1534
|
dom.push(...getActionButtonVirtualDom({
|
|
@@ -1770,8 +1837,7 @@ const getProblemsVirtualDom$1 = (viewMode, problems, filterValue) => {
|
|
|
1770
1837
|
if (viewMode === Table) {
|
|
1771
1838
|
return getProblemsTableVirtualDom(problems);
|
|
1772
1839
|
}
|
|
1773
|
-
|
|
1774
|
-
return dom;
|
|
1840
|
+
return getProblemsListVirtualDom(problems);
|
|
1775
1841
|
};
|
|
1776
1842
|
|
|
1777
1843
|
const getProblemsVirtualDom = (viewMode, problems, filterValue, isSmall) => {
|
|
@@ -1790,6 +1856,7 @@ const getProblemsVirtualDom = (viewMode, problems, filterValue, isSmall) => {
|
|
|
1790
1856
|
dom[0].childCount++;
|
|
1791
1857
|
dom.push(...getProblemsFilterVirtualDom({
|
|
1792
1858
|
command: HandleFilterInput,
|
|
1859
|
+
badgeText: '',
|
|
1793
1860
|
placeholder: filter(),
|
|
1794
1861
|
value: ''
|
|
1795
1862
|
}));
|
|
@@ -1905,16 +1972,88 @@ const render2 = (uid, diffResult) => {
|
|
|
1905
1972
|
return commands;
|
|
1906
1973
|
};
|
|
1907
1974
|
|
|
1908
|
-
const
|
|
1975
|
+
const getActionVirtualDom = action => {
|
|
1976
|
+
switch (action.type) {
|
|
1977
|
+
case Button:
|
|
1978
|
+
return getActionButtonVirtualDom(action);
|
|
1979
|
+
case ProblemsFilter:
|
|
1980
|
+
return getProblemsFilterVirtualDom(action);
|
|
1981
|
+
default:
|
|
1982
|
+
return [];
|
|
1983
|
+
}
|
|
1984
|
+
};
|
|
1985
|
+
|
|
1986
|
+
const getActionsVirtualDom = actions => {
|
|
1909
1987
|
return [{
|
|
1910
1988
|
type: VirtualDomElements.Div,
|
|
1911
|
-
|
|
1912
|
-
|
|
1989
|
+
className: Actions,
|
|
1990
|
+
role: AriaRoles.ToolBar,
|
|
1991
|
+
childCount: actions.length
|
|
1992
|
+
}, ...actions.flatMap(getActionVirtualDom)];
|
|
1993
|
+
};
|
|
1994
|
+
|
|
1995
|
+
const getActions = state => {
|
|
1996
|
+
const visibleCount = getVisibleProblems(state.problems, state.collapsedUris, state.focusedIndex, state.filterValue).length;
|
|
1997
|
+
const problemsCount = state.problems.length;
|
|
1998
|
+
const isSmall = state.width <= state.smallWidthBreakPoint;
|
|
1999
|
+
const actions = [];
|
|
2000
|
+
if (!isSmall) {
|
|
2001
|
+
actions.push({
|
|
2002
|
+
type: ProblemsFilter,
|
|
2003
|
+
id: 'Filter',
|
|
2004
|
+
command: HandleFilterInput,
|
|
2005
|
+
badgeText: visibleCount === problemsCount ? '' : showingOf(visibleCount, problemsCount),
|
|
2006
|
+
placeholder: filter(),
|
|
2007
|
+
value: state.inputSource === Script ? state.filterValue : ''
|
|
2008
|
+
});
|
|
2009
|
+
}
|
|
2010
|
+
if (state.viewMode === Table) {
|
|
2011
|
+
actions.push({
|
|
2012
|
+
type: Button,
|
|
2013
|
+
id: viewAsList$1(),
|
|
2014
|
+
command: 'viewAsList',
|
|
2015
|
+
icon: ListTree
|
|
2016
|
+
});
|
|
2017
|
+
} else {
|
|
2018
|
+
actions.push({
|
|
2019
|
+
type: Button,
|
|
2020
|
+
id: collapseAll(),
|
|
2021
|
+
command: 'collapseAll',
|
|
2022
|
+
icon: CollapseAll
|
|
2023
|
+
}, {
|
|
2024
|
+
type: Button,
|
|
2025
|
+
id: viewAsTable$1(),
|
|
2026
|
+
command: 'viewAsTable',
|
|
2027
|
+
icon: ListFlat
|
|
2028
|
+
});
|
|
2029
|
+
}
|
|
2030
|
+
return actions;
|
|
2031
|
+
};
|
|
2032
|
+
|
|
2033
|
+
const renderActions = uid => {
|
|
2034
|
+
const {
|
|
2035
|
+
newState
|
|
2036
|
+
} = get(uid);
|
|
2037
|
+
const actions = getActions(newState);
|
|
2038
|
+
const dom = getActionsVirtualDom(actions);
|
|
2039
|
+
return dom;
|
|
1913
2040
|
};
|
|
1914
2041
|
|
|
1915
2042
|
const renderEventListeners = () => {
|
|
1916
|
-
|
|
1917
|
-
|
|
2043
|
+
return [{
|
|
2044
|
+
name: HandleBlur,
|
|
2045
|
+
params: ['handleBlur']
|
|
2046
|
+
}, {
|
|
2047
|
+
name: HandleContextMenu,
|
|
2048
|
+
params: ['handleContextMenu', 'event.clientX', 'event.clientY'],
|
|
2049
|
+
preventDefault: true
|
|
2050
|
+
}, {
|
|
2051
|
+
name: HandleFilterInput,
|
|
2052
|
+
params: ['handleFilterInput', 'event.target.value']
|
|
2053
|
+
}, {
|
|
2054
|
+
name: HandleClearFilterClick,
|
|
2055
|
+
params: ['clearFilter']
|
|
2056
|
+
}];
|
|
1918
2057
|
};
|
|
1919
2058
|
|
|
1920
2059
|
const resize = (state, dimensions) => {
|
|
@@ -1970,7 +2109,8 @@ const commandMap = {
|
|
|
1970
2109
|
'Problems.handleIconThemeChange': handleIconThemeChange,
|
|
1971
2110
|
'Problems.handleContextMenu': handleContextMenu,
|
|
1972
2111
|
'Problems.viewAsTable': viewAsTable,
|
|
1973
|
-
'Problems.viewAsList': viewAsList
|
|
2112
|
+
'Problems.viewAsList': viewAsList,
|
|
2113
|
+
'Problems.handleClickAt': wrapCommand(handleClickAt)
|
|
1974
2114
|
};
|
|
1975
2115
|
|
|
1976
2116
|
const listen = async () => {
|