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,341 @@
1
+/* swiper.svelte generated by Svelte v3.24.1 */
2
+import {
3
+	SvelteComponent,
4
+	assign,
5
+	attr,
6
+	binding_callbacks,
7
+	check_outros,
8
+	compute_rest_props,
9
+	create_slot,
10
+	detach,
11
+	element,
12
+	exclude_internal_props,
13
+	get_spread_update,
14
+	group_outros,
15
+	init,
16
+	insert,
17
+	safe_not_equal,
18
+	set_attributes,
19
+	transition_in,
20
+	transition_out,
21
+	update_slot
22
+} from "svelte/internal";
23
+
24
+import { onMount, onDestroy, beforeUpdate, afterUpdate, tick } from "svelte";
25
+import { uniqueClasses } from "./utils";
26
+const get_default_slot_changes_1 = dirty => ({ data: dirty & /*slideData*/ 32 });
27
+const get_default_slot_context_1 = ctx => ({ data: /*slideData*/ ctx[5] });
28
+const get_default_slot_changes = dirty => ({ data: dirty & /*slideData*/ 32 });
29
+const get_default_slot_context = ctx => ({ data: /*slideData*/ ctx[5] });
30
+
31
+// (90:2) {:else}
32
+function create_else_block(ctx) {
33
+	let current;
34
+	const default_slot_template = /*$$slots*/ ctx[8].default;
35
+	const default_slot = create_slot(default_slot_template, ctx, /*$$scope*/ ctx[7], get_default_slot_context_1);
36
+
37
+	return {
38
+		c() {
39
+			if (default_slot) default_slot.c();
40
+		},
41
+		m(target, anchor) {
42
+			if (default_slot) {
43
+				default_slot.m(target, anchor);
44
+			}
45
+
46
+			current = true;
47
+		},
48
+		p(ctx, dirty) {
49
+			if (default_slot) {
50
+				if (default_slot.p && dirty & /*$$scope, slideData*/ 160) {
51
+					update_slot(default_slot, default_slot_template, ctx, /*$$scope*/ ctx[7], dirty, get_default_slot_changes_1, get_default_slot_context_1);
52
+				}
53
+			}
54
+		},
55
+		i(local) {
56
+			if (current) return;
57
+			transition_in(default_slot, local);
58
+			current = true;
59
+		},
60
+		o(local) {
61
+			transition_out(default_slot, local);
62
+			current = false;
63
+		},
64
+		d(detaching) {
65
+			if (default_slot) default_slot.d(detaching);
66
+		}
67
+	};
68
+}
69
+
70
+// (84:2) {#if zoom}
71
+function create_if_block(ctx) {
72
+	let div;
73
+	let div_data_swiper_zoom_value;
74
+	let current;
75
+	const default_slot_template = /*$$slots*/ ctx[8].default;
76
+	const default_slot = create_slot(default_slot_template, ctx, /*$$scope*/ ctx[7], get_default_slot_context);
77
+
78
+	return {
79
+		c() {
80
+			div = element("div");
81
+			if (default_slot) default_slot.c();
82
+			attr(div, "class", "swiper-zoom-container");
83
+
84
+			attr(div, "data-swiper-zoom", div_data_swiper_zoom_value = typeof /*zoom*/ ctx[0] === "number"
85
+			? /*zoom*/ ctx[0]
86
+			: undefined);
87
+		},
88
+		m(target, anchor) {
89
+			insert(target, div, anchor);
90
+
91
+			if (default_slot) {
92
+				default_slot.m(div, null);
93
+			}
94
+
95
+			current = true;
96
+		},
97
+		p(ctx, dirty) {
98
+			if (default_slot) {
99
+				if (default_slot.p && dirty & /*$$scope, slideData*/ 160) {
100
+					update_slot(default_slot, default_slot_template, ctx, /*$$scope*/ ctx[7], dirty, get_default_slot_changes, get_default_slot_context);
101
+				}
102
+			}
103
+
104
+			if (!current || dirty & /*zoom*/ 1 && div_data_swiper_zoom_value !== (div_data_swiper_zoom_value = typeof /*zoom*/ ctx[0] === "number"
105
+			? /*zoom*/ ctx[0]
106
+			: undefined)) {
107
+				attr(div, "data-swiper-zoom", div_data_swiper_zoom_value);
108
+			}
109
+		},
110
+		i(local) {
111
+			if (current) return;
112
+			transition_in(default_slot, local);
113
+			current = true;
114
+		},
115
+		o(local) {
116
+			transition_out(default_slot, local);
117
+			current = false;
118
+		},
119
+		d(detaching) {
120
+			if (detaching) detach(div);
121
+			if (default_slot) default_slot.d(detaching);
122
+		}
123
+	};
124
+}
125
+
126
+function create_fragment(ctx) {
127
+	let div;
128
+	let current_block_type_index;
129
+	let if_block;
130
+	let div_class_value;
131
+	let current;
132
+	const if_block_creators = [create_if_block, create_else_block];
133
+	const if_blocks = [];
134
+
135
+	function select_block_type(ctx, dirty) {
136
+		if (/*zoom*/ ctx[0]) return 0;
137
+		return 1;
138
+	}
139
+
140
+	current_block_type_index = select_block_type(ctx, -1);
141
+	if_block = if_blocks[current_block_type_index] = if_block_creators[current_block_type_index](ctx);
142
+
143
+	let div_levels = [
144
+		{
145
+			class: div_class_value = uniqueClasses(`${/*slideClasses*/ ctx[4]}${/*className*/ ctx[2] ? ` ${/*className*/ ctx[2]}` : ""}`)
146
+		},
147
+		{
148
+			"data-swiper-slide-index": /*virtualIndex*/ ctx[1]
149
+		},
150
+		/*$$restProps*/ ctx[6]
151
+	];
152
+
153
+	let div_data = {};
154
+
155
+	for (let i = 0; i < div_levels.length; i += 1) {
156
+		div_data = assign(div_data, div_levels[i]);
157
+	}
158
+
159
+	return {
160
+		c() {
161
+			div = element("div");
162
+			if_block.c();
163
+			set_attributes(div, div_data);
164
+		},
165
+		m(target, anchor) {
166
+			insert(target, div, anchor);
167
+			if_blocks[current_block_type_index].m(div, null);
168
+			/*div_binding*/ ctx[9](div);
169
+			current = true;
170
+		},
171
+		p(ctx, [dirty]) {
172
+			let previous_block_index = current_block_type_index;
173
+			current_block_type_index = select_block_type(ctx, dirty);
174
+
175
+			if (current_block_type_index === previous_block_index) {
176
+				if_blocks[current_block_type_index].p(ctx, dirty);
177
+			} else {
178
+				group_outros();
179
+
180
+				transition_out(if_blocks[previous_block_index], 1, 1, () => {
181
+					if_blocks[previous_block_index] = null;
182
+				});
183
+
184
+				check_outros();
185
+				if_block = if_blocks[current_block_type_index];
186
+
187
+				if (!if_block) {
188
+					if_block = if_blocks[current_block_type_index] = if_block_creators[current_block_type_index](ctx);
189
+					if_block.c();
190
+				}
191
+
192
+				transition_in(if_block, 1);
193
+				if_block.m(div, null);
194
+			}
195
+
196
+			set_attributes(div, div_data = get_spread_update(div_levels, [
197
+				(!current || dirty & /*slideClasses, className*/ 20 && div_class_value !== (div_class_value = uniqueClasses(`${/*slideClasses*/ ctx[4]}${/*className*/ ctx[2] ? ` ${/*className*/ ctx[2]}` : ""}`))) && { class: div_class_value },
198
+				(!current || dirty & /*virtualIndex*/ 2) && {
199
+					"data-swiper-slide-index": /*virtualIndex*/ ctx[1]
200
+				},
201
+				dirty & /*$$restProps*/ 64 && /*$$restProps*/ ctx[6]
202
+			]));
203
+		},
204
+		i(local) {
205
+			if (current) return;
206
+			transition_in(if_block);
207
+			current = true;
208
+		},
209
+		o(local) {
210
+			transition_out(if_block);
211
+			current = false;
212
+		},
213
+		d(detaching) {
214
+			if (detaching) detach(div);
215
+			if_blocks[current_block_type_index].d();
216
+			/*div_binding*/ ctx[9](null);
217
+		}
218
+	};
219
+}
220
+
221
+function instance($$self, $$props, $$invalidate) {
222
+	const omit_props_names = ["zoom","virtualIndex","class"];
223
+	let $$restProps = compute_rest_props($$props, omit_props_names);
224
+	let { zoom = undefined } = $$props;
225
+	let { virtualIndex = undefined } = $$props;
226
+	let { class: className = undefined } = $$props;
227
+	let slideEl = null;
228
+	let slideClasses = "swiper-slide";
229
+	let swiper = null;
230
+	let eventAttached = false;
231
+
232
+	const updateClasses = (_, el, classNames) => {
233
+		if (el === slideEl) {
234
+			$$invalidate(4, slideClasses = classNames);
235
+		}
236
+	};
237
+
238
+	const attachEvent = () => {
239
+		if (!swiper || eventAttached) return;
240
+		swiper.on("_slideClass", updateClasses);
241
+		eventAttached = true;
242
+	};
243
+
244
+	const detachEvent = () => {
245
+		if (!swiper) return;
246
+		swiper.off("_slideClass", updateClasses);
247
+		eventAttached = false;
248
+	};
249
+
250
+	onMount(() => {
251
+		if (typeof virtualIndex === "undefined") return;
252
+
253
+		$$invalidate(
254
+			3,
255
+			slideEl.onSwiper = _swiper => {
256
+				swiper = _swiper;
257
+				attachEvent();
258
+			},
259
+			slideEl
260
+		);
261
+
262
+		attachEvent();
263
+	});
264
+
265
+	afterUpdate(() => {
266
+		if (!slideEl || !swiper) return;
267
+
268
+		if (swiper.destroyed) {
269
+			if (slideClasses !== "swiper-slide") {
270
+				$$invalidate(4, slideClasses = "swiper-slide");
271
+			}
272
+
273
+			return;
274
+		}
275
+
276
+		attachEvent();
277
+	});
278
+
279
+	beforeUpdate(() => {
280
+		attachEvent();
281
+	});
282
+
283
+	onDestroy(() => {
284
+		if (!swiper) return;
285
+		detachEvent();
286
+	});
287
+
288
+	let { $$slots = {}, $$scope } = $$props;
289
+
290
+	function div_binding($$value) {
291
+		binding_callbacks[$$value ? "unshift" : "push"](() => {
292
+			slideEl = $$value;
293
+			$$invalidate(3, slideEl);
294
+		});
295
+	}
296
+
297
+	$$self.$$set = $$new_props => {
298
+		$$props = assign(assign({}, $$props), exclude_internal_props($$new_props));
299
+		$$invalidate(6, $$restProps = compute_rest_props($$props, omit_props_names));
300
+		if ("zoom" in $$new_props) $$invalidate(0, zoom = $$new_props.zoom);
301
+		if ("virtualIndex" in $$new_props) $$invalidate(1, virtualIndex = $$new_props.virtualIndex);
302
+		if ("class" in $$new_props) $$invalidate(2, className = $$new_props.class);
303
+		if ("$$scope" in $$new_props) $$invalidate(7, $$scope = $$new_props.$$scope);
304
+	};
305
+
306
+	let slideData;
307
+
308
+	$$self.$$.update = () => {
309
+		if ($$self.$$.dirty & /*slideClasses*/ 16) {
310
+			$: $$invalidate(5, slideData = {
311
+				isActive: slideClasses.indexOf("swiper-slide-active") >= 0 || slideClasses.indexOf("swiper-slide-duplicate-active") >= 0,
312
+				isVisible: slideClasses.indexOf("swiper-slide-visible") >= 0,
313
+				isDuplicate: slideClasses.indexOf("swiper-slide-duplicate") >= 0,
314
+				isPrev: slideClasses.indexOf("swiper-slide-prev") >= 0 || slideClasses.indexOf("swiper-slide-duplicate-prev") >= 0,
315
+				isNext: slideClasses.indexOf("swiper-slide-next") >= 0 || slideClasses.indexOf("swiper-slide-duplicate next") >= 0
316
+			});
317
+		}
318
+	};
319
+
320
+	return [
321
+		zoom,
322
+		virtualIndex,
323
+		className,
324
+		slideEl,
325
+		slideClasses,
326
+		slideData,
327
+		$$restProps,
328
+		$$scope,
329
+		$$slots,
330
+		div_binding
331
+	];
332
+}
333
+
334
+class Swiper extends SvelteComponent {
335
+	constructor(options) {
336
+		super();
337
+		init(this, options, instance, create_fragment, safe_not_equal, { zoom: 0, virtualIndex: 1, class: 2 });
338
+	}
339
+}
340
+
341
+export default Swiper;
0 342
\ No newline at end of file