0.1.94 • Published 5 months ago

expo-clear-input v0.1.94

Weekly downloads
-
License
MIT
Repository
github
Last release
5 months ago

This is not an official Expo SDK package.

❎ Expo Clear Input 📝

npm version npm downloads

supports iOS supports Android supports web

A cross-platform clear button to use in a TextInput for React Native apps built with Expo.

📲 Demo

Demo in Expo Snack

🔬 Why This Library?

The TextInput component has a clearButtonMode prop but it only support ios and not android. In addition to that, it only works in single-line mode and not multiline.

This library is a solution to the above by working on any platform (web, ios, android) and in both single and muilti line <TextInput>s.

☑️ Prerequisites

📠 Installation

npm install expo-clear-input

📎 Usage

import React from 'react';
import { StyleSheet, SafeAreaView, View } from 'react-native';
import { ClearControlTextInput } from 'expo-clear-input';

export default function App() {
    const [ text, setText ] = React.useState('');

    return (
        <SafeAreaView style={{ flex: 1, backgroundColor: '#000', alignItems: 'center', justifyContent: 'center', }}>
            <View style={{ marginHorizontal: 20, marginBottom: 20, width: "80%" }}>
            <ClearControlTextInput
                textInputProps={{
                    onChangeText: (text) => setText(text),
                    value: text,
                    placeholder: 'enter search...',
                    returnKeyType: 'done',
                }}
                showButtonMode={'always'}
            />
            </View>
        </SafeAreaView>
    );
}

Supports custom icon for the button or use the default(recommended)

// this is the default icon used
<Octicons name="x-circle-fill" size={16} color="#ccc8c8" />

🎛️ Options

PropTypeDescriptionDefault
textInputPropsAccessibilityProps & Partial<TextInputProps>All cross-platform-compatible props from TextInputProps except for style, which is handled by this componentsame defaults as <TextInput>
textColorstringThe color of the text"#fff"
backgroundColorstringThe background color of the input field"#252326"
verticalPlacement'top''center''bottom'The vertical placement of the input field (always on the right side)'center'
showButtonNodebooleanWhether to show the button node; always: visible whether or not its in focus. while-editing: visible only when the input is in focus. unless-editing: visible only when the input is not in focuswhile-editing
iconReactNodeThe icon to be displayed<Octicons name="x-circle-fill" size={16} color="#ccc8c8" />

👥 Contributing

  • Please create your own branch off of main to get started
  • Then develop, build, test, and create a Pull Request to main to trigger a review.

Pre-requisites

  • must be on WSL, Linux, or mac for local development or else you won't be able to run the scripts
  • Node.js version 18 or higher

Development

  • during development of your new code, you may want to have an example app up in parrallel to view your changes in real time.
  • YMMV but the recommended approach to this is to create a local expo project using expo-template-blank-typescript and import your ./src/* files into its App.tsx.
    • Then view your changes in real time.

Test Locally

  • After you've finished your changes, test that the packaged module works as expected.
    • Set up the testing suite with a local package of the module with your changes:
      • run from project root: npm run setuptest
    • once that runs successfuly, start up the test:
      • run from project root: npm run test

Before Submitting a Pull Request

  • No PR will be accepted without a copy of the testing report
  • Please ensure you add new tests if applicable for your new feature.
0.1.94

5 months ago

0.1.87

5 months ago

0.1.88

5 months ago

0.1.89

5 months ago

0.1.90

5 months ago

0.1.91

5 months ago

0.1.92

5 months ago

0.1.93

5 months ago

0.1.7

5 months ago

0.1.2

5 months ago

0.1.4

5 months ago

0.1.3

5 months ago

0.1.6

5 months ago

0.1.5

5 months ago

0.1.1

5 months ago

0.1.0

5 months ago