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