diff --git a/README.md b/README.md index 2a3246e..3966fdd 100644 --- a/README.md +++ b/README.md @@ -136,7 +136,7 @@ export default { }; }, methods: { - onInputChange(text) { + onInputChange(text, oldText) { if (text === null) { /* Maybe the text is null but you wanna do * something else, but don't filter by null. @@ -212,8 +212,10 @@ For more advanced usage, check out the examples below, and explore the
-
@@ -131,7 +130,6 @@ exports[`Autosuggest can mount 1`] = ` class="form-control" >
-
@@ -431,7 +429,6 @@ exports[`Autosuggest can select from suggestions using keystroke 1`] = ` class="form-control" >
-
@@ -460,7 +457,6 @@ exports[`Autosuggest can use escape key to exit 1`] = ` class="form-control" >
-
@@ -541,3 +537,81 @@ exports[`Autosuggest is aria complete 1`] = ` `; + +exports[`Autosuggest onBlur and onFocus work as expected 1`] = ` + +
+ +
+
+
    +
  • + clifford kits +
  • +
  • + friendly chemistry +
  • +
  • + phonics +
  • +
  • + life of fred +
  • +
  • + life of fred math +
  • +
+
+
+
+ +`; diff --git a/__tests__/autosuggest.test.js b/__tests__/autosuggest.test.js index 77bc958..88ad6e2 100644 --- a/__tests__/autosuggest.test.js +++ b/__tests__/autosuggest.test.js @@ -3,7 +3,7 @@ import { createRenderer } from "vue-server-renderer"; import Autosuggest from "../src/Autosuggest.vue"; -Element.prototype.scrollTo = () => {} // https://github.com/vuejs/vue-test-utils/issues/319 +Element.prototype.scrollTo = () => {}; // https://github.com/vuejs/vue-test-utils/issues/319 // Helper to call function x number of times const times = x => f => { @@ -221,26 +221,28 @@ describe("Autosuggest", () => { }); const input = wrapper.find("input"); - expect(input.attributes()['role']).toBe('combobox'); - expect(input.attributes()['aria-autocomplete']).toBe('list'); - expect(input.attributes()['aria-activedescendant']).toBe(''); - expect(input.attributes()['aria-owns']).toBe('autosuggest__results'); - expect(input.attributes()['aria-owns']).toBe('autosuggest__results'); - + expect(input.attributes()["role"]).toBe("combobox"); + expect(input.attributes()["aria-autocomplete"]).toBe("list"); + expect(input.attributes()["aria-activedescendant"]).toBe(""); + expect(input.attributes()["aria-owns"]).toBe("autosuggest__results"); + expect(input.attributes()["aria-owns"]).toBe("autosuggest__results"); + // TODO: Make sure aria-completeness is actually 2legit2quit. - + input.trigger("click"); wrapper.setData({ searchInput: "G" }); - expect(input.attributes()['aria-haspopup']).toBe('true'); - + expect(input.attributes()["aria-haspopup"]).toBe("true"); + const mouseDownTimes = 3; times(mouseDownTimes)(() => { input.trigger("keydown.down"); }); - const activeDescendentString = input.attributes()['aria-activedescendant']; - expect(parseInt(activeDescendentString[activeDescendentString.length -1])).toBe(mouseDownTimes - 1); + const activeDescendentString = input.attributes()["aria-activedescendant"]; + expect(parseInt(activeDescendentString[activeDescendentString.length - 1])).toBe( + mouseDownTimes - 1 + ); expect(input.element.value).toBe(filteredOptions[0].data[mouseDownTimes - 1]); const renderer = createRenderer(); @@ -272,15 +274,15 @@ describe("Autosuggest", () => { const input = wrapper.find("input"); input.trigger("click"); wrapper.setData({ searchInput: "G" }); - + times(3)(() => { - input.trigger("keydown.down"); + input.trigger("keydown.down"); }); - + input.trigger("keydown.enter"); - wrapper.find('li').trigger("mouseover"); - wrapper.find('li').trigger("mouseenter"); - wrapper.find('li').trigger("mouseleave"); + wrapper.find("li").trigger("mouseover"); + wrapper.find("li").trigger("mouseenter"); + wrapper.find("li").trigger("mouseleave"); const renderer = createRenderer(); renderer.renderToString(wrapper.vm, (err, str) => { @@ -290,14 +292,37 @@ describe("Autosuggest", () => { expect(str).toMatchSnapshot(); }); }); -}); -/** - * **Force** update until vue-test-utils is out of beta - * @param {*} wrapper mounted Vue component - */ -function runWatchers(wrapper) { - wrapper.vm._watchers.forEach(watcher => { - watcher.run(); + it("onBlur and onFocus work as expected", async () => { + let props = Object.assign({}, defaultProps); + const mockFn = jest.fn(); + const blurred = () => {mockFn()}; + const focused = () => {mockFn()}; + + props.inputProps.onBlur = blurred; + props.inputProps.onFocus = focused; + + const wrapper = mount(Autosuggest, { + propsData: props, + attachToDocument: true + }); + + const input = wrapper.find("input"); + + input.trigger("click"); + wrapper.setData({ searchInput: "G" }); + await wrapper.vm.$nextTick(() => {}); + + input.trigger("blur"); + input.trigger("focus"); + + const renderer = createRenderer(); + renderer.renderToString(wrapper.vm, (err, str) => { + if (err) { + return false; + } + expect(str).toMatchSnapshot(); + }); + expect(mockFn).toHaveBeenCalledTimes(2); }); -} +}); diff --git a/build/rollup.esm.config.js b/build/rollup.esm.config.js index 0824863..58b237e 100644 --- a/build/rollup.esm.config.js +++ b/build/rollup.esm.config.js @@ -4,7 +4,7 @@ import filesize from "rollup-plugin-filesize"; import json from "rollup-plugin-json"; export default { - entry: "src/vue-autosuggest.js", + input: "src/vue-autosuggest.js", plugins: [ vue({ compileTemplate: true, css: false }), json(), @@ -14,5 +14,10 @@ export default { }), filesize() ], - targets: [{ dest: `dist/vue-autosuggest.esm.js`, format: "es" }] + output: [ + { + file: `dist/vue-autosuggest.esm.js`, + format: "es" + } + ] }; diff --git a/build/rollup.umd.config.js b/build/rollup.umd.config.js index 12164ce..5f2aea0 100644 --- a/build/rollup.umd.config.js +++ b/build/rollup.umd.config.js @@ -8,9 +8,7 @@ import replace from "rollup-plugin-replace"; import json from "rollup-plugin-json"; export default { - entry: "src/vue-autosuggest.js", - moduleName: "VueAutosuggest", - exports: "named", + input: "src/vue-autosuggest.js", plugins: [ vue({ compileTemplate: true, css: false }), json(), @@ -34,5 +32,12 @@ export default { uglify(), filesize() ], - targets: [{ dest: `dist/vue-autosuggest.js`, format: "umd" }] + output: [ + { + name: "VueAutosuggest", + exports: "named", + file: `dist/vue-autosuggest.js`, + format: "umd" + } + ] }; diff --git a/docs/App.vue b/docs/App.vue index 3a53205..c555ad0 100644 --- a/docs/App.vue +++ b/docs/App.vue @@ -7,6 +7,7 @@ :input-props="inputProps" :section-configs="sectionConfigs" :getSuggestionValue="getSuggestionValue" + ref="autocomplete" /> @@ -58,15 +59,12 @@ export default { value: "The Best Blog in the Entire World" }, { - url: - "https://blog.educents.com/best-educational-games-2017-inchimals/", + url: "https://blog.educents.com/best-educational-games-2017-inchimals/", value: "The Best Educational Games and Toys of 2017: Inchimals" }, { - url: - "https://blog.educents.com/reading-exploring-world-through-literature/", - value: - "Family Read-Alouds: Exploring the World Through Literature" + url: "https://blog.educents.com/reading-exploring-world-through-literature/", + value: "Family Read-Alouds: Exploring the World Through Literature" } ] } @@ -88,16 +86,22 @@ export default { }, inputProps: { id: "autosuggest__input", - initialValue: "", onClick: () => {}, onInputChange: this.onInputChange, - placeholder: "Type 'g'" + placeholder: "Type 'g'", + onBlur: () => { + // console.log(e); + }, + onFocus: () => { + // console.log(e); + } } }; }, methods: { onInputChange(text) { let filtered = []; + const suggestionsData = this.options[0].data.filter(item => { return item.toLowerCase().indexOf(text.toLowerCase()) > -1; }); @@ -120,10 +124,10 @@ export default { this.filteredOptions = filtered; }, - getSuggestionValue(item){ - if(item.name == 'blog'){ + getSuggestionValue(item) { + if (item.name == "blog") { return item.item.value; - }else{ + } else { return item.item; } } @@ -206,8 +210,7 @@ body { .autosuggest__results .autosuggest__results_item:active, .autosuggest__results .autosuggest__results_item:hover, .autosuggest__results .autosuggest__results_item:focus, -.autosuggest__results - .autosuggest__results_item.autosuggest__results_item-highlighted { +.autosuggest__results .autosuggest__results_item.autosuggest__results_item-highlighted { background-color: #ddd; } - \ No newline at end of file + diff --git a/docs/build/app.js b/docs/build/app.js index 45139ba..1603d6d 100644 --- a/docs/build/app.js +++ b/docs/build/app.js @@ -60,7 +60,7 @@ /******/ __webpack_require__.p = "/build/"; /******/ /******/ // Load entry module and return exports -/******/ return __webpack_require__(__webpack_require__.s = 41); +/******/ return __webpack_require__(__webpack_require__.s = 44); /******/ }) /************************************************************************/ /******/ ([ @@ -103,8 +103,8 @@ module.exports = __webpack_require__(4) ? function (object, key, value) { /* 3 */ /***/ (function(module, exports, __webpack_require__) { -var anObject = __webpack_require__(9); -var IE8_DOM_DEFINE = __webpack_require__(31); +var anObject = __webpack_require__(10); +var IE8_DOM_DEFINE = __webpack_require__(34); var toPrimitive = __webpack_require__(17); var dP = Object.defineProperty; @@ -126,7 +126,7 @@ exports.f = __webpack_require__(4) ? Object.defineProperty : function defineProp /***/ (function(module, exports, __webpack_require__) { // Thank's IE8 for his funny defineProperty -module.exports = !__webpack_require__(7)(function () { +module.exports = !__webpack_require__(8)(function () { return Object.defineProperty({}, 'a', { get: function () { return 7; } }).a != 7; }); @@ -136,7 +136,7 @@ module.exports = !__webpack_require__(7)(function () { /***/ (function(module, exports, __webpack_require__) { // to indexed object, toObject with fallback for non-array-like ES3 strings -var IObject = __webpack_require__(34); +var IObject = __webpack_require__(37); var defined = __webpack_require__(18); module.exports = function (it) { return IObject(defined(it)); @@ -164,6 +164,15 @@ $exports.store = store; /* 7 */ /***/ (function(module, exports) { +module.exports = function (it) { + return typeof it === 'object' ? it !== null : typeof it === 'function'; +}; + + +/***/ }), +/* 8 */ +/***/ (function(module, exports) { + module.exports = function (exec) { try { return !!exec(); @@ -174,33 +183,24 @@ module.exports = function (exec) { /***/ }), -/* 8 */ +/* 9 */ /***/ (function(module, exports) { -var core = module.exports = { version: '2.5.1' }; +var core = module.exports = { version: '2.5.3' }; if (typeof __e == 'number') __e = core; // eslint-disable-line no-undef /***/ }), -/* 9 */ +/* 10 */ /***/ (function(module, exports, __webpack_require__) { -var isObject = __webpack_require__(10); +var isObject = __webpack_require__(7); module.exports = function (it) { if (!isObject(it)) throw TypeError(it + ' is not an object!'); return it; }; -/***/ }), -/* 10 */ -/***/ (function(module, exports) { - -module.exports = function (it) { - return typeof it === 'object' ? it !== null : typeof it === 'function'; -}; - - /***/ }), /* 11 */ /***/ (function(module, exports) { @@ -220,7 +220,7 @@ module.exports = function (bitmap, value) { /***/ (function(module, exports, __webpack_require__) { // 19.1.2.14 / 15.2.3.14 Object.keys(O) -var $keys = __webpack_require__(33); +var $keys = __webpack_require__(36); var enumBugKeys = __webpack_require__(22); module.exports = Object.keys || function keys(O) { @@ -248,30 +248,32 @@ exports.f = {}.propertyIsEnumerable; /***/ }), /* 15 */ -/***/ (function(module, exports) { +/***/ (function(module, __webpack_exports__, __webpack_require__) { +"use strict"; +/* harmony export (immutable) */ __webpack_exports__["a"] = normalizeComponent; /* globals __VUE_SSR_CONTEXT__ */ -// IMPORTANT: Do NOT use ES2015 features in this file. +// IMPORTANT: Do NOT use ES2015 features in this file (except for modules). // This module is a runtime utility for cleaner component module output and will // be included in the final webpack user bundle. -module.exports = function normalizeComponent ( - rawScriptExports, - compiledTemplate, +function normalizeComponent ( + scriptExports, + render, + staticRenderFns, functionalTemplate, injectStyles, scopeId, - moduleIdentifier /* server only */ + moduleIdentifier, /* server only */ + shadowMode /* vue-cli only */ ) { - var esModule - var scriptExports = rawScriptExports = rawScriptExports || {} + scriptExports = scriptExports || {} // ES6 modules interop - var type = typeof rawScriptExports.default + var type = typeof scriptExports.default if (type === 'object' || type === 'function') { - esModule = rawScriptExports - scriptExports = rawScriptExports.default + scriptExports = scriptExports.default } // Vue.extend constructor export interop @@ -280,9 +282,9 @@ module.exports = function normalizeComponent ( : scriptExports // render functions - if (compiledTemplate) { - options.render = compiledTemplate.render - options.staticRenderFns = compiledTemplate.staticRenderFns + if (render) { + options.render = render + options.staticRenderFns = staticRenderFns options._compiled = true } @@ -321,34 +323,32 @@ module.exports = function normalizeComponent ( // never gets called options._ssrRegister = hook } else if (injectStyles) { - hook = injectStyles + hook = shadowMode + ? function () { injectStyles.call(this, this.$root.$options.shadowRoot) } + : injectStyles } if (hook) { - var functional = options.functional - var existing = functional - ? options.render - : options.beforeCreate - - if (!functional) { - // inject component registration as beforeCreate hook - options.beforeCreate = existing - ? [].concat(existing, hook) - : [hook] - } else { + if (options.functional) { // for template-only hot-reload because in that case the render fn doesn't // go through the normalizer options._injectStyles = hook // register for functioal component in vue file + var originalRender = options.render options.render = function renderWithStyleInjection (h, context) { hook.call(context) - return existing(h, context) + return originalRender(h, context) } + } else { + // inject component registration as beforeCreate hook + var existing = options.beforeCreate + options.beforeCreate = existing + ? [].concat(existing, hook) + : [hook] } } return { - esModule: esModule, exports: scriptExports, options: options } @@ -360,8 +360,8 @@ module.exports = function normalizeComponent ( /***/ (function(module, exports, __webpack_require__) { var global = __webpack_require__(0); -var core = __webpack_require__(8); -var ctx = __webpack_require__(61); +var core = __webpack_require__(9); +var ctx = __webpack_require__(62); var hide = __webpack_require__(2); var PROTOTYPE = 'prototype'; @@ -427,7 +427,7 @@ module.exports = $export; /***/ (function(module, exports, __webpack_require__) { // 7.1.1 ToPrimitive(input [, PreferredType]) -var isObject = __webpack_require__(10); +var isObject = __webpack_require__(7); // instead of the ES6 spec version, we didn't implement @@toPrimitive case // and the second argument - flag - preferred type is a string module.exports = function (it, S) { @@ -542,7 +542,7 @@ exports.f = __webpack_require__(6); /***/ (function(module, exports, __webpack_require__) { var global = __webpack_require__(0); -var core = __webpack_require__(8); +var core = __webpack_require__(9); var LIBRARY = __webpack_require__(24); var wksExt = __webpack_require__(27); var defineProperty = __webpack_require__(3).f; @@ -583,6 +583,51 @@ module.exports = g; /* 30 */ /***/ (function(module, exports, __webpack_require__) { +var __WEBPACK_AMD_DEFINE_FACTORY__, __WEBPACK_AMD_DEFINE_ARRAY__, __WEBPACK_AMD_DEFINE_RESULT__;(function (global, factory) { + if (true) { + !(__WEBPACK_AMD_DEFINE_ARRAY__ = [exports, __webpack_require__(31)], __WEBPACK_AMD_DEFINE_FACTORY__ = (factory), + __WEBPACK_AMD_DEFINE_RESULT__ = (typeof __WEBPACK_AMD_DEFINE_FACTORY__ === 'function' ? + (__WEBPACK_AMD_DEFINE_FACTORY__.apply(exports, __WEBPACK_AMD_DEFINE_ARRAY__)) : __WEBPACK_AMD_DEFINE_FACTORY__), + __WEBPACK_AMD_DEFINE_RESULT__ !== undefined && (module.exports = __WEBPACK_AMD_DEFINE_RESULT__)); + } else if (typeof exports !== "undefined") { + factory(exports, require("../src/parts/DefaultSection.js")); + } else { + var mod = { + exports: {} + }; + factory(mod.exports, global.DefaultSection); + global.UrlSection = mod.exports; + } +})(this, function (exports, _DefaultSection) { + "use strict"; + + Object.defineProperty(exports, "__esModule", { + value: true + }); + + var _DefaultSection2 = _interopRequireDefault(_DefaultSection); + + function _interopRequireDefault(obj) { + return obj && obj.__esModule ? obj : { + default: obj + }; + } + + exports.default = { + name: "url-section", + extends: _DefaultSection2.default, + methods: { + getLabelByIndex: function getLabelByIndex(i) { + return this.section.data[i].value; + } + } + }; +}); + +/***/ }), +/* 31 */ +/***/ (function(module, exports, __webpack_require__) { + var __WEBPACK_AMD_DEFINE_FACTORY__, __WEBPACK_AMD_DEFINE_ARRAY__, __WEBPACK_AMD_DEFINE_RESULT__;(function (global, factory) { if (true) { !(__WEBPACK_AMD_DEFINE_ARRAY__ = [exports], __WEBPACK_AMD_DEFINE_FACTORY__ = (factory), @@ -682,3471 +727,2799 @@ var __WEBPACK_AMD_DEFINE_FACTORY__, __WEBPACK_AMD_DEFINE_ARRAY__, __WEBPACK_AMD_ exports.default = DefaultSection; }); -/***/ }), -/* 31 */ -/***/ (function(module, exports, __webpack_require__) { - -module.exports = !__webpack_require__(4) && !__webpack_require__(7)(function () { - return Object.defineProperty(__webpack_require__(32)('div'), 'a', { get: function () { return 7; } }).a != 7; -}); - - /***/ }), /* 32 */ /***/ (function(module, exports, __webpack_require__) { -var isObject = __webpack_require__(10); -var document = __webpack_require__(0).document; -// typeof document.createElement is 'object' in old IE -var is = isObject(document) && isObject(document.createElement); -module.exports = function (it) { - return is ? document.createElement(it) : {}; -}; - +var __WEBPACK_AMD_DEFINE_FACTORY__, __WEBPACK_AMD_DEFINE_ARRAY__, __WEBPACK_AMD_DEFINE_RESULT__;(function (global, factory) { + if (true) { + !(__WEBPACK_AMD_DEFINE_ARRAY__ = [exports, __webpack_require__(57)], __WEBPACK_AMD_DEFINE_FACTORY__ = (factory), + __WEBPACK_AMD_DEFINE_RESULT__ = (typeof __WEBPACK_AMD_DEFINE_FACTORY__ === 'function' ? + (__WEBPACK_AMD_DEFINE_FACTORY__.apply(exports, __WEBPACK_AMD_DEFINE_ARRAY__)) : __WEBPACK_AMD_DEFINE_FACTORY__), + __WEBPACK_AMD_DEFINE_RESULT__ !== undefined && (module.exports = __WEBPACK_AMD_DEFINE_RESULT__)); + } else if (typeof exports !== "undefined") { + factory(exports, require("../src/Autosuggest.vue")); + } else { + var mod = { + exports: {} + }; + factory(mod.exports, global.Autosuggest); + global.App = mod.exports; + } +})(this, function (exports, _Autosuggest) { + "use strict"; -/***/ }), -/* 33 */ -/***/ (function(module, exports, __webpack_require__) { + Object.defineProperty(exports, "__esModule", { + value: true + }); -var has = __webpack_require__(1); -var toIObject = __webpack_require__(5); -var arrayIndexOf = __webpack_require__(64)(false); -var IE_PROTO = __webpack_require__(20)('IE_PROTO'); + var _Autosuggest2 = _interopRequireDefault(_Autosuggest); -module.exports = function (object, names) { - var O = toIObject(object); - var i = 0; - var result = []; - var key; - for (key in O) if (key != IE_PROTO) has(O, key) && result.push(key); - // Don't enum bug & hidden keys - while (names.length > i) if (has(O, key = names[i++])) { - ~arrayIndexOf(result, key) || result.push(key); + function _interopRequireDefault(obj) { + return obj && obj.__esModule ? obj : { + default: obj + }; } - return result; -}; - -/***/ }), -/* 34 */ -/***/ (function(module, exports, __webpack_require__) { - -// fallback for non-array-like ES3 and non-enumerable old V8 strings -var cof = __webpack_require__(35); -// eslint-disable-next-line no-prototype-builtins -module.exports = Object('z').propertyIsEnumerable(0) ? Object : function (it) { - return cof(it) == 'String' ? it.split('') : Object(it); -}; + exports.default = { + components: { + VueAutosuggest: _Autosuggest2.default + }, + data: function data() { + return { + selected: "", + limit: 10, + filteredOptions: [], + options: [{ + data: ["clifford kits", "friendly chemistry", "phonics", "life of fred", "life of fred math", "magic school bus", "math mammoth light blue", "handwriting", "math", "minecraft", "free worksheets", "4th grade", "snap circuits", "bath toys", "channies", "fred", "lego", "math life of fred", "multiplication", "thinking tree"] + }, { + label: "Blog", + name: "blog", + data: [{ + url: "https://blog.educents.com/", + value: "The Best Blog in the Entire World" + }, { + url: "https://blog.educents.com/best-educational-games-2017-inchimals/", + value: "The Best Educational Games and Toys of 2017: Inchimals" + }, { + url: "https://blog.educents.com/reading-exploring-world-through-literature/", + value: "Family Read-Alouds: Exploring the World Through Literature" + }] + }], + sectionConfigs: { + default: { + limit: 6, + onSelected: function onSelected() { + // console.log(item, originalInput, `Selected "${item.item}"`); + } + }, + blog: { + limit: 3, + type: "url-section", + onSelected: function onSelected() { + //alert("url: " + item.item.url); + } + } + }, + inputProps: { + id: "autosuggest__input", + onClick: function onClick() {}, + onInputChange: this.onInputChange, + placeholder: "Type 'g'", + onBlur: function onBlur() { + // console.log(e); + }, + onFocus: function onFocus() { + // console.log(e); + } + } + }; + }, + methods: { + onInputChange: function onInputChange(text) { + var filtered = []; -/***/ }), -/* 35 */ -/***/ (function(module, exports) { + var suggestionsData = this.options[0].data.filter(function (item) { + return item.toLowerCase().indexOf(text.toLowerCase()) > -1; + }); + var blogData = this.options[1].data.filter(function (item) { + return item.value.toLowerCase().indexOf(text.toLowerCase()) > -1; + }); -var toString = {}.toString; + suggestionsData.length > 0 && filtered.push({ + label: "Suggestions", + data: suggestionsData + }); -module.exports = function (it) { - return toString.call(it).slice(8, -1); -}; + blogData.length > 0 && filtered.push({ + label: "Blog Resources", + name: "blog", + data: blogData + }); + this.filteredOptions = filtered; + }, + getSuggestionValue: function getSuggestionValue(item) { + if (item.name == "blog") { + return item.item.value; + } else { + return item.item; + } + } + } + }; +}); /***/ }), -/* 36 */ +/* 33 */ /***/ (function(module, exports, __webpack_require__) { -// 7.1.13 ToObject(argument) -var defined = __webpack_require__(18); -module.exports = function (it) { - return Object(defined(it)); -}; +var __WEBPACK_AMD_DEFINE_FACTORY__, __WEBPACK_AMD_DEFINE_ARRAY__, __WEBPACK_AMD_DEFINE_RESULT__;(function (global, factory) { + if (true) { + !(__WEBPACK_AMD_DEFINE_ARRAY__ = [exports, __webpack_require__(58), __webpack_require__(68), __webpack_require__(31), __webpack_require__(92)], __WEBPACK_AMD_DEFINE_FACTORY__ = (factory), + __WEBPACK_AMD_DEFINE_RESULT__ = (typeof __WEBPACK_AMD_DEFINE_FACTORY__ === 'function' ? + (__WEBPACK_AMD_DEFINE_FACTORY__.apply(exports, __WEBPACK_AMD_DEFINE_ARRAY__)) : __WEBPACK_AMD_DEFINE_FACTORY__), + __WEBPACK_AMD_DEFINE_RESULT__ !== undefined && (module.exports = __WEBPACK_AMD_DEFINE_RESULT__)); + } else if (typeof exports !== "undefined") { + factory(exports, require("babel-runtime/helpers/extends"), require("babel-runtime/helpers/typeof"), require("./parts/DefaultSection.js"), require("./utils")); + } else { + var mod = { + exports: {} + }; + factory(mod.exports, global._extends, global._typeof, global.DefaultSection, global.utils); + global.Autosuggest = mod.exports; + } +})(this, function (exports, _extends2, _typeof2, _DefaultSection, _utils) { + "use strict"; + Object.defineProperty(exports, "__esModule", { + value: true + }); -/***/ }), -/* 37 */ -/***/ (function(module, exports, __webpack_require__) { + var _extends3 = _interopRequireDefault(_extends2); -"use strict"; - -var LIBRARY = __webpack_require__(24); -var $export = __webpack_require__(16); -var redefine = __webpack_require__(38); -var hide = __webpack_require__(2); -var has = __webpack_require__(1); -var Iterators = __webpack_require__(25); -var $iterCreate = __webpack_require__(72); -var setToStringTag = __webpack_require__(26); -var getPrototypeOf = __webpack_require__(75); -var ITERATOR = __webpack_require__(6)('iterator'); -var BUGGY = !([].keys && 'next' in [].keys()); // Safari has buggy iterators w/o `next` -var FF_ITERATOR = '@@iterator'; -var KEYS = 'keys'; -var VALUES = 'values'; + var _typeof3 = _interopRequireDefault(_typeof2); -var returnThis = function () { return this; }; + var _DefaultSection2 = _interopRequireDefault(_DefaultSection); -module.exports = function (Base, NAME, Constructor, next, DEFAULT, IS_SET, FORCED) { - $iterCreate(Constructor, NAME, next); - var getMethod = function (kind) { - if (!BUGGY && kind in proto) return proto[kind]; - switch (kind) { - case KEYS: return function keys() { return new Constructor(this, kind); }; - case VALUES: return function values() { return new Constructor(this, kind); }; - } return function entries() { return new Constructor(this, kind); }; - }; - var TAG = NAME + ' Iterator'; - var DEF_VALUES = DEFAULT == VALUES; - var VALUES_BUG = false; - var proto = Base.prototype; - var $native = proto[ITERATOR] || proto[FF_ITERATOR] || DEFAULT && proto[DEFAULT]; - var $default = $native || getMethod(DEFAULT); - var $entries = DEFAULT ? !DEF_VALUES ? $default : getMethod('entries') : undefined; - var $anyNative = NAME == 'Array' ? proto.entries || $native : $native; - var methods, key, IteratorPrototype; - // Fix native - if ($anyNative) { - IteratorPrototype = getPrototypeOf($anyNative.call(new Base())); - if (IteratorPrototype !== Object.prototype && IteratorPrototype.next) { - // Set @@toStringTag to native iterators - setToStringTag(IteratorPrototype, TAG, true); - // fix for some old engines - if (!LIBRARY && !has(IteratorPrototype, ITERATOR)) hide(IteratorPrototype, ITERATOR, returnThis); - } - } - // fix Array#{values, @@iterator}.name in V8 / FF - if (DEF_VALUES && $native && $native.name !== VALUES) { - VALUES_BUG = true; - $default = function values() { return $native.call(this); }; - } - // Define iterator - if ((!LIBRARY || FORCED) && (BUGGY || VALUES_BUG || !proto[ITERATOR])) { - hide(proto, ITERATOR, $default); - } - // Plug for library - Iterators[NAME] = $default; - Iterators[TAG] = returnThis; - if (DEFAULT) { - methods = { - values: DEF_VALUES ? $default : getMethod(VALUES), - keys: IS_SET ? $default : getMethod(KEYS), - entries: $entries + function _interopRequireDefault(obj) { + return obj && obj.__esModule ? obj : { + default: obj }; - if (FORCED) for (key in methods) { - if (!(key in proto)) redefine(proto, key, methods[key]); - } else $export($export.P + $export.F * (BUGGY || VALUES_BUG), NAME, methods); } - return methods; -}; - - -/***/ }), -/* 38 */ -/***/ (function(module, exports, __webpack_require__) { - -module.exports = __webpack_require__(2); - - -/***/ }), -/* 39 */ -/***/ (function(module, exports, __webpack_require__) { - -// 19.1.2.2 / 15.2.3.5 Object.create(O [, Properties]) -var anObject = __webpack_require__(9); -var dPs = __webpack_require__(73); -var enumBugKeys = __webpack_require__(22); -var IE_PROTO = __webpack_require__(20)('IE_PROTO'); -var Empty = function () { /* empty */ }; -var PROTOTYPE = 'prototype'; - -// Create object with fake `null` prototype: use iframe Object with cleared prototype -var createDict = function () { - // Thrash, waste and sodomy: IE GC bug - var iframe = __webpack_require__(32)('iframe'); - var i = enumBugKeys.length; - var lt = '<'; - var gt = '>'; - var iframeDocument; - iframe.style.display = 'none'; - __webpack_require__(74).appendChild(iframe); - iframe.src = 'javascript:'; // eslint-disable-line no-script-url - // createDict = iframe.contentWindow.Object; - // html.removeChild(iframe); - iframeDocument = iframe.contentWindow.document; - iframeDocument.open(); - iframeDocument.write(lt + 'script' + gt + 'document.F=Object' + lt + '/script' + gt); - iframeDocument.close(); - createDict = iframeDocument.F; - while (i--) delete createDict[PROTOTYPE][enumBugKeys[i]]; - return createDict(); -}; - -module.exports = Object.create || function create(O, Properties) { - var result; - if (O !== null) { - Empty[PROTOTYPE] = anObject(O); - result = new Empty(); - Empty[PROTOTYPE] = null; - // add "__proto__" for Object.getPrototypeOf polyfill - result[IE_PROTO] = O; - } else result = createDict(); - return Properties === undefined ? result : dPs(result, Properties); -}; - - -/***/ }), -/* 40 */ -/***/ (function(module, exports, __webpack_require__) { - -// 19.1.2.7 / 15.2.3.4 Object.getOwnPropertyNames(O) -var $keys = __webpack_require__(33); -var hiddenKeys = __webpack_require__(22).concat('length', 'prototype'); - -exports.f = Object.getOwnPropertyNames || function getOwnPropertyNames(O) { - return $keys(O, hiddenKeys); -}; - - -/***/ }), -/* 41 */ -/***/ (function(module, exports, __webpack_require__) { - -var __WEBPACK_AMD_DEFINE_FACTORY__, __WEBPACK_AMD_DEFINE_ARRAY__, __WEBPACK_AMD_DEFINE_RESULT__;(function (global, factory) { - if (true) { - !(__WEBPACK_AMD_DEFINE_ARRAY__ = [__webpack_require__(42), __webpack_require__(46), __webpack_require__(49)], __WEBPACK_AMD_DEFINE_FACTORY__ = (factory), - __WEBPACK_AMD_DEFINE_RESULT__ = (typeof __WEBPACK_AMD_DEFINE_FACTORY__ === 'function' ? - (__WEBPACK_AMD_DEFINE_FACTORY__.apply(exports, __WEBPACK_AMD_DEFINE_ARRAY__)) : __WEBPACK_AMD_DEFINE_FACTORY__), - __WEBPACK_AMD_DEFINE_RESULT__ !== undefined && (module.exports = __WEBPACK_AMD_DEFINE_RESULT__)); - } else if (typeof exports !== "undefined") { - factory(require('vue'), require('./UrlSection.vue'), require('./App.vue')); - } else { - var mod = { - exports: {} - }; - factory(global.vue, global.UrlSection, global.App); - global.index = mod.exports; - } -})(this, function (_vue, _UrlSection, _App) { - 'use strict'; - - var _vue2 = _interopRequireDefault(_vue); - - var _UrlSection2 = _interopRequireDefault(_UrlSection); - - var _App2 = _interopRequireDefault(_App); - - function _interopRequireDefault(obj) { - return obj && obj.__esModule ? obj : { - default: obj - }; - } - - _vue2.default.component('UrlSection', _UrlSection2.default); - - new _vue2.default({ - el: "#app", - components: { - App: _App2.default - }, - template: "" - }); -}); - -/***/ }), -/* 42 */ -/***/ (function(module, exports, __webpack_require__) { - -/* WEBPACK VAR INJECTION */(function(global, setImmediate) {/*! - * Vue.js v2.5.2 - * (c) 2014-2017 Evan You - * Released under the MIT License. - */ -(function (global, factory) { - true ? module.exports = factory() : - typeof define === 'function' && define.amd ? define(factory) : - (global.Vue = factory()); -}(this, (function () { 'use strict'; - -/* */ - -// these helpers produces better vm code in JS engines due to their -// explicitness and function inlining -function isUndef (v) { - return v === undefined || v === null -} - -function isDef (v) { - return v !== undefined && v !== null -} - -function isTrue (v) { - return v === true -} - -function isFalse (v) { - return v === false -} - -/** - * Check if value is primitive - */ -function isPrimitive (value) { - return ( - typeof value === 'string' || - typeof value === 'number' || - typeof value === 'boolean' - ) -} - -/** - * Quick object check - this is primarily used to tell - * Objects from primitive values when we know the value - * is a JSON-compliant type. - */ -function isObject (obj) { - return obj !== null && typeof obj === 'object' -} - -/** - * Get the raw type string of a value e.g. [object Object] - */ -var _toString = Object.prototype.toString; - -function toRawType (value) { - return _toString.call(value).slice(8, -1) -} - -/** - * Strict object type check. Only returns true - * for plain JavaScript objects. - */ -function isPlainObject (obj) { - return _toString.call(obj) === '[object Object]' -} - -function isRegExp (v) { - return _toString.call(v) === '[object RegExp]' -} -/** - * Check if val is a valid array index. - */ -function isValidArrayIndex (val) { - var n = parseFloat(String(val)); - return n >= 0 && Math.floor(n) === n && isFinite(val) -} - -/** - * Convert a value to a string that is actually rendered. - */ -function toString (val) { - return val == null - ? '' - : typeof val === 'object' - ? JSON.stringify(val, null, 2) - : String(val) -} - -/** - * Convert a input value to a number for persistence. - * If the conversion fails, return original string. - */ -function toNumber (val) { - var n = parseFloat(val); - return isNaN(n) ? val : n -} - -/** - * Make a map and return a function for checking if a key - * is in that map. - */ -function makeMap ( - str, - expectsLowerCase -) { - var map = Object.create(null); - var list = str.split(','); - for (var i = 0; i < list.length; i++) { - map[list[i]] = true; - } - return expectsLowerCase - ? function (val) { return map[val.toLowerCase()]; } - : function (val) { return map[val]; } -} - -/** - * Check if a tag is a built-in tag. - */ -var isBuiltInTag = makeMap('slot,component', true); - -/** - * Check if a attribute is a reserved attribute. - */ -var isReservedAttribute = makeMap('key,ref,slot,slot-scope,is'); - -/** - * Remove an item from an array - */ -function remove (arr, item) { - if (arr.length) { - var index = arr.indexOf(item); - if (index > -1) { - return arr.splice(index, 1) - } - } -} - -/** - * Check whether the object has the property. - */ -var hasOwnProperty = Object.prototype.hasOwnProperty; -function hasOwn (obj, key) { - return hasOwnProperty.call(obj, key) -} - -/** - * Create a cached version of a pure function. - */ -function cached (fn) { - var cache = Object.create(null); - return (function cachedFn (str) { - var hit = cache[str]; - return hit || (cache[str] = fn(str)) - }) -} - -/** - * Camelize a hyphen-delimited string. - */ -var camelizeRE = /-(\w)/g; -var camelize = cached(function (str) { - return str.replace(camelizeRE, function (_, c) { return c ? c.toUpperCase() : ''; }) -}); - -/** - * Capitalize a string. - */ -var capitalize = cached(function (str) { - return str.charAt(0).toUpperCase() + str.slice(1) -}); - -/** - * Hyphenate a camelCase string. - */ -var hyphenateRE = /\B([A-Z])/g; -var hyphenate = cached(function (str) { - return str.replace(hyphenateRE, '-$1').toLowerCase() -}); - -/** - * Simple bind, faster than native - */ -function bind (fn, ctx) { - function boundFn (a) { - var l = arguments.length; - return l - ? l > 1 - ? fn.apply(ctx, arguments) - : fn.call(ctx, a) - : fn.call(ctx) - } - // record original fn length - boundFn._length = fn.length; - return boundFn -} - -/** - * Convert an Array-like object to a real Array. - */ -function toArray (list, start) { - start = start || 0; - var i = list.length - start; - var ret = new Array(i); - while (i--) { - ret[i] = list[i + start]; - } - return ret -} - -/** - * Mix properties into target object. - */ -function extend (to, _from) { - for (var key in _from) { - to[key] = _from[key]; - } - return to -} - -/** - * Merge an Array of Objects into a single Object. - */ -function toObject (arr) { - var res = {}; - for (var i = 0; i < arr.length; i++) { - if (arr[i]) { - extend(res, arr[i]); - } - } - return res -} - -/** - * Perform no operation. - * Stubbing args to make Flow happy without leaving useless transpiled code - * with ...rest (https://flow.org/blog/2017/05/07/Strict-Function-Call-Arity/) - */ -function noop (a, b, c) {} - -/** - * Always return false. - */ -var no = function (a, b, c) { return false; }; - -/** - * Return same value - */ -var identity = function (_) { return _; }; - -/** - * Generate a static keys string from compiler modules. - */ -function genStaticKeys (modules) { - return modules.reduce(function (keys, m) { - return keys.concat(m.staticKeys || []) - }, []).join(',') -} - -/** - * Check if two values are loosely equal - that is, - * if they are plain objects, do they have the same shape? - */ -function looseEqual (a, b) { - if (a === b) { return true } - var isObjectA = isObject(a); - var isObjectB = isObject(b); - if (isObjectA && isObjectB) { - try { - var isArrayA = Array.isArray(a); - var isArrayB = Array.isArray(b); - if (isArrayA && isArrayB) { - return a.length === b.length && a.every(function (e, i) { - return looseEqual(e, b[i]) - }) - } else if (!isArrayA && !isArrayB) { - var keysA = Object.keys(a); - var keysB = Object.keys(b); - return keysA.length === keysB.length && keysA.every(function (key) { - return looseEqual(a[key], b[key]) - }) - } else { - /* istanbul ignore next */ - return false + exports.default = { + name: "autosuggest", + components: { + DefaultSection: _DefaultSection2.default + }, + props: { + inputProps: { + type: Object, + required: true, + default: function _default() { + return { + id: { + type: String, + default: "autosuggest__input" + }, + onInputChange: { + type: Function, + required: true + }, + initialValue: { + type: String, + required: false + }, + onClick: { + type: Function, + required: false + } + }; + } + }, + limit: { + type: Number, + required: false, + default: Infinity + }, + suggestions: { + type: Array, + required: true, + default: [] + }, + renderSuggestion: { + type: Function, + required: false, + default: function _default(suggestion) { + return suggestion.item; + } + }, + getSuggestionValue: { + type: Function, + required: false, + default: function _default(suggestion) { + var item = suggestion.item; + if ((typeof item === "undefined" ? "undefined" : (0, _typeof3.default)(item)) === "object" && item.hasOwnProperty("name")) { + return item.name; + } else { + return item; + } + } + }, + shouldRenderSuggestions: { + type: Function, + required: false, + default: function _default() { + return true; + } + }, + sectionConfigs: { + type: Object, + required: false, + default: function _default() { + return { + default: { + onSelected: null + } + }; + } + }, + onSelected: { + type: Function, + required: false, + default: null } - } catch (e) { - /* istanbul ignore next */ - return false - } - } else if (!isObjectA && !isObjectB) { - return String(a) === String(b) - } else { - return false - } -} - -function looseIndexOf (arr, val) { - for (var i = 0; i < arr.length; i++) { - if (looseEqual(arr[i], val)) { return i } - } - return -1 -} - -/** - * Ensure a function is called only once. - */ -function once (fn) { - var called = false; - return function () { - if (!called) { - called = true; - fn.apply(this, arguments); - } - } -} - -var SSR_ATTR = 'data-server-rendered'; - -var ASSET_TYPES = [ - 'component', - 'directive', - 'filter' -]; - -var LIFECYCLE_HOOKS = [ - 'beforeCreate', - 'created', - 'beforeMount', - 'mounted', - 'beforeUpdate', - 'updated', - 'beforeDestroy', - 'destroyed', - 'activated', - 'deactivated', - 'errorCaptured' -]; - -/* */ - -var config = ({ - /** - * Option merge strategies (used in core/util/options) - */ - optionMergeStrategies: Object.create(null), - - /** - * Whether to suppress warnings. - */ - silent: false, - - /** - * Show production mode tip message on boot? - */ - productionTip: "development" !== 'production', - - /** - * Whether to enable devtools - */ - devtools: "development" !== 'production', - - /** - * Whether to record perf - */ - performance: false, - - /** - * Error handler for watcher errors - */ - errorHandler: null, - - /** - * Warn handler for watcher warns - */ - warnHandler: null, - - /** - * Ignore certain custom elements - */ - ignoredElements: [], - - /** - * Custom user key aliases for v-on - */ - keyCodes: Object.create(null), + }, + data: function data() { + return { + component_attr_id_autosuggest: "autosuggest", + component_attr_class_autosuggest__results_container: "autosuggest__results-container", + component_attr_class_autosuggest__results: "autosuggest__results", + searchInput: "", + searchInputOriginal: null, + currentIndex: null, + currentItem: null, + loading: false /** Helps with making sure the dropdown doesn't stay open after certain actions */ + , didSelectFromOptions: false, + computedSections: [], + computedSize: 0, + internal_inputProps: {}, // Nest default prop values don't work currently in Vue + defaultInputProps: { + initialValue: "", + onClick: function onClick() {}, + autocomplete: "off" + }, + defaultSectionConfig: { + name: "default", + type: "default-section" + } + }; + }, + computed: { + isOpen: function isOpen() { + return this.getSize() > 0 && this.shouldRenderSuggestions() && !this.loading; + } + }, + methods: { + _onSelected: function _onSelected() { + if (this.currentItem && this.sectionConfigs[this.currentItem.name] && this.sectionConfigs[this.currentItem.name].onSelected) { + this.sectionConfigs[this.currentItem.name].onSelected(this.currentItem, this.searchInputOriginal); + } else if (this.sectionConfigs["default"].onSelected) { + this.sectionConfigs["default"].onSelected(null, this.searchInputOriginal); + } else { + this.onSelected && this.onSelected(this.currentItem); + } + }, + getSectionRef: function getSectionRef(i) { + return "computed_section_" + i; + }, + getSize: function getSize() { + return this.computedSize; + }, + getItemByIndex: function getItemByIndex(index) { + var obj = false; + if (index === null) return obj; + for (var i = 0; i < this.computedSections.length; i++) { + if (index >= this.computedSections[i].start_index && index <= this.computedSections[i].end_index) { + var trueIndex = index - this.computedSections[i].start_index; + var childSection = this.$refs["computed_section_" + i][0]; + if (childSection) { + obj = this.normalizeItem(this.computedSections[i].name, this.computedSections[i].type, childSection.getLabelByIndex(trueIndex), childSection.getItemByIndex(trueIndex)); + break; + } + } + } - /** - * Check if a tag is reserved so that it cannot be registered as a - * component. This is platform-dependent and may be overwritten. - */ - isReservedTag: no, + return obj; + }, + handleKeyStroke: function handleKeyStroke(e) { + var _this = this; - /** - * Check if an attribute is reserved so that it cannot be used as a component - * prop. This is platform-dependent and may be overwritten. - */ - isReservedAttr: no, + var keyCode = e.keyCode; - /** - * Check if a tag is an unknown element. - * Platform-dependent. - */ - isUnknownElement: no, - /** - * Get the namespace of an element - */ - getTagNamespace: noop, + var ignoredKeyCodes = [16, // Shift + 9, // Tab + 18, // alt/option + 91, // OS Key + 93 // Right OS Key + ]; - /** - * Parse the real tag name for the specific platform. - */ - parsePlatformTagName: identity, + if (ignoredKeyCodes.indexOf(keyCode) > -1) { + return; + } - /** - * Check if an attribute must be bound using property, e.g. value - * Platform-dependent. - */ - mustUseProp: no, + this.loading = false; + this.didSelectFromOptions = false; + switch (keyCode) { + case 40: // ArrowDown + case 38: + // ArrowUp + e.preventDefault(); + if (this.isOpen) { + if (keyCode === 38 && this.currentIndex === null) { + break; + } + // Determine direction of arrow up/down and determine new currentIndex + var direction = keyCode === 40 ? 1 : -1; + var newIndex = parseInt(this.currentIndex) + direction; - /** - * Exposed for legacy reasons - */ - _lifecycleHooks: LIFECYCLE_HOOKS -}); + this.setCurrentIndex(newIndex, this.getSize(), direction); + this.didSelectFromOptions = true; + if (this.getSize() > 0 && this.currentIndex >= 0) { + this.setChangeItem(this.getItemByIndex(this.currentIndex)); + this.didSelectFromOptions = true; + } else if (this.currentIndex == -1) { + this.currentIndex = null; + this.searchInput = this.searchInputOriginal; + e.preventDefault(); + } + } + break; + case 13: + // Enter + e.preventDefault(); + if (keyCode === 229) { + // https://github.com/moroshko/react-autosuggest/pull/388 + break; + } + this.$nextTick(function () { + if (_this.getSize() > 0 && _this.currentIndex >= 0) { + _this.setChangeItem(_this.getItemByIndex(_this.currentIndex), true); + _this.didSelectFromOptions = true; + } + _this.loading = true; + _this.$nextTick(function () { + _this._onSelected(_this.didSelectFromOptions); + }); + }); + break; + case 27: + // Escape + if (this.isOpen) { + /* For 'search' input type, make sure the browser doesn't clear the input when Escape is pressed. */ + this.loading = true; + this.currentIndex = null; + this.searchInput = this.searchInputOriginal; + e.preventDefault(); + } + break; + } + }, + setChangeItem: function setChangeItem(item) { + var overrideOriginalInput = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : false; -/* */ + if (this.currentIndex === null) { + this.currentItem = null; + } else if (item) { + this.searchInput = this.getSuggestionValue(item); + this.currentItem = item; + if (overrideOriginalInput) { + this.searchInputOriginal = this.getSuggestionValue(item); + } + this.ensureItemVisible(item, this.currentIndex); + } + }, + normalizeItem: function normalizeItem(name, type, label, item) { + return { + name: name, + type: type, + label: label, + item: item + }; + }, + ensureItemVisible: function ensureItemVisible(item, index) { + var resultsScrollElement = document.querySelector("." + this.component_attr_class_autosuggest__results); -var emptyObject = Object.freeze({}); + if (!item || !index && index !== 0 || !resultsScrollElement) { + return; + } -/** - * Check if a string starts with $ or _ - */ -function isReserved (str) { - var c = (str + '').charCodeAt(0); - return c === 0x24 || c === 0x5F -} + var itemElement = document.querySelector("#autosuggest__results_item-" + index); + if (!itemElement) { + return; + } -/** - * Define a property. - */ -function def (obj, key, val, enumerable) { - Object.defineProperty(obj, key, { - value: val, - enumerable: !!enumerable, - writable: true, - configurable: true - }); -} + var resultsScrollWindowHeight = resultsScrollElement.clientHeight; + var resultsScrollScrollTop = resultsScrollElement.scrollTop; -/** - * Parse simple path. - */ -var bailRE = /[^\w.$]/; -function parsePath (path) { - if (bailRE.test(path)) { - return - } - var segments = path.split('.'); - return function (obj) { - for (var i = 0; i < segments.length; i++) { - if (!obj) { return } - obj = obj[segments[i]]; - } - return obj - } -} + var itemHeight = itemElement.clientHeight; + var currentItemScrollOffset = itemElement.offsetTop; -/* */ + if (itemHeight + currentItemScrollOffset >= resultsScrollScrollTop + resultsScrollWindowHeight) { + /** Current item goes below visible scroll window */ + resultsScrollElement.scrollTo(0, itemHeight + currentItemScrollOffset - resultsScrollWindowHeight); + } else if (currentItemScrollOffset < resultsScrollScrollTop && resultsScrollScrollTop > 0) { + /** Current item goes above visible scroll window */ + resultsScrollElement.scrollTo(0, currentItemScrollOffset); + } + }, + updateCurrentIndex: function updateCurrentIndex(index) { + this.currentIndex = index; + }, + onDocumentMouseUp: function onDocumentMouseUp() { + var _this2 = this; -// can we use __proto__? -var hasProto = '__proto__' in {}; + /** Clicks outside of dropdown to exit */ + if (this.currentIndex === null || !this.isOpen) { + this.loading = this.shouldRenderSuggestions(); + return; + } -// Browser environment sniffing -var inBrowser = typeof window !== 'undefined'; -var UA = inBrowser && window.navigator.userAgent.toLowerCase(); -var isIE = UA && /msie|trident/.test(UA); -var isIE9 = UA && UA.indexOf('msie 9.0') > 0; -var isEdge = UA && UA.indexOf('edge/') > 0; -var isAndroid = UA && UA.indexOf('android') > 0; -var isIOS = UA && /iphone|ipad|ipod|ios/.test(UA); -var isChrome = UA && /chrome\/\d+/.test(UA) && !isEdge; + /** Selects an item in the dropdown */ + this.loading = true; + this.didSelectFromOptions = true; + this.setChangeItem(this.getItemByIndex(this.currentIndex), true); + this.$nextTick(function () { + _this2._onSelected(true); + }); + }, + setCurrentIndex: function setCurrentIndex(newIndex) { + var limit = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : -1; + var direction = arguments[2]; -// Firefox has a "watch" function on Object.prototype... -var nativeWatch = ({}).watch; + var adjustedValue = newIndex; -var supportsPassive = false; -if (inBrowser) { - try { - var opts = {}; - Object.defineProperty(opts, 'passive', ({ - get: function get () { - /* istanbul ignore next */ - supportsPassive = true; - } - })); // https://github.com/facebook/flow/issues/285 - window.addEventListener('test-passive', null, opts); - } catch (e) {} -} + // if we hit the lower limit then stop iterating the index + if (this.currentIndex === null) { + adjustedValue = 0; + } -// this needs to be lazy-evaled because vue may be required before -// vue-server-renderer can set VUE_ENV -var _isServer; -var isServerRendering = function () { - if (_isServer === undefined) { - /* istanbul ignore if */ - if (!inBrowser && typeof global !== 'undefined') { - // detect presence of vue-server-renderer and avoid - // Webpack shimming the process - _isServer = global['process'].env.VUE_ENV === 'server'; - } else { - _isServer = false; - } - } - return _isServer -}; + if (this.currentIndex < 0 && direction === 1) { + adjustedValue = 0; + } -// detect devtools -var devtools = inBrowser && window.__VUE_DEVTOOLS_GLOBAL_HOOK__; + // if we hit the upper limit then just stop iterating the index + if (newIndex >= limit) { + adjustedValue = 0; + } -/* istanbul ignore next */ -function isNative (Ctor) { - return typeof Ctor === 'function' && /native code/.test(Ctor.toString()) -} + this.currentIndex = adjustedValue; -var hasSymbol = - typeof Symbol !== 'undefined' && isNative(Symbol) && - typeof Reflect !== 'undefined' && isNative(Reflect.ownKeys); + var element = document.getElementById("autosuggest__results_item-" + this.currentIndex); + var hoverClass = "autosuggest__results_item-highlighted"; + if (document.querySelector("." + hoverClass)) { + (0, _utils.removeClass)(document.querySelector("." + hoverClass), hoverClass); + } + if (element) { + (0, _utils.addClass)(element, hoverClass); + } + }, + onClick: function onClick() { + var _this3 = this; -var _Set; -/* istanbul ignore if */ // $flow-disable-line -if (typeof Set !== 'undefined' && isNative(Set)) { - // use native Set when available. - _Set = Set; -} else { - // a non-standard Set polyfill that only works with primitive keys. - _Set = (function () { - function Set () { - this.set = Object.create(null); - } - Set.prototype.has = function has (key) { - return this.set[key] === true - }; - Set.prototype.add = function add (key) { - this.set[key] = true; - }; - Set.prototype.clear = function clear () { - this.set = Object.create(null); - }; + this.loading = false; + this.internal_inputProps.onClick(this.currentItem); - return Set; - }()); -} + this.$nextTick(function () { + _this3.ensureItemVisible(_this3.currentItem, _this3.currentIndex); + }); + }, + onBlur: function onBlur(e) { + this.internal_inputProps.onBlur && this.internal_inputProps.onBlur(e); + }, + onFocus: function onFocus(e) { + this.internal_inputProps.onFocus && this.internal_inputProps.onFocus(e); + } + }, + created: function created() { + /** Take care of nested input props */ + this.internal_inputProps = (0, _extends3.default)({}, this.defaultInputProps, this.inputProps); + this.inputProps.autocomplete = this.internal_inputProps.autocomplete; -/* */ + this.searchInput = this.internal_inputProps.initialValue; // set default query, e.g. loaded server side. + }, + mounted: function mounted() { + document.addEventListener("mouseup", this.onDocumentMouseUp); + this.loading = true; + }, -var warn = noop; -var tip = noop; -var generateComponentTrace = (noop); // work around flow check -var formatComponentName = (noop); + watch: { + searchInput: function searchInput(newValue, oldValue) { + this.value = newValue; + if (!this.didSelectFromOptions) { + this.searchInputOriginal = this.value; + this.currentIndex = null; + this.internal_inputProps.onInputChange(newValue, oldValue); + } + }, -{ - var hasConsole = typeof console !== 'undefined'; - var classifyRE = /(?:^|[-_])(\w)/g; - var classify = function (str) { return str - .replace(classifyRE, function (c) { return c.toUpperCase(); }) - .replace(/[-_]/g, ''); }; + suggestions: { + immediate: true, + handler: function handler() { + var _this4 = this; - warn = function (msg, vm) { - var trace = vm ? generateComponentTrace(vm) : ''; + this.computedSections = []; + this.computedSize = 0; - if (config.warnHandler) { - config.warnHandler.call(null, msg, vm, trace); - } else if (hasConsole && (!config.silent)) { - console.error(("[Vue warn]: " + msg + trace)); - } - }; + this.suggestions.forEach(function (section) { + if (!section.data) return; - tip = function (msg, vm) { - if (hasConsole && (!config.silent)) { - console.warn("[Vue tip]: " + msg + ( - vm ? generateComponentTrace(vm) : '' - )); - } - }; + var name = section.name ? section.name : _this4.defaultSectionConfig.name; - formatComponentName = function (vm, includeFile) { - if (vm.$root === vm) { - return '' - } - var options = typeof vm === 'function' && vm.cid != null - ? vm.options - : vm._isVue - ? vm.$options || vm.constructor.options - : vm || {}; - var name = options.name || options._componentTag; - var file = options.__file; - if (!name && file) { - var match = file.match(/([^/\\]+)\.vue$/); - name = match && match[1]; - } + var _sectionConfigs$name = _this4.sectionConfigs[name], + type = _sectionConfigs$name.type, + limit = _sectionConfigs$name.limit, + label = _sectionConfigs$name.label; - return ( - (name ? ("<" + (classify(name)) + ">") : "") + - (file && includeFile !== false ? (" at " + file) : '') - ) - }; + /** Set defaults for section configs. */ - var repeat = function (str, n) { - var res = ''; - while (n) { - if (n % 2 === 1) { res += str; } - if (n > 1) { str += str; } - n >>= 1; - } - return res - }; + type = type ? type : _this4.defaultSectionConfig.type; - generateComponentTrace = function (vm) { - if (vm._isVue && vm.$parent) { - var tree = []; - var currentRecursiveSequence = 0; - while (vm) { - if (tree.length > 0) { - var last = tree[tree.length - 1]; - if (last.constructor === vm.constructor) { - currentRecursiveSequence++; - vm = vm.$parent; - continue - } else if (currentRecursiveSequence > 0) { - tree[tree.length - 1] = [last, currentRecursiveSequence]; - currentRecursiveSequence = 0; - } + limit = limit ? limit : Infinity; + limit = section.data.length < limit ? section.data.length : limit; + + label = label ? label : section.label; + + var computedSection = { + name: name, + label: label, + type: type, + limit: limit, + data: section.data, + start_index: _this4.computedSize, + end_index: _this4.computedSize + limit - 1 + }; + _this4.computedSections.push(computedSection); + _this4.computedSize += limit; + }, this); } - tree.push(vm); - vm = vm.$parent; } - return '\n\nfound in\n\n' + tree - .map(function (vm, i) { return ("" + (i === 0 ? '---> ' : repeat(' ', 5 + i * 2)) + (Array.isArray(vm) - ? ((formatComponentName(vm[0])) + "... (" + (vm[1]) + " recursive calls)") - : formatComponentName(vm))); }) - .join('\n') - } else { - return ("\n\n(found in " + (formatComponentName(vm)) + ")") } }; -} - -/* */ - +}); -var uid = 0; +/***/ }), +/* 34 */ +/***/ (function(module, exports, __webpack_require__) { -/** - * A dep is an observable that can have multiple - * directives subscribing to it. - */ -var Dep = function Dep () { - this.id = uid++; - this.subs = []; -}; +module.exports = !__webpack_require__(4) && !__webpack_require__(8)(function () { + return Object.defineProperty(__webpack_require__(35)('div'), 'a', { get: function () { return 7; } }).a != 7; +}); -Dep.prototype.addSub = function addSub (sub) { - this.subs.push(sub); -}; -Dep.prototype.removeSub = function removeSub (sub) { - remove(this.subs, sub); -}; +/***/ }), +/* 35 */ +/***/ (function(module, exports, __webpack_require__) { -Dep.prototype.depend = function depend () { - if (Dep.target) { - Dep.target.addDep(this); - } +var isObject = __webpack_require__(7); +var document = __webpack_require__(0).document; +// typeof document.createElement is 'object' in old IE +var is = isObject(document) && isObject(document.createElement); +module.exports = function (it) { + return is ? document.createElement(it) : {}; }; -Dep.prototype.notify = function notify () { - // stabilize the subscriber list first - var subs = this.subs.slice(); - for (var i = 0, l = subs.length; i < l; i++) { - subs[i].update(); + +/***/ }), +/* 36 */ +/***/ (function(module, exports, __webpack_require__) { + +var has = __webpack_require__(1); +var toIObject = __webpack_require__(5); +var arrayIndexOf = __webpack_require__(65)(false); +var IE_PROTO = __webpack_require__(20)('IE_PROTO'); + +module.exports = function (object, names) { + var O = toIObject(object); + var i = 0; + var result = []; + var key; + for (key in O) if (key != IE_PROTO) has(O, key) && result.push(key); + // Don't enum bug & hidden keys + while (names.length > i) if (has(O, key = names[i++])) { + ~arrayIndexOf(result, key) || result.push(key); } + return result; }; -// the current target watcher being evaluated. -// this is globally unique because there could be only one -// watcher being evaluated at any time. -Dep.target = null; -var targetStack = []; -function pushTarget (_target) { - if (Dep.target) { targetStack.push(Dep.target); } - Dep.target = _target; -} +/***/ }), +/* 37 */ +/***/ (function(module, exports, __webpack_require__) { -function popTarget () { - Dep.target = targetStack.pop(); -} +// fallback for non-array-like ES3 and non-enumerable old V8 strings +var cof = __webpack_require__(38); +// eslint-disable-next-line no-prototype-builtins +module.exports = Object('z').propertyIsEnumerable(0) ? Object : function (it) { + return cof(it) == 'String' ? it.split('') : Object(it); +}; -/* */ -var VNode = function VNode ( - tag, - data, - children, - text, - elm, - context, - componentOptions, - asyncFactory -) { - this.tag = tag; - this.data = data; - this.children = children; - this.text = text; - this.elm = elm; - this.ns = undefined; - this.context = context; - this.functionalContext = undefined; - this.functionalOptions = undefined; - this.functionalScopeId = undefined; - this.key = data && data.key; - this.componentOptions = componentOptions; - this.componentInstance = undefined; - this.parent = undefined; - this.raw = false; - this.isStatic = false; - this.isRootInsert = true; - this.isComment = false; - this.isCloned = false; - this.isOnce = false; - this.asyncFactory = asyncFactory; - this.asyncMeta = undefined; - this.isAsyncPlaceholder = false; -}; +/***/ }), +/* 38 */ +/***/ (function(module, exports) { -var prototypeAccessors = { child: { configurable: true } }; +var toString = {}.toString; -// DEPRECATED: alias for componentInstance for backwards compat. -/* istanbul ignore next */ -prototypeAccessors.child.get = function () { - return this.componentInstance +module.exports = function (it) { + return toString.call(it).slice(8, -1); }; -Object.defineProperties( VNode.prototype, prototypeAccessors ); -var createEmptyVNode = function (text) { - if ( text === void 0 ) text = ''; +/***/ }), +/* 39 */ +/***/ (function(module, exports, __webpack_require__) { - var node = new VNode(); - node.text = text; - node.isComment = true; - return node +// 7.1.13 ToObject(argument) +var defined = __webpack_require__(18); +module.exports = function (it) { + return Object(defined(it)); }; -function createTextVNode (val) { - return new VNode(undefined, undefined, undefined, String(val)) -} -// optimized shallow clone -// used for static nodes and slot nodes because they may be reused across -// multiple renders, cloning them avoids errors when DOM manipulations rely -// on their elm reference. -function cloneVNode (vnode, deep) { - var cloned = new VNode( - vnode.tag, - vnode.data, - vnode.children, - vnode.text, - vnode.elm, - vnode.context, - vnode.componentOptions, - vnode.asyncFactory - ); - cloned.ns = vnode.ns; - cloned.isStatic = vnode.isStatic; - cloned.key = vnode.key; - cloned.isComment = vnode.isComment; - cloned.isCloned = true; - if (deep && vnode.children) { - cloned.children = cloneVNodes(vnode.children); - } - return cloned -} +/***/ }), +/* 40 */ +/***/ (function(module, exports, __webpack_require__) { -function cloneVNodes (vnodes, deep) { - var len = vnodes.length; - var res = new Array(len); - for (var i = 0; i < len; i++) { - res[i] = cloneVNode(vnodes[i], deep); - } - return res -} +"use strict"; -/* - * not type checking this file because flow doesn't play well with - * dynamically accessing methods on Array prototype - */ +var LIBRARY = __webpack_require__(24); +var $export = __webpack_require__(16); +var redefine = __webpack_require__(41); +var hide = __webpack_require__(2); +var has = __webpack_require__(1); +var Iterators = __webpack_require__(25); +var $iterCreate = __webpack_require__(73); +var setToStringTag = __webpack_require__(26); +var getPrototypeOf = __webpack_require__(76); +var ITERATOR = __webpack_require__(6)('iterator'); +var BUGGY = !([].keys && 'next' in [].keys()); // Safari has buggy iterators w/o `next` +var FF_ITERATOR = '@@iterator'; +var KEYS = 'keys'; +var VALUES = 'values'; -var arrayProto = Array.prototype; -var arrayMethods = Object.create(arrayProto);[ - 'push', - 'pop', - 'shift', - 'unshift', - 'splice', - 'sort', - 'reverse' -] -.forEach(function (method) { - // cache original method - var original = arrayProto[method]; - def(arrayMethods, method, function mutator () { - var args = [], len = arguments.length; - while ( len-- ) args[ len ] = arguments[ len ]; +var returnThis = function () { return this; }; - var result = original.apply(this, args); - var ob = this.__ob__; - var inserted; - switch (method) { - case 'push': - case 'unshift': - inserted = args; - break - case 'splice': - inserted = args.slice(2); - break +module.exports = function (Base, NAME, Constructor, next, DEFAULT, IS_SET, FORCED) { + $iterCreate(Constructor, NAME, next); + var getMethod = function (kind) { + if (!BUGGY && kind in proto) return proto[kind]; + switch (kind) { + case KEYS: return function keys() { return new Constructor(this, kind); }; + case VALUES: return function values() { return new Constructor(this, kind); }; + } return function entries() { return new Constructor(this, kind); }; + }; + var TAG = NAME + ' Iterator'; + var DEF_VALUES = DEFAULT == VALUES; + var VALUES_BUG = false; + var proto = Base.prototype; + var $native = proto[ITERATOR] || proto[FF_ITERATOR] || DEFAULT && proto[DEFAULT]; + var $default = (!BUGGY && $native) || getMethod(DEFAULT); + var $entries = DEFAULT ? !DEF_VALUES ? $default : getMethod('entries') : undefined; + var $anyNative = NAME == 'Array' ? proto.entries || $native : $native; + var methods, key, IteratorPrototype; + // Fix native + if ($anyNative) { + IteratorPrototype = getPrototypeOf($anyNative.call(new Base())); + if (IteratorPrototype !== Object.prototype && IteratorPrototype.next) { + // Set @@toStringTag to native iterators + setToStringTag(IteratorPrototype, TAG, true); + // fix for some old engines + if (!LIBRARY && !has(IteratorPrototype, ITERATOR)) hide(IteratorPrototype, ITERATOR, returnThis); } - if (inserted) { ob.observeArray(inserted); } - // notify change - ob.dep.notify(); - return result - }); -}); - -/* */ - -var arrayKeys = Object.getOwnPropertyNames(arrayMethods); - -/** - * By default, when a reactive property is set, the new value is - * also converted to become reactive. However when passing down props, - * we don't want to force conversion because the value may be a nested value - * under a frozen data structure. Converting it would defeat the optimization. - */ -var observerState = { - shouldConvert: true -}; - -/** - * Observer class that are attached to each observed - * object. Once attached, the observer converts target - * object's property keys into getter/setters that - * collect dependencies and dispatches updates. - */ -var Observer = function Observer (value) { - this.value = value; - this.dep = new Dep(); - this.vmCount = 0; - def(value, '__ob__', this); - if (Array.isArray(value)) { - var augment = hasProto - ? protoAugment - : copyAugment; - augment(value, arrayMethods, arrayKeys); - this.observeArray(value); - } else { - this.walk(value); } -}; - -/** - * Walk through each property and convert them into - * getter/setters. This method should only be called when - * value type is Object. - */ -Observer.prototype.walk = function walk (obj) { - var keys = Object.keys(obj); - for (var i = 0; i < keys.length; i++) { - defineReactive(obj, keys[i], obj[keys[i]]); + // fix Array#{values, @@iterator}.name in V8 / FF + if (DEF_VALUES && $native && $native.name !== VALUES) { + VALUES_BUG = true; + $default = function values() { return $native.call(this); }; } -}; - -/** - * Observe a list of Array items. - */ -Observer.prototype.observeArray = function observeArray (items) { - for (var i = 0, l = items.length; i < l; i++) { - observe(items[i]); + // Define iterator + if ((!LIBRARY || FORCED) && (BUGGY || VALUES_BUG || !proto[ITERATOR])) { + hide(proto, ITERATOR, $default); + } + // Plug for library + Iterators[NAME] = $default; + Iterators[TAG] = returnThis; + if (DEFAULT) { + methods = { + values: DEF_VALUES ? $default : getMethod(VALUES), + keys: IS_SET ? $default : getMethod(KEYS), + entries: $entries + }; + if (FORCED) for (key in methods) { + if (!(key in proto)) redefine(proto, key, methods[key]); + } else $export($export.P + $export.F * (BUGGY || VALUES_BUG), NAME, methods); } + return methods; }; -// helpers - -/** - * Augment an target Object or Array by intercepting - * the prototype chain using __proto__ - */ -function protoAugment (target, src, keys) { - /* eslint-disable no-proto */ - target.__proto__ = src; - /* eslint-enable no-proto */ -} -/** - * Augment an target Object or Array by defining - * hidden properties. - */ -/* istanbul ignore next */ -function copyAugment (target, src, keys) { - for (var i = 0, l = keys.length; i < l; i++) { - var key = keys[i]; - def(target, key, src[key]); - } -} +/***/ }), +/* 41 */ +/***/ (function(module, exports, __webpack_require__) { -/** - * Attempt to create an observer instance for a value, - * returns the new observer if successfully observed, - * or the existing observer if the value already has one. - */ -function observe (value, asRootData) { - if (!isObject(value) || value instanceof VNode) { - return - } - var ob; - if (hasOwn(value, '__ob__') && value.__ob__ instanceof Observer) { - ob = value.__ob__; - } else if ( - observerState.shouldConvert && - !isServerRendering() && - (Array.isArray(value) || isPlainObject(value)) && - Object.isExtensible(value) && - !value._isVue - ) { - ob = new Observer(value); - } - if (asRootData && ob) { - ob.vmCount++; - } - return ob -} +module.exports = __webpack_require__(2); -/** - * Define a reactive property on an Object. - */ -function defineReactive ( - obj, - key, - val, - customSetter, - shallow -) { - var dep = new Dep(); - var property = Object.getOwnPropertyDescriptor(obj, key); - if (property && property.configurable === false) { - return - } +/***/ }), +/* 42 */ +/***/ (function(module, exports, __webpack_require__) { - // cater for pre-defined getter/setters - var getter = property && property.get; - var setter = property && property.set; +// 19.1.2.2 / 15.2.3.5 Object.create(O [, Properties]) +var anObject = __webpack_require__(10); +var dPs = __webpack_require__(74); +var enumBugKeys = __webpack_require__(22); +var IE_PROTO = __webpack_require__(20)('IE_PROTO'); +var Empty = function () { /* empty */ }; +var PROTOTYPE = 'prototype'; - var childOb = !shallow && observe(val); - Object.defineProperty(obj, key, { - enumerable: true, - configurable: true, - get: function reactiveGetter () { - var value = getter ? getter.call(obj) : val; - if (Dep.target) { - dep.depend(); - if (childOb) { - childOb.dep.depend(); - if (Array.isArray(value)) { - dependArray(value); - } - } - } - return value - }, - set: function reactiveSetter (newVal) { - var value = getter ? getter.call(obj) : val; - /* eslint-disable no-self-compare */ - if (newVal === value || (newVal !== newVal && value !== value)) { - return - } - /* eslint-enable no-self-compare */ - if ("development" !== 'production' && customSetter) { - customSetter(); - } - if (setter) { - setter.call(obj, newVal); - } else { - val = newVal; - } - childOb = !shallow && observe(newVal); - dep.notify(); - } - }); -} +// Create object with fake `null` prototype: use iframe Object with cleared prototype +var createDict = function () { + // Thrash, waste and sodomy: IE GC bug + var iframe = __webpack_require__(35)('iframe'); + var i = enumBugKeys.length; + var lt = '<'; + var gt = '>'; + var iframeDocument; + iframe.style.display = 'none'; + __webpack_require__(75).appendChild(iframe); + iframe.src = 'javascript:'; // eslint-disable-line no-script-url + // createDict = iframe.contentWindow.Object; + // html.removeChild(iframe); + iframeDocument = iframe.contentWindow.document; + iframeDocument.open(); + iframeDocument.write(lt + 'script' + gt + 'document.F=Object' + lt + '/script' + gt); + iframeDocument.close(); + createDict = iframeDocument.F; + while (i--) delete createDict[PROTOTYPE][enumBugKeys[i]]; + return createDict(); +}; -/** - * Set a property on an object. Adds the new property and - * triggers change notification if the property doesn't - * already exist. - */ -function set (target, key, val) { - if (Array.isArray(target) && isValidArrayIndex(key)) { - target.length = Math.max(target.length, key); - target.splice(key, 1, val); - return val - } - if (hasOwn(target, key)) { - target[key] = val; - return val - } - var ob = (target).__ob__; - if (target._isVue || (ob && ob.vmCount)) { - "development" !== 'production' && warn( - 'Avoid adding reactive properties to a Vue instance or its root $data ' + - 'at runtime - declare it upfront in the data option.' - ); - return val - } - if (!ob) { - target[key] = val; - return val - } - defineReactive(ob.value, key, val); - ob.dep.notify(); - return val -} +module.exports = Object.create || function create(O, Properties) { + var result; + if (O !== null) { + Empty[PROTOTYPE] = anObject(O); + result = new Empty(); + Empty[PROTOTYPE] = null; + // add "__proto__" for Object.getPrototypeOf polyfill + result[IE_PROTO] = O; + } else result = createDict(); + return Properties === undefined ? result : dPs(result, Properties); +}; -/** - * Delete a property and trigger change if necessary. - */ -function del (target, key) { - if (Array.isArray(target) && isValidArrayIndex(key)) { - target.splice(key, 1); - return - } - var ob = (target).__ob__; - if (target._isVue || (ob && ob.vmCount)) { - "development" !== 'production' && warn( - 'Avoid deleting properties on a Vue instance or its root $data ' + - '- just set it to null.' - ); - return - } - if (!hasOwn(target, key)) { - return - } - delete target[key]; - if (!ob) { - return - } - ob.dep.notify(); -} -/** - * Collect dependencies on array elements when the array is touched, since - * we cannot intercept array element access like property getters. - */ -function dependArray (value) { - for (var e = (void 0), i = 0, l = value.length; i < l; i++) { - e = value[i]; - e && e.__ob__ && e.__ob__.dep.depend(); - if (Array.isArray(e)) { - dependArray(e); - } - } -} +/***/ }), +/* 43 */ +/***/ (function(module, exports, __webpack_require__) { -/* */ +// 19.1.2.7 / 15.2.3.4 Object.getOwnPropertyNames(O) +var $keys = __webpack_require__(36); +var hiddenKeys = __webpack_require__(22).concat('length', 'prototype'); -/** - * Option overwriting strategies are functions that handle - * how to merge a parent option value and a child option - * value into the final value. - */ -var strats = config.optionMergeStrategies; +exports.f = Object.getOwnPropertyNames || function getOwnPropertyNames(O) { + return $keys(O, hiddenKeys); +}; -/** - * Options with restrictions - */ -{ - strats.el = strats.propsData = function (parent, child, vm, key) { - if (!vm) { - warn( - "option \"" + key + "\" can only be used during instance " + - 'creation with the `new` keyword.' - ); - } - return defaultStrat(parent, child) - }; -} -/** - * Helper that recursively merges two data objects together. - */ -function mergeData (to, from) { - if (!from) { return to } - var key, toVal, fromVal; - var keys = Object.keys(from); - for (var i = 0; i < keys.length; i++) { - key = keys[i]; - toVal = to[key]; - fromVal = from[key]; - if (!hasOwn(to, key)) { - set(to, key, fromVal); - } else if (isPlainObject(toVal) && isPlainObject(fromVal)) { - mergeData(toVal, fromVal); - } - } - return to -} +/***/ }), +/* 44 */ +/***/ (function(module, exports, __webpack_require__) { -/** - * Data - */ -function mergeDataOrFn ( - parentVal, - childVal, - vm -) { - if (!vm) { - // in a Vue.extend merge, both should be functions - if (!childVal) { - return parentVal - } - if (!parentVal) { - return childVal - } - // when parentVal & childVal are both present, - // we need to return a function that returns the - // merged result of both functions... no need to - // check if parentVal is a function here because - // it has to be a function to pass previous merges. - return function mergedDataFn () { - return mergeData( - typeof childVal === 'function' ? childVal.call(this) : childVal, - typeof parentVal === 'function' ? parentVal.call(this) : parentVal - ) - } - } else if (parentVal || childVal) { - return function mergedInstanceDataFn () { - // instance merge - var instanceData = typeof childVal === 'function' - ? childVal.call(vm) - : childVal; - var defaultData = typeof parentVal === 'function' - ? parentVal.call(vm) - : parentVal; - if (instanceData) { - return mergeData(instanceData, defaultData) - } else { - return defaultData - } +var __WEBPACK_AMD_DEFINE_FACTORY__, __WEBPACK_AMD_DEFINE_ARRAY__, __WEBPACK_AMD_DEFINE_RESULT__;(function (global, factory) { + if (true) { + !(__WEBPACK_AMD_DEFINE_ARRAY__ = [__webpack_require__(45), __webpack_require__(49), __webpack_require__(51)], __WEBPACK_AMD_DEFINE_FACTORY__ = (factory), + __WEBPACK_AMD_DEFINE_RESULT__ = (typeof __WEBPACK_AMD_DEFINE_FACTORY__ === 'function' ? + (__WEBPACK_AMD_DEFINE_FACTORY__.apply(exports, __WEBPACK_AMD_DEFINE_ARRAY__)) : __WEBPACK_AMD_DEFINE_FACTORY__), + __WEBPACK_AMD_DEFINE_RESULT__ !== undefined && (module.exports = __WEBPACK_AMD_DEFINE_RESULT__)); + } else if (typeof exports !== "undefined") { + factory(require('vue'), require('./UrlSection.vue'), require('./App.vue')); + } else { + var mod = { + exports: {} + }; + factory(global.vue, global.UrlSection, global.App); + global.index = mod.exports; } - } -} +})(this, function (_vue, _UrlSection, _App) { + 'use strict'; -strats.data = function ( - parentVal, - childVal, - vm -) { - if (!vm) { - if (childVal && typeof childVal !== 'function') { - "development" !== 'production' && warn( - 'The "data" option should be a function ' + - 'that returns a per-instance value in component ' + - 'definitions.', - vm - ); + var _vue2 = _interopRequireDefault(_vue); - return parentVal - } - return mergeDataOrFn.call(this, parentVal, childVal) - } + var _UrlSection2 = _interopRequireDefault(_UrlSection); - return mergeDataOrFn(parentVal, childVal, vm) -}; + var _App2 = _interopRequireDefault(_App); -/** - * Hooks and props are merged as arrays. - */ -function mergeHook ( - parentVal, - childVal -) { - return childVal - ? parentVal - ? parentVal.concat(childVal) - : Array.isArray(childVal) - ? childVal - : [childVal] - : parentVal -} + function _interopRequireDefault(obj) { + return obj && obj.__esModule ? obj : { + default: obj + }; + } -LIFECYCLE_HOOKS.forEach(function (hook) { - strats[hook] = mergeHook; + _vue2.default.component('UrlSection', _UrlSection2.default); + + new _vue2.default({ + el: "#app", + components: { + App: _App2.default + }, + template: "" + }); }); -/** - * Assets - * - * When a vm is present (instance creation), we need to do - * a three-way merge between constructor options, instance - * options and parent options. +/***/ }), +/* 45 */ +/***/ (function(module, exports, __webpack_require__) { + +/* WEBPACK VAR INJECTION */(function(global, setImmediate) {/*! + * Vue.js v2.5.13 + * (c) 2014-2017 Evan You + * Released under the MIT License. */ -function mergeAssets ( - parentVal, - childVal, - vm, - key -) { - var res = Object.create(parentVal || null); - if (childVal) { - "development" !== 'production' && assertObjectType(key, childVal, vm); - return extend(res, childVal) - } else { - return res - } -} +(function (global, factory) { + true ? module.exports = factory() : + typeof define === 'function' && define.amd ? define(factory) : + (global.Vue = factory()); +}(this, (function () { 'use strict'; -ASSET_TYPES.forEach(function (type) { - strats[type + 's'] = mergeAssets; -}); +/* */ -/** - * Watchers. - * - * Watchers hashes should not overwrite one - * another, so we merge them as arrays. - */ -strats.watch = function ( - parentVal, - childVal, - vm, - key -) { - // work around Firefox's Object.prototype.watch... - if (parentVal === nativeWatch) { parentVal = undefined; } - if (childVal === nativeWatch) { childVal = undefined; } - /* istanbul ignore if */ - if (!childVal) { return Object.create(parentVal || null) } - { - assertObjectType(key, childVal, vm); - } - if (!parentVal) { return childVal } - var ret = {}; - extend(ret, parentVal); - for (var key$1 in childVal) { - var parent = ret[key$1]; - var child = childVal[key$1]; - if (parent && !Array.isArray(parent)) { - parent = [parent]; - } - ret[key$1] = parent - ? parent.concat(child) - : Array.isArray(child) ? child : [child]; - } - return ret -}; +var emptyObject = Object.freeze({}); -/** - * Other object hashes. - */ -strats.props = -strats.methods = -strats.inject = -strats.computed = function ( - parentVal, - childVal, - vm, - key -) { - if (childVal && "development" !== 'production') { - assertObjectType(key, childVal, vm); - } - if (!parentVal) { return childVal } - var ret = Object.create(null); - extend(ret, parentVal); - if (childVal) { extend(ret, childVal); } - return ret -}; -strats.provide = mergeDataOrFn; +// these helpers produces better vm code in JS engines due to their +// explicitness and function inlining +function isUndef (v) { + return v === undefined || v === null +} -/** - * Default strategy. - */ -var defaultStrat = function (parentVal, childVal) { - return childVal === undefined - ? parentVal - : childVal -}; +function isDef (v) { + return v !== undefined && v !== null +} + +function isTrue (v) { + return v === true +} + +function isFalse (v) { + return v === false +} /** - * Validate component names + * Check if value is primitive */ -function checkComponents (options) { - for (var key in options.components) { - var lower = key.toLowerCase(); - if (isBuiltInTag(lower) || config.isReservedTag(lower)) { - warn( - 'Do not use built-in or reserved HTML elements as component ' + - 'id: ' + key - ); - } - } +function isPrimitive (value) { + return ( + typeof value === 'string' || + typeof value === 'number' || + // $flow-disable-line + typeof value === 'symbol' || + typeof value === 'boolean' + ) } /** - * Ensure all props option syntax are normalized into the - * Object-based format. + * Quick object check - this is primarily used to tell + * Objects from primitive values when we know the value + * is a JSON-compliant type. */ -function normalizeProps (options, vm) { - var props = options.props; - if (!props) { return } - var res = {}; - var i, val, name; - if (Array.isArray(props)) { - i = props.length; - while (i--) { - val = props[i]; - if (typeof val === 'string') { - name = camelize(val); - res[name] = { type: null }; - } else { - warn('props must be strings when using array syntax.'); - } - } - } else if (isPlainObject(props)) { - for (var key in props) { - val = props[key]; - name = camelize(key); - res[name] = isPlainObject(val) - ? val - : { type: val }; - } - } else { - warn( - "Invalid value for option \"props\": expected an Array or an Object, " + - "but got " + (toRawType(props)) + ".", - vm - ); - } - options.props = res; +function isObject (obj) { + return obj !== null && typeof obj === 'object' } /** - * Normalize all injections into Object-based format + * Get the raw type string of a value e.g. [object Object] */ -function normalizeInject (options, vm) { - var inject = options.inject; - var normalized = options.inject = {}; - if (Array.isArray(inject)) { - for (var i = 0; i < inject.length; i++) { - normalized[inject[i]] = { from: inject[i] }; - } - } else if (isPlainObject(inject)) { - for (var key in inject) { - var val = inject[key]; - normalized[key] = isPlainObject(val) - ? extend({ from: key }, val) - : { from: val }; - } - } else if ("development" !== 'production' && inject) { - warn( - "Invalid value for option \"inject\": expected an Array or an Object, " + - "but got " + (toRawType(inject)) + ".", - vm - ); - } +var _toString = Object.prototype.toString; + +function toRawType (value) { + return _toString.call(value).slice(8, -1) } /** - * Normalize raw function directives into object format. + * Strict object type check. Only returns true + * for plain JavaScript objects. */ -function normalizeDirectives (options) { - var dirs = options.directives; - if (dirs) { - for (var key in dirs) { - var def = dirs[key]; - if (typeof def === 'function') { - dirs[key] = { bind: def, update: def }; - } - } - } +function isPlainObject (obj) { + return _toString.call(obj) === '[object Object]' } -function assertObjectType (name, value, vm) { - if (!isPlainObject(value)) { - warn( - "Invalid value for option \"" + name + "\": expected an Object, " + - "but got " + (toRawType(value)) + ".", - vm - ); - } +function isRegExp (v) { + return _toString.call(v) === '[object RegExp]' } /** - * Merge two option objects into a new one. - * Core utility used in both instantiation and inheritance. + * Check if val is a valid array index. */ -function mergeOptions ( - parent, - child, - vm -) { - { - checkComponents(child); - } +function isValidArrayIndex (val) { + var n = parseFloat(String(val)); + return n >= 0 && Math.floor(n) === n && isFinite(val) +} - if (typeof child === 'function') { - child = child.options; - } +/** + * Convert a value to a string that is actually rendered. + */ +function toString (val) { + return val == null + ? '' + : typeof val === 'object' + ? JSON.stringify(val, null, 2) + : String(val) +} - normalizeProps(child, vm); - normalizeInject(child, vm); - normalizeDirectives(child); - var extendsFrom = child.extends; - if (extendsFrom) { - parent = mergeOptions(parent, extendsFrom, vm); - } - if (child.mixins) { - for (var i = 0, l = child.mixins.length; i < l; i++) { - parent = mergeOptions(parent, child.mixins[i], vm); - } - } - var options = {}; - var key; - for (key in parent) { - mergeField(key); - } - for (key in child) { - if (!hasOwn(parent, key)) { - mergeField(key); - } - } - function mergeField (key) { - var strat = strats[key] || defaultStrat; - options[key] = strat(parent[key], child[key], vm, key); - } - return options +/** + * Convert a input value to a number for persistence. + * If the conversion fails, return original string. + */ +function toNumber (val) { + var n = parseFloat(val); + return isNaN(n) ? val : n } /** - * Resolve an asset. - * This function is used because child instances need access - * to assets defined in its ancestor chain. + * Make a map and return a function for checking if a key + * is in that map. */ -function resolveAsset ( - options, - type, - id, - warnMissing +function makeMap ( + str, + expectsLowerCase ) { - /* istanbul ignore if */ - if (typeof id !== 'string') { - return - } - var assets = options[type]; - // check local registration variations first - if (hasOwn(assets, id)) { return assets[id] } - var camelizedId = camelize(id); - if (hasOwn(assets, camelizedId)) { return assets[camelizedId] } - var PascalCaseId = capitalize(camelizedId); - if (hasOwn(assets, PascalCaseId)) { return assets[PascalCaseId] } - // fallback to prototype chain - var res = assets[id] || assets[camelizedId] || assets[PascalCaseId]; - if ("development" !== 'production' && warnMissing && !res) { - warn( - 'Failed to resolve ' + type.slice(0, -1) + ': ' + id, - options - ); + var map = Object.create(null); + var list = str.split(','); + for (var i = 0; i < list.length; i++) { + map[list[i]] = true; } - return res + return expectsLowerCase + ? function (val) { return map[val.toLowerCase()]; } + : function (val) { return map[val]; } } -/* */ +/** + * Check if a tag is a built-in tag. + */ +var isBuiltInTag = makeMap('slot,component', true); -function validateProp ( - key, - propOptions, - propsData, - vm -) { - var prop = propOptions[key]; - var absent = !hasOwn(propsData, key); - var value = propsData[key]; - // handle boolean props - if (isType(Boolean, prop.type)) { - if (absent && !hasOwn(prop, 'default')) { - value = false; - } else if (!isType(String, prop.type) && (value === '' || value === hyphenate(key))) { - value = true; - } - } - // check default value - if (value === undefined) { - value = getPropDefaultValue(vm, prop, key); - // since the default value is a fresh copy, - // make sure to observe it. - var prevShouldConvert = observerState.shouldConvert; - observerState.shouldConvert = true; - observe(value); - observerState.shouldConvert = prevShouldConvert; - } - { - assertProp(prop, key, value, vm, absent); +/** + * Check if a attribute is a reserved attribute. + */ +var isReservedAttribute = makeMap('key,ref,slot,slot-scope,is'); + +/** + * Remove an item from an array + */ +function remove (arr, item) { + if (arr.length) { + var index = arr.indexOf(item); + if (index > -1) { + return arr.splice(index, 1) + } } - return value } /** - * Get the default value of a prop. + * Check whether the object has the property. */ -function getPropDefaultValue (vm, prop, key) { - // no default, return undefined - if (!hasOwn(prop, 'default')) { - return undefined - } - var def = prop.default; - // warn against non-factory defaults for Object & Array - if ("development" !== 'production' && isObject(def)) { - warn( - 'Invalid default value for prop "' + key + '": ' + - 'Props with type Object/Array must use a factory function ' + - 'to return the default value.', - vm - ); - } - // the raw prop value was also undefined from previous render, - // return previous default value to avoid unnecessary watcher trigger - if (vm && vm.$options.propsData && - vm.$options.propsData[key] === undefined && - vm._props[key] !== undefined - ) { - return vm._props[key] - } - // call factory function for non-Function types - // a value is Function if its prototype is function even across different execution context - return typeof def === 'function' && getType(prop.type) !== 'Function' - ? def.call(vm) - : def +var hasOwnProperty = Object.prototype.hasOwnProperty; +function hasOwn (obj, key) { + return hasOwnProperty.call(obj, key) } /** - * Assert whether a prop is valid. + * Create a cached version of a pure function. */ -function assertProp ( - prop, - name, - value, - vm, - absent -) { - if (prop.required && absent) { - warn( - 'Missing required prop: "' + name + '"', - vm - ); - return - } - if (value == null && !prop.required) { - return - } - var type = prop.type; - var valid = !type || type === true; - var expectedTypes = []; - if (type) { - if (!Array.isArray(type)) { - type = [type]; - } - for (var i = 0; i < type.length && !valid; i++) { - var assertedType = assertType(value, type[i]); - expectedTypes.push(assertedType.expectedType || ''); - valid = assertedType.valid; - } - } - if (!valid) { - warn( - "Invalid prop: type check failed for prop \"" + name + "\"." + - " Expected " + (expectedTypes.map(capitalize).join(', ')) + - ", got " + (toRawType(value)) + ".", - vm - ); - return - } - var validator = prop.validator; - if (validator) { - if (!validator(value)) { - warn( - 'Invalid prop: custom validator check failed for prop "' + name + '".', - vm - ); - } - } +function cached (fn) { + var cache = Object.create(null); + return (function cachedFn (str) { + var hit = cache[str]; + return hit || (cache[str] = fn(str)) + }) } -var simpleCheckRE = /^(String|Number|Boolean|Function|Symbol)$/; +/** + * Camelize a hyphen-delimited string. + */ +var camelizeRE = /-(\w)/g; +var camelize = cached(function (str) { + return str.replace(camelizeRE, function (_, c) { return c ? c.toUpperCase() : ''; }) +}); -function assertType (value, type) { - var valid; - var expectedType = getType(type); - if (simpleCheckRE.test(expectedType)) { - var t = typeof value; - valid = t === expectedType.toLowerCase(); - // for primitive wrapper objects - if (!valid && t === 'object') { - valid = value instanceof type; - } - } else if (expectedType === 'Object') { - valid = isPlainObject(value); - } else if (expectedType === 'Array') { - valid = Array.isArray(value); - } else { - valid = value instanceof type; - } - return { - valid: valid, - expectedType: expectedType +/** + * Capitalize a string. + */ +var capitalize = cached(function (str) { + return str.charAt(0).toUpperCase() + str.slice(1) +}); + +/** + * Hyphenate a camelCase string. + */ +var hyphenateRE = /\B([A-Z])/g; +var hyphenate = cached(function (str) { + return str.replace(hyphenateRE, '-$1').toLowerCase() +}); + +/** + * Simple bind, faster than native + */ +function bind (fn, ctx) { + function boundFn (a) { + var l = arguments.length; + return l + ? l > 1 + ? fn.apply(ctx, arguments) + : fn.call(ctx, a) + : fn.call(ctx) } + // record original fn length + boundFn._length = fn.length; + return boundFn } /** - * Use function string name to check built-in types, - * because a simple equality check will fail when running - * across different vms / iframes. + * Convert an Array-like object to a real Array. */ -function getType (fn) { - var match = fn && fn.toString().match(/^\s*function (\w+)/); - return match ? match[1] : '' +function toArray (list, start) { + start = start || 0; + var i = list.length - start; + var ret = new Array(i); + while (i--) { + ret[i] = list[i + start]; + } + return ret } -function isType (type, fn) { - if (!Array.isArray(fn)) { - return getType(fn) === getType(type) +/** + * Mix properties into target object. + */ +function extend (to, _from) { + for (var key in _from) { + to[key] = _from[key]; } - for (var i = 0, len = fn.length; i < len; i++) { - if (getType(fn[i]) === getType(type)) { - return true + return to +} + +/** + * Merge an Array of Objects into a single Object. + */ +function toObject (arr) { + var res = {}; + for (var i = 0; i < arr.length; i++) { + if (arr[i]) { + extend(res, arr[i]); } } - /* istanbul ignore next */ - return false + return res } -/* */ +/** + * Perform no operation. + * Stubbing args to make Flow happy without leaving useless transpiled code + * with ...rest (https://flow.org/blog/2017/05/07/Strict-Function-Call-Arity/) + */ +function noop (a, b, c) {} -function handleError (err, vm, info) { - if (vm) { - var cur = vm; - while ((cur = cur.$parent)) { - var hooks = cur.$options.errorCaptured; - if (hooks) { - for (var i = 0; i < hooks.length; i++) { - try { - var capture = hooks[i].call(cur, err, vm, info) === false; - if (capture) { return } - } catch (e) { - globalHandleError(e, cur, 'errorCaptured hook'); - } - } +/** + * Always return false. + */ +var no = function (a, b, c) { return false; }; + +/** + * Return same value + */ +var identity = function (_) { return _; }; + +/** + * Generate a static keys string from compiler modules. + */ +function genStaticKeys (modules) { + return modules.reduce(function (keys, m) { + return keys.concat(m.staticKeys || []) + }, []).join(',') +} + +/** + * Check if two values are loosely equal - that is, + * if they are plain objects, do they have the same shape? + */ +function looseEqual (a, b) { + if (a === b) { return true } + var isObjectA = isObject(a); + var isObjectB = isObject(b); + if (isObjectA && isObjectB) { + try { + var isArrayA = Array.isArray(a); + var isArrayB = Array.isArray(b); + if (isArrayA && isArrayB) { + return a.length === b.length && a.every(function (e, i) { + return looseEqual(e, b[i]) + }) + } else if (!isArrayA && !isArrayB) { + var keysA = Object.keys(a); + var keysB = Object.keys(b); + return keysA.length === keysB.length && keysA.every(function (key) { + return looseEqual(a[key], b[key]) + }) + } else { + /* istanbul ignore next */ + return false } + } catch (e) { + /* istanbul ignore next */ + return false } + } else if (!isObjectA && !isObjectB) { + return String(a) === String(b) + } else { + return false } - globalHandleError(err, vm, info); } -function globalHandleError (err, vm, info) { - if (config.errorHandler) { - try { - return config.errorHandler.call(null, err, vm, info) - } catch (e) { - logError(e, null, 'config.errorHandler'); - } +function looseIndexOf (arr, val) { + for (var i = 0; i < arr.length; i++) { + if (looseEqual(arr[i], val)) { return i } } - logError(err, vm, info); + return -1 } -function logError (err, vm, info) { - { - warn(("Error in " + info + ": \"" + (err.toString()) + "\""), vm); - } - /* istanbul ignore else */ - if (inBrowser && typeof console !== 'undefined') { - console.error(err); - } else { - throw err +/** + * Ensure a function is called only once. + */ +function once (fn) { + var called = false; + return function () { + if (!called) { + called = true; + fn.apply(this, arguments); + } } } +var SSR_ATTR = 'data-server-rendered'; + +var ASSET_TYPES = [ + 'component', + 'directive', + 'filter' +]; + +var LIFECYCLE_HOOKS = [ + 'beforeCreate', + 'created', + 'beforeMount', + 'mounted', + 'beforeUpdate', + 'updated', + 'beforeDestroy', + 'destroyed', + 'activated', + 'deactivated', + 'errorCaptured' +]; + /* */ -/* globals MessageChannel */ -var callbacks = []; -var pending = false; +var config = ({ + /** + * Option merge strategies (used in core/util/options) + */ + // $flow-disable-line + optionMergeStrategies: Object.create(null), -function flushCallbacks () { - pending = false; - var copies = callbacks.slice(0); - callbacks.length = 0; - for (var i = 0; i < copies.length; i++) { - copies[i](); - } -} + /** + * Whether to suppress warnings. + */ + silent: false, -// Here we have async deferring wrappers using both micro and macro tasks. -// In < 2.4 we used micro tasks everywhere, but there are some scenarios where -// micro tasks have too high a priority and fires in between supposedly -// sequential events (e.g. #4521, #6690) or even between bubbling of the same -// event (#6566). However, using macro tasks everywhere also has subtle problems -// when state is changed right before repaint (e.g. #6813, out-in transitions). -// Here we use micro task by default, but expose a way to force macro task when -// needed (e.g. in event handlers attached by v-on). -var microTimerFunc; -var macroTimerFunc; -var useMacroTask = false; + /** + * Show production mode tip message on boot? + */ + productionTip: "development" !== 'production', -// Determine (macro) Task defer implementation. -// Technically setImmediate should be the ideal choice, but it's only available -// in IE. The only polyfill that consistently queues the callback after all DOM -// events triggered in the same loop is by using MessageChannel. -/* istanbul ignore if */ -if (typeof setImmediate !== 'undefined' && isNative(setImmediate)) { - macroTimerFunc = function () { - setImmediate(flushCallbacks); - }; -} else if (typeof MessageChannel !== 'undefined' && ( - isNative(MessageChannel) || - // PhantomJS - MessageChannel.toString() === '[object MessageChannelConstructor]' -)) { - var channel = new MessageChannel(); - var port = channel.port2; - channel.port1.onmessage = flushCallbacks; - macroTimerFunc = function () { - port.postMessage(1); - }; -} else { - /* istanbul ignore next */ - macroTimerFunc = function () { - setTimeout(flushCallbacks, 0); - }; -} + /** + * Whether to enable devtools + */ + devtools: "development" !== 'production', -// Determine MicroTask defer implementation. -/* istanbul ignore next, $flow-disable-line */ -if (typeof Promise !== 'undefined' && isNative(Promise)) { - var p = Promise.resolve(); - microTimerFunc = function () { - p.then(flushCallbacks); - // in problematic UIWebViews, Promise.then doesn't completely break, but - // it can get stuck in a weird state where callbacks are pushed into the - // microtask queue but the queue isn't being flushed, until the browser - // needs to do some other work, e.g. handle a timer. Therefore we can - // "force" the microtask queue to be flushed by adding an empty timer. - if (isIOS) { setTimeout(noop); } - }; -} else { - // fallback to macro - microTimerFunc = macroTimerFunc; -} + /** + * Whether to record perf + */ + performance: false, -/** - * Wrap a function so that if any code inside triggers state change, - * the changes are queued using a Task instead of a MicroTask. - */ -function withMacroTask (fn) { - return fn._withTask || (fn._withTask = function () { - useMacroTask = true; - var res = fn.apply(null, arguments); - useMacroTask = false; - return res - }) -} + /** + * Error handler for watcher errors + */ + errorHandler: null, -function nextTick (cb, ctx) { - var _resolve; - callbacks.push(function () { - if (cb) { - try { - cb.call(ctx); - } catch (e) { - handleError(e, ctx, 'nextTick'); - } - } else if (_resolve) { - _resolve(ctx); - } - }); - if (!pending) { - pending = true; - if (useMacroTask) { - macroTimerFunc(); - } else { - microTimerFunc(); - } - } - // $flow-disable-line - if (!cb && typeof Promise !== 'undefined') { - return new Promise(function (resolve) { - _resolve = resolve; - }) - } -} + /** + * Warn handler for watcher warns + */ + warnHandler: null, -/* */ + /** + * Ignore certain custom elements + */ + ignoredElements: [], -var mark; -var measure; + /** + * Custom user key aliases for v-on + */ + // $flow-disable-line + keyCodes: Object.create(null), -{ - var perf = inBrowser && window.performance; - /* istanbul ignore if */ - if ( - perf && - perf.mark && - perf.measure && - perf.clearMarks && - perf.clearMeasures - ) { - mark = function (tag) { return perf.mark(tag); }; - measure = function (name, startTag, endTag) { - perf.measure(name, startTag, endTag); - perf.clearMarks(startTag); - perf.clearMarks(endTag); - perf.clearMeasures(name); - }; - } -} + /** + * Check if a tag is reserved so that it cannot be registered as a + * component. This is platform-dependent and may be overwritten. + */ + isReservedTag: no, -/* not type checking this file because flow doesn't play well with Proxy */ + /** + * Check if an attribute is reserved so that it cannot be used as a component + * prop. This is platform-dependent and may be overwritten. + */ + isReservedAttr: no, -var initProxy; + /** + * Check if a tag is an unknown element. + * Platform-dependent. + */ + isUnknownElement: no, -{ - var allowedGlobals = makeMap( - 'Infinity,undefined,NaN,isFinite,isNaN,' + - 'parseFloat,parseInt,decodeURI,decodeURIComponent,encodeURI,encodeURIComponent,' + - 'Math,Number,Date,Array,Object,Boolean,String,RegExp,Map,Set,JSON,Intl,' + - 'require' // for Webpack/Browserify - ); + /** + * Get the namespace of an element + */ + getTagNamespace: noop, + + /** + * Parse the real tag name for the specific platform. + */ + parsePlatformTagName: identity, - var warnNonPresent = function (target, key) { - warn( - "Property or method \"" + key + "\" is not defined on the instance but " + - 'referenced during render. Make sure that this property is reactive, ' + - 'either in the data option, or for class-based components, by ' + - 'initializing the property. ' + - 'See: https://vuejs.org/v2/guide/reactivity.html#Declaring-Reactive-Properties.', - target - ); - }; + /** + * Check if an attribute must be bound using property, e.g. value + * Platform-dependent. + */ + mustUseProp: no, - var hasProxy = - typeof Proxy !== 'undefined' && - Proxy.toString().match(/native code/); + /** + * Exposed for legacy reasons + */ + _lifecycleHooks: LIFECYCLE_HOOKS +}); - if (hasProxy) { - var isBuiltInModifier = makeMap('stop,prevent,self,ctrl,shift,alt,meta,exact'); - config.keyCodes = new Proxy(config.keyCodes, { - set: function set (target, key, value) { - if (isBuiltInModifier(key)) { - warn(("Avoid overwriting built-in modifier in config.keyCodes: ." + key)); - return false - } else { - target[key] = value; - return true - } - } - }); - } +/* */ - var hasHandler = { - has: function has (target, key) { - var has = key in target; - var isAllowed = allowedGlobals(key) || key.charAt(0) === '_'; - if (!has && !isAllowed) { - warnNonPresent(target, key); - } - return has || !isAllowed - } - }; +/** + * Check if a string starts with $ or _ + */ +function isReserved (str) { + var c = (str + '').charCodeAt(0); + return c === 0x24 || c === 0x5F +} - var getHandler = { - get: function get (target, key) { - if (typeof key === 'string' && !(key in target)) { - warnNonPresent(target, key); - } - return target[key] - } - }; +/** + * Define a property. + */ +function def (obj, key, val, enumerable) { + Object.defineProperty(obj, key, { + value: val, + enumerable: !!enumerable, + writable: true, + configurable: true + }); +} - initProxy = function initProxy (vm) { - if (hasProxy) { - // determine which proxy handler to use - var options = vm.$options; - var handlers = options.render && options.render._withStripped - ? getHandler - : hasHandler; - vm._renderProxy = new Proxy(vm, handlers); - } else { - vm._renderProxy = vm; +/** + * Parse simple path. + */ +var bailRE = /[^\w.$]/; +function parsePath (path) { + if (bailRE.test(path)) { + return + } + var segments = path.split('.'); + return function (obj) { + for (var i = 0; i < segments.length; i++) { + if (!obj) { return } + obj = obj[segments[i]]; } - }; + return obj + } } /* */ -var normalizeEvent = cached(function (name) { - var passive = name.charAt(0) === '&'; - name = passive ? name.slice(1) : name; - var once$$1 = name.charAt(0) === '~'; // Prefixed last, checked first - name = once$$1 ? name.slice(1) : name; - var capture = name.charAt(0) === '!'; - name = capture ? name.slice(1) : name; - return { - name: name, - once: once$$1, - capture: capture, - passive: passive - } -}); -function createFnInvoker (fns) { - function invoker () { - var arguments$1 = arguments; +// can we use __proto__? +var hasProto = '__proto__' in {}; - var fns = invoker.fns; - if (Array.isArray(fns)) { - var cloned = fns.slice(); - for (var i = 0; i < cloned.length; i++) { - cloned[i].apply(null, arguments$1); +// Browser environment sniffing +var inBrowser = typeof window !== 'undefined'; +var inWeex = typeof WXEnvironment !== 'undefined' && !!WXEnvironment.platform; +var weexPlatform = inWeex && WXEnvironment.platform.toLowerCase(); +var UA = inBrowser && window.navigator.userAgent.toLowerCase(); +var isIE = UA && /msie|trident/.test(UA); +var isIE9 = UA && UA.indexOf('msie 9.0') > 0; +var isEdge = UA && UA.indexOf('edge/') > 0; +var isAndroid = (UA && UA.indexOf('android') > 0) || (weexPlatform === 'android'); +var isIOS = (UA && /iphone|ipad|ipod|ios/.test(UA)) || (weexPlatform === 'ios'); +var isChrome = UA && /chrome\/\d+/.test(UA) && !isEdge; + +// Firefox has a "watch" function on Object.prototype... +var nativeWatch = ({}).watch; + +var supportsPassive = false; +if (inBrowser) { + try { + var opts = {}; + Object.defineProperty(opts, 'passive', ({ + get: function get () { + /* istanbul ignore next */ + supportsPassive = true; } + })); // https://github.com/facebook/flow/issues/285 + window.addEventListener('test-passive', null, opts); + } catch (e) {} +} + +// this needs to be lazy-evaled because vue may be required before +// vue-server-renderer can set VUE_ENV +var _isServer; +var isServerRendering = function () { + if (_isServer === undefined) { + /* istanbul ignore if */ + if (!inBrowser && typeof global !== 'undefined') { + // detect presence of vue-server-renderer and avoid + // Webpack shimming the process + _isServer = global['process'].env.VUE_ENV === 'server'; } else { - // return handler return value for single handlers - return fns.apply(null, arguments) + _isServer = false; } } - invoker.fns = fns; - return invoker + return _isServer +}; + +// detect devtools +var devtools = inBrowser && window.__VUE_DEVTOOLS_GLOBAL_HOOK__; + +/* istanbul ignore next */ +function isNative (Ctor) { + return typeof Ctor === 'function' && /native code/.test(Ctor.toString()) } -function updateListeners ( - on, - oldOn, - add, - remove$$1, - vm -) { - var name, cur, old, event; - for (name in on) { - cur = on[name]; - old = oldOn[name]; - event = normalizeEvent(name); - if (isUndef(cur)) { - "development" !== 'production' && warn( - "Invalid handler for event \"" + (event.name) + "\": got " + String(cur), - vm - ); - } else if (isUndef(old)) { - if (isUndef(cur.fns)) { - cur = on[name] = createFnInvoker(cur); - } - add(event.name, cur, event.once, event.capture, event.passive); - } else if (cur !== old) { - old.fns = cur; - on[name] = old; - } - } - for (name in oldOn) { - if (isUndef(on[name])) { - event = normalizeEvent(name); - remove$$1(event.name, oldOn[name], event.capture); +var hasSymbol = + typeof Symbol !== 'undefined' && isNative(Symbol) && + typeof Reflect !== 'undefined' && isNative(Reflect.ownKeys); + +var _Set; +/* istanbul ignore if */ // $flow-disable-line +if (typeof Set !== 'undefined' && isNative(Set)) { + // use native Set when available. + _Set = Set; +} else { + // a non-standard Set polyfill that only works with primitive keys. + _Set = (function () { + function Set () { + this.set = Object.create(null); } - } + Set.prototype.has = function has (key) { + return this.set[key] === true + }; + Set.prototype.add = function add (key) { + this.set[key] = true; + }; + Set.prototype.clear = function clear () { + this.set = Object.create(null); + }; + + return Set; + }()); } /* */ -function mergeVNodeHook (def, hookKey, hook) { - var invoker; - var oldHook = def[hookKey]; +var warn = noop; +var tip = noop; +var generateComponentTrace = (noop); // work around flow check +var formatComponentName = (noop); - function wrappedHook () { - hook.apply(this, arguments); - // important: remove merged hook to ensure it's called only once - // and prevent memory leak - remove(invoker.fns, wrappedHook); - } +{ + var hasConsole = typeof console !== 'undefined'; + var classifyRE = /(?:^|[-_])(\w)/g; + var classify = function (str) { return str + .replace(classifyRE, function (c) { return c.toUpperCase(); }) + .replace(/[-_]/g, ''); }; + + warn = function (msg, vm) { + var trace = vm ? generateComponentTrace(vm) : ''; + + if (config.warnHandler) { + config.warnHandler.call(null, msg, vm, trace); + } else if (hasConsole && (!config.silent)) { + console.error(("[Vue warn]: " + msg + trace)); + } + }; - if (isUndef(oldHook)) { - // no existing hook - invoker = createFnInvoker([wrappedHook]); - } else { - /* istanbul ignore if */ - if (isDef(oldHook.fns) && isTrue(oldHook.merged)) { - // already a merged invoker - invoker = oldHook; - invoker.fns.push(wrappedHook); - } else { - // existing plain hook - invoker = createFnInvoker([oldHook, wrappedHook]); + tip = function (msg, vm) { + if (hasConsole && (!config.silent)) { + console.warn("[Vue tip]: " + msg + ( + vm ? generateComponentTrace(vm) : '' + )); } - } + }; - invoker.merged = true; - def[hookKey] = invoker; -} + formatComponentName = function (vm, includeFile) { + if (vm.$root === vm) { + return '' + } + var options = typeof vm === 'function' && vm.cid != null + ? vm.options + : vm._isVue + ? vm.$options || vm.constructor.options + : vm || {}; + var name = options.name || options._componentTag; + var file = options.__file; + if (!name && file) { + var match = file.match(/([^/\\]+)\.vue$/); + name = match && match[1]; + } -/* */ + return ( + (name ? ("<" + (classify(name)) + ">") : "") + + (file && includeFile !== false ? (" at " + file) : '') + ) + }; -function extractPropsFromVNodeData ( - data, - Ctor, - tag -) { - // we are only extracting raw values here. - // validation and default values are handled in the child - // component itself. - var propOptions = Ctor.options.props; - if (isUndef(propOptions)) { - return - } - var res = {}; - var attrs = data.attrs; - var props = data.props; - if (isDef(attrs) || isDef(props)) { - for (var key in propOptions) { - var altKey = hyphenate(key); - { - var keyInLowerCase = key.toLowerCase(); - if ( - key !== keyInLowerCase && - attrs && hasOwn(attrs, keyInLowerCase) - ) { - tip( - "Prop \"" + keyInLowerCase + "\" is passed to component " + - (formatComponentName(tag || Ctor)) + ", but the declared prop name is" + - " \"" + key + "\". " + - "Note that HTML attributes are case-insensitive and camelCased " + - "props need to use their kebab-case equivalents when using in-DOM " + - "templates. You should probably use \"" + altKey + "\" instead of \"" + key + "\"." - ); - } - } - checkProp(res, props, key, altKey, true) || - checkProp(res, attrs, key, altKey, false); + var repeat = function (str, n) { + var res = ''; + while (n) { + if (n % 2 === 1) { res += str; } + if (n > 1) { str += str; } + n >>= 1; } - } - return res -} + return res + }; -function checkProp ( - res, - hash, - key, - altKey, - preserve -) { - if (isDef(hash)) { - if (hasOwn(hash, key)) { - res[key] = hash[key]; - if (!preserve) { - delete hash[key]; - } - return true - } else if (hasOwn(hash, altKey)) { - res[key] = hash[altKey]; - if (!preserve) { - delete hash[altKey]; + generateComponentTrace = function (vm) { + if (vm._isVue && vm.$parent) { + var tree = []; + var currentRecursiveSequence = 0; + while (vm) { + if (tree.length > 0) { + var last = tree[tree.length - 1]; + if (last.constructor === vm.constructor) { + currentRecursiveSequence++; + vm = vm.$parent; + continue + } else if (currentRecursiveSequence > 0) { + tree[tree.length - 1] = [last, currentRecursiveSequence]; + currentRecursiveSequence = 0; + } + } + tree.push(vm); + vm = vm.$parent; } - return true + return '\n\nfound in\n\n' + tree + .map(function (vm, i) { return ("" + (i === 0 ? '---> ' : repeat(' ', 5 + i * 2)) + (Array.isArray(vm) + ? ((formatComponentName(vm[0])) + "... (" + (vm[1]) + " recursive calls)") + : formatComponentName(vm))); }) + .join('\n') + } else { + return ("\n\n(found in " + (formatComponentName(vm)) + ")") } - } - return false + }; } /* */ -// The template compiler attempts to minimize the need for normalization by -// statically analyzing the template at compile time. -// -// For plain HTML markup, normalization can be completely skipped because the -// generated render function is guaranteed to return Array. There are -// two cases where extra normalization is needed: -// 1. When the children contains components - because a functional component -// may return an Array instead of a single root. In this case, just a simple -// normalization is needed - if any child is an Array, we flatten the whole -// thing with Array.prototype.concat. It is guaranteed to be only 1-level deep -// because functional components already normalize their own children. -function simpleNormalizeChildren (children) { - for (var i = 0; i < children.length; i++) { - if (Array.isArray(children[i])) { - return Array.prototype.concat.apply([], children) - } - } - return children -} +var uid = 0; -// 2. When the children contains constructs that always generated nested Arrays, -// e.g.