Skip to content
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

feat(autoComplete): add inputProps prop #1619

Merged
merged 1 commit into from
Nov 18, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions CHANGELOG.en-US.md
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@
- `n-button` add `secondary` prop.
- `n-button` add `tertiary` prop.
- `n-button` add `quaternary` prop.
- `n-auto-complete` add `input-props` prop, closes [#1610](https://github.com/TuSimple/naive-ui/issues/1610).

### Fixes

Expand Down
1 change: 1 addition & 0 deletions CHANGELOG.zh-CN.md
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@
- `n-button` 新增 `secondary` 属性
- `n-button` 新增 `tertiary` 属性
- `n-button` 新增 `quaternary` 属性
- `n-auto-complete` 新增 `input-props` 属性,关闭 [#1610](https://github.com/TuSimple/naive-ui/issues/1610)

### Fixes

Expand Down
1 change: 1 addition & 0 deletions src/auto-complete/demos/enUS/index.demo-entry.md
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ show-options-by-value
| default-value | `string` | `null` | Default value of autocomplete. |
| disabled | `boolean` | `false` | Whether the autocomplete is disabled. |
| get-show | `(value: string) => boolean` | `undefined` | Use the input to determine whether to show options on focus. |
| input-props | `HTMLInputAttributes` | `undefined` | The attributes of input element in autocomplete. |
| loading | `boolean` | `false` | Whether to show a loading status. |
| options | `Array<string \| AutoCompleteOption \| AutoCompleteGroupOption>` | `[]` | Options to autocomplete from. |
| placeholder | `string` | `'Please Input'` | Autocomplete's placeholder. |
Expand Down
1 change: 1 addition & 0 deletions src/auto-complete/demos/zhCN/index.demo-entry.md
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ show-options-by-value
| default-value | `string` | `null` | 自动填充的默认值 |
| disabled | `boolean` | `false` | 自动填充是否禁用 |
| get-show | `(value: string) => boolean` | `undefined` | 根据输入值在聚焦的状态中决定是否显示菜单 |
| input-props | `HTMLInputAttributes` | `undefined` | 自动填充中 input 元素的属性 |
| loading | `boolean` | `false` | 是否展示加载状态 |
| options | `Array<string \| AutoCompleteOption \| AutoCompleteGroupOption>` | `[]` | 自动填充的自定义选项 |
| placeholder | `string` | `'请输入'` | 自动填充的提示信息 |
Expand Down
5 changes: 4 additions & 1 deletion src/auto-complete/src/AutoComplete.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,8 @@ import {
Transition,
PropType,
withDirectives,
CSSProperties
CSSProperties,
InputHTMLAttributes
} from 'vue'
import { createTreeMate, TreeNode } from 'treemate'
import { VBinder, VTarget, VFollower } from 'vueuc'
Expand Down Expand Up @@ -71,6 +72,7 @@ const autoCompleteProps = {
blurAfterSelect: Boolean,
clearAfterSelect: Boolean,
getShow: Function as PropType<(inputValue: string) => boolean>,
inputProps: Object as PropType<InputHTMLAttributes>,
size: String as PropType<'small' | 'medium' | 'large'>,
options: {
type: Array as PropType<AutoCompleteOptions>,
Expand Down Expand Up @@ -323,6 +325,7 @@ export default defineComponent({
disabled={this.mergedDisabled}
clearable={this.clearable}
loading={this.loading}
inputProps={this.inputProps}
onClear={this.handleClear}
onFocus={this.handleFocus}
onUpdateValue={this.handleInput}
Expand Down
13 changes: 13 additions & 0 deletions src/auto-complete/tests/AutoComplete.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -99,4 +99,17 @@ describe('n-auto-complete', () => {
expect(document.querySelector('.n-auto-complete-menu')).not.toEqual(null)
wrapper.unmount()
})

it('should work with `input-props` prop', async () => {
const wrapper = mount(NAutoComplete, {
props: {
inputProps: {
id: 'input',
max: '10'
}
}
})
expect(wrapper.find('input').attributes('max')).toEqual('10')
wrapper.unmount()
})
})