🚀 DAY 5 OF LAUNCH WEEK: Introducing Socket Firewall Enterprise.Learn more →
Socket
Book a DemoInstallSign in
Socket

@stnew/forms

Package Overview
Dependencies
Maintainers
4
Versions
1
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@stnew/forms

Inputs for common use cases with built-in validation

latest
Source
npmnpm
Version
1.0.3
Version published
Maintainers
4
Created
Source

@stnew/forms

Modular form components with some pre-configured form inputs for common use-cases.

npm install @stnew/forms

FormInput

A controlled component that composes an input element with a wrapper element and an optional and extendable indicator component. The indicator component is meant to provide visual indication of valid/invalid states.

import { FormInput } from '@stnew/forms';
Controlled PropsTypeDesc
typestringtype of the input field
valuestringcurrent value of the input field
invalidbooleanshould be true if the current value is invalid
validatedbooleanshould be true if the current value is valid
General PropsTypeDesc
idstringid of the input element
namestringname of the input element
classNamestringclass of the input element
requiredbooleantoggle to make the input field required
autoFocusbooleantoggle to make the input field focused by default
placeholderstringplaceholder text for the input field
customInputIndicatorReactNodeElement to be nested in the existing indicator div element
disableIndicatorbooleanif true, the indicator div element will not be rendered
onChangefunctiononChange callback function
onFocusfunctiononFocus callback function
onBlurfunctiononBlur callback function

ValidatedInput

Component that wraps FormInput and handles validation and state management.

import { ValidatedInput } from '@stnew/forms';
PropsTypeDesc
onValidfunctioncallback for when the input's value is valid
onInvalidfunctioncallback for when the input's value is invalid
onEmptyfunctioncallback for when the input's value is empty
validatorfunctionfunction that takes in the value of the input and returns true if valid, false otherwise
typestringtype of the input element
inputobjectobject will all attributes listed under 'General Props' for FormInput

Others

The package also includes some extentions of ValidatedInput that have built-in validation functions for common use cases. Each of these are the same, but with different validation functions.

  • EmailInput
  • ZipCodeInput
import { EmailInput, ZipCodeInput } from '@stnew/forms';
PropsTypeDesc
onValidfunctioncallback for when the input's value is valid
onInvalidfunctioncallback for when the input's value is invalid
onEmptyfunctioncallback for when the input's value is empty
  • also includes all props listed under 'General Props' for FormInput

FAQs

Package last updated on 29 Aug 2019

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts