1 |
|
2 |
|
3 |
|
4 |
|
5 |
|
6 | (function (global, factory) {
|
7 | typeof exports === 'object' && typeof module !== 'undefined' ? factory(exports) :
|
8 | typeof define === 'function' && define.amd ? define(['exports'], factory) :
|
9 | (global = global || self, factory(global.VueClassComponent = {}));
|
10 | }(this, (function (exports) { 'use strict';
|
11 |
|
12 | function _classCallCheck(instance, Constructor) {
|
13 | if (!(instance instanceof Constructor)) {
|
14 | throw new TypeError("Cannot call a class as a function");
|
15 | }
|
16 | }
|
17 |
|
18 | function _defineProperties(target, props) {
|
19 | for (var i = 0; i < props.length; i++) {
|
20 | var descriptor = props[i];
|
21 | descriptor.enumerable = descriptor.enumerable || false;
|
22 | descriptor.configurable = true;
|
23 | if ("value" in descriptor) descriptor.writable = true;
|
24 | Object.defineProperty(target, descriptor.key, descriptor);
|
25 | }
|
26 | }
|
27 |
|
28 | function _createClass(Constructor, protoProps, staticProps) {
|
29 | if (protoProps) _defineProperties(Constructor.prototype, protoProps);
|
30 | if (staticProps) _defineProperties(Constructor, staticProps);
|
31 | return Constructor;
|
32 | }
|
33 |
|
34 | function _defineProperty(obj, key, value) {
|
35 | if (key in obj) {
|
36 | Object.defineProperty(obj, key, {
|
37 | value: value,
|
38 | enumerable: true,
|
39 | configurable: true,
|
40 | writable: true
|
41 | });
|
42 | } else {
|
43 | obj[key] = value;
|
44 | }
|
45 |
|
46 | return obj;
|
47 | }
|
48 |
|
49 | function ownKeys(object, enumerableOnly) {
|
50 | var keys = Object.keys(object);
|
51 |
|
52 | if (Object.getOwnPropertySymbols) {
|
53 | var symbols = Object.getOwnPropertySymbols(object);
|
54 | if (enumerableOnly) symbols = symbols.filter(function (sym) {
|
55 | return Object.getOwnPropertyDescriptor(object, sym).enumerable;
|
56 | });
|
57 | keys.push.apply(keys, symbols);
|
58 | }
|
59 |
|
60 | return keys;
|
61 | }
|
62 |
|
63 | function _objectSpread2(target) {
|
64 | for (var i = 1; i < arguments.length; i++) {
|
65 | var source = arguments[i] != null ? arguments[i] : {};
|
66 |
|
67 | if (i % 2) {
|
68 | ownKeys(Object(source), true).forEach(function (key) {
|
69 | _defineProperty(target, key, source[key]);
|
70 | });
|
71 | } else if (Object.getOwnPropertyDescriptors) {
|
72 | Object.defineProperties(target, Object.getOwnPropertyDescriptors(source));
|
73 | } else {
|
74 | ownKeys(Object(source)).forEach(function (key) {
|
75 | Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key));
|
76 | });
|
77 | }
|
78 | }
|
79 |
|
80 | return target;
|
81 | }
|
82 |
|
83 | function _inherits(subClass, superClass) {
|
84 | if (typeof superClass !== "function" && superClass !== null) {
|
85 | throw new TypeError("Super expression must either be null or a function");
|
86 | }
|
87 |
|
88 | subClass.prototype = Object.create(superClass && superClass.prototype, {
|
89 | constructor: {
|
90 | value: subClass,
|
91 | writable: true,
|
92 | configurable: true
|
93 | }
|
94 | });
|
95 | if (superClass) _setPrototypeOf(subClass, superClass);
|
96 | }
|
97 |
|
98 | function _getPrototypeOf(o) {
|
99 | _getPrototypeOf = Object.setPrototypeOf ? Object.getPrototypeOf : function _getPrototypeOf(o) {
|
100 | return o.__proto__ || Object.getPrototypeOf(o);
|
101 | };
|
102 | return _getPrototypeOf(o);
|
103 | }
|
104 |
|
105 | function _setPrototypeOf(o, p) {
|
106 | _setPrototypeOf = Object.setPrototypeOf || function _setPrototypeOf(o, p) {
|
107 | o.__proto__ = p;
|
108 | return o;
|
109 | };
|
110 |
|
111 | return _setPrototypeOf(o, p);
|
112 | }
|
113 |
|
114 | function _assertThisInitialized(self) {
|
115 | if (self === void 0) {
|
116 | throw new ReferenceError("this hasn't been initialised - super() hasn't been called");
|
117 | }
|
118 |
|
119 | return self;
|
120 | }
|
121 |
|
122 | function _possibleConstructorReturn(self, call) {
|
123 | if (call && (typeof call === "object" || typeof call === "function")) {
|
124 | return call;
|
125 | }
|
126 |
|
127 | return _assertThisInitialized(self);
|
128 | }
|
129 |
|
130 | function _toConsumableArray(arr) {
|
131 | return _arrayWithoutHoles(arr) || _iterableToArray(arr) || _nonIterableSpread();
|
132 | }
|
133 |
|
134 | function _arrayWithoutHoles(arr) {
|
135 | if (Array.isArray(arr)) {
|
136 | for (var i = 0, arr2 = new Array(arr.length); i < arr.length; i++) arr2[i] = arr[i];
|
137 |
|
138 | return arr2;
|
139 | }
|
140 | }
|
141 |
|
142 | function _iterableToArray(iter) {
|
143 | if (Symbol.iterator in Object(iter) || Object.prototype.toString.call(iter) === "[object Arguments]") return Array.from(iter);
|
144 | }
|
145 |
|
146 | function _nonIterableSpread() {
|
147 | throw new TypeError("Invalid attempt to spread non-iterable instance");
|
148 | }
|
149 |
|
150 | function isFunction(value) {
|
151 | return typeof value === 'function';
|
152 | }
|
153 |
|
154 | function getSuperOptions(Ctor) {
|
155 | var superProto = Object.getPrototypeOf(Ctor.prototype);
|
156 |
|
157 | if (!superProto) {
|
158 | return undefined;
|
159 | }
|
160 |
|
161 | var Super = superProto.constructor;
|
162 | return Super.__vccOpts;
|
163 | }
|
164 |
|
165 | var Vue =
|
166 |
|
167 | function () {
|
168 | function Vue(props) {
|
169 | var _this = this;
|
170 |
|
171 | _classCallCheck(this, Vue);
|
172 |
|
173 | this.$props = props;
|
174 | Object.keys(props).forEach(function (key) {
|
175 | Object.defineProperty(_this, key, {
|
176 | enumerable: false,
|
177 | configurable: true,
|
178 | writable: true,
|
179 | value: props[key]
|
180 | });
|
181 | });
|
182 | }
|
183 |
|
184 |
|
185 |
|
186 | _createClass(Vue, null, [{
|
187 | key: "registerHooks",
|
188 | value: function registerHooks(keys) {
|
189 | var _this$__vccHooks;
|
190 |
|
191 | (_this$__vccHooks = this.__vccHooks).push.apply(_this$__vccHooks, _toConsumableArray(keys));
|
192 | }
|
193 | }, {
|
194 | key: "__vccOpts",
|
195 | get: function get() {
|
196 |
|
197 | if (this === Vue) {
|
198 | return {};
|
199 | }
|
200 |
|
201 | var cache = this.hasOwnProperty('__vccCache') && this.__vccCache;
|
202 |
|
203 | if (cache) {
|
204 | return cache;
|
205 | }
|
206 |
|
207 | var Ctor = this;
|
208 |
|
209 | var options = this.__vccCache = this.hasOwnProperty('__vccBase') ? _objectSpread2({}, this.__vccBase) : {};
|
210 |
|
211 | options["extends"] = getSuperOptions(Ctor);
|
212 |
|
213 | var mixins = this.hasOwnProperty('__vccMixins') && this.__vccMixins;
|
214 |
|
215 | if (mixins) {
|
216 | options.mixins = options.mixins ? options.mixins.concat(mixins) : mixins;
|
217 | }
|
218 |
|
219 |
|
220 | options.name = options.name || Ctor.name;
|
221 | options.methods = _objectSpread2({}, options.methods);
|
222 | options.computed = _objectSpread2({}, options.computed);
|
223 | var proto = Ctor.prototype;
|
224 | Object.getOwnPropertyNames(proto).forEach(function (key) {
|
225 | if (key === 'constructor') {
|
226 | return;
|
227 | }
|
228 |
|
229 |
|
230 | if (Ctor.__vccHooks.indexOf(key) > -1) {
|
231 | options[key] = proto[key];
|
232 | return;
|
233 | }
|
234 |
|
235 | var descriptor = Object.getOwnPropertyDescriptor(proto, key);
|
236 |
|
237 | if (typeof descriptor.value === 'function') {
|
238 | options.methods[key] = descriptor.value;
|
239 | return;
|
240 | }
|
241 |
|
242 |
|
243 | if (descriptor.get || descriptor.set) {
|
244 | options.computed[key] = {
|
245 | get: descriptor.get,
|
246 | set: descriptor.set
|
247 | };
|
248 | return;
|
249 | }
|
250 | }); // Class properties -> reactive data
|
251 |
|
252 | var hookDataOption = options.data;
|
253 |
|
254 | options.data = function () {
|
255 | var hookData = isFunction(hookDataOption) ? hookDataOption.call(this, this) : hookDataOption;
|
256 |
|
257 | var data = new Ctor(this.$props);
|
258 |
|
259 | var plainData = {};
|
260 | Object.keys(data).forEach(function (key) {
|
261 | if (data[key] !== undefined && key !== '$props') {
|
262 | plainData[key] = data[key];
|
263 | }
|
264 | });
|
265 | return _objectSpread2({}, hookData, {}, plainData);
|
266 | };
|
267 |
|
268 | var decorators = this.hasOwnProperty('__vccDecorators') && this.__vccDecorators;
|
269 |
|
270 | if (decorators) {
|
271 | decorators.forEach(function (fn) {
|
272 | return fn(options);
|
273 | });
|
274 | }
|
275 |
|
276 |
|
277 | if (Ctor.render) {
|
278 | options.render = Ctor.render;
|
279 | }
|
280 |
|
281 | if (Ctor.__file) {
|
282 | options.__file = Ctor.__file;
|
283 | }
|
284 |
|
285 | if (Ctor.__cssModules) {
|
286 | options.__cssModules = Ctor.__cssModules;
|
287 | }
|
288 |
|
289 | if (Ctor.__scopeId) {
|
290 | options.__scopeId = Ctor.__scopeId;
|
291 | }
|
292 |
|
293 | return options;
|
294 | }
|
295 | }]);
|
296 |
|
297 | return Vue;
|
298 | }();
|
299 |
|
300 |
|
301 | Vue.__vccHooks = ['data', 'beforeCreate', 'created', 'beforeMount', 'mounted', 'beforeUnmount', 'unmounted', 'beforeUpdate', 'updated', 'activated', 'deactivated', 'render', 'errorCaptured', 'serverPrefetch'];
|
302 |
|
303 | function Options(options) {
|
304 | return function (Component) {
|
305 | Component.__vccBase = options;
|
306 | return Component;
|
307 | };
|
308 | }
|
309 | function createDecorator(factory) {
|
310 | return function (target, key, index) {
|
311 | var Ctor = typeof target === 'function' ? target : target.constructor;
|
312 |
|
313 | if (!Ctor.__vccDecorators) {
|
314 | Ctor.__vccDecorators = [];
|
315 | }
|
316 |
|
317 | if (typeof index !== 'number') {
|
318 | index = undefined;
|
319 | }
|
320 |
|
321 | Ctor.__vccDecorators.push(function (options) {
|
322 | return factory(options, key, index);
|
323 | });
|
324 | };
|
325 | }
|
326 | function mixins() {
|
327 | var _a;
|
328 |
|
329 | for (var _len = arguments.length, Ctors = new Array(_len), _key = 0; _key < _len; _key++) {
|
330 | Ctors[_key] = arguments[_key];
|
331 | }
|
332 |
|
333 | return _a =
|
334 |
|
335 | function (_Vue) {
|
336 | _inherits(MixedVue, _Vue);
|
337 |
|
338 | function MixedVue() {
|
339 | _classCallCheck(this, MixedVue);
|
340 |
|
341 | return _possibleConstructorReturn(this, _getPrototypeOf(MixedVue).apply(this, arguments));
|
342 | }
|
343 |
|
344 | return MixedVue;
|
345 | }(Vue), _a.__vccMixins = Ctors.map(function (Ctor) {
|
346 | return Ctor.__vccOpts;
|
347 | }), _a;
|
348 | }
|
349 |
|
350 | exports.Options = Options;
|
351 | exports.Vue = Vue;
|
352 | exports.createDecorator = createDecorator;
|
353 | exports.mixins = mixins;
|
354 |
|
355 | Object.defineProperty(exports, '__esModule', { value: true });
|
356 |
|
357 | })));
|