mirror of
https://github.com/tenrok/vue2-datepicker.git
synced 2026-06-10 13:22:26 +03:00
feat: add prop inputAttr
This commit is contained in:
@@ -92,6 +92,7 @@ export default {
|
||||
| first-day-of-week | Number | 7 | set the first day of week (1-7) |
|
||||
| input-class | String | 'mx-input' | the input class name |
|
||||
| input-name | String | 'date' | the input name attr |
|
||||
| input-attr | Object | | the input attr(eg: { required: true, id: 'input'}) |
|
||||
| confirm-text | String | 'OK' | the default text to display on confirm button |
|
||||
| range-separator | String | '~' | the range separator text |
|
||||
| date-format | String | '' | format the time header and tooltip |
|
||||
|
||||
+4
-2
@@ -12,11 +12,12 @@
|
||||
<div class="mx-input-wrapper"
|
||||
@click="showPopup">
|
||||
<input
|
||||
:class="inputClass"
|
||||
:name="inputName"
|
||||
v-bind="inputAttr"
|
||||
ref="input"
|
||||
type="text"
|
||||
autocomplete="off"
|
||||
:class="inputClass"
|
||||
:name="inputName"
|
||||
:disabled="disabled"
|
||||
:readonly="!editable"
|
||||
:value="text"
|
||||
@@ -185,6 +186,7 @@ export default {
|
||||
type: [String, Array],
|
||||
default: 'mx-input'
|
||||
},
|
||||
inputAttr: Object,
|
||||
appendToBody: {
|
||||
type: Boolean,
|
||||
default: false
|
||||
|
||||
+14
-1
@@ -13,6 +13,17 @@ afterEach(() => {
|
||||
})
|
||||
|
||||
describe('datepicker', () => {
|
||||
it('prop: inputAttr', () => {
|
||||
wrapper = mount(DatePicker, {
|
||||
propsData: {
|
||||
inputAttr: { required: true, id: 'input' }
|
||||
}
|
||||
})
|
||||
const input = wrapper.find('input').element
|
||||
expect(input).toHaveProperty('required', true)
|
||||
expect(input).toHaveProperty('id', 'input')
|
||||
})
|
||||
|
||||
it('prop: appendToBody', () => {
|
||||
wrapper = mount(DatePicker, {
|
||||
propsData: {
|
||||
@@ -366,7 +377,9 @@ describe('calendar-panel', () => {
|
||||
|
||||
it('click: prev/next year', () => {
|
||||
wrapper = mount(CalendarPanel, {
|
||||
value: new Date(2018, 4, 5)
|
||||
propsData: {
|
||||
value: new Date(2018, 4, 5)
|
||||
}
|
||||
})
|
||||
const nextBtn = wrapper.find('.mx-icon-next-year')
|
||||
const lastBtn = wrapper.find('.mx-icon-last-year')
|
||||
|
||||
Reference in New Issue
Block a user