@egjs/vue3-flicking 4.15.0 → 4.17.0-beta.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,230 +1,9 @@
1
- /*
2
- Copyright (c) NAVER Corp.
3
- name: @egjs/vue3-flicking
4
- license: MIT
5
- author: NAVER Corp.
6
- repository: https://github.com/naver/egjs-flicking/tree/master/packages/vue3-flicking
7
- version: 4.15.0
8
- */
9
- 'use strict';
10
-
11
- var vue = require('vue');
12
- var ListDiffer = require('@egjs/list-differ');
13
- var Component = require('@egjs/component');
14
- var VanillaFlicking = require('@egjs/flicking');
15
- var vue3 = require('@cfcs/vue3');
16
-
17
- /*! *****************************************************************************
18
- Copyright (c) Microsoft Corporation.
19
-
20
- Permission to use, copy, modify, and/or distribute this software for any
21
- purpose with or without fee is hereby granted.
22
-
23
- THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH
24
- REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY
25
- AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT,
26
- INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM
27
- LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR
28
- OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
29
- PERFORMANCE OF THIS SOFTWARE.
30
- ***************************************************************************** */
31
-
32
- /* global Reflect, Promise */
33
- var extendStatics = function (d, b) {
34
- extendStatics = Object.setPrototypeOf || {
35
- __proto__: []
36
- } instanceof Array && function (d, b) {
37
- d.__proto__ = b;
38
- } || function (d, b) {
39
- for (var p in b) if (Object.prototype.hasOwnProperty.call(b, p)) d[p] = b[p];
40
- };
41
-
42
- return extendStatics(d, b);
43
- };
44
-
45
- function __extends(d, b) {
46
- if (typeof b !== "function" && b !== null) throw new TypeError("Class extends value " + String(b) + " is not a constructor or null");
47
- extendStatics(d, b);
48
-
49
- function __() {
50
- this.constructor = d;
51
- }
52
-
53
- d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
54
- }
55
- var __assign = function () {
56
- __assign = Object.assign || function __assign(t) {
57
- for (var s, i = 1, n = arguments.length; i < n; i++) {
58
- s = arguments[i];
59
-
60
- for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p)) t[p] = s[p];
61
- }
62
-
63
- return t;
64
- };
65
-
66
- return __assign.apply(this, arguments);
67
- };
68
- function __rest(s, e) {
69
- var t = {};
70
-
71
- for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0) t[p] = s[p];
72
-
73
- if (s != null && typeof Object.getOwnPropertySymbols === "function") for (var i = 0, p = Object.getOwnPropertySymbols(s); i < p.length; i++) {
74
- if (e.indexOf(p[i]) < 0 && Object.prototype.propertyIsEnumerable.call(s, p[i])) t[p[i]] = s[p[i]];
75
- }
76
- return t;
77
- }
78
- function __awaiter(thisArg, _arguments, P, generator) {
79
- function adopt(value) {
80
- return value instanceof P ? value : new P(function (resolve) {
81
- resolve(value);
82
- });
83
- }
84
-
85
- return new (P || (P = Promise))(function (resolve, reject) {
86
- function fulfilled(value) {
87
- try {
88
- step(generator.next(value));
89
- } catch (e) {
90
- reject(e);
91
- }
92
- }
93
-
94
- function rejected(value) {
95
- try {
96
- step(generator["throw"](value));
97
- } catch (e) {
98
- reject(e);
99
- }
100
- }
101
-
102
- function step(result) {
103
- result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected);
104
- }
105
-
106
- step((generator = generator.apply(thisArg, _arguments || [])).next());
107
- });
108
- }
109
- function __generator(thisArg, body) {
110
- var _ = {
111
- label: 0,
112
- sent: function () {
113
- if (t[0] & 1) throw t[1];
114
- return t[1];
115
- },
116
- trys: [],
117
- ops: []
118
- },
119
- f,
120
- y,
121
- t,
122
- g;
123
- return g = {
124
- next: verb(0),
125
- "throw": verb(1),
126
- "return": verb(2)
127
- }, typeof Symbol === "function" && (g[Symbol.iterator] = function () {
128
- return this;
129
- }), g;
130
-
131
- function verb(n) {
132
- return function (v) {
133
- return step([n, v]);
134
- };
135
- }
136
-
137
- function step(op) {
138
- if (f) throw new TypeError("Generator is already executing.");
139
-
140
- while (_) try {
141
- if (f = 1, y && (t = op[0] & 2 ? y["return"] : op[0] ? y["throw"] || ((t = y["return"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t;
142
- if (y = 0, t) op = [op[0] & 2, t.value];
143
-
144
- switch (op[0]) {
145
- case 0:
146
- case 1:
147
- t = op;
148
- break;
149
-
150
- case 4:
151
- _.label++;
152
- return {
153
- value: op[1],
154
- done: false
155
- };
156
-
157
- case 5:
158
- _.label++;
159
- y = op[1];
160
- op = [0];
161
- continue;
162
-
163
- case 7:
164
- op = _.ops.pop();
165
-
166
- _.trys.pop();
167
-
168
- continue;
169
-
170
- default:
171
- if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) {
172
- _ = 0;
173
- continue;
174
- }
175
-
176
- if (op[0] === 3 && (!t || op[1] > t[0] && op[1] < t[3])) {
177
- _.label = op[1];
178
- break;
179
- }
180
-
181
- if (op[0] === 6 && _.label < t[1]) {
182
- _.label = t[1];
183
- t = op;
184
- break;
185
- }
186
-
187
- if (t && _.label < t[2]) {
188
- _.label = t[2];
189
-
190
- _.ops.push(op);
191
-
192
- break;
193
- }
194
-
195
- if (t[2]) _.ops.pop();
196
-
197
- _.trys.pop();
198
-
199
- continue;
200
- }
201
-
202
- op = body.call(thisArg, _);
203
- } catch (e) {
204
- op = [6, e];
205
- y = 0;
206
- } finally {
207
- f = t = 0;
208
- }
209
-
210
- if (op[0] & 5) throw op[1];
211
- return {
212
- value: op[0] ? op[1] : void 0,
213
- done: true
214
- };
215
- }
216
- }
217
- function __spreadArray(to, from, pack) {
218
- if (pack || arguments.length === 2) for (var i = 0, l = from.length, ar; i < l; i++) {
219
- if (ar || !(i in from)) {
220
- if (!ar) ar = Array.prototype.slice.call(from, 0, i);
221
- ar[i] = from[i];
222
- }
223
- }
224
- return to.concat(ar || Array.prototype.slice.call(from));
225
- }
226
-
227
- var FlickingProps = {
1
+ "use strict";
2
+ const Component = require("@egjs/component");
3
+ const VanillaFlicking = require("@egjs/flicking");
4
+ const ListDiffer = require("@egjs/list-differ");
5
+ const vue = require("vue");
6
+ const FlickingProps = {
228
7
  viewportTag: {
229
8
  type: String,
230
9
  default: "div",
@@ -251,16 +30,12 @@ var FlickingProps = {
251
30
  },
252
31
  options: {
253
32
  type: Object,
254
- default: function () {
255
- return {};
256
- },
33
+ default: () => ({}),
257
34
  required: false
258
35
  },
259
36
  plugins: {
260
37
  type: Array,
261
- default: function () {
262
- return [];
263
- },
38
+ default: () => [],
264
39
  required: false
265
40
  },
266
41
  status: {
@@ -268,388 +43,250 @@ var FlickingProps = {
268
43
  required: false
269
44
  }
270
45
  };
271
-
272
- var VueRenderer =
273
- /*#__PURE__*/
274
- function (_super) {
275
- __extends(VueRenderer, _super);
276
-
277
- function VueRenderer(options) {
278
- var _this = _super.call(this, options) || this;
279
-
280
- _this._vueFlicking = options.vueFlicking;
281
- return _this;
46
+ class VueElementProvider {
47
+ get rendered() {
48
+ return !this._el.hide;
282
49
  }
283
-
284
- var __proto = VueRenderer.prototype;
285
-
286
- __proto.render = function () {
287
- return __awaiter(this, void 0, void 0, function () {
288
- var flicking, vueFlicking, strategy;
289
-
290
- var _this = this;
291
-
292
- return __generator(this, function (_a) {
293
- flicking = VanillaFlicking.getFlickingAttached(this._flicking);
294
- vueFlicking = this._vueFlicking;
295
- strategy = this._strategy;
296
- strategy.updateRenderingPanels(flicking);
297
- strategy.renderPanels(flicking);
298
- return [2
299
- /*return*/
300
- , new Promise(function (resolve) {
301
- vueFlicking.renderEmitter.once("render", function () {
302
- _this._afterRender();
303
-
304
- resolve();
305
- });
306
- vueFlicking.$forceUpdate();
307
- })];
308
- });
309
- });
310
- };
311
-
312
- __proto.forceRenderAllPanels = function () {
313
- return __awaiter(this, void 0, void 0, function () {
314
- var vueFlicking;
315
- return __generator(this, function (_a) {
316
- switch (_a.label) {
317
- case 0:
318
- vueFlicking = this._vueFlicking;
319
- return [4
320
- /*yield*/
321
- , _super.prototype.forceRenderAllPanels.call(this)];
322
-
323
- case 1:
324
- _a.sent();
325
-
326
- return [2
327
- /*return*/
328
- , new Promise(function (resolve) {
329
- vueFlicking.renderEmitter.once("render", resolve);
330
- vueFlicking.$forceUpdate();
331
- })];
332
- }
333
- });
334
- });
335
- };
336
-
337
- __proto._collectPanels = function () {
338
- var flicking = VanillaFlicking.getFlickingAttached(this._flicking);
339
- var vueFlicking = this._vueFlicking;
340
- var childRefs = vueFlicking.$refs;
341
- var vuePanels = Object.keys(childRefs).map(function (refKey) {
342
- return childRefs[refKey];
343
- });
344
- this._panels = this._strategy.collectPanels(flicking, vuePanels);
345
- };
346
-
347
- __proto._createPanel = function (externalComponent, options) {
348
- return this._strategy.createPanel(externalComponent, options);
349
- };
350
-
351
- return VueRenderer;
352
- }(VanillaFlicking.ExternalRenderer);
353
-
354
- /*
355
- * Copyright (c) 2015 NAVER Corp.
356
- * egjs projects are licensed under the MIT license
357
- */
358
- var VuePanel = vue.defineComponent({
359
- data: function () {
50
+ get element() {
51
+ const el = this._el.$el.nextSibling;
52
+ if (el && el.nodeType === Node.ELEMENT_NODE) {
53
+ this._cachedElement = el;
54
+ }
55
+ return this._cachedElement;
56
+ }
57
+ constructor(el) {
58
+ this._el = el;
59
+ }
60
+ show() {
61
+ this._el.hide = false;
62
+ }
63
+ hide() {
64
+ this._el.hide = true;
65
+ }
66
+ }
67
+ const VuePanel = vue.defineComponent({
68
+ data() {
360
69
  return {
361
70
  hide: false
362
71
  };
363
72
  },
364
- render: function () {
73
+ render() {
365
74
  if (this.hide || !this.$slots.default) return;
366
75
  return this.$slots.default();
367
76
  }
368
77
  });
369
-
370
- var VueElementProvider =
371
- /*#__PURE__*/
372
- function () {
373
- function VueElementProvider(el) {
374
- this._el = el;
78
+ class VueRenderer extends VanillaFlicking.ExternalRenderer {
79
+ constructor(options) {
80
+ super(options);
81
+ this._vueFlicking = options.vueFlicking;
375
82
  }
376
-
377
- var __proto = VueElementProvider.prototype;
378
- Object.defineProperty(__proto, "rendered", {
379
- get: function () {
380
- return !this._el.hide;
381
- },
382
- enumerable: false,
383
- configurable: true
384
- });
385
- Object.defineProperty(__proto, "element", {
386
- get: function () {
387
- var el = this._el.$el.nextSibling;
388
-
389
- if (el && el.nodeType === Node.ELEMENT_NODE) {
390
- this._cachedElement = el;
391
- }
392
-
393
- return this._cachedElement;
394
- },
395
- enumerable: false,
396
- configurable: true
397
- });
398
-
399
- __proto.show = function () {
400
- this._el.hide = false;
401
- };
402
-
403
- __proto.hide = function () {
404
- this._el.hide = true;
405
- };
406
-
407
- return VueElementProvider;
408
- }();
409
-
410
- var Flicking = vue.defineComponent({
83
+ async render() {
84
+ const flicking = VanillaFlicking.getFlickingAttached(this._flicking);
85
+ const vueFlicking = this._vueFlicking;
86
+ const strategy = this._strategy;
87
+ strategy.updateRenderingPanels(flicking);
88
+ strategy.renderPanels(flicking);
89
+ return new Promise((resolve) => {
90
+ vueFlicking.renderEmitter.once("render", () => {
91
+ this._afterRender();
92
+ resolve();
93
+ });
94
+ vueFlicking.$forceUpdate();
95
+ });
96
+ }
97
+ async forceRenderAllPanels() {
98
+ const vueFlicking = this._vueFlicking;
99
+ await super.forceRenderAllPanels();
100
+ return new Promise((resolve) => {
101
+ vueFlicking.renderEmitter.once("render", resolve);
102
+ vueFlicking.$forceUpdate();
103
+ });
104
+ }
105
+ _collectPanels() {
106
+ const flicking = VanillaFlicking.getFlickingAttached(this._flicking);
107
+ const vueFlicking = this._vueFlicking;
108
+ const childRefs = vueFlicking.$refs;
109
+ const vuePanels = Object.keys(childRefs).map((refKey) => childRefs[refKey]);
110
+ this._panels = this._strategy.collectPanels(flicking, vuePanels);
111
+ }
112
+ _createPanel(externalComponent, options) {
113
+ return this._strategy.createPanel(externalComponent, options);
114
+ }
115
+ }
116
+ const Flicking = vue.defineComponent({
411
117
  props: FlickingProps,
412
118
  components: {
413
119
  Panel: VuePanel
414
120
  },
415
- data: function () {
121
+ data() {
416
122
  return {};
417
123
  },
418
- created: function () {
419
- var _this = this;
420
-
124
+ created() {
421
125
  this.vanillaFlicking = null;
422
126
  this.renderEmitter = new Component();
423
127
  this.diffResult = null;
424
-
425
- this.getPanels = function () {
426
- var componentInstance = vue.getCurrentInstance();
427
- var vueFlicking = componentInstance === null || componentInstance === void 0 ? void 0 : componentInstance.ctx;
428
- var flicking = _this.vanillaFlicking;
429
-
430
- var defaultSlots = _this.getSlots();
431
-
432
- var diffResult = vueFlicking === null || vueFlicking === void 0 ? void 0 : vueFlicking.diffResult;
433
- var slots = diffResult ? VanillaFlicking.getRenderingPanels(flicking, diffResult) : defaultSlots;
434
- var panelComponent = vue.resolveComponent("Panel");
435
- var panels = slots.map(function (slot, idx) {
436
- return vue.h(panelComponent, {
437
- key: slot.key,
438
- ref: idx.toString()
439
- }, function () {
440
- return slot;
441
- });
442
- });
128
+ this.getPanels = () => {
129
+ const componentInstance = vue.getCurrentInstance();
130
+ const vueFlicking = componentInstance?.ctx;
131
+ const flicking = this.vanillaFlicking;
132
+ const defaultSlots = this.getSlots();
133
+ const diffResult = vueFlicking?.diffResult;
134
+ const slots = diffResult ? VanillaFlicking.getRenderingPanels(flicking, diffResult) : defaultSlots;
135
+ const panelComponent = vue.resolveComponent("Panel");
136
+ const panels = slots.map(
137
+ (slot, idx) => vue.h(
138
+ panelComponent,
139
+ {
140
+ key: slot.key,
141
+ ref: idx.toString()
142
+ },
143
+ () => slot
144
+ )
145
+ );
443
146
  return panels;
444
147
  };
445
-
446
- this.getVirtualPanels = function () {
447
- var options = _this.options;
448
- var _a = options.virtual.panelClass,
449
- panelClass = _a === void 0 ? "flicking-panel" : _a;
450
- var panelsPerView = options.panelsPerView;
451
- var flicking = _this.vanillaFlicking;
452
- var initialized = flicking && flicking.initialized;
453
- var renderingIndexes = initialized ? flicking.renderer.strategy.getRenderingIndexesByOrder(flicking) : VanillaFlicking.range(panelsPerView + 1);
454
- var firstPanel = initialized && flicking.panels[0];
455
- var size = firstPanel ? flicking.horizontal ? {
456
- width: firstPanel.size
457
- } : {
458
- height: firstPanel.size
459
- } : {};
460
- return renderingIndexes.map(function (idx) {
461
- return vue.h("div", {
148
+ this.getVirtualPanels = () => {
149
+ const options = this.options;
150
+ const { panelClass = "flicking-panel" } = options.virtual;
151
+ const panelsPerView = options.panelsPerView;
152
+ const flicking = this.vanillaFlicking;
153
+ const initialized = flicking?.initialized;
154
+ const renderingIndexes = initialized ? flicking.renderer.strategy.getRenderingIndexesByOrder(flicking) : VanillaFlicking.range(panelsPerView + 1);
155
+ const firstPanel = initialized && flicking.panels[0];
156
+ const size = firstPanel ? flicking.horizontal ? { width: firstPanel.size } : { height: firstPanel.size } : {};
157
+ return renderingIndexes.map(
158
+ (idx) => vue.h("div", {
462
159
  key: idx,
463
160
  ref: idx.toString(),
464
161
  class: panelClass,
465
162
  style: size,
466
163
  "data-element-index": idx
467
- });
468
- });
164
+ })
165
+ );
469
166
  };
470
-
471
167
  VanillaFlicking.withFlickingMethods(this, "vanillaFlicking");
472
168
  },
473
- mounted: function () {
474
- var _this = this;
475
-
476
- var _a;
477
-
478
- var options = this.options;
479
- var viewportEl = this.$el;
480
- var rendererOptions = {
169
+ mounted() {
170
+ const options = this.options;
171
+ const viewportEl = this.$el;
172
+ const rendererOptions = {
481
173
  vueFlicking: this,
482
174
  align: options.align,
483
- strategy: options.virtual && ((_a = options.panelsPerView) !== null && _a !== void 0 ? _a : -1) > 0 ? new VanillaFlicking.VirtualRenderingStrategy() : new VanillaFlicking.NormalRenderingStrategy({
175
+ strategy: options.virtual && (options.panelsPerView ?? -1) > 0 ? new VanillaFlicking.VirtualRenderingStrategy() : new VanillaFlicking.NormalRenderingStrategy({
484
176
  providerCtor: VueElementProvider
485
177
  })
486
178
  };
487
- var flicking = new VanillaFlicking(viewportEl, __assign(__assign({}, options), {
179
+ const flicking = new VanillaFlicking(viewportEl, {
180
+ ...options,
488
181
  externalRenderer: new VueRenderer(rendererOptions)
489
- }));
490
- this.vanillaFlicking = flicking;
491
- flicking.once(VanillaFlicking.EVENTS.READY, function () {
492
- _this.$forceUpdate();
493
182
  });
494
- var slots = this.getSlots();
495
- this.slotDiffer = new ListDiffer(slots, function (vnode) {
496
- return vnode.key;
183
+ this.vanillaFlicking = flicking;
184
+ flicking.once(VanillaFlicking.EVENTS.READY, () => {
185
+ this.$forceUpdate();
497
186
  });
187
+ const slots = this.getSlots();
188
+ this.slotDiffer = new ListDiffer(slots, (vnode) => vnode.key);
498
189
  this.pluginsDiffer = new ListDiffer();
499
190
  this.bindEvents();
500
191
  this.checkPlugins();
501
-
502
192
  if (this.status) {
503
193
  flicking.setStatus(this.status);
504
194
  }
505
195
  },
506
- beforeUnmount: function () {
507
- var _a;
508
-
509
- (_a = this.vanillaFlicking) === null || _a === void 0 ? void 0 : _a.destroy();
196
+ beforeUnmount() {
197
+ this.vanillaFlicking?.destroy();
510
198
  },
511
- beforeMount: function () {
199
+ beforeMount() {
512
200
  this.fillKeys();
513
201
  },
514
- beforeUpdate: function () {
515
- var _a;
516
-
202
+ beforeUpdate() {
517
203
  this.fillKeys();
518
- this.diffResult = (_a = this.slotDiffer) === null || _a === void 0 ? void 0 : _a.update(this.getSlots());
204
+ this.diffResult = this.slotDiffer?.update(this.getSlots());
519
205
  },
520
- updated: function () {
521
- var flicking = this.vanillaFlicking;
522
- var diffResult = this.diffResult;
206
+ updated() {
207
+ const flicking = this.vanillaFlicking;
208
+ const diffResult = this.diffResult;
523
209
  this.checkPlugins();
524
210
  this.renderEmitter.trigger("render");
525
- if (!diffResult || !(flicking === null || flicking === void 0 ? void 0 : flicking.initialized)) return;
526
- var children = this.getChildren();
211
+ if (!diffResult || !flicking?.initialized) return;
212
+ const children = this.getChildren();
527
213
  VanillaFlicking.sync(flicking, diffResult, children);
528
-
529
214
  if (diffResult.added.length > 0 || diffResult.removed.length > 0) {
530
215
  this.$forceUpdate();
531
216
  }
532
-
533
- this.diffResult = undefined;
217
+ this.diffResult = void 0;
534
218
  },
535
- render: function () {
536
- var _a;
537
-
538
- var _b;
539
-
540
- var flicking = this.vanillaFlicking;
541
- var options = this.options;
542
- var initialized = flicking && flicking.initialized;
543
- var isHorizontal = flicking ? flicking.horizontal : (_b = this.options.horizontal) !== null && _b !== void 0 ? _b : true;
544
- var viewportData = {
219
+ render() {
220
+ const flicking = this.vanillaFlicking;
221
+ const options = this.options;
222
+ const initialized = flicking?.initialized;
223
+ const isHorizontal = flicking ? flicking.horizontal : this.options.horizontal ?? true;
224
+ const viewportData = {
545
225
  class: {
546
226
  "flicking-viewport": true,
547
- "vertical": !isHorizontal,
227
+ vertical: !isHorizontal,
548
228
  "flicking-hidden": this.hideBeforeInit && !initialized
549
229
  }
550
230
  };
551
- var cameraData = {
552
- class: (_a = {
553
- "flicking-camera": true
554
- }, _a[this.cameraClass] = !!this.cameraClass, _a),
555
- style: !initialized && this.firstPanelSize ? {
556
- transform: VanillaFlicking.getDefaultCameraTransform(this.options.align, this.options.horizontal, this.firstPanelSize)
557
- } : {}
231
+ const cameraData = {
232
+ class: {
233
+ "flicking-camera": true,
234
+ [this.cameraClass]: !!this.cameraClass
235
+ },
236
+ style: !initialized && this.firstPanelSize ? { transform: VanillaFlicking.getDefaultCameraTransform(this.options.align, this.options.horizontal, this.firstPanelSize) } : {}
558
237
  };
559
- var panels = options.virtual && options.panelsPerView && options.panelsPerView > 0 ? this.getVirtualPanels : this.getPanels;
560
- var viewportSlots = this.$slots.viewport ? this.$slots.viewport() : [];
561
- return vue.h(this.viewportTag, viewportData, __spreadArray([vue.h(this.cameraTag, cameraData, {
562
- default: panels
563
- })], viewportSlots, true));
238
+ const panels = options.virtual && options.panelsPerView && options.panelsPerView > 0 ? this.getVirtualPanels : this.getPanels;
239
+ const viewportSlots = this.$slots.viewport ? this.$slots.viewport() : [];
240
+ return vue.h(this.viewportTag, viewportData, [vue.h(this.cameraTag, cameraData, { default: panels }), ...viewportSlots]);
564
241
  },
565
242
  methods: {
566
- getSlots: function () {
567
- var _this = this;
568
-
569
- var slots = this.$slots.default ? this.$slots.default() : [];
570
- return slots.reduce(function (elementSlots, slot) {
571
- return __spreadArray(__spreadArray([], elementSlots, true), _this.getElementVNodes(slot), true);
572
- }, []).filter(function (slot) {
573
- return slot.type !== vue.Comment && slot.type !== vue.Text;
574
- });
243
+ getSlots() {
244
+ const slots = this.$slots.default ? this.$slots.default() : [];
245
+ return slots.reduce((elementSlots, slot) => [...elementSlots, ...this.getElementVNodes(slot)], []).filter((slot) => slot.type !== vue.Comment && slot.type !== vue.Text);
575
246
  },
576
- getElementVNodes: function (slot, childSlots) {
577
- var _this = this;
578
-
579
- if (childSlots === void 0) {
580
- childSlots = [];
581
- }
582
-
247
+ getElementVNodes(slot, childSlots = []) {
583
248
  if (slot.type === vue.Fragment && Array.isArray(slot.children)) {
584
- slot.children.filter(function (child) {
585
- return child && typeof child === "object";
586
- }).forEach(function (child) {
587
- return _this.getElementVNodes(child, childSlots);
588
- });
249
+ slot.children.filter((child) => child && typeof child === "object").forEach((child) => this.getElementVNodes(child, childSlots));
589
250
  } else {
590
251
  childSlots.push(slot);
591
252
  }
592
-
593
253
  return childSlots;
594
254
  },
595
- bindEvents: function () {
596
- var _this = this;
597
-
598
- var flicking = this.vanillaFlicking;
599
- var events = Object.keys(VanillaFlicking.EVENTS).map(function (key) {
600
- return VanillaFlicking.EVENTS[key];
601
- });
602
- events.forEach(function (eventName) {
603
- flicking.on(eventName, function (e) {
604
- e.currentTarget = _this; // Make events from camelCase to kebab-case
605
-
606
- _this.$emit(eventName.replace(/([A-Z])/g, "-$1").toLowerCase(), e);
255
+ bindEvents() {
256
+ const flicking = this.vanillaFlicking;
257
+ const events = Object.keys(VanillaFlicking.EVENTS).map((key) => VanillaFlicking.EVENTS[key]);
258
+ events.forEach((eventName) => {
259
+ flicking.on(eventName, (e) => {
260
+ e.currentTarget = this;
261
+ this.$emit(eventName.replace(/([A-Z])/g, "-$1").toLowerCase(), e);
607
262
  });
608
263
  });
609
264
  },
610
- checkPlugins: function () {
611
- var _a, _b;
612
-
613
- var _c = this.pluginsDiffer.update(this.plugins),
614
- list = _c.list,
615
- added = _c.added,
616
- removed = _c.removed,
617
- prevList = _c.prevList;
618
-
619
- (_a = this.vanillaFlicking).addPlugins.apply(_a, added.map(function (index) {
620
- return list[index];
621
- }));
622
-
623
- (_b = this.vanillaFlicking).removePlugins.apply(_b, removed.map(function (index) {
624
- return prevList[index];
625
- }));
265
+ checkPlugins() {
266
+ const { list, added, removed, prevList } = this.pluginsDiffer.update(this.plugins);
267
+ this.vanillaFlicking.addPlugins(...added.map((index) => list[index]));
268
+ this.vanillaFlicking.removePlugins(...removed.map((index) => prevList[index]));
626
269
  },
627
- fillKeys: function () {
628
- var vnodes = this.getSlots();
629
- vnodes.forEach(function (node, idx) {
270
+ fillKeys() {
271
+ const vnodes = this.getSlots();
272
+ vnodes.forEach((node, idx) => {
630
273
  if (node.key == null) {
631
- node.key = "$_".concat(idx);
274
+ node.key = `$_${idx}`;
632
275
  }
633
276
  });
634
277
  },
635
- getChildren: function () {
636
- var childRefs = this.$refs;
637
- return Object.keys(childRefs).map(function (refKey) {
638
- return childRefs[refKey];
639
- });
278
+ getChildren() {
279
+ const childRefs = this.$refs;
280
+ return Object.keys(childRefs).map((refKey) => childRefs[refKey]);
640
281
  }
641
282
  },
642
283
  watch: {
643
284
  options: {
644
- handler: function (newOptions) {
645
- var flicking = this.vanillaFlicking;
646
- if (!flicking) return; // Omit 'virtual', as it can't have any setter
647
-
648
- newOptions.virtual;
649
- var options = __rest(newOptions, ["virtual"]); // eslint-disable-line @typescript-eslint/no-unused-vars
650
-
651
-
652
- for (var key in options) {
285
+ handler(newOptions) {
286
+ const flicking = this.vanillaFlicking;
287
+ if (!flicking) return;
288
+ const { virtual, ...options } = newOptions;
289
+ for (const key in options) {
653
290
  if (key in flicking && flicking[key] !== options[key]) {
654
291
  flicking[key] = options[key];
655
292
  }
@@ -660,19 +297,286 @@ var Flicking = vue.defineComponent({
660
297
  }
661
298
  }
662
299
  });
663
-
664
- var useFlickingReactiveAPI = function (flickingRef, options) {
665
- return vue3.useReactive(VanillaFlicking.flickingReactiveAPIAdapter, function () {
666
- var _a;
667
-
668
- return {
669
- flicking: (_a = flickingRef.value) !== null && _a !== void 0 ? _a : undefined,
670
- options: options
300
+ function keys(obj) {
301
+ return Object.keys(obj);
302
+ }
303
+ function camelize(str) {
304
+ return str.replace(/[\s-_]([a-z])/g, function(all, letter) {
305
+ return letter.toUpperCase();
306
+ });
307
+ }
308
+ function isFunction(val) {
309
+ return typeof val === "function";
310
+ }
311
+ var OBSERVERS_PATH = "__observers__";
312
+ var COMPUTED_PATH = "__computed__";
313
+ function __spreadArray(to, from, pack) {
314
+ if (arguments.length === 2) for (var i = 0, l = from.length, ar; i < l; i++) {
315
+ if (ar || !(i in from)) {
316
+ if (!ar) ar = Array.prototype.slice.call(from, 0, i);
317
+ ar[i] = from[i];
318
+ }
319
+ }
320
+ return to.concat(ar || Array.prototype.slice.call(from));
321
+ }
322
+ function withReactiveMethods(ref, methods) {
323
+ var obj = {};
324
+ if (!methods) {
325
+ return obj;
326
+ }
327
+ methods.forEach(function(name) {
328
+ obj[name] = function() {
329
+ var args = [];
330
+ for (var _i = 0; _i < arguments.length; _i++) {
331
+ args[_i] = arguments[_i];
332
+ }
333
+ var current = ref.current || ref.value;
334
+ return current[name].apply(current, args);
671
335
  };
672
336
  });
337
+ return obj;
338
+ }
339
+ function defineObservers(instance) {
340
+ var observers = {};
341
+ Object.defineProperty(instance, OBSERVERS_PATH, {
342
+ get: function() {
343
+ return observers;
344
+ }
345
+ });
346
+ return observers;
347
+ }
348
+ function getObservers(instance, isComputed) {
349
+ var _a, _b;
350
+ if (!instance[OBSERVERS_PATH]) {
351
+ defineObservers(instance);
352
+ }
353
+ var observers = instance[OBSERVERS_PATH];
354
+ {
355
+ var computedList = (_b = (_a = instance === null || instance === void 0 ? void 0 : instance.constructor) === null || _a === void 0 ? void 0 : _a.prototype) === null || _b === void 0 ? void 0 : _b[COMPUTED_PATH];
356
+ if (computedList) {
357
+ computedList.forEach(function(name) {
358
+ if (!(name in observers) && name in instance) {
359
+ instance[name];
360
+ }
361
+ });
362
+ }
363
+ }
364
+ return observers;
365
+ }
366
+ function adaptReactive(adapter, props) {
367
+ var objectAdapter = isFunction(adapter) ? {
368
+ setup: adapter
369
+ } : adapter;
370
+ function getProps() {
371
+ var _a, _b, _c, _d, _e;
372
+ return (_e = (_c = (_a = props === null || props === void 0 ? void 0 : props()) !== null && _a !== void 0 ? _a : (_b = objectAdapter.props) === null || _b === void 0 ? void 0 : _b.call(objectAdapter)) !== null && _c !== void 0 ? _c : (_d = objectAdapter.data) === null || _d === void 0 ? void 0 : _d.call(objectAdapter)) !== null && _e !== void 0 ? _e : {};
373
+ }
374
+ var eventEmitter = new Component();
375
+ var mountedHooks = [];
376
+ var initHooks = [];
377
+ var destroyHooks = [];
378
+ var onHooks = [];
379
+ var instanceRef = {
380
+ current: null
381
+ };
382
+ var offHooksList = [];
383
+ var initialState = null;
384
+ var eventNames = [];
385
+ var methodNames = [];
386
+ var onMounted = function(callback) {
387
+ mountedHooks.push(callback);
388
+ };
389
+ var onInit = function(callback) {
390
+ initHooks.push(callback);
391
+ };
392
+ var onDestroy = function(callback) {
393
+ destroyHooks.push(callback);
394
+ };
395
+ var on = function(callback) {
396
+ onHooks.push(callback);
397
+ };
398
+ var emit = function(eventName) {
399
+ var params = [];
400
+ for (var _i = 1; _i < arguments.length; _i++) {
401
+ params[_i - 1] = arguments[_i];
402
+ }
403
+ eventEmitter.trigger.apply(eventEmitter, __spreadArray([eventName], params, false));
404
+ };
405
+ var setInitialState = function(state) {
406
+ initialState = state;
407
+ };
408
+ var setEvents = function(events) {
409
+ eventNames = events;
410
+ };
411
+ var setMethods = function(methods) {
412
+ methodNames = methods;
413
+ };
414
+ if (objectAdapter.setup) {
415
+ instanceRef.current = objectAdapter.setup({
416
+ getProps,
417
+ setInitialState,
418
+ setEvents,
419
+ setMethods,
420
+ onMounted,
421
+ onDestroy,
422
+ onInit,
423
+ emit,
424
+ on
425
+ }) || null;
426
+ }
427
+ if (objectAdapter.created) {
428
+ instanceRef.current = objectAdapter.created(getProps()) || null;
429
+ }
430
+ if (objectAdapter.events) {
431
+ setEvents(objectAdapter.events);
432
+ }
433
+ if (objectAdapter.state) {
434
+ setInitialState(objectAdapter.state);
435
+ }
436
+ if (objectAdapter.methods) {
437
+ setMethods(objectAdapter.methods);
438
+ }
439
+ if (objectAdapter.mounted) {
440
+ onMounted(objectAdapter.mounted);
441
+ }
442
+ if (objectAdapter.destroy) {
443
+ destroyHooks.push(objectAdapter.destroy);
444
+ }
445
+ if (objectAdapter.init) {
446
+ initHooks.push(objectAdapter.init);
447
+ }
448
+ if (objectAdapter.on) {
449
+ onHooks.push(function(instance, eventName, listener) {
450
+ var off = objectAdapter.on(instance, eventName, listener);
451
+ return function() {
452
+ var _a;
453
+ off && off();
454
+ (_a = objectAdapter.off) === null || _a === void 0 ? void 0 : _a.call(objectAdapter, instance, eventName, listener);
455
+ };
456
+ });
457
+ }
458
+ return {
459
+ events: function() {
460
+ return eventNames;
461
+ },
462
+ state: function() {
463
+ var inst = instanceRef.current;
464
+ if (initialState) {
465
+ return initialState;
466
+ }
467
+ if (inst) {
468
+ var observers_1 = getObservers(inst);
469
+ setInitialState(keys(observers_1).reduce(function(prev, cur) {
470
+ prev[cur] = observers_1[cur].current;
471
+ return prev;
472
+ }, {}));
473
+ }
474
+ return initialState || {};
475
+ },
476
+ instance: function() {
477
+ return instanceRef.current;
478
+ },
479
+ mounted: function() {
480
+ var props2 = getProps();
481
+ mountedHooks.forEach(function(hook) {
482
+ instanceRef.current = hook(props2, instanceRef.current) || instanceRef.current;
483
+ });
484
+ },
485
+ init: function() {
486
+ var instance = instanceRef.current;
487
+ var props2 = getProps();
488
+ offHooksList = eventNames.map(function(eventName) {
489
+ var listener = function() {
490
+ var _a;
491
+ var params = [];
492
+ for (var _i = 0; _i < arguments.length; _i++) {
493
+ params[_i] = arguments[_i];
494
+ }
495
+ (_a = eventEmitter).trigger.apply(_a, __spreadArray([eventName], params, false));
496
+ };
497
+ var instance2 = instanceRef.current;
498
+ return onHooks.map(function(hook) {
499
+ return hook(instance2, eventName, listener);
500
+ }).filter(Boolean);
501
+ });
502
+ initHooks.forEach(function(hook) {
503
+ hook(instance, props2);
504
+ });
505
+ },
506
+ destroy: function() {
507
+ offHooksList.forEach(function(offHooks) {
508
+ offHooks.forEach(function(hook) {
509
+ hook();
510
+ });
511
+ });
512
+ eventEmitter.off();
513
+ var instance = instanceRef.current;
514
+ var props2 = getProps();
515
+ destroyHooks.forEach(function(hook) {
516
+ hook(instance, props2);
517
+ });
518
+ },
519
+ methods: function() {
520
+ return withReactiveMethods(instanceRef, methodNames);
521
+ },
522
+ on: function(eventName, listener) {
523
+ eventEmitter.on(eventName, listener);
524
+ },
525
+ off: function(eventName, listener) {
526
+ eventEmitter.off(eventName, listener);
527
+ }
528
+ };
529
+ }
530
+ var __assign = function() {
531
+ __assign = Object.assign || function __assign2(t) {
532
+ for (var s, i = 1, n = arguments.length; i < n; i++) {
533
+ s = arguments[i];
534
+ for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p)) t[p] = s[p];
535
+ }
536
+ return t;
537
+ };
538
+ return __assign.apply(this, arguments);
539
+ };
540
+ function useReactive(reactiveAdapter, props) {
541
+ var adaptResult = adaptReactive(reactiveAdapter, props);
542
+ var reactiveState = adaptResult.state();
543
+ var names = Object.keys(reactiveState);
544
+ var refs = {};
545
+ for (var name in reactiveState) {
546
+ refs[name] = vue.ref(reactiveState[name]);
547
+ }
548
+ var methods = adaptResult.methods();
549
+ vue.onMounted(function() {
550
+ adaptResult.mounted();
551
+ var inst = adaptResult.instance();
552
+ names.forEach(function(name2) {
553
+ inst.subscribe(name2, function(value) {
554
+ refs[name2].value = value;
555
+ });
556
+ });
557
+ adaptResult.init();
558
+ });
559
+ vue.onUnmounted(function() {
560
+ adaptResult.destroy();
561
+ });
562
+ var reactiveEvents = adaptResult.events();
563
+ var events = reactiveEvents.reduce(function(eventResult, name2) {
564
+ eventResult[camelize("on ".concat(name2))] = function(callback) {
565
+ adaptResult.on(name2, callback);
566
+ vue.onUnmounted(function() {
567
+ adaptResult.off(name2, callback);
568
+ });
569
+ };
570
+ return eventResult;
571
+ }, {});
572
+ return __assign(__assign(__assign({}, refs), methods), events);
573
+ }
574
+ const useFlickingReactiveAPI = (flickingRef, options) => {
575
+ return useReactive(VanillaFlicking.flickingReactiveAPIAdapter, () => ({
576
+ flicking: flickingRef.value ?? void 0,
577
+ options
578
+ }));
673
579
  };
674
-
675
580
  Flicking.useFlickingReactiveAPI = useFlickingReactiveAPI;
676
-
677
581
  module.exports = Flicking;
678
582
  //# sourceMappingURL=flicking.cjs.js.map