Browse code

Refactor and rewrite as contao bundle

Benjamin Roth authored on04/11/2022 22:32:32
Showing1 changed files
1 1
new file mode 100644
... ...
@@ -0,0 +1,551 @@
1
+/* swiper.svelte generated by Svelte v3.24.1 */
2
+import {
3
+	SvelteComponent,
4
+	append,
5
+	assign,
6
+	attr,
7
+	binding_callbacks,
8
+	compute_rest_props,
9
+	create_slot,
10
+	detach,
11
+	element,
12
+	exclude_internal_props,
13
+	get_spread_update,
14
+	init,
15
+	insert,
16
+	noop,
17
+	safe_not_equal,
18
+	set_attributes,
19
+	space,
20
+	transition_in,
21
+	transition_out,
22
+	update_slot
23
+} from "svelte/internal";
24
+
25
+import {
26
+	onMount,
27
+	onDestroy,
28
+	afterUpdate,
29
+	createEventDispatcher,
30
+	tick,
31
+	beforeUpdate
32
+} from "svelte";
33
+
34
+import { getParams } from "./get-params";
35
+import { initSwiper } from "./init-swiper";
36
+
37
+import {
38
+	needsScrollbar,
39
+	needsNavigation,
40
+	needsPagination,
41
+	uniqueClasses
42
+} from "./utils";
43
+
44
+import { getChangedParams } from "./get-changed-params";
45
+import { updateSwiper } from "./update-swiper";
46
+const get_content_end_slot_changes = dirty => ({ virtualData: dirty & /*virtualData*/ 512 });
47
+const get_content_end_slot_context = ctx => ({ virtualData: /*virtualData*/ ctx[9] });
48
+const get_wrapper_end_slot_changes = dirty => ({ virtualData: dirty & /*virtualData*/ 512 });
49
+const get_wrapper_end_slot_context = ctx => ({ virtualData: /*virtualData*/ ctx[9] });
50
+const get_default_slot_changes = dirty => ({ virtualData: dirty & /*virtualData*/ 512 });
51
+const get_default_slot_context = ctx => ({ virtualData: /*virtualData*/ ctx[9] });
52
+const get_wrapper_start_slot_changes = dirty => ({ virtualData: dirty & /*virtualData*/ 512 });
53
+const get_wrapper_start_slot_context = ctx => ({ virtualData: /*virtualData*/ ctx[9] });
54
+const get_content_start_slot_changes = dirty => ({ virtualData: dirty & /*virtualData*/ 512 });
55
+const get_content_start_slot_context = ctx => ({ virtualData: /*virtualData*/ ctx[9] });
56
+
57
+// (142:2) {#if needsNavigation(swiperParams)}
58
+function create_if_block_2(ctx) {
59
+	let div0;
60
+	let t;
61
+	let div1;
62
+
63
+	return {
64
+		c() {
65
+			div0 = element("div");
66
+			t = space();
67
+			div1 = element("div");
68
+			attr(div0, "class", "swiper-button-prev");
69
+			attr(div1, "class", "swiper-button-next");
70
+		},
71
+		m(target, anchor) {
72
+			insert(target, div0, anchor);
73
+			/*div0_binding*/ ctx[13](div0);
74
+			insert(target, t, anchor);
75
+			insert(target, div1, anchor);
76
+			/*div1_binding*/ ctx[14](div1);
77
+		},
78
+		p: noop,
79
+		d(detaching) {
80
+			if (detaching) detach(div0);
81
+			/*div0_binding*/ ctx[13](null);
82
+			if (detaching) detach(t);
83
+			if (detaching) detach(div1);
84
+			/*div1_binding*/ ctx[14](null);
85
+		}
86
+	};
87
+}
88
+
89
+// (146:2) {#if needsScrollbar(swiperParams)}
90
+function create_if_block_1(ctx) {
91
+	let div;
92
+
93
+	return {
94
+		c() {
95
+			div = element("div");
96
+			attr(div, "class", "swiper-scrollbar");
97
+		},
98
+		m(target, anchor) {
99
+			insert(target, div, anchor);
100
+			/*div_binding*/ ctx[15](div);
101
+		},
102
+		p: noop,
103
+		d(detaching) {
104
+			if (detaching) detach(div);
105
+			/*div_binding*/ ctx[15](null);
106
+		}
107
+	};
108
+}
109
+
110
+// (149:2) {#if needsPagination(swiperParams)}
111
+function create_if_block(ctx) {
112
+	let div;
113
+
114
+	return {
115
+		c() {
116
+			div = element("div");
117
+			attr(div, "class", "swiper-pagination");
118
+		},
119
+		m(target, anchor) {
120
+			insert(target, div, anchor);
121
+			/*div_binding_1*/ ctx[16](div);
122
+		},
123
+		p: noop,
124
+		d(detaching) {
125
+			if (detaching) detach(div);
126
+			/*div_binding_1*/ ctx[16](null);
127
+		}
128
+	};
129
+}
130
+
131
+function create_fragment(ctx) {
132
+	let div1;
133
+	let t0;
134
+	let show_if_2 = needsNavigation(/*swiperParams*/ ctx[2]);
135
+	let t1;
136
+	let show_if_1 = needsScrollbar(/*swiperParams*/ ctx[2]);
137
+	let t2;
138
+	let show_if = needsPagination(/*swiperParams*/ ctx[2]);
139
+	let t3;
140
+	let div0;
141
+	let t4;
142
+	let t5;
143
+	let t6;
144
+	let div1_class_value;
145
+	let current;
146
+	const content_start_slot_template = /*$$slots*/ ctx[12]["content-start"];
147
+	const content_start_slot = create_slot(content_start_slot_template, ctx, /*$$scope*/ ctx[11], get_content_start_slot_context);
148
+	let if_block0 = show_if_2 && create_if_block_2(ctx);
149
+	let if_block1 = show_if_1 && create_if_block_1(ctx);
150
+	let if_block2 = show_if && create_if_block(ctx);
151
+	const wrapper_start_slot_template = /*$$slots*/ ctx[12]["wrapper-start"];
152
+	const wrapper_start_slot = create_slot(wrapper_start_slot_template, ctx, /*$$scope*/ ctx[11], get_wrapper_start_slot_context);
153
+	const default_slot_template = /*$$slots*/ ctx[12].default;
154
+	const default_slot = create_slot(default_slot_template, ctx, /*$$scope*/ ctx[11], get_default_slot_context);
155
+	const wrapper_end_slot_template = /*$$slots*/ ctx[12]["wrapper-end"];
156
+	const wrapper_end_slot = create_slot(wrapper_end_slot_template, ctx, /*$$scope*/ ctx[11], get_wrapper_end_slot_context);
157
+	const content_end_slot_template = /*$$slots*/ ctx[12]["content-end"];
158
+	const content_end_slot = create_slot(content_end_slot_template, ctx, /*$$scope*/ ctx[11], get_content_end_slot_context);
159
+
160
+	let div1_levels = [
161
+		{
162
+			class: div1_class_value = uniqueClasses(`${/*containerClasses*/ ctx[1]}${/*className*/ ctx[0] ? ` ${/*className*/ ctx[0]}` : ""}`)
163
+		},
164
+		/*restProps*/ ctx[3]
165
+	];
166
+
167
+	let div1_data = {};
168
+
169
+	for (let i = 0; i < div1_levels.length; i += 1) {
170
+		div1_data = assign(div1_data, div1_levels[i]);
171
+	}
172
+
173
+	return {
174
+		c() {
175
+			div1 = element("div");
176
+			if (content_start_slot) content_start_slot.c();
177
+			t0 = space();
178
+			if (if_block0) if_block0.c();
179
+			t1 = space();
180
+			if (if_block1) if_block1.c();
181
+			t2 = space();
182
+			if (if_block2) if_block2.c();
183
+			t3 = space();
184
+			div0 = element("div");
185
+			if (wrapper_start_slot) wrapper_start_slot.c();
186
+			t4 = space();
187
+			if (default_slot) default_slot.c();
188
+			t5 = space();
189
+			if (wrapper_end_slot) wrapper_end_slot.c();
190
+			t6 = space();
191
+			if (content_end_slot) content_end_slot.c();
192
+			attr(div0, "class", "swiper-wrapper");
193
+			set_attributes(div1, div1_data);
194
+		},
195
+		m(target, anchor) {
196
+			insert(target, div1, anchor);
197
+
198
+			if (content_start_slot) {
199
+				content_start_slot.m(div1, null);
200
+			}
201
+
202
+			append(div1, t0);
203
+			if (if_block0) if_block0.m(div1, null);
204
+			append(div1, t1);
205
+			if (if_block1) if_block1.m(div1, null);
206
+			append(div1, t2);
207
+			if (if_block2) if_block2.m(div1, null);
208
+			append(div1, t3);
209
+			append(div1, div0);
210
+
211
+			if (wrapper_start_slot) {
212
+				wrapper_start_slot.m(div0, null);
213
+			}
214
+
215
+			append(div0, t4);
216
+
217
+			if (default_slot) {
218
+				default_slot.m(div0, null);
219
+			}
220
+
221
+			append(div0, t5);
222
+
223
+			if (wrapper_end_slot) {
224
+				wrapper_end_slot.m(div0, null);
225
+			}
226
+
227
+			append(div1, t6);
228
+
229
+			if (content_end_slot) {
230
+				content_end_slot.m(div1, null);
231
+			}
232
+
233
+			/*div1_binding_1*/ ctx[17](div1);
234
+			current = true;
235
+		},
236
+		p(ctx, [dirty]) {
237
+			if (content_start_slot) {
238
+				if (content_start_slot.p && dirty & /*$$scope, virtualData*/ 2560) {
239
+					update_slot(content_start_slot, content_start_slot_template, ctx, /*$$scope*/ ctx[11], dirty, get_content_start_slot_changes, get_content_start_slot_context);
240
+				}
241
+			}
242
+
243
+			if (dirty & /*swiperParams*/ 4) show_if_2 = needsNavigation(/*swiperParams*/ ctx[2]);
244
+
245
+			if (show_if_2) {
246
+				if (if_block0) {
247
+					if_block0.p(ctx, dirty);
248
+				} else {
249
+					if_block0 = create_if_block_2(ctx);
250
+					if_block0.c();
251
+					if_block0.m(div1, t1);
252
+				}
253
+			} else if (if_block0) {
254
+				if_block0.d(1);
255
+				if_block0 = null;
256
+			}
257
+
258
+			if (dirty & /*swiperParams*/ 4) show_if_1 = needsScrollbar(/*swiperParams*/ ctx[2]);
259
+
260
+			if (show_if_1) {
261
+				if (if_block1) {
262
+					if_block1.p(ctx, dirty);
263
+				} else {
264
+					if_block1 = create_if_block_1(ctx);
265
+					if_block1.c();
266
+					if_block1.m(div1, t2);
267
+				}
268
+			} else if (if_block1) {
269
+				if_block1.d(1);
270
+				if_block1 = null;
271
+			}
272
+
273
+			if (dirty & /*swiperParams*/ 4) show_if = needsPagination(/*swiperParams*/ ctx[2]);
274
+
275
+			if (show_if) {
276
+				if (if_block2) {
277
+					if_block2.p(ctx, dirty);
278
+				} else {
279
+					if_block2 = create_if_block(ctx);
280
+					if_block2.c();
281
+					if_block2.m(div1, t3);
282
+				}
283
+			} else if (if_block2) {
284
+				if_block2.d(1);
285
+				if_block2 = null;
286
+			}
287
+
288
+			if (wrapper_start_slot) {
289
+				if (wrapper_start_slot.p && dirty & /*$$scope, virtualData*/ 2560) {
290
+					update_slot(wrapper_start_slot, wrapper_start_slot_template, ctx, /*$$scope*/ ctx[11], dirty, get_wrapper_start_slot_changes, get_wrapper_start_slot_context);
291
+				}
292
+			}
293
+
294
+			if (default_slot) {
295
+				if (default_slot.p && dirty & /*$$scope, virtualData*/ 2560) {
296
+					update_slot(default_slot, default_slot_template, ctx, /*$$scope*/ ctx[11], dirty, get_default_slot_changes, get_default_slot_context);
297
+				}
298
+			}
299
+
300
+			if (wrapper_end_slot) {
301
+				if (wrapper_end_slot.p && dirty & /*$$scope, virtualData*/ 2560) {
302
+					update_slot(wrapper_end_slot, wrapper_end_slot_template, ctx, /*$$scope*/ ctx[11], dirty, get_wrapper_end_slot_changes, get_wrapper_end_slot_context);
303
+				}
304
+			}
305
+
306
+			if (content_end_slot) {
307
+				if (content_end_slot.p && dirty & /*$$scope, virtualData*/ 2560) {
308
+					update_slot(content_end_slot, content_end_slot_template, ctx, /*$$scope*/ ctx[11], dirty, get_content_end_slot_changes, get_content_end_slot_context);
309
+				}
310
+			}
311
+
312
+			set_attributes(div1, div1_data = get_spread_update(div1_levels, [
313
+				(!current || dirty & /*containerClasses, className*/ 3 && div1_class_value !== (div1_class_value = uniqueClasses(`${/*containerClasses*/ ctx[1]}${/*className*/ ctx[0] ? ` ${/*className*/ ctx[0]}` : ""}`))) && { class: div1_class_value },
314
+				dirty & /*restProps*/ 8 && /*restProps*/ ctx[3]
315
+			]));
316
+		},
317
+		i(local) {
318
+			if (current) return;
319
+			transition_in(content_start_slot, local);
320
+			transition_in(wrapper_start_slot, local);
321
+			transition_in(default_slot, local);
322
+			transition_in(wrapper_end_slot, local);
323
+			transition_in(content_end_slot, local);
324
+			current = true;
325
+		},
326
+		o(local) {
327
+			transition_out(content_start_slot, local);
328
+			transition_out(wrapper_start_slot, local);
329
+			transition_out(default_slot, local);
330
+			transition_out(wrapper_end_slot, local);
331
+			transition_out(content_end_slot, local);
332
+			current = false;
333
+		},
334
+		d(detaching) {
335
+			if (detaching) detach(div1);
336
+			if (content_start_slot) content_start_slot.d(detaching);
337
+			if (if_block0) if_block0.d();
338
+			if (if_block1) if_block1.d();
339
+			if (if_block2) if_block2.d();
340
+			if (wrapper_start_slot) wrapper_start_slot.d(detaching);
341
+			if (default_slot) default_slot.d(detaching);
342
+			if (wrapper_end_slot) wrapper_end_slot.d(detaching);
343
+			if (content_end_slot) content_end_slot.d(detaching);
344
+			/*div1_binding_1*/ ctx[17](null);
345
+		}
346
+	};
347
+}
348
+
349
+function instance($$self, $$props, $$invalidate) {
350
+	const omit_props_names = ["class","swiper"];
351
+	let $$restProps = compute_rest_props($$props, omit_props_names);
352
+	const dispatch = createEventDispatcher();
353
+	let { class: className = undefined } = $$props;
354
+	let containerClasses = "swiper-container";
355
+	let breakpointChanged = false;
356
+	let swiperInstance = null;
357
+	let oldPassedParams = null;
358
+	let paramsData;
359
+	let swiperParams;
360
+	let passedParams;
361
+	let restProps;
362
+	let swiperEl = null;
363
+	let prevEl = null;
364
+	let nextEl = null;
365
+	let scrollbarEl = null;
366
+	let paginationEl = null;
367
+	let virtualData = { slides: [] };
368
+
369
+	function swiper() {
370
+		return swiperInstance;
371
+	}
372
+
373
+	const setVirtualData = data => {
374
+		$$invalidate(9, virtualData = data);
375
+
376
+		tick().then(() => {
377
+			swiperInstance.$wrapperEl.children(".swiper-slide").each(el => {
378
+				if (el.onSwiper) el.onSwiper(swiperInstance);
379
+			});
380
+
381
+			swiperInstance.updateSlides();
382
+			swiperInstance.updateProgress();
383
+			swiperInstance.updateSlidesClasses();
384
+
385
+			if (swiperInstance.lazy && swiperInstance.params.lazy.enabled) {
386
+				swiperInstance.lazy.load();
387
+			}
388
+		});
389
+	};
390
+
391
+	const calcParams = () => {
392
+		paramsData = getParams($$restProps);
393
+		$$invalidate(2, swiperParams = paramsData.params);
394
+		passedParams = paramsData.passedParams;
395
+		$$invalidate(3, restProps = paramsData.rest);
396
+	};
397
+
398
+	calcParams();
399
+	oldPassedParams = passedParams;
400
+
401
+	const onBeforeBreakpoint = () => {
402
+		breakpointChanged = true;
403
+	};
404
+
405
+	swiperParams.onAny = (event, ...args) => {
406
+		dispatch(event, [args]);
407
+	};
408
+
409
+	Object.assign(swiperParams.on, {
410
+		_beforeBreakpoint: onBeforeBreakpoint,
411
+		_containerClasses(_swiper, classes) {
412
+			$$invalidate(1, containerClasses = classes);
413
+		},
414
+		_swiper(_swiper) {
415
+			swiperInstance = _swiper;
416
+
417
+			if (_swiper.virtual && _swiper.params.virtual.enabled) {
418
+				_swiper.params.virtual.cache = false;
419
+				_swiper.params.virtual.renderExternalUpdate = false;
420
+
421
+				_swiper.params.virtual.renderExternal = data => {
422
+					setVirtualData(data);
423
+
424
+					if (swiperParams.virtual && swiperParams.virtual.renderExternal) {
425
+						swiperParams.virtual.renderExternal(data);
426
+					}
427
+				};
428
+			}
429
+
430
+			dispatch("swiper", [_swiper]);
431
+		}
432
+	});
433
+
434
+	onMount(() => {
435
+		if (!swiperEl) return;
436
+
437
+		initSwiper(
438
+			{
439
+				el: swiperEl,
440
+				nextEl,
441
+				prevEl,
442
+				paginationEl,
443
+				scrollbarEl
444
+			},
445
+			swiperParams
446
+		);
447
+
448
+		if (swiperParams.virtual) return;
449
+
450
+		swiperInstance.slides.each(el => {
451
+			if (el.onSwiper) el.onSwiper(swiperInstance);
452
+		});
453
+	});
454
+
455
+	afterUpdate(() => {
456
+		if (!swiperInstance) return;
457
+		calcParams();
458
+		const changedParams = getChangedParams(passedParams, oldPassedParams);
459
+
460
+		if ((changedParams.length || breakpointChanged) && swiperInstance && !swiperInstance.destroyed) {
461
+			updateSwiper(swiperInstance, passedParams, changedParams);
462
+		}
463
+
464
+		breakpointChanged = false;
465
+		oldPassedParams = passedParams;
466
+	});
467
+
468
+	onDestroy(() => {
469
+		if (swiperInstance && !swiperInstance.destroyed) {
470
+			swiperInstance.destroy();
471
+		}
472
+	});
473
+
474
+	let { $$slots = {}, $$scope } = $$props;
475
+
476
+	function div0_binding($$value) {
477
+		binding_callbacks[$$value ? "unshift" : "push"](() => {
478
+			prevEl = $$value;
479
+			$$invalidate(5, prevEl);
480
+		});
481
+	}
482
+
483
+	function div1_binding($$value) {
484
+		binding_callbacks[$$value ? "unshift" : "push"](() => {
485
+			nextEl = $$value;
486
+			$$invalidate(6, nextEl);
487
+		});
488
+	}
489
+
490
+	function div_binding($$value) {
491
+		binding_callbacks[$$value ? "unshift" : "push"](() => {
492
+			scrollbarEl = $$value;
493
+			$$invalidate(7, scrollbarEl);
494
+		});
495
+	}
496
+
497
+	function div_binding_1($$value) {
498
+		binding_callbacks[$$value ? "unshift" : "push"](() => {
499
+			paginationEl = $$value;
500
+			$$invalidate(8, paginationEl);
501
+		});
502
+	}
503
+
504
+	function div1_binding_1($$value) {
505
+		binding_callbacks[$$value ? "unshift" : "push"](() => {
506
+			swiperEl = $$value;
507
+			$$invalidate(4, swiperEl);
508
+		});
509
+	}
510
+
511
+	$$self.$$set = $$new_props => {
512
+		$$props = assign(assign({}, $$props), exclude_internal_props($$new_props));
513
+		$$invalidate(27, $$restProps = compute_rest_props($$props, omit_props_names));
514
+		if ("class" in $$new_props) $$invalidate(0, className = $$new_props.class);
515
+		if ("$$scope" in $$new_props) $$invalidate(11, $$scope = $$new_props.$$scope);
516
+	};
517
+
518
+	return [
519
+		className,
520
+		containerClasses,
521
+		swiperParams,
522
+		restProps,
523
+		swiperEl,
524
+		prevEl,
525
+		nextEl,
526
+		scrollbarEl,
527
+		paginationEl,
528
+		virtualData,
529
+		swiper,
530
+		$$scope,
531
+		$$slots,
532
+		div0_binding,
533
+		div1_binding,
534
+		div_binding,
535
+		div_binding_1,
536
+		div1_binding_1
537
+	];
538
+}
539
+
540
+class Swiper extends SvelteComponent {
541
+	constructor(options) {
542
+		super();
543
+		init(this, options, instance, create_fragment, safe_not_equal, { class: 0, swiper: 10 });
544
+	}
545
+
546
+	get swiper() {
547
+		return this.$$.ctx[10];
548
+	}
549
+}
550
+
551
+export default Swiper;
0 552
\ No newline at end of file