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