1.1.3 • Published 2 years ago

@alitajs/input-tag v1.1.3

Weekly downloads
-
License
MIT
Repository
github
Last release
2 years ago

@alitajs/input-tag

简介

可输入可设置 tag 的编辑框。

开始使用

$ npm i @alitajs/input-tag

or

$ yarn add @alitajs/input-tag

API

参数说明类型默认值是否必填
valueValueItemProps[][]
onChange值改变事件(res: ValueItemProps) => void-
mode类型tags|multiple|comboboxtags
placeholderplaceholderstring请选择
style样式React.CSSProperties{}
disabled不可编辑booleanfalse
onClick点击事件() => void-
addOnAfter后缀string | React.ReactNode-
editable输入框是否可编辑boolean-

ValueItemProps

参数说明类型默认值是否必填
label文本string-
valuestring-
type类型'text'|'tag'-
disabled是否可编辑booleanfalse

demo

import { Button } from 'antd';
import type { ValueItemProps } from '@alitajs/input-tag';
import Select from '@alitajs/input-tag';

export const getRandom = () => {
  const val = `${Math.random().toString(36).slice(2, 6)}`;
  return val;
};

const Test: React.FC = () => {
  const [value, setValue] = React.useState<ValueItemProps[]>([
    { label: '111', value: '111', type: 'tag', disabled: true },
    { label: '222', value: '222', type: 'text' },
    { label: '333', value: '333', type: 'tag' },
  ]);

  const addTag = () => {
    const random = getRandom();
    const newVal = [...value];
    newVal.push({ label: random, value: random, type: 'tag' });
    setValue(newVal);
  };

  return (
    <div>
      <Select
        placeholder="请选择"
        mode="tags"
        style={{ width: 500 }}
        value={value}
        onChange={(val: ValueItemProps[]) => {
          setValue(val);
        }}
        onClick={() => console.log('this is click')}
      />
      <Button onClick={addTag}>新增一个 tag</Button>
    </div>
  );
};

export default Test;
1.1.3

2 years ago

1.1.2

2 years ago

1.1.1

2 years ago

1.1.0

2 years ago

1.0.9

2 years ago

1.0.8

2 years ago

1.0.7

2 years ago

1.0.6

2 years ago

1.0.5

2 years ago

1.0.4

2 years ago

1.0.3

2 years ago

1.0.2

2 years ago

1.0.1

2 years ago

1.0.0

2 years ago