
Security News
PEP 810 Proposes Explicit Lazy Imports for Python 3.15
An opt-in lazy import keyword aims to speed up Python startups, especially CLIs, without the ecosystem-wide risks that sank PEP 690.
@eaze/input
Advanced tools
This is a new (as of Jan 2017) set of input/form components.
import {
Checkbox,
Password,
Email,
Zipcode,
PhoneNumber,
Form,
Input,
InputWithLabel,
TextField,
Select
} from '@eaze/input'
We need a set of controlled inputs and forms that allow for autocompletion in mobile and enough built-in management that forms come with the following:
Go
on Safari mobile keyboards and manage their disabled statesChanges from old inputs (made by @ghigo):
cloneElement
, so they are safe to modify after constructionForm
componentHere are some examples of how to use/create the new inputs and forms.
Example:
<Form
// define an onSubmit, which will receive an object with
// keys equal to the `name` supplied to each input
// ex: {email: { value: 'john@smith.com', valid: true }, password: { value: '123', valid: false }}
onSubmit={this.onSubmit}
// This submit text will appear on the submit button
// automatically included with and managed by the form
// unless you set the `includeButton` prop to false,
// in which case you'll have to supply your own button.
submitText={'Sign up'}
// `includeButton` defaults to true.
// If you set it to false, supply your own buttons, as in this example
includeButton={false}
>
// A higher level component that consumes `./input-with-label.js`
<EmailInput
name='email'
placeholder='Email'
eagerValidate
required
/>
// ... Other inputs like EmailInput
// Because we declared `includeButton` prop as false, we set buttons here
<div className={style.buttons}>
// Use FormButton when making custom form buttons
// This consumes EazeButton and overwrites props with
// the correct props taken in through React `context` methods
<FormButton
buttonProps={{
loading: this.props.loading,
title: 'Sign up',
type: buttonTypes.PRIMARY
}}
/>
<div className={style.border}>
<Border />
</div>
<div className={style.logIn}>
Already have an account?
<div className={style.logInButton}>
<FormButton
buttonProps={{
title: 'Log In',
type: buttonTypes.TERTIARY
}}
/>
</div>
</div>
</div>
</Form>
Inputs self-register through context methods. Required methods/properties for a new higher-level input include the following:
<Component>.contextTypes
: Must include #register and #onChange context methods to be used in the constructor and when the input updates.this.validators
array of functions that are used by the consumed Input#componentDidMount
: Must register using the this.context.register
function#onChange
: Must make a function that takes the input
's change event and abstracts its value into the context.onChange
methodGenerally you'll want to consume and use InputWithLabel
, as that comes with float labels.
Example:
import React from 'react'
import PropTypes from 'prop-types'
import zip from 'zippo'
import InputWithLabel from './input-with-label'
class Zipcode extends React.Component {
constructor () {
super()
this.onChange = this.onChange.bind(this)
// This array should have functions that either return null when there are no errors
// and return strings of error messages when there are errors
this.validators = [
// check for null if required
(value) => {
if (!this.props.required) return null
if (!value) return 'Zipcode is required.'
},
(value) => {
if (!value) return null
return zip.validate(value) ? null : 'Please enter a valid zipcode'
}
]
}
onChange (e) {
this.context.onChange(this.props.name, e.target.value, this.wrapper.inputContainer.isValid())
}
componentDidMount () {
this.context.register(this.props.name, this.props.initialValue)
}
// if you want to provide a parser to be used by Input, define it here and pass it down.
// Make it a function that takes and returns a string.
parser (value) {
return zip.parse(value || '')
}
render () {
// Use phone type input to force number keyboard on mobile devices
return (
<InputWithLabel
{...this.props}
name={this.props.name}
type='phone'
parser={this.parser}
validators={this.validators}
onChange={this.onChange}
ref={(wrapper) => { this.wrapper = wrapper }}
eagerValidate
/>
)
}
}
Zipcode.contextTypes = {
onChange: PropTypes.func,
register: PropTypes.func
}
export default Zipcode
Disclaimer: This is not a complete list
FAQs
React components:
The npm package @eaze/input receives a total of 5 weekly downloads. As such, @eaze/input popularity was classified as not popular.
We found that @eaze/input demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 22 open source maintainers collaborating on the project.
Did you know?
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.
Security News
An opt-in lazy import keyword aims to speed up Python startups, especially CLIs, without the ecosystem-wide risks that sank PEP 690.
Security News
Socket CEO Feross Aboukhadijeh discusses the recent npm supply chain attacks on PodRocket, covering novel attack vectors and how developers can protect themselves.
Security News
Maintainers back GitHub’s npm security overhaul but raise concerns about CI/CD workflows, enterprise support, and token management.