diff --git a/CHANGELOG.md b/CHANGELOG.md index 757eaed..e9ce836 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,3 +1,9 @@ +## [2.0.0-rc1] - 2016-09-22 + +## Breaking changes +- Vue 2.0 now required +- `v-focus-model` and `v-focus-auto` are removed + ## [1.0.0] - 2016-09-22 ## Changed @@ -30,3 +36,4 @@ Initial release [0.1.1]: https://github.com/simplesmiler/vue-focus/compare/0.1.0...0.1.1 [0.1.2]: https://github.com/simplesmiler/vue-focus/compare/0.1.1...0.1.2 [1.0.0]: https://github.com/simplesmiler/vue-focus/compare/0.1.2...1.0.0 +[2.0.0-rc1]: https://github.com/simplesmiler/vue-focus/compare/1.0.0...2.0.0-rc1 diff --git a/dist/vue-focus.common.js b/dist/vue-focus.common.js index cd1217e..bb8040c 100644 --- a/dist/vue-focus.common.js +++ b/dist/vue-focus.common.js @@ -1,138 +1,22 @@ 'use strict'; -var Vue = require('vue'); -var Vue__default = 'default' in Vue ? Vue['default'] : Vue; - -// @NOTE: We have to use Vue.nextTick because the element might not be -// present at the time model changes, but will be in the next batch. -// But because we use Vue.nextTick, the directive may already be unbound -// by the time the callback executes, so we have to make sure it was not. - var focus = { - priority: 1000, - - bind: function() { - var self = this; - this.bound = true; - - this.focus = function() { - if (self.bound === true) { - self.el.focus(); - } - }; - - this.blur = function() { - if (self.bound === true) { - self.el.blur(); - } - }; - }, - - update: function(value) { - if (value) { - Vue__default.nextTick(this.focus); - } else { - Vue__default.nextTick(this.blur); - } + inserted: function(el, binding) { + if (binding.value) el.focus(); + else el.blur(); }, - unbind: function() { - this.bound = false; - }, -}; - -var focusModel = { - twoWay: true, - priority: 1000, - - bind: function() { - Vue.util.warn( - this.name + '="' + - this.expression + '" is deprecated, ' + - 'use v-focus="' + this.expression + '" @focus="' + this.expression + ' = true" @blur="' + this.expression + ' = false" instead' - ); - - var self = this; - this.bound = true; - - this.focus = function() { - if (self.bound === true) { - self.el.focus(); - } - }; - - this.blur = function() { - if (self.bound === true) { - self.el.blur(); - } - }; - - this.focusHandler = function() { - self.set(true); - }; - - this.blurHandler = function() { - self.set(false); - }; - - Vue.util.on(this.el, 'focus', this.focusHandler); - Vue.util.on(this.el, 'blur', this.blurHandler); - }, - - update: function(value) { - if (value === true) { - Vue__default.nextTick(this.focus); - } else if (value === false) { - Vue__default.nextTick(this.blur); - } else { - if (process.env.NODE_ENV !== 'production') { - Vue.util.warn( - this.name + '="' + - this.expression + '" expects a boolean value, ' + - 'got ' + JSON.stringify(value) - ); - } - } - }, - - unbind: function() { - Vue.util.off(this.el, 'focus', this.focusHandler); - Vue.util.off(this.el, 'blur', this.blurHandler); - this.bound = false; - }, -}; - -var focusAuto = { - priority: 100, - bind: function() { - Vue.util.warn( - this.name + ' is deprecated, ' + - 'use v-focus="true" instead' - ); - - var self = this; - this.bound = true; - - Vue__default.nextTick(function() { - if (self.bound === true) { - self.el.focus(); - } - }); - }, - unbind: function(){ - this.bound = false; + componentUpdated: function(el, binding) { + if (binding.value) el.focus(); + else el.blur(); }, }; var mixin = { directives: { focus: focus, - focusModel: focusModel, - focusAuto: focusAuto, }, }; exports.focus = focus; -exports.focusModel = focusModel; -exports.focusAuto = focusAuto; exports.mixin = mixin; \ No newline at end of file diff --git a/dist/vue-focus.js b/dist/vue-focus.js index e6c5c34..9c129ab 100644 --- a/dist/vue-focus.js +++ b/dist/vue-focus.js @@ -1,139 +1,24 @@ -(function (exports,Vue) { 'use strict'; - - var Vue__default = 'default' in Vue ? Vue['default'] : Vue; - - // @NOTE: We have to use Vue.nextTick because the element might not be - // present at the time model changes, but will be in the next batch. - // But because we use Vue.nextTick, the directive may already be unbound - // by the time the callback executes, so we have to make sure it was not. +(function (exports) { 'use strict'; var focus = { - priority: 1000, - - bind: function() { - var self = this; - this.bound = true; - - this.focus = function() { - if (self.bound === true) { - self.el.focus(); - } - }; - - this.blur = function() { - if (self.bound === true) { - self.el.blur(); - } - }; - }, - - update: function(value) { - if (value) { - Vue__default.nextTick(this.focus); - } else { - Vue__default.nextTick(this.blur); - } + inserted: function(el, binding) { + if (binding.value) el.focus(); + else el.blur(); }, - unbind: function() { - this.bound = false; - }, - }; - - var focusModel = { - twoWay: true, - priority: 1000, - - bind: function() { - Vue.util.warn( - this.name + '="' + - this.expression + '" is deprecated, ' + - 'use v-focus="' + this.expression + '" @focus="' + this.expression + ' = true" @blur="' + this.expression + ' = false" instead' - ); - - var self = this; - this.bound = true; - - this.focus = function() { - if (self.bound === true) { - self.el.focus(); - } - }; - - this.blur = function() { - if (self.bound === true) { - self.el.blur(); - } - }; - - this.focusHandler = function() { - self.set(true); - }; - - this.blurHandler = function() { - self.set(false); - }; - - Vue.util.on(this.el, 'focus', this.focusHandler); - Vue.util.on(this.el, 'blur', this.blurHandler); - }, - - update: function(value) { - if (value === true) { - Vue__default.nextTick(this.focus); - } else if (value === false) { - Vue__default.nextTick(this.blur); - } else { - if ('development' !== 'production') { - Vue.util.warn( - this.name + '="' + - this.expression + '" expects a boolean value, ' + - 'got ' + JSON.stringify(value) - ); - } - } - }, - - unbind: function() { - Vue.util.off(this.el, 'focus', this.focusHandler); - Vue.util.off(this.el, 'blur', this.blurHandler); - this.bound = false; - }, - }; - - var focusAuto = { - priority: 100, - bind: function() { - Vue.util.warn( - this.name + ' is deprecated, ' + - 'use v-focus="true" instead' - ); - - var self = this; - this.bound = true; - - Vue__default.nextTick(function() { - if (self.bound === true) { - self.el.focus(); - } - }); - }, - unbind: function(){ - this.bound = false; + componentUpdated: function(el, binding) { + if (binding.value) el.focus(); + else el.blur(); }, }; var mixin = { directives: { focus: focus, - focusModel: focusModel, - focusAuto: focusAuto, }, }; exports.focus = focus; - exports.focusModel = focusModel; - exports.focusAuto = focusAuto; exports.mixin = mixin; -})((this.VueFocus = {}),Vue); \ No newline at end of file +})((this.VueFocus = {})); \ No newline at end of file diff --git a/dist/vue-focus.min.js b/dist/vue-focus.min.js index d1d92cf..37e2168 100644 --- a/dist/vue-focus.min.js +++ b/dist/vue-focus.min.js @@ -1 +1 @@ -!function(i,u){"use strict";var t="default"in u?u.default:u,n={priority:1e3,bind:function(){var i=this;this.bound=!0,this.focus=function(){i.bound===!0&&i.el.focus()},this.blur=function(){i.bound===!0&&i.el.blur()}},update:function(i){i?t.nextTick(this.focus):t.nextTick(this.blur)},unbind:function(){this.bound=!1}},s={twoWay:!0,priority:1e3,bind:function(){u.util.warn(this.name+'="'+this.expression+'" is deprecated, use v-focus="'+this.expression+'" @focus="'+this.expression+' = true" @blur="'+this.expression+' = false" instead');var i=this;this.bound=!0,this.focus=function(){i.bound===!0&&i.el.focus()},this.blur=function(){i.bound===!0&&i.el.blur()},this.focusHandler=function(){i.set(!0)},this.blurHandler=function(){i.set(!1)},u.util.on(this.el,"focus",this.focusHandler),u.util.on(this.el,"blur",this.blurHandler)},update:function(i){i===!0?t.nextTick(this.focus):i===!1&&t.nextTick(this.blur)},unbind:function(){u.util.off(this.el,"focus",this.focusHandler),u.util.off(this.el,"blur",this.blurHandler),this.bound=!1}},o={priority:100,bind:function(){u.util.warn(this.name+' is deprecated, use v-focus="true" instead');var i=this;this.bound=!0,t.nextTick(function(){i.bound===!0&&i.el.focus()})},unbind:function(){this.bound=!1}},e={directives:{focus:n,focusModel:s,focusAuto:o}};i.focus=n,i.focusModel=s,i.focusAuto=o,i.mixin=e}(this.VueFocus={},Vue); \ No newline at end of file +!function(u){"use strict";var c={inserted:function(u,c){c.value?u.focus():u.blur()},componentUpdated:function(u,c){c.value?u.focus():u.blur()}},e={directives:{focus:c}};u.focus=c,u.mixin=e}(this.VueFocus={}); \ No newline at end of file diff --git a/package.json b/package.json index 078c3c3..a8bf192 100644 --- a/package.json +++ b/package.json @@ -1,7 +1,7 @@ { "name": "vue-focus", "description": "A set of reusable focus directives for reusable Vue.js components", - "version": "1.0.0", + "version": "2.0.0-rc1", "author": "Denis Karabaza ", "browserify": { "transform": [ @@ -36,7 +36,7 @@ "license": "MIT", "main": "dist/vue-focus.common.js", "peerDependencies": { - "vue": "^1.0.0" + "vue": "^2.0.0" }, "repository": { "type": "git",