| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961 |
- import React, { useState, useCallback } from 'react';
- import GraphemeSplitter from 'grapheme-splitter';
- import { isFunction, isString } from 'lodash';
- import {
- Input,
- InputGroup,
- TextArea,
- TimePicker,
- DatePicker,
- AutoComplete,
- Cascader,
- Select,
- TagInput,
- Tree,
- TreeSelect,
- Icon,
- TabPane,
- Tabs,
- Button,
- Typography,
- Switch,
- Form,
- Space,
- Radio,
- InputNumber
- } from '../../index';
- import './input.scss';
- import RTLWrapper from '../../configProvider/_story/RTLDirection/RTLWrapper';
- import { IconSearch, IconCopy, IconClear, IconStar } from '@douyinfe/semi-icons';
- export default {
- title: 'Input',
- parameters: {
- chromatic: { disableSnapshot: true },
- }
- }
- const { Title, Text } = Typography;
- const log = (...args) => console.log(...args);
- export const _Input = () => (
- <div
- className="input"
- style={{
- width: 200,
- }}
- >
- <Input />
- <Input validateStatus="warning" />
- <Input validateStatus="error" />
- <br />
- <br />
- <Input size="large" />
- <Input size="large" validateStatus="warning" />
- <Input size="large" validateStatus="error" />
- <br />
- <br />
- <Input size="small" />
- <Input size="small" validateStatus="warning" />
- <Input size="small" validateStatus="error" />
- </div>
- );
- _Input.parameters = {
- chromatic: { disableSnapshot: false },
- };
- export const InputAutofocus = () => (
- <div className="input">
- <Input placeholder="ies input" autofocus />
- </div>
- );
- InputAutofocus.story = {
- name: 'Input autofocus',
- };
- export const InputPlaceholder = () => (
- <div className="input">
- <Input placeholder="ies input" />
- </div>
- );
- InputPlaceholder.story = {
- name: 'Input placeholder',
- };
- export const InputDisabled = () => (
- <div className="input">
- <Input disabled value="禁用文本框值" />
- </div>
- );
- InputDisabled.parameters = {
- chromatic: { disableSnapshot: false },
- };
- InputDisabled.story = {
- name: 'Input disabled',
- };
- export const InputClearable = () => (
- <div className="input">
- <Input showClear defaultValue="ies" />
- </div>
- );
- InputClearable.story = {
- name: 'Input clearable',
- };
- export const InputPrefixSuffixDemo = () => (
- <div className="input">
- <Input prefix="search" showClear defaultValue="Semi Design" />
- <Input prefix={<span>pre</span>} showClear defaultValue="Semi Design" />
- <Input prefix={<span>pre</span>} showClear defaultValue="Semi Design" />
- <Input suffix={<IconSearch />} autofocus showClear defaultValue="Semi Design"></Input>
- <Input suffix="Semi Design" showClear defaultValue="Semi Design"></Input>
- <Input
- suffix={
- <Typography.Text
- strong
- type="secondary"
- style={{
- margin: '0 8px',
- }}
- >
- Suffix
- </Typography.Text>
- }
- showClear
- defaultValue="Semi Design"
- ></Input>
- </div>
- );
- InputPrefixSuffixDemo.story = {
- name: '前缀/后缀 Input prefix suffix',
- };
- InputPrefixSuffixDemo.parameters = {
- chromatic: { disableSnapshot: false },
- };
- export const InputAddonBeforeAddonAfter = () => (
- <div className="input">
- <Input addonBefore="https://" addonAfter=".com" />
- </div>
- );
- InputAddonBeforeAddonAfter.story = {
- name: '前置/后置标签 Input addonBefore addonAfter',
- };
- InputAddonBeforeAddonAfter.parameters = {
- chromatic: { disableSnapshot: false },
- };
- export const InputPassword = () => (
- <div className="input">
- <Input mode="password" placeholder="请输入密码" />
- <Input mode="password" defaultValue="ies" />
- <Input mode="password" showClear defaultValue="ies" />
- <Input mode="password" disabled defaultValue="ies" />
- </div>
- );
- InputPassword.story = {
- name: 'Input password',
- };
- InputPassword.parameters = {
- chromatic: { disableSnapshot: false },
- };
- export const ControlInput = () => {
- const [value, setValue] = useState('initString');
- return (
- <div className="input">
- <Input value={value} onChange={setValue} showClear />
- <Input value={value} onChange={log} showClear />
- </div>
- );
- };
- ControlInput.story = { name: '受控组件' };
- export const UnControlInput = () => (
- <div className="input">
- <Input onChange={v => console.log(v)} defaultValue="initString" />
- </div>
- );
- UnControlInput.story = { name: '非受控组件' };
- export const Password = () => (
- <div className="input">
- <Input type="password" />
- </div>
- );
- Password.story = {
- name: 'password',
- };
- const treeData = [
- {
- label: '亚洲',
- value: 'Asia',
- key: '0',
- children: [
- {
- label: '中国',
- value: 'China',
- key: '0-0',
- children: [
- {
- label: '北京',
- value: 'Beijing',
- key: '0-0-0',
- },
- {
- label: '上海',
- value: 'Shanghai',
- key: '0-0-1',
- },
- ],
- },
- ],
- },
- {
- label: '北美洲',
- value: 'North America',
- key: '1',
- },
- ];
- export const Group = () => (
- <div className="input">
- <InputGroup>
- <Select
- placeholder="Name"
- style={{
- width: 100,
- }}
- optionList={[
- {
- value: 1,
- label: 1,
- },
- {
- value: 2,
- label: 2,
- },
- ]}
- />
- <Select
- placeholder="Score"
- style={{
- width: 140,
- }}
- optionList={[
- {
- value: 1,
- label: 1,
- },
- {
- value: 2,
- label: 2,
- },
- ]}
- />
- </InputGroup>
- <br />
- <br />
- {/* <InputGroup>
- <Input placeholder="Name" style={{ width: 100 }} />
- <InputNumber placeholder="Score" style={{ width: 140 }} />
- </InputGroup>
- <br/><br/>
- <InputGroup size={'small'}>
- <Select style={{ width: '100px' }} defaultValue='home'>
- <Option value='home'>Home</Option>
- <Option value='work'>Work</Option>
- </Select>
- <AutoComplete
- data={['Beijing Haidian']}
- placeholder='Address: '
- style={{ width: 180 }}
- >
- </AutoComplete>
- </InputGroup>
- <br/><br/>
- <InputGroup size={'small'}>
- <Select style={{ width: '100px' }} defaultValue='signup'>
- <Option value='signup'>Sign Up</Option>
- <Option value='signin'>Sign In</Option>
- </Select>
- <Input placeholder="Email" style={{ width: 180 }} />
- </InputGroup>
- <br/><br/>
- <InputGroup>
- <Select style={{ width: '100px' }} defaultValue='signup'>
- <Option value='signup'>Sign Up</Option>
- <Option value='signin'>Sign In</Option>
- </Select>
- <TreeSelect
- style={{ width: 300 }}
- treeData={treeData}
- placeholder="Please select"
- />
- </InputGroup>
- <br/><br/>
- <InputGroup>
- <Select style={{ width: 100 }} defaultValue='signup'>
- <Option value='signup'>Sign Up</Option>
- <Option value='signin'>Sign In</Option>
- </Select>
- <TreeSelect
- style={{ width: 300 }}
- treeData={treeData}
- placeholder="Please select"
- />
- <Cascader
- style={{ width: 300 }}
- treeData={treeData}
- placeholder="Please select"
- />
- </InputGroup> */}
- </div>
- );
- Group.story = {
- name: 'group',
- };
- Group.parameters = {
- chromatic: { disableSnapshot: false },
- };
- export const Textarea = () => <TextArea limit={100} onChange={v => console.log(v)} />;
- Textarea.story = {
- name: 'textarea',
- };
- export const AutosizeTextarea = () => (
- <div className="input">
- <TextArea autosize onChange={v => console.log(v)} />
- {/* <TextArea autosize limit={500} onChange={v => console.log(v)} />
- <TextArea autosize rows={1} onChange={v => console.log(v)} /> */}
- </div>
- );
- AutosizeTextarea.story = {
- name: 'autosize textarea',
- };
- export const TextareaInnerMaxCount = () => (
- <div className="input">
- <TextArea defaultValue="TextArea without maxCount" />
- <br />
- <br />
- <TextArea maxCount={10} defaultValue="0123456789" />
- <br />
- <br />
- <TextArea maxCount={10} defaultValue="Semi Design System exceed maxCount" />
- <br />
- <br />
- <TextArea maxCount={10} defaultValue="Semi Design System autosize" autosize rows={2} />
- <br />
- <br />
- <TextArea maxCount={10} defaultValue="Semi Design System disabled" disabled />
- <br />
- <br />
- <TextArea maxCount={10} defaultValue="Semi Design System readonly" readonly />
- <br />
- <br />
- <TextArea maxCount={10} defaultValue="Semi Design System warning" validateStatus="warning" />
- <br />
- <br />
- <TextArea maxCount={10} defaultValue="Semi Design System error" validateStatus="error" />
- <br />
- <br />
- <TextArea maxCount={10} defaultValue="Semi Design System normal" validateStatus="normal" />
- <br />
- <br />
- </div>
- );
- TextareaInnerMaxCount.story = {
- name: 'textarea inner maxCount ',
- };
- TextareaInnerMaxCount.parameters = {
- chromatic: { disableSnapshot: false },
- };
- class RefDemo extends React.Component {
- constructor() {
- super();
- this.state = {
- loading: false,
- };
- this.inputRef = React.createRef();
- this.focus = this.focus.bind(this);
- }
- focus(inputValue) {
- console.log(this.inputRef);
- debugger;
- this.inputRef.current.focus();
- }
- render() {
- return (
- <div>
- <Input ref={this.inputRef} />
- <Button onClick={this.focus}>focus</Button>
- </div>
- );
- }
- }
- class TARefDemo extends React.Component {
- constructor() {
- super();
- this.ref = React.createRef();
- this.focus = this.focus.bind(this);
- this.blur = this.blur.bind(this);
- }
- focus(val) {
- console.log(this.ref, val);
- this.ref.current.focus();
- }
- blur() {
- this.ref.current.blur();
- }
- render() {
- return (
- <div>
- <TextArea ref={this.ref} />
- <Button onClick={this.focus}>focus</Button>
- <Button onClick={this.blur}>blur</Button>
- </div>
- );
- }
- }
- export const InputRefDemo = () => (
- <>
- <RefDemo />
- <TARefDemo />
- </>
- );
- InputRefDemo.story = {
- name: 'ref的使用',
- };
- export const InputHideSuffix = () => (
- <div className="input" onClick={() => console.log('clicking DIV....')}>
- <Input suffix={<IconCopy onClick={() => console.log('clicking')} />} showClear hideSuffix />
- </div>
- );
- InputHideSuffix.story = {
- name: 'Input hideSuffix',
- };
- InputHideSuffix.parameters = {
- chromatic: { disableSnapshot: false },
- };
- export const TextareaInTabPane = () => (
- <div>
- <Tabs type="line">
- <TabPane tab="文档" itemKey="1">
- <TextArea
- autosize={true}
- value={
- '卡垃圾速度快;发神经地方;京阿是;大家;发生空间的浪费空间阿莱克斯\n决定分开了京阿是快进到风口浪尖阿斯顿克己复礼卡就是快乐减肥空间就是快乐的健康京阿是快的\n解放路口京阿是来对\n抗肌肤阿就是大家阿节点空间阿斯顿空间卡经典款九分裤阿是加快立法开始饭卡空间发考\n虑时间快放假啊肯德基快放辣椒的;放假啊;江东父老卡快放假\n啊快到家快放假啊的快乐减肥咖哩鸡的卡上看到肌肤卡经典空间卡;框架'
- }
- />
- </TabPane>
- <TabPane tab="快速起步" itemKey="2">
- <TextArea
- autosize={true}
- value={
- '1234\n卡垃圾速度快;发神经地方;京阿是;大家;发生空间的浪费空间阿莱克斯\n决定分开了京阿是快进到风口浪尖阿斯顿克己复礼卡就是快乐减肥空间就是快乐的健康京阿是快的\n解放路口京阿是来对\n抗肌肤阿就是大家阿节点空间阿斯顿空间卡经典款九分裤阿是加快立法开始饭卡空间发考\n虑时间快放假啊肯德基快放辣椒的;放假啊;江东父老卡快放假\n啊快到家快放假啊的快乐减肥咖哩鸡的卡上看到肌肤卡经典空间卡;框架'
- }
- />
- </TabPane>
- </Tabs>
- </div>
- );
- TextareaInTabPane.story = {
- name: 'Textarea in TabPane',
- };
- const ControlTextarea = () => {
- const [value, setValue] = useState('initString');
- return (
- <>
- <TextArea value={value} onChange={setValue} />
- <br />
- <TextArea value={value} onChange={setValue} autosize />
- </>
- );
- };
- export const ControlledTextarea = () => <ControlTextarea />;
- ControlledTextarea.story = {
- name: '受控textarea'
- }
- export const FixAddonBeforeShowClear = () => (
- <Space wrap>
- <Input
- style={{
- width: 300,
- }}
- autofocus
- defaultValue="Semi Design"
- addonBefore="http://"
- showClear
- />
- <Input
- style={{
- width: 300,
- }}
- defaultValue="Semi Design"
- addonBefore="http://"
- addonAfter=".com"
- showClear
- />
- <Input
- style={{
- width: 300,
- }}
- defaultValue="Semi Design"
- showClear
- />
- <Input
- style={{
- width: 300,
- }}
- defaultValue="Semi Design"
- addonBefore="http://"
- />
- <Input
- style={{
- width: 300,
- }}
- defaultValue="Semi Design"
- />
- <Input
- style={{
- width: 300,
- }}
- defaultValue="Semi Design"
- addonBefore="http://"
- showClear
- validateStatus="warning"
- />
- <Input
- style={{
- width: 300,
- }}
- defaultValue="Semi Design"
- addonBefore="http://"
- showClear
- validateStatus="error"
- />
- <Input
- style={{
- width: 300,
- }}
- defaultValue="Semi Design"
- addonBefore="http://"
- mode="password"
- showClear
- />
- <Input
- style={{
- width: 300,
- }}
- defaultValue="Semi Design"
- addonBefore="http://"
- addonAfter=".com"
- mode="password"
- showClear
- />
- <Input
- style={{
- width: 300,
- }}
- defaultValue="Semi Design"
- addonBefore="http://"
- addonAfter=".com"
- mode="password"
- showClear
- size="small"
- />
- <Input
- style={{
- width: 300,
- }}
- defaultValue="Semi Design"
- addonBefore="http://"
- addonAfter=".com"
- mode="password"
- showClear
- size="large"
- />
- </Space>
- );
- FixAddonBeforeShowClear.story = {
- name: 'fix addonBefore + showClear',
- };
- FixAddonBeforeShowClear.parameters = {
- chromatic: { disableSnapshot: false },
- };
- export const FocusWhenClickPrefixSuffix = () => (
- <Space wrap>
- <Input
- style={{ width: 200 }}
- onFocus={() => console.log('focused')}
- prefix="search"
- defaultValue="Semi Design"
- />
- <Input
- style={{ width: 200 }}
- onFocus={() => console.log('focused')}
- onBlur={() => {
- console.log('blur');
- }}
- suffix={<IconSearch />}
- defaultValue="Semi Design"
- ></Input>
- <Input
- disabled
- style={{ width: 200 }}
- onFocus={() => console.log('focused')}
- prefix="search"
- suffix={<IconSearch />}
- defaultValue="disabled"
- />
- </Space>
- );
- FocusWhenClickPrefixSuffix.story = {
- name: 'focus when click prefix/suffix',
- };
- export const GetValueLengthEmojiLengthProcess = () => {
- function getValueLength(str) {
- if (isString(str)) {
- const splitter = new GraphemeSplitter();
- return splitter.countGraphemes(str);
- } else {
- return -1;
- }
- }
- const [getVisibleLengthFC, setGetVisibleLength] = useState(() => getValueLength);
- const [value, setValue] = useState();
- const handleSwitch = useCallback(value => {
- if (value) {
- setGetVisibleLength(() => getValueLength);
- } else {
- setGetVisibleLength(value);
- }
- }, []);
- const strExceed10 = '0123456789semi design';
- return (
- <div className="input">
- <div>
- <Title
- heading={6}
- style={{
- margin: 8,
- }}
- >
- getValueLength = {isFunction(getVisibleLengthFC) ? 'function' : 'null'}
- </Title>
- <Switch checked={isFunction(getVisibleLengthFC)} onChange={handleSwitch}>
- getValueLength
- </Switch>
- </div>
- <h4>maxLength=10</h4>
- <Input
- maxLength={10}
- getValueLength={getVisibleLengthFC}
- style={{
- width: 200,
- }}
- />
- <h4>controlled mode + maxLength=10</h4>
- <Input
- value={value}
- onChange={value => {
- console.log('input change', value);
- setValue(value);
- }}
- maxLength={10}
- getValueLength={getVisibleLengthFC}
- style={{
- width: 200,
- }}
- />
- <h4>controlled mode + given value exceed maxLength</h4>
- <div>
- <Input
- value={strExceed10}
- maxLength={10}
- getValueLength={getVisibleLengthFC}
- style={{
- width: 200,
- }}
- />
- {getVisibleLengthFC && (
- <Text>{`getValueLength('${strExceed10}')=${getVisibleLengthFC(strExceed10)}`}</Text>
- )}
- </div>
- <h4>maxCount=10</h4>
- <TextArea
- maxCount={10}
- getValueLength={getVisibleLengthFC}
- style={{
- width: 200,
- }}
- />
- <h4>maxCount=10 + maxLength=10</h4>
- <TextArea
- maxCount={10}
- maxLength={10}
- getValueLength={getVisibleLengthFC}
- style={{
- width: 200,
- }}
- />
- <h4>form.input + minLength=4</h4>
- <Form>
- <Form.Input
- field="username"
- minLength={4}
- getValueLength={getVisibleLengthFC}
- style={{
- width: 200,
- }}
- />
- <Button type="primary" htmlType="submit">
- 提交
- </Button>
- </Form>
- </div>
- );
- };
- GetValueLengthEmojiLengthProcess.story = {
- name: 'getValueLength emoji length process',
- };
- GetValueLengthEmojiLengthProcess.parameters = {
- chromatic: { disableSnapshot: false },
- };
- const ShowClearTextarea = () => {
- const [value, setValue] = useState('initString');
- const handleChange = value => {
- setValue(value);
- };
- return (
- <>
- <div>受控+onFocus/onBlur</div>
- <TextArea
- value={value}
- onChange={v => handleChange(v)}
- showClear
- onClear={e => console.log('clear', e)}
- onFocus={() => console.log('focus')}
- onBlur={() => console.log('blur')}
- />
- <br />
- <br />
- <div>disabled</div>
- <TextArea defaultValue="123" disabled showClear onClear={e => console.log('clear', e)} />
- <br />
- <br />
- <div>readonly</div>
- <TextArea defaultValue="123" readonly showClear onClear={e => console.log('clear', e)} />
- <br />
- <br />
- <div>rows=1,cols=1</div>
- <TextArea rows={1} cols={1} showClear onClear={e => console.log('clear', e)} />
- </>
- );
- };
- export const TextareaShowClear = () => <ShowClearTextarea />;
- TextareaShowClear.story = {
- name: 'textarea showClear',
- };
- export const ClearButton = () => {
- const [direction, setDirection] = React.useState('ltr');
- const treeData = [
- {
- label: '亚洲',
- value: 'Asia',
- key: '0',
- children: [
- {
- label: '中国',
- value: 'China',
- key: '0-0',
- children: [
- {
- label: '北京',
- value: 'Beijing',
- key: '0-0-0',
- },
- {
- label: '上海',
- value: 'Shanghai',
- key: '0-0-1',
- },
- ],
- },
- ],
- },
- {
- label: '北美洲',
- value: 'North America',
- key: '1',
- },
- ];
- return (
- <RTLWrapper
- onDirectionChange={dir => {
- console.log('dir', dir);
- setDirection(dir);
- }}
- >
- <Input defaultValue="semi" suffix={<IconClear />} />
- <Input defaultValue="semi" showClear suffix={<IconStar />} />
- <Input
- defaultValue="semi"
- showClear
- suffix={
- <Typography.Text
- strong
- type="secondary"
- style={direction === 'ltr' ? { marginRight: 8 } : { marginLeft: 8 }}
- >
- Suffix
- </Typography.Text>
- }
- />
- <Input showClear defaultValue="semi" />
- <Input showClear mode="password" defaultValue="semi" />
- <Input mode="password" defaultValue="semi" />
- <br />
- <br />
- <Cascader defaultValue="semi design" showClear />
- <Select defaultValue="semi design" showClear />
- <TagInput defaultValue={['semi design']} showClear />
- {/* <Transfer showClear /> */}
- <TimePicker defaultValue={new Date()} showClear />
- <DatePicker defaultValue={new Date()} showClear />
- <Tree filterTreeNode treeData={treeData} showClear />
- <TreeSelect defaultValue="semi design" showClear />
- </RTLWrapper>
- );
- };
- ClearButton.story = {
- name: 'clear button',
- };
- export const InputFocus = () => {
- const ref = React.useRef();
- const handleClick = () => {
- ref.current.focus();
- };
- return (
- <>
- <Button onClick={handleClick}>focus input</Button>
- <Input ref={ref} onChange={() => console.log('ref', ref) } onFocus={() => console.log('focus')} />
- </>
- );
- };
- export const TextAreaAutosize = () => {
- return (
- <div style={{ width: 200 }}>
- <TextArea autosize />
- </div>
- )
- };
- TextAreaAutosize.storyName = "textarea autosize";
- export const InputA11y = () => {
- return (
- <div style={{ width: 300 }}>
- <Input prefix="search" defaultValue="Semi Design" showClear />
- <br/><br/>
- <Input aria-required prefix="search" defaultValue="Semi Design" showClear suffix="semi" />
- <br/><br/>
- <Input data-cy="password" defaultValue="Semi Design" mode="password" />
- <br/><br/>
- <Input defaultValue="Semi Design" mode="password" disabled />
- <br/><br/>
- <Input defaultValue='this value is too long' validateStatus='error' showClear></Input>
- <br/><br/>
- <TextArea defaultValue='semi' showClear />
- <TextArea aria-required defaultValue='不能为空' showClear />
- <InputGroup label={{ text: '成绩信息' }}>
- <Input placeholder="Name" style={{ width: 100 }} />
- <Input placeholder="Score" style={{ width: 140 }} />
- </InputGroup>
- <br/><br/>
- <Form onSubmit={() => alert('submit')}>
- <button>submit</button>
- <Form.Input field="password" label="密码按钮上敲击 Enter 测试是否会触发 Form submit" mode="password" />
- </Form>
- </div>
- );
- }
- InputA11y.storyName = "input a11y";
- export const FixInputGroup = () => {
- const groupFocus = () => {
- console.log('group focus');
- }
- const groupBlur = () => {
- console.log('group blur');
- }
- const inputFocus = () => {
- console.log('input focus');
- }
- const inputBlur = () => {
- console.log('input blur');
- }
- return (
- <InputGroup disabled={true} onFocus={groupFocus} onBlur={groupBlur}>
- <Input disabled={false} onFocus={inputFocus} onBlur={inputBlur} placeholder="Name" style={{ width: 100 }} />
- <InputNumber placeholder="Score" style={{ width: 140 }} />
- </InputGroup>
- );
- }
|