@lvce-editor/extension-search-view 3.3.0 → 3.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.
|
@@ -1146,6 +1146,28 @@ const create$1 = () => {
|
|
|
1146
1146
|
return Object.keys(states).map(key => {
|
|
1147
1147
|
return Number.parseInt(key);
|
|
1148
1148
|
});
|
|
1149
|
+
},
|
|
1150
|
+
clear() {
|
|
1151
|
+
for (const key of Object.keys(states)) {
|
|
1152
|
+
delete states[key];
|
|
1153
|
+
}
|
|
1154
|
+
},
|
|
1155
|
+
wrapCommand(fn) {
|
|
1156
|
+
const wrapped = async (uid, ...args) => {
|
|
1157
|
+
const {
|
|
1158
|
+
newState
|
|
1159
|
+
} = states[uid];
|
|
1160
|
+
const newerState = await fn(newState, ...args);
|
|
1161
|
+
if (newState === newerState) {
|
|
1162
|
+
return;
|
|
1163
|
+
}
|
|
1164
|
+
const latest = states[uid];
|
|
1165
|
+
states[uid] = {
|
|
1166
|
+
oldState: latest.oldState,
|
|
1167
|
+
newState: newerState
|
|
1168
|
+
};
|
|
1169
|
+
};
|
|
1170
|
+
return wrapped;
|
|
1149
1171
|
}
|
|
1150
1172
|
};
|
|
1151
1173
|
};
|
|
@@ -1153,7 +1175,9 @@ const create$1 = () => {
|
|
|
1153
1175
|
const {
|
|
1154
1176
|
get: get$1,
|
|
1155
1177
|
set: set$1,
|
|
1156
|
-
dispose: dispose$1
|
|
1178
|
+
dispose: dispose$1,
|
|
1179
|
+
wrapCommand
|
|
1180
|
+
} = create$1();
|
|
1157
1181
|
|
|
1158
1182
|
const create = (id, uri, x, y, width, height, platform, assetDir) => {
|
|
1159
1183
|
const state = {
|
|
@@ -1325,6 +1349,9 @@ const last = items => {
|
|
|
1325
1349
|
const next = (items, index) => {
|
|
1326
1350
|
return (index + 1) % items.length;
|
|
1327
1351
|
};
|
|
1352
|
+
const previous = (items, index) => {
|
|
1353
|
+
return index === 0 ? items.length - 1 : index - 1;
|
|
1354
|
+
};
|
|
1328
1355
|
const focusFirst = state => {
|
|
1329
1356
|
const firstIndex = first();
|
|
1330
1357
|
return focusIndex(state, firstIndex);
|
|
@@ -1366,6 +1393,17 @@ const focusNextPage = state => {
|
|
|
1366
1393
|
const indexNextPage = Math.min(maxLineY + (maxLineY - minLineY) - 2, lastIndex(items));
|
|
1367
1394
|
return focusIndex(state, indexNextPage);
|
|
1368
1395
|
};
|
|
1396
|
+
const focusPrevious = state => {
|
|
1397
|
+
const {
|
|
1398
|
+
focusedIndex,
|
|
1399
|
+
items
|
|
1400
|
+
} = state;
|
|
1401
|
+
if (focusedIndex === 0 || focusedIndex === -1) {
|
|
1402
|
+
return state;
|
|
1403
|
+
}
|
|
1404
|
+
const previousIndex = previous(items, focusedIndex);
|
|
1405
|
+
return focusIndex(state, previousIndex);
|
|
1406
|
+
};
|
|
1369
1407
|
const focusPreviousPage = state => {
|
|
1370
1408
|
const {
|
|
1371
1409
|
focusedIndex,
|
|
@@ -1975,14 +2013,16 @@ const getSearchFieldButtonVirtualDom = button => {
|
|
|
1975
2013
|
const {
|
|
1976
2014
|
icon,
|
|
1977
2015
|
title,
|
|
1978
|
-
enabled
|
|
2016
|
+
enabled,
|
|
2017
|
+
onClick
|
|
1979
2018
|
} = button;
|
|
1980
2019
|
return [{
|
|
1981
2020
|
type: Div,
|
|
1982
2021
|
className: getClassName$1(enabled),
|
|
1983
2022
|
title,
|
|
1984
2023
|
tabIndex: 0,
|
|
1985
|
-
childCount: 1
|
|
2024
|
+
childCount: 1,
|
|
2025
|
+
onClick
|
|
1986
2026
|
}, {
|
|
1987
2027
|
type: Div,
|
|
1988
2028
|
className: mergeClassNames(MaskIcon, icon),
|
|
@@ -2037,7 +2077,7 @@ const getExtensionHeaderVirtualDom = (placeholder, actions) => {
|
|
|
2037
2077
|
const getInputActions = newState => {
|
|
2038
2078
|
const clearEnabled = newState.searchValue.length > 0;
|
|
2039
2079
|
const actions = [{
|
|
2040
|
-
|
|
2080
|
+
onClick: HandleClearSearchResults,
|
|
2041
2081
|
icon: `MaskIcon${ClearAll}`,
|
|
2042
2082
|
title: clearExtensionSearchResults(),
|
|
2043
2083
|
type: Button$1,
|
|
@@ -2046,7 +2086,7 @@ const getInputActions = newState => {
|
|
|
2046
2086
|
icon: `MaskIcon${Filter}`,
|
|
2047
2087
|
title: filter(),
|
|
2048
2088
|
type: Button$1,
|
|
2049
|
-
|
|
2089
|
+
onClick: HandleClickFilter,
|
|
2050
2090
|
enabled: true
|
|
2051
2091
|
}];
|
|
2052
2092
|
return actions;
|
|
@@ -2378,17 +2418,6 @@ const toggleSuggest = state => {
|
|
|
2378
2418
|
return state;
|
|
2379
2419
|
};
|
|
2380
2420
|
|
|
2381
|
-
const wrapCommand = fn => {
|
|
2382
|
-
const wrapped = async (uid, ...args) => {
|
|
2383
|
-
const {
|
|
2384
|
-
newState
|
|
2385
|
-
} = get$1(uid);
|
|
2386
|
-
const newerState = await fn(newState, ...args);
|
|
2387
|
-
set$1(uid, newState, newerState);
|
|
2388
|
-
};
|
|
2389
|
-
return wrapped;
|
|
2390
|
-
};
|
|
2391
|
-
|
|
2392
2421
|
const commandMap = {
|
|
2393
2422
|
'SearchExtensions.clearSearchResults': wrapCommand(clearSearchResults),
|
|
2394
2423
|
'SearchExtensions.closeSuggest': wrapCommand(closeSuggest),
|
|
@@ -2401,9 +2430,11 @@ const commandMap = {
|
|
|
2401
2430
|
'SearchExtensions.focusNext': wrapCommand(focusNext),
|
|
2402
2431
|
'SearchExtensions.focusNextPage': wrapCommand(focusNextPage),
|
|
2403
2432
|
'SearchExtensions.focusPreviousPage': wrapCommand(focusPreviousPage),
|
|
2433
|
+
'SearchExtensions.focusPrevious': wrapCommand(focusPrevious),
|
|
2404
2434
|
'SearchExtensions.getActions': getActions,
|
|
2405
2435
|
'SearchExtensions.getCommandIds': getCommandIds,
|
|
2406
2436
|
'SearchExtensions.getKeyBindings': getKeyBindings,
|
|
2437
|
+
'SearchExtensions.getMenuEntries': getMenuEntries,
|
|
2407
2438
|
'SearchExtensions.handleBlur': wrapCommand(handleBlur),
|
|
2408
2439
|
'SearchExtensions.handleClick': wrapCommand(handleClick),
|
|
2409
2440
|
'SearchExtensions.handleClickAt': wrapCommand(handleClickAt),
|
|
@@ -2426,12 +2457,12 @@ const commandMap = {
|
|
|
2426
2457
|
'SearchExtensions.render3': render3,
|
|
2427
2458
|
'SearchExtensions.renderActions': renderActions,
|
|
2428
2459
|
'SearchExtensions.renderEventListeners': renderEventListeners,
|
|
2460
|
+
'SearchExtensions.restoreState': restoreState,
|
|
2429
2461
|
'SearchExtensions.saveState': saveState,
|
|
2430
2462
|
'SearchExtensions.scrollDown': wrapCommand(scrollDown),
|
|
2431
2463
|
'SearchExtensions.searchExtensions': searchExtensions,
|
|
2432
2464
|
'SearchExtensions.selectIndex': wrapCommand(selectIndex),
|
|
2433
2465
|
'SearchExtensions.setDeltaY': wrapCommand(setDeltaY),
|
|
2434
|
-
'SearchExtensions.getMenuEntries': getMenuEntries,
|
|
2435
2466
|
'SearchExtensions.terminate': terminate,
|
|
2436
2467
|
'SearchExtensions.toggleSuggest': wrapCommand(toggleSuggest)
|
|
2437
2468
|
};
|