PromucFlow_constructor/app/client/src/components/designSystems/appsmith/SearchComponent.tsx
Hetu Nandu 0e7c0c3ce4
Widget fixes (#242)
* fix table styles

* rich text editor fix

* Fix action panes showing as blank

* correct fix this time

* cleanup

* default search in table

* Fix for text widget heading style

* Fix for table widget filtered table search

* Another approach to see if app has been created

* Fixes in styles of table and text
2020-08-07 23:39:54 +05:30

62 lines
1.3 KiB
TypeScript

import React from "react";
import styled from "styled-components";
import { InputGroup } from "@blueprintjs/core";
interface SearchProps {
onSearch: (value: any) => void;
placeholder: string;
value: string;
}
const SearchInputWrapper = styled(InputGroup)`
&&& input {
box-shadow: none;
}
&&& svg {
opacity: 0.6;
}
margin: 14px 20px;
width: 250px;
`;
class SearchComponent extends React.Component<
SearchProps,
{ localValue: string }
> {
constructor(props: SearchProps) {
super(props);
this.state = {
localValue: props.value,
};
}
componentDidUpdate(prevProps: Readonly<SearchProps>) {
// Reset local state if the value has updated via default value
if (prevProps.value !== this.props.value) {
this.setState({ localValue: this.props.value });
}
}
handleSearch = (
event:
| React.ChangeEvent<HTMLInputElement>
| React.ChangeEvent<HTMLTextAreaElement>,
) => {
const search = event.target.value;
this.setState({ localValue: search });
this.props.onSearch(search);
};
render() {
return (
<SearchInputWrapper
leftIcon="search"
type="search"
onChange={this.handleSearch}
placeholder={this.props.placeholder}
value={this.state.localValue}
/>
);
}
}
export default SearchComponent;