npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

react-native-customisable-combobox

v1.0.23

Published

A simple react native combobox

Downloads

409

Readme

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

| Property | Type | Description | Optional | Configuration | | ------------------------ | ------------------------------------------------------------------------- |-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------| ------------ | ----------------------------- | | items | Array<T> / Array<string \| number> | The list of items displayed in the combobox. | No | Common, Dynamic | | useFlatList | boolean | Whether 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 false | Yes | Common | | mainContainerStyle | ViewStyle | Custom styles for the main combobox container. | Yes | Common | | label | string | Label for the combobox. | Yes | Common | | labelStyle | TextStyle | Custom styles for the label. | Yes | Common | | noFoundItemText | string | Text for the non-existent item. | Yes | Common | | noFoundItemStyle | TextStyle | Custom styles for the non-existent item. | Yes | Common | | showTextStyle | TextStyle | Custom styles for the selected item text. | Yes | Common | | renderLabel | () => React.ReactNode | Custom function to render the label. | Yes | Common | | error | string | Error message for the combobox. | Yes | Common | | errorStyle | TextStyle | Custom styles for the error message. | Yes | Common | | renderError | () => React.ReactNode | Custom function to render the error message. | Yes | Common | | style | ViewStyle | Custom styles for the combobox container. | Yes | Common | | itemStyle | ViewStyle | Custom styles for each item in the list. | Yes | Common | | selectedStyle | ViewStyle | Custom styles for the selected item. | Yes | Common | | showBorder | boolean | Whether to show border for the combobox. | Yes | Common | | containerRadius | number | Radius for the combobox container. | Yes | Common | | dropdownStyle | ViewStyle | Custom styles for the dropdown. | Yes | Common | | value | T | The currently selected value. | No | Common | | onFocus | () => void | Callback triggered when the combobox gains focus. | Yes | Common | | onBlur | () => void | Callback triggered when the combobox loses focus. | Yes | Common | | labelField | keyof T / never | The key in the item object for the label value. | No / N/A | Dynamic | | valueField | keyof T / never | The key in the item object for the value. | No / N/A | Dynamic | | renderItem | ({ item, selected }: { item: T; selected: boolean }) => React.ReactNode | Custom function to render each item. | Yes | Dynamic | | onChange | (value: T \| string \| number) => void | Callback triggered when an item is selected. | No | Dynamic | | searchable | true / false | Enables or disables search functionality. | No | Searchable | | searchField | keyof T / never | The key in the item object for searching. | No / N/A | Searchable | | searchPlaceholder | string | Placeholder text for the search input. | Yes | Searchable (searchable: true) | | renderSearchIcon | () => React.ReactNode | Custom function to render a search icon. | Yes | Searchable (searchable: true) | | showItemOnNoSearch | boolean | Shows all items if there is no search input. | Yes | Searchable (searchable: true) | | showAlwaysNoSearchItem | boolean | Always shows a specific item when there is no search input. | Yes | Searchable (searchable: true) | | renderNoSearchItem | (value: string) => React.ReactNode | Custom function to render an item when no search results are found. | Yes | Searchable (searchable: true) | | onSelectedNotFoundItem | (value: string) => void | Callback triggered when a non-existent item is selected after a search. | Yes | Searchable (searchable: true) | | renderNotFoundItem | (value: string) => React.ReactNode | Custom function to render a non-existent item. | Yes | Searchable (searchable: true) | | debounceDelay | number | Delay in milliseconds for the search input. Default is 300 | Yes | Searchable (searchable: true) |