Socket
Socket
Sign inDemoInstall

m-inputs

Package Overview
Dependencies
23
Maintainers
1
Versions
2
Alerts
File Explorer

Advanced tools

Install Socket

Detect and block malicious and high-risk dependencies

Install

    m-inputs

m-inputs 输入框


Version published
Weekly downloads
2
Maintainers
1
Install size
5.51 MB
Created
Weekly downloads
 

Readme

Source

m-inputs


用于表单的输入。

何时使用

封装了原生的input和textarea输入框,当需要使用表单输入的时候使用此组件。

API

属性说明类型默认值
type设置输入框样式类型,可选值为bordered linestringbordered
htmlType设置输入框的html类型,可选值为input的原生类型以及textareastringtext
defaultValue输入框的默认值string
placeholder输入框的提示文案string
clearable是否有清除按钮,htmlType为textarea时无效booleantrue
countertextarea的计数器,只有当htmlType是textarea的时候生效booleanfalse
state输入框的状态,可选值为error, success, warningstring
readOnly设置输入框为只读booleanfalse
disabled禁用输入框booleanfalse
onChange输入框的内容change事件Function

基本输入框

  • order: 0

基本输入框默认是带边框的,其中htmlType与原生的input类型对应,默认为'text',其它属性如nameplaceholderreadonlydisabledmaxLength等所原生input属性一致;

clearable属性表示是否带清除按钮,默认为true


import {FormItem, Input} from 'npm_name';
ReactDOM.render(
    <div>
        <FormItem>
            <Input onChange={(curr, prev) => console.log('%conChange: ', 'color:green', curr, prev)} maxLength="20" placeholder="普通的输入框(默认带清除按钮)" />
        </FormItem>
        <FormItem>
            <Input clearable={false} placeholder="不带清除按钮的输入框" />
        </FormItem>
        <FormItem>
            <Input htmlType="password" maxLength="20" placeholder="密码输入框" />
        </FormItem>
        <FormItem>
            <Input htmlType="search" defaultValue="秋裤" clearable placeholder="搜索框" />
        </FormItem>
        <FormItem>
            <Input readOnly defaultValue="只读的文本框" />
        </FormItem>
        <FormItem>
            <Input disabled defaultValue="禁用的文本框" />
        </FormItem>
    </div>
, document.getElementById('container'));

下横线输入框

  • order: 1

通过设置type="line"使输入框只带下横线。


import {FormItem, Input} from 'npm_name';
ReactDOM.render(
    <div>
        <FormItem>
            <Input type="line" placeholder="下横线文本框" />
        </FormItem>
        <FormItem>
            <Input type="line" disabled defaultValue="禁用的下横线文本框" />
        </FormItem>
        <FormItem>
            <Input type="line" defaultValue="我是默认的值~~" placeholder="带清除的下横线文本框" />
        </FormItem>
        <FormItem>
            <Input type="line" readOnly defaultValue="只读的下横线文本框" />
        </FormItem>
        <FormItem>
            <Input type="line" htmlType="password" placeholder="请输入密码……" />
        </FormItem>
    </div>
, document.getElementById('container'));

不同显示状态

  • order: 2

通过设置state来改变输入框的显示状态,可选值有errorsuccesswarning


import {FormItem, Input} from 'npm_name';
ReactDOM.render(
    <div>
        <FormItem>
            <Input state="error" placeholder="状态为error" />
        </FormItem>
        <FormItem>
            <Input state="success" placeholder="状态为success" />
        </FormItem>
        <FormItem>
            <Input state="warning" placeholder="状态为warning" />
        </FormItem>
        <FormItem>
            <Input type="line" state="error" placeholder="状态为error" />
        </FormItem>
        <FormItem>
            <Input type="line" state="success" placeholder="状态为success" />
        </FormItem>
        <FormItem>
            <Input type="line" state="warning" placeholder="状态为warning" />
        </FormItem>
    </div>
, document.getElementById('container'));

多行文件输入框

  • order: 3

通过设置htmlType="textarea"显示为多行文件输入框,即原生的textarea,其它属性colrow等textarea的原生属性均会生效;

通过设置counter来增加文本记数器,默认为false


import {FormItem, Input} from 'npm_name';
ReactDOM.render(
    <div>
        <FormItem>
            <Input htmlType="textarea" maxLength="100" placeholder="普通的textarea" />
        </FormItem>
        <FormItem>
            <Input htmlType="textarea" maxLength="150" counter placeholder="带记数器的textarea" />
        </FormItem>
    </div>
, document.getElementById('container'));

Keywords

FAQs

Last updated on 23 May 2017

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.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc