1.0.25 • Published 9 months ago

react-native-customisable-combobox v1.0.25

Weekly downloads
-
License
ISC
Repository
github
Last release
9 months ago

Combobox Component

A customizable combobox component for React Native. It works with both static and dynamic data, and it supports search functionality. it works with both bared and managed workflow(Expo). it is written in TypeScript.

Updates and Bug Reporting

This package is continuously improving and there may be some bugs. Your feedback is invaluable in making this package better. If you encounter any issues, please report them. Regular updates will be released to fix bugs and add new features, so please ensure to keep your package up-to-date.

Features

  • Customizable: You can customize the combobox with your own styles and render functions.
  • Searchable: You can enable search functionality to filter items.
  • Dynamic Data: You can use dynamic data to populate the combobox.
  • Keyboard Avoiding: The combobox avoids the keyboard when active.
  • Common Configuration: You can configure common properties like styles, focus, and blur events.
  • Dynamic Configuration: You can configure dynamic properties like label and value fields.
  • Searchable Configuration: You can configure searchable properties like search field, search placeholder, and search icon.
  • Searchable Callbacks: You can use callbacks for non-existent items and custom rendering.
  • Searchable Items: You can show a specific item when there is no search input.
  • Searchable No Results: You can show a custom item when no search results are found.
  • Searchable Always Show: You can always show a specific item when there is no search input.

Demo

Combobox Demo

Installation

npm i react-native-customisable-combobox

Usage

import React from "react";
import { View } from "react-native";
import { Combobox } from "react-native-customisable-combobox";

const items = [
  { label: "Item 1", value: "item1" },
  { label: "Item 2", value: "item2" },
  // Add more items here
];

const App = () => {
  const [selectedItem, setSelectedItem] = React.useState(items[0]);

  return (
    <View>
      <Combobox
        items={items}
        labelField="label"
        valueField="value"
        searchField="label"
        value={selectedItem}
        onChange={setSelectedItem}
        searchable
        searchPlaceholder="Search items..."
      />
    </View>
  );
};

export default App;

Props

PropertyTypeDescriptionOptionalConfiguration
itemsArray<T> / Array<string \| number>The list of items displayed in the combobox.NoCommon, Dynamic
useFlatListbooleanWhether to use a FlatList for the dropdown. Default is setted and recommanded to be true. In case it gives the "VirtualizedLists should never be nested inside plain ScrollViews" error, set this prop to falseYesCommon
mainContainerStyleViewStyleCustom styles for the main combobox container.YesCommon
labelstringLabel for the combobox.YesCommon
labelStyleTextStyleCustom styles for the label.YesCommon
noFoundItemTextstringText for the non-existent item.YesCommon
noFoundItemStyleTextStyleCustom styles for the non-existent item.YesCommon
showTextStyleTextStyleCustom styles for the selected item text.YesCommon
renderLabel() => React.ReactNodeCustom function to render the label.YesCommon
errorstringError message for the combobox.YesCommon
errorStyleTextStyleCustom styles for the error message.YesCommon
renderError() => React.ReactNodeCustom function to render the error message.YesCommon
styleViewStyleCustom styles for the combobox container.YesCommon
itemStyleViewStyleCustom styles for each item in the list.YesCommon
selectedStyleViewStyleCustom styles for the selected item.YesCommon
showBorderbooleanWhether to show border for the combobox.YesCommon
containerRadiusnumberRadius for the combobox container.YesCommon
dropdownStyleViewStyleCustom styles for the dropdown.YesCommon
valueTThe currently selected value.NoCommon
onFocus() => voidCallback triggered when the combobox gains focus.YesCommon
onBlur() => voidCallback triggered when the combobox loses focus.YesCommon
labelFieldkeyof T / neverThe key in the item object for the label value.No / N/ADynamic
valueFieldkeyof T / neverThe key in the item object for the value.No / N/ADynamic
renderItem({ item, selected }: { item: T; selected: boolean }) => React.ReactNodeCustom function to render each item.YesDynamic
onChange(value: T \| string \| number) => voidCallback triggered when an item is selected.NoDynamic
searchabletrue / falseEnables or disables search functionality.NoSearchable
searchFieldkeyof T / neverThe key in the item object for searching.No / N/ASearchable
searchPlaceholderstringPlaceholder text for the search input.YesSearchable (searchable: true)
renderSearchIcon() => React.ReactNodeCustom function to render a search icon.YesSearchable (searchable: true)
showItemOnNoSearchbooleanShows all items if there is no search input.YesSearchable (searchable: true)
showAlwaysNoSearchItembooleanAlways shows a specific item when there is no search input.YesSearchable (searchable: true)
renderNoSearchItem(value: string) => React.ReactNodeCustom function to render an item when no search results are found.YesSearchable (searchable: true)
onSelectedNotFoundItem(value: string) => voidCallback triggered when a non-existent item is selected after a search.YesSearchable (searchable: true)
renderNotFoundItem(value: string) => React.ReactNodeCustom function to render a non-existent item.YesSearchable (searchable: true)
debounceDelaynumberDelay in milliseconds for the search input. Default is 300YesSearchable (searchable: true)
1.0.22

11 months ago

1.0.25

9 months ago

1.0.23

11 months ago

1.0.21

11 months ago

1.0.20

11 months ago

1.0.19

11 months ago

1.0.18

11 months ago

1.0.17

11 months ago

1.0.16

11 months ago

1.0.15

11 months ago

1.0.14

11 months ago

1.0.13

11 months ago

1.0.12

11 months ago

1.0.11

11 months ago

1.0.10

11 months ago

1.0.9

11 months ago

1.0.8

11 months ago

1.0.7

11 months ago

1.0.6

11 months ago

1.0.5

11 months ago

1.0.4

11 months ago

1.0.3

11 months ago

1.0.2

11 months ago

1.0.1

11 months ago

1.0.0

11 months ago