@lvce-editor/find-widget-worker 2.5.0 → 2.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/findWidgetWorkerMain.js +23 -8
- package/package.json +1 -1
|
@@ -889,10 +889,11 @@ const create$2 = () => {
|
|
|
889
889
|
wrapCommand(fn) {
|
|
890
890
|
const wrapped = async (uid, ...args) => {
|
|
891
891
|
const {
|
|
892
|
+
oldState,
|
|
892
893
|
newState
|
|
893
894
|
} = states[uid];
|
|
894
895
|
const newerState = await fn(newState, ...args);
|
|
895
|
-
if (newState === newerState) {
|
|
896
|
+
if (oldState === newerState || newState === newerState) {
|
|
896
897
|
return;
|
|
897
898
|
}
|
|
898
899
|
const latest = states[uid];
|
|
@@ -2343,6 +2344,7 @@ const SearchFieldButton = 'SearchFieldButton';
|
|
|
2343
2344
|
const SearchFieldButtonChecked = 'SearchFieldButtonChecked';
|
|
2344
2345
|
const SearchFieldButtons = 'SearchFieldButtons';
|
|
2345
2346
|
const SearchFieldError = 'SearchFieldError';
|
|
2347
|
+
const SearchFieldFocused = 'SearchFieldFocused';
|
|
2346
2348
|
const SearchToggleButton = 'SearchToggleButton';
|
|
2347
2349
|
const SearchToggleButtonExpanded = 'SearchToggleButtonExpanded';
|
|
2348
2350
|
const Viewlet = 'Viewlet';
|
|
@@ -2453,8 +2455,17 @@ const getSearchFieldVirtualDom = (name, placeholder, onInput, insideButtons, out
|
|
|
2453
2455
|
return dom;
|
|
2454
2456
|
};
|
|
2455
2457
|
|
|
2456
|
-
const
|
|
2457
|
-
|
|
2458
|
+
const getExtraClassName = (hasError, inputFocused) => {
|
|
2459
|
+
if (hasError) {
|
|
2460
|
+
return SearchFieldError;
|
|
2461
|
+
}
|
|
2462
|
+
if (inputFocused) {
|
|
2463
|
+
return SearchFieldFocused;
|
|
2464
|
+
}
|
|
2465
|
+
return '';
|
|
2466
|
+
};
|
|
2467
|
+
const getFindWidgetFindVirtualDom = (matchCountText, buttons, fieldButtons, matchCount, hasValue, hasError, inputFocused) => {
|
|
2468
|
+
const extraClassName = getExtraClassName(hasError, inputFocused);
|
|
2458
2469
|
return [{
|
|
2459
2470
|
type: Div,
|
|
2460
2471
|
className: FindWidgetFind,
|
|
@@ -2466,15 +2477,16 @@ const getFindWidgetFindVirtualDom = (matchCountText, buttons, fieldButtons, matc
|
|
|
2466
2477
|
}, ...getMatchCountVirtualDom(matchCountText, matchCount, hasValue), ...buttons.flatMap(getIconButtonVirtualDom)];
|
|
2467
2478
|
};
|
|
2468
2479
|
|
|
2469
|
-
const getFindWidgetReplaceVirtualDom = (replaceExpanded, replaceButtons, replaceFieldButtons) => {
|
|
2480
|
+
const getFindWidgetReplaceVirtualDom = (replaceExpanded, replaceButtons, replaceFieldButtons, replaceInputFocused) => {
|
|
2470
2481
|
if (!replaceExpanded) {
|
|
2471
2482
|
return [];
|
|
2472
2483
|
}
|
|
2484
|
+
const extraClassName = replaceInputFocused ? SearchFieldFocused : '';
|
|
2473
2485
|
return [{
|
|
2474
2486
|
type: Div,
|
|
2475
2487
|
className: FindWidgetReplace,
|
|
2476
2488
|
childCount: 1 + replaceButtons.length
|
|
2477
|
-
}, ...getSearchFieldVirtualDom(ReplaceValue, replace(), HandleReplaceInput, [], [], HandleReplaceFocus,
|
|
2489
|
+
}, ...getSearchFieldVirtualDom(ReplaceValue, replace(), HandleReplaceInput, [], [], HandleReplaceFocus, extraClassName), ...replaceButtons.flatMap(getIconButtonVirtualDom)];
|
|
2478
2490
|
};
|
|
2479
2491
|
|
|
2480
2492
|
const getResizerVirtualDom = () => {
|
|
@@ -2516,12 +2528,12 @@ const parentNode = {
|
|
|
2516
2528
|
childCount: 3,
|
|
2517
2529
|
role: Group
|
|
2518
2530
|
};
|
|
2519
|
-
const getFindWidgetVirtualDom = (matchCountText, replaceExpanded, findButtons, findFieldButtons, replaceButtons, replaceFieldButtons, matchCount, value, hasError) => {
|
|
2531
|
+
const getFindWidgetVirtualDom = (matchCountText, replaceExpanded, findButtons, findFieldButtons, replaceButtons, replaceFieldButtons, matchCount, value, hasError, inputFocused, replaceInputFocused) => {
|
|
2520
2532
|
return [parentNode, ...getResizerVirtualDom(), ...getSearchToggleButtonVirtualDom(replaceExpanded, 'handleClickToggleReplace'), {
|
|
2521
2533
|
type: Div,
|
|
2522
2534
|
className: FindWidgetRight,
|
|
2523
2535
|
childCount: replaceExpanded ? 2 : 1
|
|
2524
|
-
}, ...getFindWidgetFindVirtualDom(matchCountText, findButtons, findFieldButtons, matchCount, Boolean(value), hasError), ...getFindWidgetReplaceVirtualDom(replaceExpanded, replaceButtons)];
|
|
2536
|
+
}, ...getFindWidgetFindVirtualDom(matchCountText, findButtons, findFieldButtons, matchCount, Boolean(value), hasError, inputFocused), ...getFindWidgetReplaceVirtualDom(replaceExpanded, replaceButtons, replaceFieldButtons, replaceInputFocused)];
|
|
2525
2537
|
};
|
|
2526
2538
|
|
|
2527
2539
|
const getMatchCountText = (matchIndex, matchCount) => {
|
|
@@ -2533,6 +2545,7 @@ const getMatchCountText = (matchIndex, matchCount) => {
|
|
|
2533
2545
|
|
|
2534
2546
|
const renderContent = (oldState, newState) => {
|
|
2535
2547
|
const {
|
|
2548
|
+
focus,
|
|
2536
2549
|
uid,
|
|
2537
2550
|
matchCount,
|
|
2538
2551
|
value,
|
|
@@ -2555,7 +2568,9 @@ const renderContent = (oldState, newState) => {
|
|
|
2555
2568
|
replaceFieldButtons
|
|
2556
2569
|
} = getFindWidgetButtons(findButtonsEnabled, replaceButtonsEnabled, matchCase, matchWholeWord, useRegularExpression, preserveCase);
|
|
2557
2570
|
const hasError = Boolean(inputErrorMessage);
|
|
2558
|
-
const
|
|
2571
|
+
const inputFocused = focus === FocusSearchInput;
|
|
2572
|
+
const replaceInputFocused = focus === FocusSearchReplaceInput;
|
|
2573
|
+
const dom = getFindWidgetVirtualDom(matchCountText, replaceExpanded, findButtons, findFieldButtons, replaceButtons, replaceFieldButtons, matchCount, value, hasError, inputFocused, replaceInputFocused);
|
|
2559
2574
|
return [SetDom2, uid, dom];
|
|
2560
2575
|
};
|
|
2561
2576
|
|