This repository was archived by the owner on Mar 14, 2025. It is now read-only.
File tree 4 files changed +35
-3
lines changed
4 files changed +35
-3
lines changed Original file line number Diff line number Diff line change 1
1
# Changelog
2
2
3
+ ## [ 6.1.0] ( https://github.com/ankurk91/vue-flatpickr-component/compare/6.0.0...6.1.0 )
4
+ * Add: ` events ` props to customise the emitted events, fixes [ #53 ] ( https://github.com/ankurk91/vue-flatpickr-component/issues/53 )
5
+ ``` html
6
+ <flatpickr v-model =" date" events =" ['onChange']" >
7
+ ```
8
+ - `events` prop is optional and component emits all events when prop is not specified.
9
+
3
10
## [6.0.0](https://github.com/ankurk91/vue-flatpickr-component/compare/5.0.5...6.0.0)
4
11
* Add: emit all events, fixes [#37](https://github.com/ankurk91/vue-flatpickr-component/issues/37)
5
12
* Fix: dynamically change configs, [#20](https://github.com/ankurk91/vue-flatpickr-component/issues/20)
Original file line number Diff line number Diff line change @@ -154,6 +154,7 @@ The component accepts these props:
154
154
| :--- | :---: | :---: | :--- |
155
155
| v-model / value | String / Date Object / Array / Timestamp / null | ` null ` | Set or Get date-picker value (required) |
156
156
| config | Object | ` {wrap:false} ` | Flatpickr configuration [ options] ( https://chmln.github.io/flatpickr/options/ ) |
157
+ | events | Array | Array of all events | Customise the [ events] ( https://chmln.github.io/flatpickr/events/ ) to be emitted|
157
158
158
159
## Install in non-module environments (without webpack)
159
160
* Include required files
Original file line number Diff line number Diff line change @@ -46,5 +46,24 @@ describe('Flatpickr events', () => {
46
46
expect ( onChangeStub ) . toHaveBeenCalled ( ) ;
47
47
} ) ;
48
48
49
+ test ( 'emits only those are specified via prop' , ( ) => {
50
+ wrapper = shallow ( Component , {
51
+ propsData : {
52
+ value : null ,
53
+ events : [ 'onChange' ]
54
+ }
55
+ } ) ;
56
+
57
+ const onOpen = jest . fn ( ) ;
58
+ wrapper . vm . $on ( 'on-open' , onOpen ) ;
59
+ wrapper . trigger ( 'focus' ) ;
60
+ expect ( onOpen ) . not . toHaveBeenCalled ( ) ;
61
+
62
+ const onChange = jest . fn ( ) ;
63
+ wrapper . vm . $on ( 'on-change' , onChange ) ;
64
+ wrapper . setProps ( { value : '2017-10-04' } ) ;
65
+ expect ( onChange ) . toHaveBeenCalled ( ) ;
66
+ } ) ;
67
+
49
68
50
69
} ) ;
Original file line number Diff line number Diff line change 50
50
wrap: false
51
51
})
52
52
},
53
+ events: {
54
+ type: Array ,
55
+ default : () => hooks
56
+ }
53
57
},
54
58
data () {
55
59
return {
64
68
/* istanbul ignore if */
65
69
if (this .fp ) return ;
66
70
67
- // Inject our method into hooks array
68
- hooks .forEach ((hook ) => {
71
+ // Inject our method into events array
72
+ this . events .forEach ((hook ) => {
69
73
this .config [hook] = arrayify (this .config [hook] || []).concat ((... args ) => {
70
74
this .$emit (camelToKebab (hook), ... args)
71
75
});
104
108
config: {
105
109
deep: true ,
106
110
handler (newConfig ) {
107
- // Workaround: Don't pass hooks to configs again
111
+ // Workaround: Don't pass hooks to configs again otherwise
112
+ // previously registered hooks will stop working
108
113
hooks .forEach ((hook ) => {
109
114
delete newConfig[hook];
110
115
});
You can’t perform that action at this time.
0 commit comments