diff --git a/packages/components/src/SearchInput.scss b/packages/components/src/SearchInput.scss index ff93f1ca71..e49e46a72a 100644 --- a/packages/components/src/SearchInput.scss +++ b/packages/components/src/SearchInput.scss @@ -42,17 +42,30 @@ } } - .search-match { - pointer-events: none; + .search-change-selection { position: absolute; - right: $spacer-5; + right: $spacer-1; top: 15%; bottom: 15%; height: 70%; - display: flex; - align-items: center; - padding: 0 $spacer-2; - border-radius: 1rem; - background-color: rgba($white, 0.25); + } + + .search-change-button { + background: none; + border: none; + padding: 1px 2px; + } + + .search-change-text { + background-color: rgba($white, 0.2); + border-radius: 10px; + padding: 1px 5px; + } + + .search-match { + background-color: rgba($white, 0.2); + border-radius: 10px; + padding: 1px 5px; + margin: 0 5px; } } diff --git a/packages/components/src/SearchInput.tsx b/packages/components/src/SearchInput.tsx index 165292d736..1d5c0104c5 100644 --- a/packages/components/src/SearchInput.tsx +++ b/packages/components/src/SearchInput.tsx @@ -1,8 +1,11 @@ import React, { PureComponent } from 'react'; import { FontAwesomeIcon } from '@fortawesome/react-fontawesome'; -import { vsSearch } from '@deephaven/icons'; +import { vsArrowLeft, vsArrowRight, vsSearch } from '@deephaven/icons'; import classNames from 'classnames'; +import Button from './Button'; import './SearchInput.scss'; +import { GLOBAL_SHORTCUTS } from './shortcuts'; +import { ContextActions } from './context-actions'; interface SearchInputProps { value: string; @@ -15,6 +18,10 @@ interface SearchInputProps { matchCount: number; id: string; 'data-testid'?: string; + cursor?: { + index: number | undefined; + next: (direction: 'forward' | 'back') => void; + }; } class SearchInput extends PureComponent { @@ -27,19 +34,40 @@ class SearchInput extends PureComponent { }, id: '', 'data-testid': undefined, + cursor: undefined, }; constructor(props: SearchInputProps) { super(props); this.inputField = React.createRef(); + this.searchChangeSelection = React.createRef(); } - inputField: React.RefObject; + componentDidMount(): void { + this.setInputPaddingRight(); + } + + componentDidUpdate(): void { + this.setInputPaddingRight(); + } focus(): void { this.inputField.current?.focus(); } + inputField: React.RefObject; + + searchChangeSelection: React.RefObject; + + setInputPaddingRight(): void { + const inputField = this.inputField.current; + const searchChangeSelection = this.searchChangeSelection.current; + if (inputField && searchChangeSelection) { + const paddingRight = searchChangeSelection.getBoundingClientRect().width; + inputField.style.paddingRight = `${paddingRight}px`; + } + } + render(): JSX.Element { const { value, @@ -52,7 +80,56 @@ class SearchInput extends PureComponent { id, onKeyDown, 'data-testid': dataTestId, + cursor, } = this.props; + + let matchCountSection; + const contextActions = [ + { + action: () => cursor?.next('forward'), + shortcut: GLOBAL_SHORTCUTS.NEXT, + }, + { + action: () => cursor?.next('back'), + shortcut: GLOBAL_SHORTCUTS.PREVIOUS, + }, + ]; + + if (cursor && matchCount > 1) { + matchCountSection = ( + <> +