1.0.7 • Published 1 year ago

@toppr-engg/byjus-search-qna v1.0.7

Weekly downloads
-
License
ISC
Repository
github
Last release
1 year ago
import SearchBar from '@toppr-engg/byjus-search-qna/lib/esm';
import '@toppr-engg/byjus-search-qna/lib/esm/index.css';

function Home() {
  return (
    <SearchBar
      onSuggestionClick={onSuggestionClick}
      onCustomSearch={onCustomSearch}
      onImageUploaded={onImageUploaded}
      onGetSearchInputRef={onGetSearchInputRef}
      apiBaseUrl={apiBaseUrl}
      authKey={authKey}
      userId={userId}
      origin={origin}
      maxInputLength={maxInputLength}
      placeholder={placeholder}
      suggestionsOrHistoryData={suggestionsOrHistoryData}
      imageUploadPopupData={imageUploadPopupData}
      cameraWrapperData={cameraWrapperData}
      className={className}
      focussedClassName={focussedClassName}
      inputClassName={inputClassName}
      inputFocussedClassName={inputFocussedClassName}
      searchClassName={searchClassName}
      searchFocussedClassName={searchFocussedClassName}
      suggestionsClassName={suggestionsClassName}
      suggestionsFocussedClassName={suggestionsFocussedClassName}
    />
  );
}

PROPS TABLE

PropsDescriptionTypeRequired
onSuggestionClickA function which gets triggered on clicking any suggestion itemfunctionYes
onCustomSearchA function which gets triggered on enter press to invoke a custom text searchfunctionYes
onImageUploadedA function which gets triggered when the selected image has been uploadedfunctionYes
onGetSearchInputRefA function to get the search input bar ref so that actions can be performed on it from outside the package (focus)functionNo
apiBaseUrlBase path of search apis (Default is prod Api)stringNo
authKeyRelated to authentication of the userstringYes
userIdUser Id to be used in api calls usernumberYes
originOrigin to be used in api callsnumberNo
maxInputLengthA number for max input length which can be typed/pasted in searchbar calls (Default 1000)numberNo
placeholderA string for input bar placeholder calls (Default - Search)
suggestionsOrHistoryDataAn object for passing props to SuggestionOrHistory componentobjectNo
imageUploadPopupDataAn object for passing props to ImageUploadModal componentobjectNo
cameraWrapperDataAn object for passing props to CameraWrapper componentobjectNo
classNameA string containing css which appends to the App container container cssstringNo
focussedClassNameA string containing css which appends to the App container container css on focus of search inputstringNo
inputClassNameA string containing css which appends to the SearchBar input container cssstringNo
inputFocussedClassNameA string containing css which appends to the SearchBar input container css on focus of search inputstringNo
searchClassNameA string containing css which appends to the SearchBar container cssstringNo
searchFocussedClassNameA string containing css which appends to the SearchBar container css on focus of search inputstringNo
suggestionsClassNameA string containing css which appends to the suggestions-container cssstringNo
suggestionsFocussedClassNameA string containing css which appends to the suggestions-container when focussedstringNo
suggestionsFocussedClassNameA string containing css which appends to the single suggestion itemstringNo

Function Definitions

/**
 *  A callback function which gets triggered on clicking any suggestion
 * @param {object} data - the object of a single suggestion item from the api response
 */
function onSuggestionClick(data) {}

/**
 *  A callback function which gets triggered on enter press to invoke a custom text search
 * @param {string} text - the text typed/pasted in the searchbar
 */
function onCustomSearch(text) {}

/**
 *  A callback function which gets triggered on enter press to invoke a custom text search
 * @param {object} data - the api response and the base64 string of the selected image
 */
function onImageUploaded(data) {}

/**
 *  callback to get the ref for the search input
 * @param {object} ref
 */
function onGetSearchInputRef(ref) {}