@lvce-editor/problems-view 1.5.0 → 1.7.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 +72 -39
- package/package.json +1 -1
|
@@ -1086,6 +1086,18 @@ const focusIndex = (state, index) => {
|
|
|
1086
1086
|
};
|
|
1087
1087
|
};
|
|
1088
1088
|
|
|
1089
|
+
const commandMapRef = {};
|
|
1090
|
+
|
|
1091
|
+
const toCommandId = key => {
|
|
1092
|
+
const dotIndex = key.indexOf('.');
|
|
1093
|
+
return key.slice(dotIndex + 1);
|
|
1094
|
+
};
|
|
1095
|
+
const getCommandIds = () => {
|
|
1096
|
+
const keys = Object.keys(commandMapRef);
|
|
1097
|
+
const ids = keys.map(toCommandId);
|
|
1098
|
+
return ids;
|
|
1099
|
+
};
|
|
1100
|
+
|
|
1089
1101
|
const None = 'none';
|
|
1090
1102
|
const ToolBar = 'toolbar';
|
|
1091
1103
|
const Tree$1 = 'tree';
|
|
@@ -1495,6 +1507,19 @@ const getActionButtonVirtualDom = action => {
|
|
|
1495
1507
|
}, getIconVirtualDom(icon)];
|
|
1496
1508
|
};
|
|
1497
1509
|
|
|
1510
|
+
const getInputBoxVirtualDom = (name, onInput, placeholder) => {
|
|
1511
|
+
return {
|
|
1512
|
+
type: VirtualDomElements.Input,
|
|
1513
|
+
className: InputBox,
|
|
1514
|
+
autocapitalize: 'off',
|
|
1515
|
+
autocorrect: 'off',
|
|
1516
|
+
name,
|
|
1517
|
+
onInput: onInput,
|
|
1518
|
+
placeholder: placeholder,
|
|
1519
|
+
spellcheck: false
|
|
1520
|
+
};
|
|
1521
|
+
};
|
|
1522
|
+
|
|
1498
1523
|
const Filter$1 = 'filter';
|
|
1499
1524
|
|
|
1500
1525
|
const CollapseAll = 'CollapseAll';
|
|
@@ -1502,41 +1527,36 @@ const Filter = 'Filter';
|
|
|
1502
1527
|
const ListFlat = 'ListFlat';
|
|
1503
1528
|
const ListTree = 'ListTree';
|
|
1504
1529
|
|
|
1530
|
+
const getChildCount = badgeText => {
|
|
1531
|
+
let childCount = 0;
|
|
1532
|
+
childCount++; // input
|
|
1533
|
+
if (badgeText) {
|
|
1534
|
+
childCount++; // badge
|
|
1535
|
+
}
|
|
1536
|
+
childCount++; // action button
|
|
1537
|
+
return childCount;
|
|
1538
|
+
};
|
|
1539
|
+
const getBadgeDom = badgeText => {
|
|
1540
|
+
if (!badgeText) {
|
|
1541
|
+
return [];
|
|
1542
|
+
}
|
|
1543
|
+
return [{
|
|
1544
|
+
type: VirtualDomElements.Div,
|
|
1545
|
+
className: FilterBadge,
|
|
1546
|
+
childCount: 1
|
|
1547
|
+
}, text(badgeText)];
|
|
1548
|
+
};
|
|
1505
1549
|
const getProblemsFilterVirtualDom = action => {
|
|
1506
|
-
|
|
1507
|
-
const dom = [];
|
|
1508
|
-
dom.push({
|
|
1550
|
+
return [{
|
|
1509
1551
|
type: VirtualDomElements.Div,
|
|
1510
1552
|
className: Filter$2,
|
|
1511
|
-
childCount:
|
|
1512
|
-
}, {
|
|
1513
|
-
type: VirtualDomElements.Input,
|
|
1514
|
-
className: InputBox,
|
|
1515
|
-
spellcheck: false,
|
|
1516
|
-
autocapitalize: 'off',
|
|
1517
|
-
autocorrect: 'off',
|
|
1518
|
-
placeholder: action.placeholder,
|
|
1519
|
-
onInput: action.command,
|
|
1520
|
-
name: Filter$1,
|
|
1521
|
-
value: action.value
|
|
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
|
-
}
|
|
1532
|
-
// @ts-ignore
|
|
1533
|
-
dom[0].childCount++;
|
|
1534
|
-
dom.push(...getActionButtonVirtualDom({
|
|
1553
|
+
childCount: getChildCount(action.badgeText)
|
|
1554
|
+
}, getInputBoxVirtualDom(Filter$1, action.command, action.placeholder || ''), ...getBadgeDom(action.badgeText), ...getActionButtonVirtualDom({
|
|
1535
1555
|
id: 'more filters',
|
|
1556
|
+
// TODO use i18n string
|
|
1536
1557
|
icon: Filter,
|
|
1537
1558
|
command: 'more filters'
|
|
1538
|
-
})
|
|
1539
|
-
return dom;
|
|
1559
|
+
})];
|
|
1540
1560
|
};
|
|
1541
1561
|
|
|
1542
1562
|
const getBadgeVirtualDom = (className, count) => {
|
|
@@ -1857,9 +1877,7 @@ const getProblemsVirtualDom = (viewMode, problems, filterValue, isSmall) => {
|
|
|
1857
1877
|
dom.push(...getProblemsFilterVirtualDom({
|
|
1858
1878
|
command: HandleFilterInput,
|
|
1859
1879
|
badgeText: '',
|
|
1860
|
-
placeholder: filter()
|
|
1861
|
-
value: ''
|
|
1862
|
-
}));
|
|
1880
|
+
placeholder: filter()}));
|
|
1863
1881
|
}
|
|
1864
1882
|
dom.push(...getProblemsVirtualDom$1(viewMode, problems, filterValue));
|
|
1865
1883
|
return dom;
|
|
@@ -1993,9 +2011,19 @@ const getActionsVirtualDom = actions => {
|
|
|
1993
2011
|
};
|
|
1994
2012
|
|
|
1995
2013
|
const getActions = state => {
|
|
1996
|
-
const
|
|
1997
|
-
|
|
1998
|
-
|
|
2014
|
+
const {
|
|
2015
|
+
problems,
|
|
2016
|
+
width,
|
|
2017
|
+
collapsedUris,
|
|
2018
|
+
focusedIndex,
|
|
2019
|
+
smallWidthBreakPoint,
|
|
2020
|
+
filterValue,
|
|
2021
|
+
inputSource,
|
|
2022
|
+
viewMode
|
|
2023
|
+
} = state;
|
|
2024
|
+
const visibleCount = getVisibleProblems(problems, collapsedUris, focusedIndex, filterValue).length;
|
|
2025
|
+
const problemsCount = problems.length;
|
|
2026
|
+
const isSmall = width <= smallWidthBreakPoint;
|
|
1999
2027
|
const actions = [];
|
|
2000
2028
|
if (!isSmall) {
|
|
2001
2029
|
actions.push({
|
|
@@ -2004,10 +2032,10 @@ const getActions = state => {
|
|
|
2004
2032
|
command: HandleFilterInput,
|
|
2005
2033
|
badgeText: visibleCount === problemsCount ? '' : showingOf(visibleCount, problemsCount),
|
|
2006
2034
|
placeholder: filter(),
|
|
2007
|
-
value:
|
|
2035
|
+
value: inputSource === Script ? filterValue : ''
|
|
2008
2036
|
});
|
|
2009
2037
|
}
|
|
2010
|
-
if (
|
|
2038
|
+
if (viewMode === Table) {
|
|
2011
2039
|
actions.push({
|
|
2012
2040
|
type: Button,
|
|
2013
2041
|
id: viewAsList$1(),
|
|
@@ -2053,6 +2081,9 @@ const renderEventListeners = () => {
|
|
|
2053
2081
|
}, {
|
|
2054
2082
|
name: HandleClearFilterClick,
|
|
2055
2083
|
params: ['clearFilter']
|
|
2084
|
+
}, {
|
|
2085
|
+
name: HandlePointerDown,
|
|
2086
|
+
params: ['handleClickAt', 'event.clientX', 'event.clientY']
|
|
2056
2087
|
}];
|
|
2057
2088
|
};
|
|
2058
2089
|
|
|
@@ -2110,12 +2141,14 @@ const commandMap = {
|
|
|
2110
2141
|
'Problems.handleContextMenu': handleContextMenu,
|
|
2111
2142
|
'Problems.viewAsTable': viewAsTable,
|
|
2112
2143
|
'Problems.viewAsList': viewAsList,
|
|
2113
|
-
'Problems.handleClickAt': wrapCommand(handleClickAt)
|
|
2144
|
+
'Problems.handleClickAt': wrapCommand(handleClickAt),
|
|
2145
|
+
'Problems.getCommandIds': getCommandIds
|
|
2114
2146
|
};
|
|
2115
2147
|
|
|
2116
2148
|
const listen = async () => {
|
|
2149
|
+
Object.assign(commandMapRef, commandMap);
|
|
2117
2150
|
const rpc = await WebWorkerRpcClient.create({
|
|
2118
|
-
commandMap:
|
|
2151
|
+
commandMap: commandMapRef
|
|
2119
2152
|
});
|
|
2120
2153
|
set$1(rpc);
|
|
2121
2154
|
};
|