github.com/minio/console@v1.4.1/web-app/src/screens/Console/Common/SearchBox.tsx (about)

     1  // This file is part of MinIO Console Server
     2  // Copyright (c) 2022 MinIO, Inc.
     3  //
     4  // This program is free software: you can redistribute it and/or modify
     5  // it under the terms of the GNU Affero General Public License as published by
     6  // the Free Software Foundation, either version 3 of the License, or
     7  // (at your option) any later version.
     8  //
     9  // This program is distributed in the hope that it will be useful,
    10  // but WITHOUT ANY WARRANTY; without even the implied warranty of
    11  // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
    12  // GNU Affero General Public License for more details.
    13  //
    14  // You should have received a copy of the GNU Affero General Public License
    15  // along with this program.  If not, see <http://www.gnu.org/licenses/>.
    16  
    17  import React from "react";
    18  import { InputBox, SearchIcon } from "mds";
    19  import { CSSObject } from "styled-components";
    20  
    21  type SearchBoxProps = {
    22    placeholder?: string;
    23    value: string;
    24    onChange: (value: string) => void;
    25    overrideClass?: any;
    26    id?: string;
    27    label?: string;
    28    sx?: CSSObject;
    29  };
    30  
    31  const SearchBox = ({
    32    placeholder = "",
    33    onChange,
    34    overrideClass,
    35    value,
    36    id = "search-resource",
    37    label = "",
    38    sx,
    39  }: SearchBoxProps) => {
    40    return (
    41      <InputBox
    42        placeholder={placeholder}
    43        className={overrideClass ? overrideClass : ""}
    44        id={id}
    45        label={label}
    46        onChange={(e) => {
    47          onChange(e.target.value);
    48        }}
    49        value={value}
    50        startIcon={<SearchIcon />}
    51        sx={sx}
    52      />
    53    );
    54  };
    55  
    56  export default SearchBox;