-
Notifications
You must be signed in to change notification settings - Fork 338
feat(tag-input): tag-input component #3951
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,182 @@ | ||
| export default { | ||
| mode: ['pc', 'mobile-first'], | ||
| apis: [ | ||
| { | ||
| name: 'tag-input', | ||
| type: 'component', | ||
| props: [ | ||
| { | ||
| name: 'model-value / v-model', | ||
| type: 'array', | ||
| defaultValue: '[]', | ||
| desc: { | ||
| 'zh-CN': '绑定值', | ||
| 'en-US': 'Binding Value' | ||
| }, | ||
| mode: ['pc', 'mobile-first'], | ||
| pcDemo: 'tag-group-size', | ||
| mfDemo: 'tag-group-size' | ||
| }, | ||
| { | ||
| name: 'size', | ||
| type: "'medium' | 'small'", | ||
| defaultValue: "'medium'", | ||
| desc: { | ||
| 'zh-CN': '尺寸', | ||
| 'en-US': 'Size ' | ||
| }, | ||
| mode: ['pc', 'mobile-first'], | ||
| pcDemo: 'tag-group-size', | ||
| mfDemo: 'tag-group-size' | ||
| }, | ||
| { | ||
| name: 'tag-type', | ||
| typeAnchorName: 'IType', | ||
| type: 'IType', | ||
| defaultValue: '', | ||
| desc: { | ||
| 'zh-CN': '显示类型', | ||
| 'en-US': 'Display type' | ||
| }, | ||
| mode: ['pc', 'mobile-first'], | ||
| pcDemo: 'basic-usage', | ||
| mfDemo: '' | ||
| }, | ||
| { | ||
| name: 'tag-effect', | ||
| typeAnchorName: 'IEffect', | ||
| type: 'IEffect', | ||
| defaultValue: "'light'", | ||
| desc: { | ||
| 'zh-CN': '主题', | ||
| 'en-US': 'Theme Color' | ||
| }, | ||
| mode: ['pc', 'mobile-first'], | ||
| pcDemo: 'effect', | ||
| mfDemo: '' | ||
| }, | ||
| { | ||
| name: 'clearable', | ||
| type: 'boolean', | ||
| defaultValue: 'false', | ||
| desc: { | ||
| 'zh-CN': '是否可清空', | ||
| 'en-US': 'Whether it can be cleared' | ||
| }, | ||
| mode: ['pc', 'mobile-first'], | ||
| pcDemo: 'basic-usage', | ||
| mfDemo: '' | ||
| }, | ||
| { | ||
| name: 'disabled', | ||
| type: 'boolean', | ||
| defaultValue: 'false', | ||
| desc: { | ||
| 'zh-CN': '是否禁用标签输入框', | ||
| 'en-US': 'Whether the tag input box is disabled' | ||
| }, | ||
| mode: ['pc', 'mobile-first'], | ||
| pcDemo: 'basic-usage', | ||
| mfDemo: '' | ||
| }, | ||
| { | ||
| name: 'max', | ||
| type: 'number', | ||
| defaultValue: 'Infinity', | ||
| desc: { | ||
| 'zh-CN': '最大允许输入的标签数量', | ||
| 'en-US': 'Maximum number of tags allowed to be input' | ||
| }, | ||
| mode: ['pc', 'mobile-first'], | ||
| pcDemo: 'basic-usage', | ||
| mfDemo: '' | ||
| }, | ||
| { | ||
| name: 'placeholder', | ||
| type: 'string', | ||
| defaultValue: '', | ||
| desc: { | ||
| 'zh-CN': '占位符', | ||
| 'en-US': 'Placeholder' | ||
| }, | ||
| mode: ['pc', 'mobile-first'], | ||
| pcDemo: 'basic-usage', | ||
| mfDemo: '' | ||
| }, | ||
| { | ||
| name: 'readonly', | ||
| type: 'boolean', | ||
| defaultValue: 'false', | ||
| desc: { | ||
| 'zh-CN': '是否只读', | ||
| 'en-US': 'Whether it is read-only' | ||
| }, | ||
| mode: ['pc', 'mobile-first'], | ||
| pcDemo: 'basic-usage', | ||
| mfDemo: '' | ||
| }, | ||
| { | ||
| name: 'draggable', | ||
| type: 'boolean', | ||
| defaultValue: 'false', | ||
| desc: { | ||
| 'zh-CN': '是否可拖拽', | ||
| 'en-US': 'Whether it is draggable' | ||
| }, | ||
| mode: ['pc', 'mobile-first'], | ||
| pcDemo: 'basic-usage', | ||
| mfDemo: '' | ||
| }, | ||
| { | ||
| name: 'minCollapsedNum', | ||
| type: 'number', | ||
| defaultValue: 'Infinity', | ||
| desc: { | ||
| 'zh-CN': '最小折叠数量', | ||
| 'en-US': 'Minimum collapsed number' | ||
| }, | ||
| mode: ['pc', 'mobile-first'], | ||
| pcDemo: 'basic-usage', | ||
| mfDemo: '' | ||
| }, | ||
| { | ||
| name: 'separator', | ||
| type: 'string', | ||
| defaultValue: ',', | ||
| desc: { | ||
| 'zh-CN': '批量输入时标签分隔符', | ||
| 'en-US': 'Tag separator for batch input' | ||
| }, | ||
| mode: ['pc', 'mobile-first'], | ||
| pcDemo: 'basic-usage', | ||
| mfDemo: '' | ||
| } | ||
| ], | ||
| events: [], | ||
| methods: [], | ||
| slots: [ | ||
| { | ||
| name: 'prefix', | ||
| defaultValue: '', | ||
| desc: { | ||
| 'zh-CN': '输入框前缀内容的插槽', | ||
| 'en-US': 'Input prefix slot' | ||
| }, | ||
| mode: ['pc'], | ||
| pcDemo: 'basic-usage' | ||
| }, | ||
| { | ||
| name: 'suffix', | ||
| defaultValue: '', | ||
| desc: { | ||
| 'zh-CN': '输入框后缀内容的插槽', | ||
| 'en-US': 'Input suffix slot' | ||
| }, | ||
| mode: ['pc'], | ||
| pcDemo: 'basic-usage' | ||
| } | ||
| ] | ||
| } | ||
| ], | ||
| types: [] | ||
| } | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,23 @@ | ||
| <template> | ||
| <div class="tiny-tag-input-demo"> | ||
| <tiny-tag-input v-model="data" :placeholder="placeholder"></tiny-tag-input> | ||
| <tiny-tag-input v-model="data1" :placeholder="placeholder" tag-type="info" tag-effect="light"></tiny-tag-input> | ||
| <tiny-tag-input v-model="data2" :placeholder="placeholder" tag-type="success" tag-effect="plain"></tiny-tag-input> | ||
| </div> | ||
| </template> | ||
|
|
||
| <script setup> | ||
| import { TinyTagInput } from '@opentiny/vue' | ||
| import { reactive, ref } from 'vue' | ||
|
|
||
| const data = reactive(['tag1', 'tag2', 'tag3', 'tag4', 'tag5', 'tag6']) | ||
| const data1 = reactive(['tag1', 'tag2', 'tag3', 'tag4', 'tag5', 'tag6']) | ||
| const data2 = reactive(['tag1', 'tag2', 'tag3', 'tag4', 'tag5', 'tag6']) | ||
| const placeholder = ref('please enter a tag') | ||
| </script> | ||
|
|
||
| <style scoped> | ||
| .tiny-tag-input-demo .tiny-tag-input { | ||
| margin-bottom: 20px; | ||
| } | ||
| </style> |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,32 @@ | ||
| <template> | ||
| <div class="tiny-tag-input-demo"> | ||
| <tiny-tag-input v-model="data" :placeholder="placeholder"></tiny-tag-input> | ||
| <tiny-tag-input v-model="data1" :placeholder="placeholder" tag-type="info" tag-effect="light"></tiny-tag-input> | ||
| <tiny-tag-input v-model="data2" :placeholder="placeholder" tag-type="success" tag-effect="plain"></tiny-tag-input> | ||
| </div> | ||
| </template> | ||
|
|
||
| <script> | ||
| import { TinyTagInput } from '@opentiny/vue' | ||
|
|
||
| export default { | ||
| components: { | ||
| TinyTagInput | ||
| }, | ||
| data() { | ||
| return { | ||
| data: ['tag1', 'tag2', 'tag3', 'tag4', 'tag5', 'tag6'], | ||
|
Collaborator
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 问题: tagInput的数据格式,是否需要支持对象,比如 : {label: 'tag1', value: 't1" } 原因: select中的多选是使用到tagInput组件的, 它需要上面的格式。 所以tagINput的data 不能是简单的 string[]
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. select多选组件应该无法使用这个组件。 |
||
| data1: ['tag1', 'tag2', 'tag3', 'tag4', 'tag5', 'tag6'], | ||
| data2: ['tag1', 'tag2', 'tag3', 'tag4', 'tag5', 'tag6'], | ||
| maxTagCount: 3, | ||
| placeholder: 'please enter a tag' | ||
| } | ||
| } | ||
| } | ||
| </script> | ||
|
|
||
| <style scoped> | ||
| .tiny-tag-input-demo .tiny-tag-input { | ||
| margin-bottom: 20px; | ||
| } | ||
| </style> | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,7 @@ | ||
| --- | ||
| title: TagInput 标签输入框 | ||
| --- | ||
|
|
||
| # TagInput 标签输入框 | ||
|
|
||
| <div>用于输入标签。</div> |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,7 @@ | ||
| --- | ||
| title: TagInput | ||
| --- | ||
|
|
||
| # TagInput | ||
|
|
||
| <div>Used to enter the label.</div> |
| Original file line number | Diff line number | Diff line change | ||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|
| @@ -0,0 +1,23 @@ | ||||||||||||
| export default { | ||||||||||||
| column: '2', | ||||||||||||
| owner: '', | ||||||||||||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Suggested change
|
||||||||||||
| meta: { | ||||||||||||
| experimental: '3.29.0' | ||||||||||||
| }, | ||||||||||||
| show: true, | ||||||||||||
| cloud: true, | ||||||||||||
| demos: [ | ||||||||||||
| { | ||||||||||||
| demoId: 'basic-usage', | ||||||||||||
| name: { | ||||||||||||
| 'zh-CN': '基本用法', | ||||||||||||
| 'en-US': 'basic usage' | ||||||||||||
| }, | ||||||||||||
| desc: { | ||||||||||||
| 'zh-CN': `按enter回车键添加标签,按backspace删除最后一个标签。<br>`, | ||||||||||||
| 'en-US': `Press Enter to add a tag, and press Backspace to delete the last one. <br>` | ||||||||||||
| }, | ||||||||||||
| codeFiles: ['basic-usage.vue'] | ||||||||||||
| } | ||||||||||||
| ] | ||||||||||||
| } | ||||||||||||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
AUI6曾使用 maxTagCount 来表示要展示的最大数。---- 建议只使用这个
max如果是限制 data的数组长度,完全没有必要。
minCollapsedNum: 这个属性名字也不好理解哪个值最小, 显示的最小还是隐藏起来的tag数最小。
max, minCollapsedNum 建议都去掉
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
我认为还是有必要的
max:限制用户输入添加的标签数量的
minCollapsedNum:表示标签数量超过minCollapsedNum,就折叠展示后面的标签