@lvce-editor/find-widget-worker 3.7.4 → 3.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.
@@ -854,6 +854,7 @@ const createMockRpc = ({
854
854
  return mockRpc;
855
855
  };
856
856
 
857
+ const Alert = 'alert';
857
858
  const CheckBox = 'checkbox';
858
859
  const Group = 'group';
859
860
  const None = 'none';
@@ -2416,7 +2417,7 @@ const ViewletFindWidget = 'ViewletFindWidget';
2416
2417
  const getIconVirtualDom = (icon, type = Div) => {
2417
2418
  return {
2418
2419
  childCount: 0,
2419
- className: `${MaskIcon} MaskIcon${icon}`,
2420
+ className: mergeClassNames(MaskIcon, `MaskIcon${icon}`),
2420
2421
  role: None,
2421
2422
  type
2422
2423
  };
@@ -2430,10 +2431,7 @@ const getIconButtonVirtualDom = iconButton => {
2430
2431
  name,
2431
2432
  onClick
2432
2433
  } = iconButton;
2433
- let className = IconButton;
2434
- if (disabled) {
2435
- className += ' ' + IconButtonDisabled;
2436
- }
2434
+ const className = mergeClassNames(IconButton, disabled ? IconButtonDisabled : '');
2437
2435
  return [{
2438
2436
  ariaLabel: label,
2439
2437
  childCount: 1,
@@ -2454,14 +2452,20 @@ const getFindMatchCountClassName = (matchCount, hasValue) => {
2454
2452
  return FindWidgetMatchCount;
2455
2453
  };
2456
2454
 
2457
- const getMatchCountVirtualDom = (matchCountText, matchCount, hasValue) => {
2455
+ const getMatchCountVirtualDom = (matchCountText, matchCount, hasValue, hasError = false) => {
2458
2456
  return [{
2459
2457
  childCount: 1,
2460
2458
  className: getFindMatchCountClassName(matchCount, hasValue),
2459
+ ...(hasError && {
2460
+ id: 'FindWidgetInputError',
2461
+ role: Alert
2462
+ }),
2461
2463
  type: Div
2462
2464
  }, text(matchCountText)];
2463
2465
  };
2464
2466
 
2467
+ const Focusable = 0;
2468
+
2465
2469
  const checkedClassName = mergeClassNames(SearchFieldButton, SearchFieldButtonChecked);
2466
2470
  const unCheckedClassName = SearchFieldButton;
2467
2471
  const getSearchFieldButtonVirtualDom = button => {
@@ -2479,7 +2483,7 @@ const getSearchFieldButtonVirtualDom = button => {
2479
2483
  name,
2480
2484
  onClick,
2481
2485
  role: CheckBox,
2482
- tabIndex: 0,
2486
+ tabIndex: Focusable,
2483
2487
  title,
2484
2488
  type: Button
2485
2489
  }, {
@@ -2489,7 +2493,7 @@ const getSearchFieldButtonVirtualDom = button => {
2489
2493
  }];
2490
2494
  };
2491
2495
 
2492
- const getSearchFieldVirtualDom = (name, placeholder, onInput, insideButtons, outsideButtons, onFocus, extraClassName, autofocus = false) => {
2496
+ const getSearchFieldVirtualDom = (name, placeholder, onInput, insideButtons, outsideButtons, onFocus, extraClassName, autofocus = false, ariaDescribedBy = '', ariaInvalid = '') => {
2493
2497
  if (outsideButtons.length > 0) {
2494
2498
  throw new Error('outsideButtons are deprecated');
2495
2499
  }
@@ -2511,6 +2515,12 @@ const getSearchFieldVirtualDom = (name, placeholder, onInput, insideButtons, out
2511
2515
  type: TextArea,
2512
2516
  ...(autofocus && {
2513
2517
  autofocus: true
2518
+ }),
2519
+ ...(ariaDescribedBy && {
2520
+ ariaDescribedBy
2521
+ }),
2522
+ ...(ariaInvalid && {
2523
+ ariaInvalid
2514
2524
  })
2515
2525
  }, {
2516
2526
  childCount: insideButtons.length,
@@ -2520,6 +2530,11 @@ const getSearchFieldVirtualDom = (name, placeholder, onInput, insideButtons, out
2520
2530
  return dom;
2521
2531
  };
2522
2532
 
2533
+ const findWidgetFindNode = {
2534
+ childCount: 2,
2535
+ className: FindWidgetFind,
2536
+ type: Div
2537
+ };
2523
2538
  const getExtraClassName = (hasError, inputFocused) => {
2524
2539
  if (hasError) {
2525
2540
  return SearchFieldError;
@@ -2531,15 +2546,11 @@ const getExtraClassName = (hasError, inputFocused) => {
2531
2546
  };
2532
2547
  const getFindWidgetFindVirtualDom = (matchCountText, buttons, fieldButtons, matchCount, hasValue, hasError, inputFocused) => {
2533
2548
  const extraClassName = getExtraClassName(hasError, inputFocused);
2534
- return [{
2535
- childCount: 2,
2536
- className: FindWidgetFind,
2537
- type: Div
2538
- }, ...getSearchFieldVirtualDom(SearchValue, find(), HandleInput, fieldButtons, [], HandleFocus, extraClassName, inputFocused), {
2549
+ return [findWidgetFindNode, ...getSearchFieldVirtualDom(SearchValue, find(), HandleInput, fieldButtons, [], HandleFocus, extraClassName, inputFocused, hasError ? 'FindWidgetInputError' : '', hasError ? 'true' : ''), {
2539
2550
  childCount: 1 + buttons.length,
2540
2551
  className: 'FindWidgetActions',
2541
2552
  type: Div
2542
- }, ...getMatchCountVirtualDom(matchCountText, matchCount, hasValue), ...buttons.flatMap(getIconButtonVirtualDom)];
2553
+ }, ...getMatchCountVirtualDom(matchCountText, matchCount, hasValue, hasError), ...buttons.flatMap(getIconButtonVirtualDom)];
2543
2554
  };
2544
2555
 
2545
2556
  const getFindWidgetReplaceVirtualDom = (replaceExpanded, replaceButtons, replaceFieldButtons, replaceInputFocused) => {
@@ -2554,17 +2565,19 @@ const getFindWidgetReplaceVirtualDom = (replaceExpanded, replaceButtons, replace
2554
2565
  }, ...getSearchFieldVirtualDom(ReplaceValue, replace(), HandleReplaceInput, [], [], HandleReplaceFocus, extraClassName, replaceInputFocused), ...replaceButtons.flatMap(getIconButtonVirtualDom)];
2555
2566
  };
2556
2567
 
2568
+ const resizerNode = {
2569
+ childCount: 1,
2570
+ className: Resizer,
2571
+ onPointerDown: HandleResizerPointerDown,
2572
+ type: Div
2573
+ };
2574
+ const resizerHighlightNode = {
2575
+ childCount: 0,
2576
+ className: ResizerHighlight,
2577
+ type: Div
2578
+ };
2557
2579
  const getResizerVirtualDom = () => {
2558
- return [{
2559
- childCount: 1,
2560
- className: Resizer,
2561
- onPointerDown: HandleResizerPointerDown,
2562
- type: Div
2563
- }, {
2564
- childCount: 0,
2565
- className: ResizerHighlight,
2566
- type: Div
2567
- }];
2580
+ return [resizerNode, resizerHighlightNode];
2568
2581
  };
2569
2582
 
2570
2583
  const getSearchToggleButtonVirtualDom = (replaceExpanded, onClick = '') => {
@@ -2621,7 +2634,7 @@ const renderContent = (oldState, newState) => {
2621
2634
  useRegularExpression,
2622
2635
  value
2623
2636
  } = newState;
2624
- const matchCountText = getMatchCountText(newState.matchIndex, newState.matchCount);
2637
+ const matchCountText = inputErrorMessage || getMatchCountText(newState.matchIndex, newState.matchCount);
2625
2638
  const {
2626
2639
  findButtonsEnabled,
2627
2640
  replaceButtonsEnabled
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@lvce-editor/find-widget-worker",
3
- "version": "3.7.4",
3
+ "version": "3.8.0",
4
4
  "description": "Web Worker for the find widget in Lvce Editor",
5
5
  "repository": {
6
6
  "type": "git",