diff --git a/.babelrc b/.babelrc deleted file mode 100644 index ce6e9f08..00000000 --- a/.babelrc +++ /dev/null @@ -1,20 +0,0 @@ -{ - "presets": [ - [ - "@babel/env", - { - "modules": false, - "loose": true - } - ] - ], - "env": { - "test": { - "presets": [ - [ - "@babel/env" - ] - ] - } - } -} \ No newline at end of file diff --git a/.eslintrc b/.eslintrc index 7ff9be99..6f724d80 100644 --- a/.eslintrc +++ b/.eslintrc @@ -15,9 +15,6 @@ "browser": true, "node": true }, - "ignorePatterns": [ - "*.esm.js" - ], "rules": { "semi": [ "error", @@ -28,11 +25,11 @@ ], "space-in-parens": [ "error", - "always" + "never" ], "array-bracket-spacing": [ "error", - "always" + "never" ], "object-curly-spacing": [ "error", @@ -40,7 +37,7 @@ ], "computed-property-spacing": [ "error", - "always" + "never" ], "camelcase": "error", "comma-dangle": [ @@ -50,7 +47,7 @@ "objects": "always-multiline", "imports": "always-multiline", "exports": "always-multiline", - "functions": "never" + "functions": "always-multiline" } ], "comma-spacing": [ @@ -69,14 +66,7 @@ "VariableDeclarator": "first" } ], - "no-console": [ - "error", - { - "allow": [ - "error" - ] - } - ], + "no-console": "error", "no-empty-function": [ "error", { diff --git a/.stylelintrc b/.stylelintrc index f8894ca2..cffabab9 100644 --- a/.stylelintrc +++ b/.stylelintrc @@ -5,6 +5,7 @@ "stylelint-order" ], "rules": { + "selector-class-pattern": "[a-z_\\-]+", "number-leading-zero": "never", "max-nesting-depth": 7, "selector-max-compound-selectors": null, diff --git a/README.md b/README.md index 77aa1ad2..9e091231 100644 --- a/README.md +++ b/README.md @@ -1,6 +1,6 @@
- Splide + Splide

Splide

@@ -33,19 +33,19 @@ No dependencies, no Lighthouse errors.

- React Splide + React Splide - React Splide + TypeScript - React Splide + React Splide - Vue Splide + Vue Splide - Vue Splide + Svelte Splide

@@ -104,7 +104,7 @@ Please support the project if you like it! Here is the mobile version result of the [Splide front page](https://splidejs.com): -Lighthouse result of the Splide frontpage +Lighthouse result of the Splide frontpage The Splide slider does not degrade Accessibility, Best Practices and SEO 🎉 diff --git a/app/assets/css/basic.scss b/app/assets/css/basic.scss new file mode 100644 index 00000000..bb21a6c9 --- /dev/null +++ b/app/assets/css/basic.scss @@ -0,0 +1,39 @@ +@import url('https://fonts.googleapis.com/css2?family=Inter:wght@200..700&display=swap'); + +body { + color: #3d4b56; + font-family: Inter, sans-serif; + margin: 2rem; +} + +h2 { + margin-top: 6rem; + text-align: center; +} + +.splide { + $root: &; + margin: 2rem auto; + + &__slide { + align-items: center; + background: #ecf3fa; + display: flex; + font-size: 2rem; + justify-content: center; + + &.is-active { + background: #e1e9f3; + } + + img { + height: 100%; + object-fit: cover; + width: 100%; + } + } +} + +.controls { + text-align: center; +} diff --git a/src/js/test/assets/images/pics/slide01.jpg b/app/assets/images/pics/slide01.jpg similarity index 100% rename from src/js/test/assets/images/pics/slide01.jpg rename to app/assets/images/pics/slide01.jpg diff --git a/src/js/test/assets/images/pics/slide02.jpg b/app/assets/images/pics/slide02.jpg similarity index 100% rename from src/js/test/assets/images/pics/slide02.jpg rename to app/assets/images/pics/slide02.jpg diff --git a/src/js/test/assets/images/pics/slide03.jpg b/app/assets/images/pics/slide03.jpg similarity index 100% rename from src/js/test/assets/images/pics/slide03.jpg rename to app/assets/images/pics/slide03.jpg diff --git a/src/js/test/assets/images/pics/slide04.jpg b/app/assets/images/pics/slide04.jpg similarity index 100% rename from src/js/test/assets/images/pics/slide04.jpg rename to app/assets/images/pics/slide04.jpg diff --git a/src/js/test/assets/images/pics/slide05.jpg b/app/assets/images/pics/slide05.jpg similarity index 100% rename from src/js/test/assets/images/pics/slide05.jpg rename to app/assets/images/pics/slide05.jpg diff --git a/src/js/test/assets/images/pics/slide06.jpg b/app/assets/images/pics/slide06.jpg similarity index 100% rename from src/js/test/assets/images/pics/slide06.jpg rename to app/assets/images/pics/slide06.jpg diff --git a/src/js/test/assets/images/pics/slide07.jpg b/app/assets/images/pics/slide07.jpg similarity index 100% rename from src/js/test/assets/images/pics/slide07.jpg rename to app/assets/images/pics/slide07.jpg diff --git a/src/js/test/assets/images/pics/slide08.jpg b/app/assets/images/pics/slide08.jpg similarity index 100% rename from src/js/test/assets/images/pics/slide08.jpg rename to app/assets/images/pics/slide08.jpg diff --git a/src/js/test/assets/images/pics/slide09.jpg b/app/assets/images/pics/slide09.jpg similarity index 100% rename from src/js/test/assets/images/pics/slide09.jpg rename to app/assets/images/pics/slide09.jpg diff --git a/src/js/test/assets/images/pics/slide10.jpg b/app/assets/images/pics/slide10.jpg similarity index 100% rename from src/js/test/assets/images/pics/slide10.jpg rename to app/assets/images/pics/slide10.jpg diff --git a/src/js/test/assets/images/pics/slide11.jpg b/app/assets/images/pics/slide11.jpg similarity index 100% rename from src/js/test/assets/images/pics/slide11.jpg rename to app/assets/images/pics/slide11.jpg diff --git a/src/js/test/assets/images/pics/slide12.jpg b/app/assets/images/pics/slide12.jpg similarity index 100% rename from src/js/test/assets/images/pics/slide12.jpg rename to app/assets/images/pics/slide12.jpg diff --git a/src/js/test/assets/images/pics/slide13.jpg b/app/assets/images/pics/slide13.jpg similarity index 100% rename from src/js/test/assets/images/pics/slide13.jpg rename to app/assets/images/pics/slide13.jpg diff --git a/src/js/test/assets/images/pics/slide14.jpg b/app/assets/images/pics/slide14.jpg similarity index 100% rename from src/js/test/assets/images/pics/slide14.jpg rename to app/assets/images/pics/slide14.jpg diff --git a/src/js/test/assets/images/pics/slide15.jpg b/app/assets/images/pics/slide15.jpg similarity index 100% rename from src/js/test/assets/images/pics/slide15.jpg rename to app/assets/images/pics/slide15.jpg diff --git a/src/js/test/assets/images/pics/slide16.jpg b/app/assets/images/pics/slide16.jpg similarity index 100% rename from src/js/test/assets/images/pics/slide16.jpg rename to app/assets/images/pics/slide16.jpg diff --git a/src/js/test/assets/images/pics/slide17.jpg b/app/assets/images/pics/slide17.jpg similarity index 100% rename from src/js/test/assets/images/pics/slide17.jpg rename to app/assets/images/pics/slide17.jpg diff --git a/src/js/test/assets/images/pics/slide18.jpg b/app/assets/images/pics/slide18.jpg similarity index 100% rename from src/js/test/assets/images/pics/slide18.jpg rename to app/assets/images/pics/slide18.jpg diff --git a/src/js/test/assets/images/pics/slide19.jpg b/app/assets/images/pics/slide19.jpg similarity index 100% rename from src/js/test/assets/images/pics/slide19.jpg rename to app/assets/images/pics/slide19.jpg diff --git a/src/js/test/assets/images/pics/slide20.jpg b/app/assets/images/pics/slide20.jpg similarity index 100% rename from src/js/test/assets/images/pics/slide20.jpg rename to app/assets/images/pics/slide20.jpg diff --git a/src/js/test/assets/images/planets/mars.jpg b/app/assets/images/planets/mars.jpg similarity index 100% rename from src/js/test/assets/images/planets/mars.jpg rename to app/assets/images/planets/mars.jpg diff --git a/src/js/test/assets/images/planets/neptune.jpg b/app/assets/images/planets/neptune.jpg similarity index 100% rename from src/js/test/assets/images/planets/neptune.jpg rename to app/assets/images/planets/neptune.jpg diff --git a/src/js/test/assets/images/planets/saturn.jpg b/app/assets/images/planets/saturn.jpg similarity index 100% rename from src/js/test/assets/images/planets/saturn.jpg rename to app/assets/images/planets/saturn.jpg diff --git a/app/index.html b/app/index.html new file mode 100644 index 00000000..805deb8e --- /dev/null +++ b/app/index.html @@ -0,0 +1,43 @@ + + + + + + + + + + + + + \ No newline at end of file diff --git a/app/js/common.ts b/app/js/common.ts new file mode 100644 index 00000000..c7f5c260 --- /dev/null +++ b/app/js/common.ts @@ -0,0 +1,2 @@ +import '../../src/css/themes/default/index.scss'; +import '../assets/css/basic.scss'; \ No newline at end of file diff --git a/app/js/html.ts b/app/js/html.ts new file mode 100644 index 00000000..46d7d23f --- /dev/null +++ b/app/js/html.ts @@ -0,0 +1,13 @@ +import { buildHtml as _buildHtml, BuildHtmlConfig, insertHtml as _insertHtml, InsertHtmlConfig } from '@test'; +import { SLIDES } from './pics'; + + +export function buildHtml(config: BuildHtmlConfig = {}): string { + const src = config.useImage ? SLIDES : undefined; + return _buildHtml({ ...config, src }); +} + +export function insertHtml(config: InsertHtmlConfig = {}): void { + const src = config.useImage ? SLIDES : undefined; + _insertHtml({ ...config, src }); +} \ No newline at end of file diff --git a/app/js/pics/index.ts b/app/js/pics/index.ts new file mode 100644 index 00000000..da12f7d9 --- /dev/null +++ b/app/js/pics/index.ts @@ -0,0 +1,36 @@ +/// + +import slide01 from '../../assets/images/pics/slide01.jpg'; +import slide02 from '../../assets/images/pics/slide02.jpg'; +import slide03 from '../../assets/images/pics/slide03.jpg'; +import slide04 from '../../assets/images/pics/slide04.jpg'; +import slide05 from '../../assets/images/pics/slide05.jpg'; +import slide06 from '../../assets/images/pics/slide06.jpg'; +import slide07 from '../../assets/images/pics/slide07.jpg'; +import slide08 from '../../assets/images/pics/slide08.jpg'; +import slide09 from '../../assets/images/pics/slide09.jpg'; +import slide10 from '../../assets/images/pics/slide10.jpg'; +import slide11 from '../../assets/images/pics/slide09.jpg'; +import slide12 from '../../assets/images/pics/slide10.jpg'; +import slide13 from '../../assets/images/pics/slide13.jpg'; +import slide14 from '../../assets/images/pics/slide14.jpg'; +import slide15 from '../../assets/images/pics/slide15.jpg'; + +export const SLIDES = [ + slide01, + slide02, + slide03, + slide04, + slide05, + slide06, + slide07, + slide08, + slide09, + slide10, + slide11, + slide12, + slide13, + slide14, + slide15, +]; + diff --git a/app/pages/add/index.html b/app/pages/add/index.html new file mode 100644 index 00000000..731514ae --- /dev/null +++ b/app/pages/add/index.html @@ -0,0 +1,14 @@ + + + + + + + +
+ + +
+ + + \ No newline at end of file diff --git a/app/pages/add/script.ts b/app/pages/add/script.ts new file mode 100644 index 00000000..4d01d010 --- /dev/null +++ b/app/pages/add/script.ts @@ -0,0 +1,33 @@ +import { Splide } from '../../../src/js'; +import { insertHtml } from '../../js/html'; +import { SLIDES } from '../../js/pics'; +import '../../js/common'; + + +insertHtml({ useImage: true }); + +const splide = new Splide('#splide01', { + type: 'loop', + width: 1000, + height: 400, + perPage: 3, + gap: '1rem', +}).mount(); + +const addButton = document.getElementById('add'); +const removeButton = document.getElementById('remove'); + +if (addButton) { + addButton.addEventListener('click', function () { + splide.add([ + `
`, + `
`, + ]); + }); +} + +if (removeButton) { + removeButton.addEventListener('click', function () { + splide.remove(splide.length - 1); + }); +} \ No newline at end of file diff --git a/app/pages/auto-height/index.html b/app/pages/auto-height/index.html new file mode 100644 index 00000000..f80392da --- /dev/null +++ b/app/pages/auto-height/index.html @@ -0,0 +1,10 @@ + + + + + + + + + + \ No newline at end of file diff --git a/app/pages/auto-height/script.ts b/app/pages/auto-height/script.ts new file mode 100644 index 00000000..6e9d4fb0 --- /dev/null +++ b/app/pages/auto-height/script.ts @@ -0,0 +1,29 @@ +import { Splide } from '../../../src/js'; +import { insertHtml } from '../../js/html'; +import '../../js/common'; + + +insertHtml({ id: 'splide01', autoHeight: true }); + +new Splide('#splide01', { + direction: 'ttb', + width: 600, + height: '90vh', + gap: '1rem', + focus: 0, + drag: 'free', + omitEnd: true, + autoHeight: true, +}).mount(); + +insertHtml({ id: 'splide02', useImage: true, autoHeight: true }); + +new Splide('#splide02', { + type: 'loop', + width: 600, + direction: 'ttb', + height: '90vh', + gap: '1rem', + autoHeight: true, + focus: 'center', +}).mount(); diff --git a/app/pages/auto-width/index.html b/app/pages/auto-width/index.html new file mode 100644 index 00000000..f80392da --- /dev/null +++ b/app/pages/auto-width/index.html @@ -0,0 +1,10 @@ + + + + + + + + + + \ No newline at end of file diff --git a/app/pages/auto-width/script.ts b/app/pages/auto-width/script.ts new file mode 100644 index 00000000..9d29f0f3 --- /dev/null +++ b/app/pages/auto-width/script.ts @@ -0,0 +1,26 @@ +import { Splide } from '../../../src/js'; +import { insertHtml } from '../../js/html'; +import '../../js/common'; + + +insertHtml({ id: 'splide01', useImage: true, autoWidth: true }); + +new Splide('#splide01', { + height: 400, + gap: '1rem', + focus: 0, + drag: 'free', + omitEnd: true, + autoWidth: true, +}).mount(); + +insertHtml({ id: 'splide02', useImage: true, autoWidth: true }); + +new Splide('#splide02', { + type: 'loop', + width: 1000, + height: 400, + gap: '1rem', + autoWidth: true, + focus: 'center', +}).mount(); diff --git a/app/pages/autoplay/index.html b/app/pages/autoplay/index.html new file mode 100644 index 00000000..f80392da --- /dev/null +++ b/app/pages/autoplay/index.html @@ -0,0 +1,10 @@ + + + + + + + + + + \ No newline at end of file diff --git a/app/pages/autoplay/script.ts b/app/pages/autoplay/script.ts new file mode 100644 index 00000000..cefb72d5 --- /dev/null +++ b/app/pages/autoplay/script.ts @@ -0,0 +1,36 @@ +import { Splide } from '../../../src/js'; +import { insertHtml } from '../../js/html'; +import '../../js/common'; + + +insertHtml({ + hasProgress: true, + hasToggle: true, + onRenderSlide(index) { + if (index === 0) { + return { attrs: { 'data-splide-interval': 1000 } }; + } + + if (index === 2) { + return { attrs: { 'data-splide-interval': 10000 } }; + } + + return {}; + }, +}); + +const splide01 = new Splide('#splide01', { + width: 1000, + height: 400, + gap: '1rem', + autoplay: true, + // pauseOnFocus: false, + // pauseOnHover: false, +}).mount(); + +const rateElm = document.createElement('pre'); +splide01.root.append(rateElm); + +splide01.on('autoplay:playing', rate => { + rateElm.textContent = rate.toFixed(3); +}); \ No newline at end of file diff --git a/app/pages/basic/index.html b/app/pages/basic/index.html new file mode 100644 index 00000000..83eb783e --- /dev/null +++ b/app/pages/basic/index.html @@ -0,0 +1,26 @@ + + + + + + + +
+
+
+
01
+
02
+
03
+
04
+
05
+
06
+
07
+
08
+
09
+
10
+
+
+
+ + + \ No newline at end of file diff --git a/app/pages/basic/script.ts b/app/pages/basic/script.ts new file mode 100644 index 00000000..4ff37f43 --- /dev/null +++ b/app/pages/basic/script.ts @@ -0,0 +1,11 @@ +import { Splide } from '../../../src/js'; +import '../../js/common'; + + +const splide = new Splide('#splide01', { + width: 1000, + height: 400, +}).mount(); + +splide.on('move', () => console.log('move')); +splide.on('moved', () => console.log('moved')); \ No newline at end of file diff --git a/app/pages/breakpoints/index.html b/app/pages/breakpoints/index.html new file mode 100644 index 00000000..f80392da --- /dev/null +++ b/app/pages/breakpoints/index.html @@ -0,0 +1,10 @@ + + + + + + + + + + \ No newline at end of file diff --git a/app/pages/breakpoints/script.ts b/app/pages/breakpoints/script.ts new file mode 100644 index 00000000..dcd858f4 --- /dev/null +++ b/app/pages/breakpoints/script.ts @@ -0,0 +1,38 @@ +import { Splide } from '../../../src/js'; +import { insertHtml } from '../../js/html'; +import '../../js/common'; + + +insertHtml({ id: 'splide01', useImage: true }); + +const options = { + perPage: 3, + arrows: false, + // mediaQuery: 'min', + breakpoints: { + 1200: { + perPage: 1, + gap: '1rem', + arrows: true, + padding: 50, + height: 500, + destroy: false, + }, + 1000: { + perPage: 2, + gap: 0, + arrows: false, + padding: 0, + pagination: false, + }, + 800: { + destroy: true, + }, + }, +}; + +new Splide('#splide01', options).mount(); + +insertHtml({ id: 'splide02', hasArrows: true, hasPagination: true }); +new Splide('#splide02', options).mount(); + diff --git a/app/pages/container/index.html b/app/pages/container/index.html new file mode 100644 index 00000000..b9c4f914 --- /dev/null +++ b/app/pages/container/index.html @@ -0,0 +1,63 @@ + + + + + + + + + +
+
+
+
+
+ +
+

+ Lorem ipsum dolor sit amet, ius cu novum splendide contentiones, vim dolorem delicata explicari no. Posidonium sadipscing delicatissimi ad vix, vim at utamur ponderum. Eu doming verear complectitur vim. +

+
+ +
+
+ +
+

+ Lorem ipsum dolor sit amet, in usu facilis philosophia, exerci adolescens honestatis ei eum. Et vis nulla simul, pri cu euismod accusam vulputate. +

+
+ +
+
+ +
+

+ Lorem ipsum dolor sit amet, ius cu novum splendide contentiones, vim dolorem delicata explicari no. Posidonium sadipscing delicatissimi ad vix, vim at utamur ponderum. Eu doming verear complectitur vim. +

+
+ +
+
+ +
+

+ Lorem ipsum dolor sit amet, in usu facilis philosophia, exerci adolescens honestatis ei eum. Et vis nulla simul, pri cu euismod accusam vulputate. +

+
+
+
+
+ + + \ No newline at end of file diff --git a/app/pages/container/script.ts b/app/pages/container/script.ts new file mode 100644 index 00000000..9299b4d2 --- /dev/null +++ b/app/pages/container/script.ts @@ -0,0 +1,10 @@ +import { Splide } from '../../../src/js'; +import '../../../src/css/themes/default/index.scss'; + + +new Splide('#splide01', { + width: 1000, + perPage: 2, + gap: '1rem', + heightRatio: 0.3, +}).mount(); diff --git a/app/pages/drag-free/index.html b/app/pages/drag-free/index.html new file mode 100644 index 00000000..4abbe403 --- /dev/null +++ b/app/pages/drag-free/index.html @@ -0,0 +1,11 @@ + + + + + + + +
+ + + \ No newline at end of file diff --git a/app/pages/drag-free/script.ts b/app/pages/drag-free/script.ts new file mode 100644 index 00000000..6ead0bdf --- /dev/null +++ b/app/pages/drag-free/script.ts @@ -0,0 +1,41 @@ +import { Splide } from '../../../src/js'; +import { insertHtml } from '../../js/html'; +import '../../js/common'; +import './style.scss'; + + +insertHtml({ id: 'splide01', heading: 'Drag Free - Slide' }); + +const splide01 = new Splide('#splide01', { + width: 1000, + height: 400, + // type: 'loop', + parPage: 3, + drag: 'free', + snap: true, + gap: '2rem', +}).mount(); + +const bar = document.querySelector('.bar'); + +if (bar) { + const { getRate } = splide01.Components.Move; + + splide01.on('dragging scrolling', () => { + bar.style.width = `${ getRate() * 100 }%`; + }); +} else { + throw new Error('Could not find a bar element'); +} + +insertHtml({ id: 'splide02', heading: 'Drag Free - Loop' }); + +new Splide('#splide02', { + width: 1000, + height: 400, + type: 'loop', + parPage: 3, + drag: 'free', + snap: false, + gap: '2rem', +}).mount(); diff --git a/app/pages/drag-free/style.scss b/app/pages/drag-free/style.scss new file mode 100644 index 00000000..8b500d8a --- /dev/null +++ b/app/pages/drag-free/style.scss @@ -0,0 +1,4 @@ +.bar { + background: #b1f3f3; + height: 3px; +} diff --git a/app/pages/extension/index.html b/app/pages/extension/index.html new file mode 100644 index 00000000..f80392da --- /dev/null +++ b/app/pages/extension/index.html @@ -0,0 +1,10 @@ + + + + + + + + + + \ No newline at end of file diff --git a/app/pages/extension/script.ts b/app/pages/extension/script.ts new file mode 100644 index 00000000..49146b57 --- /dev/null +++ b/app/pages/extension/script.ts @@ -0,0 +1,28 @@ +import { BaseComponent, ComponentConstructor, Splide } from '../../../src/js'; +import { insertHtml } from '../../js/html'; +import '../../js/common'; + + +insertHtml(); + +const CustomExtension: ComponentConstructor = (Splide, Components, options, event) => { + const { root } = Splide; + const { bind } = event; + + function mount(): void { + const button = document.createElement('button'); + button.textContent = 'Jump'; + bind(button, 'click', () => Splide.go('>>')); + root.append(button); + } + + return { + mount, + }; +}; + +new Splide('#splide01', { + width: 1000, + height: 400, +}).mount({ CustomExtension }); + diff --git a/app/pages/fade/index.html b/app/pages/fade/index.html new file mode 100644 index 00000000..4065b5e8 --- /dev/null +++ b/app/pages/fade/index.html @@ -0,0 +1,43 @@ + + + + + + + +
+
+
    +
  • + +

    + Lorem ipsum dolor sit amet, quod sale at pro, everti iisque tractatos sit ea. Agam alterum sit at. Libris + petentium his ne, ne eam detraxit inimicus tractatos. Ius mundi verear ad, at percipit constituto pro, ei + possim eirmod quo. Vim laudem aperiam reprehendunt in. +

    +
  • +
  • + +

    + Has cu etiam veniam recusabo, his animal nostrud fabellas ne. Vis suas qualisque eu, eum ei impedit civibus, + an solum definiebas pro. +

    +
  • +
  • + +

    + Mollis epicuri laboramus ea qui, his ei meis graecis quaestio. Ius ne suscipit prodesset. Qui at delicata + euripidis eloquentiam, eius solum volumus eum eu. Usu eu deserunt abhorreant, errem qualisque nec in. Te has + labitur virtute hendrerit, cum quaeque oportere mediocritatem in, eos imperdiet intellegam id. +

    +

    + Has cu etiam veniam recusabo, his animal nostrud fabellas ne. Vis suas qualisque eu, eum ei impedit civibus, + an solum definiebas pro. +

    +
  • +
+
+
+ + + \ No newline at end of file diff --git a/app/pages/fade/script.ts b/app/pages/fade/script.ts new file mode 100644 index 00000000..80bed53a --- /dev/null +++ b/app/pages/fade/script.ts @@ -0,0 +1,11 @@ +import { Splide } from '../../../src/js'; +import '../../../src/css/themes/default/index.scss'; +import './style.scss'; + + +new Splide('#splide01', { + type: 'fade', + width: 1000, + rewind: true, + rewindByDrag: true, +}).mount(); diff --git a/app/pages/fade/style.scss b/app/pages/fade/style.scss new file mode 100644 index 00000000..93f5c518 --- /dev/null +++ b/app/pages/fade/style.scss @@ -0,0 +1,16 @@ +body { + margin: 2rem; +} + +.splide { + margin: 0 auto; + + &__slide { + background: #ecf3fa; + padding: 1rem; + + img { + width: 100%; + } + } +} diff --git a/app/pages/fixed-size/index.html b/app/pages/fixed-size/index.html new file mode 100644 index 00000000..f80392da --- /dev/null +++ b/app/pages/fixed-size/index.html @@ -0,0 +1,10 @@ + + + + + + + + + + \ No newline at end of file diff --git a/app/pages/fixed-size/script.ts b/app/pages/fixed-size/script.ts new file mode 100644 index 00000000..248d71d4 --- /dev/null +++ b/app/pages/fixed-size/script.ts @@ -0,0 +1,24 @@ +import { Splide } from '../../../src/js'; +import { insertHtml } from '../../js/html'; +import '../../js/common'; + + +insertHtml({ id: 'splide01' }); + +new Splide('#splide01', { + type: 'loop', + fixedWidth: '6rem', + gap: 10, + focus: 0, + omitEnd: true, +}).mount(); + + +insertHtml({ id: 'splide02' }); + +new Splide('#splide02', { + fixedWidth: 200, + gap: '1rem', +}).mount(); + + diff --git a/app/pages/images/index.html b/app/pages/images/index.html new file mode 100644 index 00000000..f80392da --- /dev/null +++ b/app/pages/images/index.html @@ -0,0 +1,10 @@ + + + + + + + + + + \ No newline at end of file diff --git a/app/pages/images/script.ts b/app/pages/images/script.ts new file mode 100644 index 00000000..6953b4fb --- /dev/null +++ b/app/pages/images/script.ts @@ -0,0 +1,11 @@ +import { Splide } from '../../../src/js'; +import { insertHtml } from '../../js/html'; +import '../../js/common'; + + +insertHtml({ id: 'splide01', useImage: true }); + +new Splide('#splide01', { + width: 1000, + height: 400, +}).mount(); diff --git a/app/pages/json/index.html b/app/pages/json/index.html new file mode 100644 index 00000000..f80392da --- /dev/null +++ b/app/pages/json/index.html @@ -0,0 +1,10 @@ + + + + + + + + + + \ No newline at end of file diff --git a/app/pages/json/script.ts b/app/pages/json/script.ts new file mode 100644 index 00000000..19d2ad64 --- /dev/null +++ b/app/pages/json/script.ts @@ -0,0 +1,23 @@ +import { Splide } from '../../../src/js'; +import { insertHtml } from '../../js/html'; +import '../../js/common'; + + +insertHtml(); + +const options = { + width: 1000, + height: 400, + perPage: 2, + gap: '1rem', +}; + +const root = document.getElementById('splide01'); + +if (root) { + root.dataset.splide = JSON.stringify(options); + new Splide(root).mount(); +} else { + throw new Error('Could not find a root element.'); +} + diff --git a/app/pages/lazy-load/index.html b/app/pages/lazy-load/index.html new file mode 100644 index 00000000..f80392da --- /dev/null +++ b/app/pages/lazy-load/index.html @@ -0,0 +1,10 @@ + + + + + + + + + + \ No newline at end of file diff --git a/app/pages/lazy-load/script.ts b/app/pages/lazy-load/script.ts new file mode 100644 index 00000000..8d36d037 --- /dev/null +++ b/app/pages/lazy-load/script.ts @@ -0,0 +1,57 @@ +import { Splide } from '../../../src/js'; +import { insertHtml } from '../../js/html'; +import '../../js/common'; + + +const placeholder = 'data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAEAAAABCAYAAAAfFcSJAAAADUlEQVR42mPc9/3HfwAI1gOuq1Su+AAAAABJRU5ErkJggg=='; + +insertHtml({ + id: 'splide01', + heading: 'Src & Placeholder', + onRenderSlide(index) { + const url = `https://source.unsplash.com/random/960x540?sig=${ index + 1 }`; + + return { + content: ``, + }; + }, +}); + +const splide01 = new Splide('#splide01', { + lazyLoad: 'nearby', + heightRatio: (9 / 16) / 2, + gap: '1rem', + drag: 'free', +}).mount(); + +let sig = 20; + +splide01.on('moved', index => { + if (index === splide01.length - 1) { + splide01.add([ + `
`, + `
`, + ]); + } +}); + +insertHtml({ + id: 'splide02', + heading: 'Srcset', + onRenderSlide(index) { + const small = `https://source.unsplash.com/random/640x360?sig=${ index + 1 }`; + const large = `https://source.unsplash.com/random/960x540?sig=${ index + 1 }`; + + return { + content: ``, + }; + }, +}); + +new Splide('#splide02', { + perPage: 2, + lazyLoad: 'sequential', + heightRatio: (9 / 16) / 2, + gap: '1rem', +}).mount(); + diff --git a/app/pages/live-regions/index.html b/app/pages/live-regions/index.html new file mode 100644 index 00000000..708beabd --- /dev/null +++ b/app/pages/live-regions/index.html @@ -0,0 +1,59 @@ + + + + + + + +
+
+
+
    +
  • +
    + +

    Neptune

    +
    +

    + Neptune is the eighth and farthest-known Solar planet from the Sun. +

    + +
    +
    +
  • +
  • +
    + + +

    Saturn

    +
    +

    + Saturn is the sixth planet from the Sun and the second-largest in the Solar System, after Jupiter. +

    + +
    +
    +
  • +
  • +
    + + +

    Mars

    +
    +

    + Mars is the fourth planet from the Sun and the second-smallest planet in the Solar System. +

    + +
    +
    +
  • +
+
+
+
+ + + \ No newline at end of file diff --git a/app/pages/live-regions/script.ts b/app/pages/live-regions/script.ts new file mode 100644 index 00000000..049b8788 --- /dev/null +++ b/app/pages/live-regions/script.ts @@ -0,0 +1,14 @@ +import { Splide } from '../../../src/js'; +import '../../../src/css/themes/default/index.scss'; +import './style.scss'; + + +new Splide('#splide01', { + type: 'loop', + width: 480, + rewind: true, + // live : false, + speed: 600, + arrowPath: 'm13.5 7.01 13 13m-13 13 13-13', + updateOnMove: true, +}).mount(); diff --git a/app/pages/live-regions/style.scss b/app/pages/live-regions/style.scss new file mode 100644 index 00000000..ca4e75fe --- /dev/null +++ b/app/pages/live-regions/style.scss @@ -0,0 +1,123 @@ +body { + background: linear-gradient( 0deg, #8cde1d, #c0e900 ); + color: #d7e9f5; + font-family: SplideBody, sans-serif; + font-weight: normal; + height: 200vh; + line-height: 1.8; + overflow-x: hidden; + padding: 2rem; +} + +img { + height: auto; + width: 100%; +} + +p { + margin: 0 0 1em; +} + +cite { + font-size: .8em; + font-style: normal; + opacity: .7; +} + +.wrapper { + display: flex; + justify-content: center; + margin-top: 10rem; +} + +.splide { + &__track { + height: 100%; + } + + &__slide { + height: 100%; + padding: 2rem 1rem; + + &:focus-visible { + outline: #fff dotted 3px !important; + } + + &__inner { + background: #000; + border-radius: 10px; + height: 100%; + opacity: 0; + overflow: hidden; + transform: scale( .8 ); + transition: all .5s cubic-bezier( .17, .67, .44, 1 ); + } + + &.is-active { + .splide__slide__inner { + box-shadow: 0 0 15px 4px rgba( 0, 0, 0, .25 ); + opacity: 1; + transform: scale( 1 ); + } + } + } + + &__heading { + color: #fff; + font-family: SplideHeading, sans-serif; + font-size: 2rem; + line-height: 1; + margin: 0; + padding: 1rem 1.5rem .5rem; + } + + &__desc { + margin: 0; + padding: .5rem 1.5rem 3rem; + } + + &__arrow { + background: transparent; + border-radius: 0; + height: 2rem; + opacity: 1; + width: 2rem; + + &:focus-visible { + outline: #fff dotted 3px !important; + } + + svg { + fill: none; + height: 2rem; + stroke: #fff; + stroke-linecap: square; + stroke-width: 8px; + vertical-align: middle; + width: 2rem; + } + + &--prev { + left: -2.7rem; + } + + &--next { + right: -2.7rem; + } + } + + &__pagination { + bottom: 3rem; + + &__page { + background: #d7e9f5; + height: 10px; + width: 10px; + + &.is-active { + background: #8cde1d; + opacity: 1; + } + } + } +} diff --git a/app/pages/loop/index.html b/app/pages/loop/index.html new file mode 100644 index 00000000..f80392da --- /dev/null +++ b/app/pages/loop/index.html @@ -0,0 +1,10 @@ + + + + + + + + + + \ No newline at end of file diff --git a/app/pages/loop/script.ts b/app/pages/loop/script.ts new file mode 100644 index 00000000..e228772f --- /dev/null +++ b/app/pages/loop/script.ts @@ -0,0 +1,18 @@ +import { Splide } from '../../../src/js'; +import { insertHtml } from '../../js/html'; +import '../../js/common'; +import './styles.scss'; + + +insertHtml(); + +new Splide('#splide01', { + type: 'loop', + width: 1000, + height: 400, + speed: 1000, + perPage: 3, + gap: 5, + updateOnMove: true, + // padding: '3rem', +}).mount(); diff --git a/app/pages/loop/styles.scss b/app/pages/loop/styles.scss new file mode 100644 index 00000000..c8dd7114 --- /dev/null +++ b/app/pages/loop/styles.scss @@ -0,0 +1,7 @@ +.splide { + &__slide { + &.is-visible { + background: #779cc4; + } + } +} \ No newline at end of file diff --git a/app/pages/nest/index.html b/app/pages/nest/index.html new file mode 100644 index 00000000..48b48aad --- /dev/null +++ b/app/pages/nest/index.html @@ -0,0 +1,19 @@ + + + + + + + +
+
+
+
+
+
+
+
+
+ + + \ No newline at end of file diff --git a/app/pages/nest/script.ts b/app/pages/nest/script.ts new file mode 100644 index 00000000..cf9ae38b --- /dev/null +++ b/app/pages/nest/script.ts @@ -0,0 +1,27 @@ +import { Splide } from '../../../src/js'; +import { insertHtml } from '../../js/html'; +import '../../../src/css/themes/default/index.scss'; +import './style.scss'; + + +insertHtml({ id: 'nested01', selector: '.nest1' }); +insertHtml({ id: 'nested02', selector: '.nest2' }); + +new Splide('#splide01', { + gap: '1.5rem', + height: 600, +}).mount(); + +new Splide('#nested01', { + perPage: 2, + height: 400, + rewind: true, + gap: '1rem', +}).mount(); + +new Splide('#nested02', { + perPage: 2, + direction: 'ttb', + height: 400, + gap: '1rem', +}).mount(); diff --git a/app/pages/nest/style.scss b/app/pages/nest/style.scss new file mode 100644 index 00000000..a71639c1 --- /dev/null +++ b/app/pages/nest/style.scss @@ -0,0 +1,27 @@ +body { + margin: 2rem; +} + +.splide { + margin: 0 auto; + + &__slide { + align-items: center; + background: #ecf3fa; + display: flex; + justify-content: center; + padding: 1rem; + } +} + +.nest1, +.nest2 { + .splide { + width: 90%; + + &__slide { + background: #c6d7e5; + font-size: 3rem; + } + } +} diff --git a/app/pages/overflow/index.html b/app/pages/overflow/index.html new file mode 100644 index 00000000..f80392da --- /dev/null +++ b/app/pages/overflow/index.html @@ -0,0 +1,10 @@ + + + + + + + + + + \ No newline at end of file diff --git a/app/pages/overflow/script.ts b/app/pages/overflow/script.ts new file mode 100644 index 00000000..bb96aac7 --- /dev/null +++ b/app/pages/overflow/script.ts @@ -0,0 +1,43 @@ +import { Splide } from '../../../src/js'; +import { insertHtml } from '../../js/html'; +import '../../js/common'; +import './style.scss'; + + +insertHtml({ id: 'splide01', heading: 'Loop' }); + +const splide01 = new Splide('#splide01', { + type: 'loop', + fixedWidth: '6rem', + fixedHeight: '4rem', + gap: 10, + omitEnd: true, + focus: 0, + breakpoints: { + '!overflow': { + arrows: false, + drag: false, + pagination: false, + clones: 0, + }, + }, +}).mount(); + +splide01.on('overflow', overflow => console.log('overflow', overflow)); + +insertHtml({ id: 'splide02', heading: 'Slide' }); + +const splide02 = new Splide('#splide02', { + fixedWidth: '6rem', + fixedHeight: '4rem', + gap: 10, + breakpoints: { + '!overflow': { + arrows: false, + drag: false, + pagination: false, + }, + }, +}).mount(); + +splide02.on('overflow', overflow => console.log('overflow', overflow)); \ No newline at end of file diff --git a/app/pages/overflow/style.scss b/app/pages/overflow/style.scss new file mode 100644 index 00000000..75ef5ebc --- /dev/null +++ b/app/pages/overflow/style.scss @@ -0,0 +1,13 @@ +.splide { + &:not(.is-overflow) { + .splide__list { + justify-content: center; + } + + .splide__slide { + &:last-child { + margin: 0 !important; + } + } + } +} diff --git a/app/pages/rtl/index.html b/app/pages/rtl/index.html new file mode 100644 index 00000000..f80392da --- /dev/null +++ b/app/pages/rtl/index.html @@ -0,0 +1,10 @@ + + + + + + + + + + \ No newline at end of file diff --git a/app/pages/rtl/script.ts b/app/pages/rtl/script.ts new file mode 100644 index 00000000..a793f349 --- /dev/null +++ b/app/pages/rtl/script.ts @@ -0,0 +1,19 @@ +import { Splide } from '../../../src/js'; +import { insertHtml } from '../../js/html'; +import '../../js/common'; + + +insertHtml(); + +new Splide('#splide01', { + type: 'loop', + width: 1000, + height: 400, + perPage: 3, + gap: 5, + direction: 'rtl', + padding: { + left: 40, + right: 0, + }, +}).mount(); diff --git a/app/pages/sync/index.html b/app/pages/sync/index.html new file mode 100644 index 00000000..f80392da --- /dev/null +++ b/app/pages/sync/index.html @@ -0,0 +1,10 @@ + + + + + + + + + + \ No newline at end of file diff --git a/app/pages/sync/script.ts b/app/pages/sync/script.ts new file mode 100644 index 00000000..aabbcce5 --- /dev/null +++ b/app/pages/sync/script.ts @@ -0,0 +1,59 @@ +import { Splide } from '../../../src/js'; +import { insertHtml } from '../../js/html'; +import '../../js/common'; + + +insertHtml({ id: 'splide01', useImage: true }); + +const splide01 = new Splide('#splide01', { + type: 'loop', + width: 800, + heightRatio: 0.4, + perPage: 1, + pagination: false, + keyboard: true, +}); + +insertHtml({ id: 'splide02', useImage: true }); + +const splide02 = new Splide('#splide02', { + width: 600, + fixedWidth: 100, + fixedHeight: 56, + gap: '.7em', + isNavigation: true, + focus: 'center', + pagination: false, + rewind: true, + keyboard: true, + drag: 'free', + updateOnDragged: false, + dragMinThreshold: { + mouse: 10, + touch: 10, + }, +}); + +insertHtml({ id: 'splide03', useImage: true }); + +const splide03 = new Splide('#splide03', { + width: 100, + type: 'loop', + direction: 'ttb', + height: 300, + fixedWidth: 100, + fixedHeight: 56, + gap: '.7em', + isNavigation: true, + pagination: false, + keyboard: true, +}); + +splide01.sync(splide02); + +splide01.mount(); +splide02.mount(); +splide03.mount(); + +// Attempts to sync after mount. +splide01.sync(splide03); \ No newline at end of file diff --git a/app/pages/ttb/index.html b/app/pages/ttb/index.html new file mode 100644 index 00000000..f80392da --- /dev/null +++ b/app/pages/ttb/index.html @@ -0,0 +1,10 @@ + + + + + + + + + + \ No newline at end of file diff --git a/app/pages/ttb/script.ts b/app/pages/ttb/script.ts new file mode 100644 index 00000000..a44a41e6 --- /dev/null +++ b/app/pages/ttb/script.ts @@ -0,0 +1,17 @@ +import { Splide } from '../../../src/js'; +import { insertHtml } from '../../js/html'; +import '../../js/common'; +import './style.scss'; + + +insertHtml({ id: 'splide01', heading: 'Loop' }); + +new Splide('#splide01', { + width: 400, + type: 'loop', + perPage: 2, + padding: '3rem', + gap: '1rem', + direction: 'ttb', + height: '90vh', +}).mount(); \ No newline at end of file diff --git a/app/pages/ttb/style.scss b/app/pages/ttb/style.scss new file mode 100644 index 00000000..db14aaf3 --- /dev/null +++ b/app/pages/ttb/style.scss @@ -0,0 +1,3 @@ +.splide { + margin-bottom: 50vh; +} diff --git a/dist/css/splide-core.min.css b/dist/css/splide-core.min.css index 089c72ee..89166c6c 100644 --- a/dist/css/splide-core.min.css +++ b/dist/css/splide-core.min.css @@ -1 +1 @@ -@keyframes splide-loading{0%{transform:rotate(0)}to{transform:rotate(1turn)}}.splide__track--draggable{-webkit-touch-callout:none;-webkit-user-select:none;-ms-user-select:none;user-select:none}.splide__track--fade>.splide__list>.splide__slide{margin:0!important;opacity:0;z-index:0}.splide__track--fade>.splide__list>.splide__slide.is-active{opacity:1;z-index:1}.splide--rtl{direction:rtl}.splide__track--ttb>.splide__list{display:block}.splide__container{box-sizing:border-box;position:relative}.splide__list{backface-visibility:hidden;display:-ms-flexbox;display:flex;height:100%;margin:0!important;padding:0!important}.splide.is-initialized:not(.is-active) .splide__list{display:block}.splide__pagination{-ms-flex-align:center;align-items:center;display:-ms-flexbox;display:flex;-ms-flex-wrap:wrap;flex-wrap:wrap;-ms-flex-pack:center;justify-content:center;margin:0;pointer-events:none}.splide__pagination li{display:inline-block;line-height:1;list-style-type:none;margin:0;pointer-events:auto}.splide:not(.is-overflow) .splide__pagination{display:none}.splide__progress__bar{width:0}.splide{position:relative;visibility:hidden}.splide.is-initialized,.splide.is-rendered{visibility:visible}.splide__slide{backface-visibility:hidden;box-sizing:border-box;-ms-flex-negative:0;flex-shrink:0;list-style-type:none!important;margin:0;position:relative}.splide__slide img{vertical-align:bottom}.splide__spinner{animation:splide-loading 1s linear infinite;border:2px solid #999;border-left-color:transparent;border-radius:50%;bottom:0;contain:strict;display:inline-block;height:20px;left:0;margin:auto;position:absolute;right:0;top:0;width:20px}.splide__sr{clip:rect(0 0 0 0);border:0;height:1px;margin:-1px;overflow:hidden;padding:0;position:absolute;width:1px}.splide__toggle.is-active .splide__toggle__play,.splide__toggle__pause{display:none}.splide__toggle.is-active .splide__toggle__pause{display:inline}.splide__track{overflow:hidden;position:relative;z-index:0} \ No newline at end of file +@keyframes splide-loading{0%{transform:rotateZ(0)}100%{transform:rotateZ(360deg)}}.splide__track--draggable{-webkit-touch-callout:none;user-select:none}.splide__track--fade>.splide__list>.splide__slide{margin:0 !important;opacity:0;z-index:0}.splide__track--fade>.splide__list>.splide__slide.is-active{opacity:1;z-index:1}.splide--rtl{direction:rtl}.splide__track--ttb>.splide__list{display:block}.splide__container{box-sizing:border-box;position:relative}.splide__list{backface-visibility:hidden;display:flex;height:100%;margin:0 !important;padding:0 !important}.splide.is-initialized:not(.is-active) .splide__list{display:block}.splide__pagination{align-items:center;display:flex;flex-wrap:wrap;justify-content:center;margin:0;pointer-events:none}.splide__pagination li{display:inline-block;line-height:1;list-style-type:none;margin:0;pointer-events:auto}.splide:not(.is-overflow) .splide__pagination{display:none}.splide__progress__bar{width:0}.splide{position:relative;visibility:hidden}.splide.is-initialized,.splide.is-rendered{visibility:visible}.splide__slide{backface-visibility:hidden;box-sizing:border-box;flex-shrink:0;list-style-type:none !important;margin:0;position:relative}.splide__slide img{vertical-align:bottom}.splide__spinner{animation:splide-loading 1s infinite linear;border:2px solid #999;border-left-color:rgba(0,0,0,0);border-radius:50%;bottom:0;contain:strict;display:inline-block;height:20px;left:0;margin:auto;position:absolute;right:0;top:0;width:20px}.splide__sr{border:0 !important;clip:rect(0 0 0 0) !important;height:1px !important;margin:-1px !important;overflow:hidden !important;padding:0 !important;position:absolute !important;width:1px !important}.splide__toggle__pause{display:none}.splide__toggle.is-active .splide__toggle__play{display:none}.splide__toggle.is-active .splide__toggle__pause{display:inline}.splide__track{overflow:hidden;position:relative;z-index:0} \ No newline at end of file diff --git a/dist/css/splide.min.css b/dist/css/splide.min.css index 7e014b47..6fa7c552 100644 --- a/dist/css/splide.min.css +++ b/dist/css/splide.min.css @@ -1 +1 @@ -.splide__container{box-sizing:border-box;position:relative}.splide__list{backface-visibility:hidden;display:-ms-flexbox;display:flex;height:100%;margin:0!important;padding:0!important}.splide.is-initialized:not(.is-active) .splide__list{display:block}.splide__pagination{-ms-flex-align:center;align-items:center;display:-ms-flexbox;display:flex;-ms-flex-wrap:wrap;flex-wrap:wrap;-ms-flex-pack:center;justify-content:center;margin:0;pointer-events:none}.splide__pagination li{display:inline-block;line-height:1;list-style-type:none;margin:0;pointer-events:auto}.splide:not(.is-overflow) .splide__pagination{display:none}.splide__progress__bar{width:0}.splide{position:relative;visibility:hidden}.splide.is-initialized,.splide.is-rendered{visibility:visible}.splide__slide{backface-visibility:hidden;box-sizing:border-box;-ms-flex-negative:0;flex-shrink:0;list-style-type:none!important;margin:0;position:relative}.splide__slide img{vertical-align:bottom}.splide__spinner{animation:splide-loading 1s linear infinite;border:2px solid #999;border-left-color:transparent;border-radius:50%;bottom:0;contain:strict;display:inline-block;height:20px;left:0;margin:auto;position:absolute;right:0;top:0;width:20px}.splide__sr{clip:rect(0 0 0 0);border:0;height:1px;margin:-1px;overflow:hidden;padding:0;position:absolute;width:1px}.splide__toggle.is-active .splide__toggle__play,.splide__toggle__pause{display:none}.splide__toggle.is-active .splide__toggle__pause{display:inline}.splide__track{overflow:hidden;position:relative;z-index:0}@keyframes splide-loading{0%{transform:rotate(0)}to{transform:rotate(1turn)}}.splide__track--draggable{-webkit-touch-callout:none;-webkit-user-select:none;-ms-user-select:none;user-select:none}.splide__track--fade>.splide__list>.splide__slide{margin:0!important;opacity:0;z-index:0}.splide__track--fade>.splide__list>.splide__slide.is-active{opacity:1;z-index:1}.splide--rtl{direction:rtl}.splide__track--ttb>.splide__list{display:block}.splide__arrow{-ms-flex-align:center;align-items:center;background:#ccc;border:0;border-radius:50%;cursor:pointer;display:-ms-flexbox;display:flex;height:2em;-ms-flex-pack:center;justify-content:center;opacity:.7;padding:0;position:absolute;top:50%;transform:translateY(-50%);width:2em;z-index:1}.splide__arrow svg{fill:#000;height:1.2em;width:1.2em}.splide__arrow:hover:not(:disabled){opacity:.9}.splide__arrow:disabled{opacity:.3}.splide__arrow:focus-visible{outline:3px solid #0bf;outline-offset:3px}.splide__arrow--prev{left:1em}.splide__arrow--prev svg{transform:scaleX(-1)}.splide__arrow--next{right:1em}.splide.is-focus-in .splide__arrow:focus{outline:3px solid #0bf;outline-offset:3px}.splide__pagination{bottom:.5em;left:0;padding:0 1em;position:absolute;right:0;z-index:1}.splide__pagination__page{background:#ccc;border:0;border-radius:50%;display:inline-block;height:8px;margin:3px;opacity:.7;padding:0;position:relative;transition:transform .2s linear;width:8px}.splide__pagination__page.is-active{background:#fff;transform:scale(1.4);z-index:1}.splide__pagination__page:hover{cursor:pointer;opacity:.9}.splide__pagination__page:focus-visible{outline:3px solid #0bf;outline-offset:3px}.splide.is-focus-in .splide__pagination__page:focus{outline:3px solid #0bf;outline-offset:3px}.splide__progress__bar{background:#ccc;height:3px}.splide__slide{-webkit-tap-highlight-color:rgba(0,0,0,0)}.splide__slide:focus{outline:0}@supports(outline-offset:-3px){.splide__slide:focus-visible{outline:3px solid #0bf;outline-offset:-3px}}@media screen and (-ms-high-contrast:none){.splide__slide:focus-visible{border:3px solid #0bf}}@supports(outline-offset:-3px){.splide.is-focus-in .splide__slide:focus{outline:3px solid #0bf;outline-offset:-3px}}@media screen and (-ms-high-contrast:none){.splide.is-focus-in .splide__slide:focus{border:3px solid #0bf}.splide.is-focus-in .splide__track>.splide__list>.splide__slide:focus{border-color:#0bf}}.splide__toggle{cursor:pointer}.splide__toggle:focus-visible{outline:3px solid #0bf;outline-offset:3px}.splide.is-focus-in .splide__toggle:focus{outline:3px solid #0bf;outline-offset:3px}.splide__track--nav>.splide__list>.splide__slide{border:3px solid transparent;cursor:pointer}.splide__track--nav>.splide__list>.splide__slide.is-active{border:3px solid #000}.splide__arrows--rtl .splide__arrow--prev{left:auto;right:1em}.splide__arrows--rtl .splide__arrow--prev svg{transform:scaleX(1)}.splide__arrows--rtl .splide__arrow--next{left:1em;right:auto}.splide__arrows--rtl .splide__arrow--next svg{transform:scaleX(-1)}.splide__arrows--ttb .splide__arrow{left:50%;transform:translate(-50%)}.splide__arrows--ttb .splide__arrow--prev{top:1em}.splide__arrows--ttb .splide__arrow--prev svg{transform:rotate(-90deg)}.splide__arrows--ttb .splide__arrow--next{bottom:1em;top:auto}.splide__arrows--ttb .splide__arrow--next svg{transform:rotate(90deg)}.splide__pagination--ttb{bottom:0;display:-ms-flexbox;display:flex;-ms-flex-direction:column;flex-direction:column;left:auto;padding:1em 0;right:.5em;top:0} \ No newline at end of file +.splide__container{box-sizing:border-box;position:relative}.splide__list{backface-visibility:hidden;display:flex;height:100%;margin:0 !important;padding:0 !important}.splide.is-initialized:not(.is-active) .splide__list{display:block}.splide__pagination{align-items:center;display:flex;flex-wrap:wrap;justify-content:center;margin:0;pointer-events:none}.splide__pagination li{display:inline-block;line-height:1;list-style-type:none;margin:0;pointer-events:auto}.splide:not(.is-overflow) .splide__pagination{display:none}.splide__progress__bar{width:0}.splide{position:relative;visibility:hidden}.splide.is-initialized,.splide.is-rendered{visibility:visible}.splide__slide{backface-visibility:hidden;box-sizing:border-box;flex-shrink:0;list-style-type:none !important;margin:0;position:relative}.splide__slide img{vertical-align:bottom}.splide__spinner{animation:splide-loading 1s infinite linear;border:2px solid #999;border-left-color:rgba(0,0,0,0);border-radius:50%;bottom:0;contain:strict;display:inline-block;height:20px;left:0;margin:auto;position:absolute;right:0;top:0;width:20px}.splide__sr{border:0 !important;clip:rect(0 0 0 0) !important;height:1px !important;margin:-1px !important;overflow:hidden !important;padding:0 !important;position:absolute !important;width:1px !important}.splide__toggle__pause{display:none}.splide__toggle.is-active .splide__toggle__play{display:none}.splide__toggle.is-active .splide__toggle__pause{display:inline}.splide__track{overflow:hidden;position:relative;z-index:0}@keyframes splide-loading{0%{transform:rotateZ(0)}100%{transform:rotateZ(360deg)}}.splide__track--draggable{-webkit-touch-callout:none;user-select:none}.splide__track--fade>.splide__list>.splide__slide{margin:0 !important;opacity:0;z-index:0}.splide__track--fade>.splide__list>.splide__slide.is-active{opacity:1;z-index:1}.splide--rtl{direction:rtl}.splide__track--ttb>.splide__list{display:block}.splide__arrow{background:#ccc;border:0;cursor:pointer;padding:0;position:absolute;top:50%;transform:translateY(-50%);z-index:1;opacity:.7;align-items:center;border-radius:50%;display:flex;height:2em;justify-content:center;width:2em}.splide__arrow svg{fill:#000;height:1.2em;width:1.2em}.splide__arrow:hover:not(:disabled){opacity:.9}.splide__arrow:disabled{opacity:.3}.splide__arrow:focus-visible{outline:#0bf 3px solid;outline-offset:3px}.splide__arrow--prev{left:1em}.splide__arrow--prev svg{transform:scaleX(-1)}.splide__arrow--next{right:1em}.splide.is-focus-in .splide__arrow:focus{outline:#0bf 3px solid;outline-offset:3px}.splide__pagination{bottom:.5em;left:0;padding:0 1em;position:absolute;right:0;z-index:1}.splide__pagination__page{background:#ccc;border:0;border-radius:50%;display:inline-block;height:8px;margin:3px;padding:0;position:relative;transition:transform .2s linear;width:8px;opacity:.7}.splide__pagination__page.is-active{background:#fff;z-index:1;transform:scale(1.4)}.splide__pagination__page:hover{cursor:pointer;opacity:.9}.splide__pagination__page:focus-visible{outline:#0bf 3px solid;outline-offset:3px}.splide.is-focus-in .splide__pagination__page:focus{outline:#0bf 3px solid;outline-offset:3px}.splide__progress__bar{background:#ccc;height:3px}.splide__slide{-webkit-tap-highlight-color:rgba(0,0,0,0)}.splide__slide:focus{outline:0}@supports(outline-offset: -3px){.splide__slide:focus-visible{outline:#0bf 3px solid;outline-offset:-3px}}@media screen and (-ms-high-contrast: none){.splide__slide:focus-visible{border:#0bf 3px solid}}@supports(outline-offset: -3px){.splide.is-focus-in .splide__slide:focus{outline:#0bf 3px solid;outline-offset:-3px}}@media screen and (-ms-high-contrast: none){.splide.is-focus-in .splide__slide:focus{border:#0bf 3px solid}}@media screen and (-ms-high-contrast: none){.splide.is-focus-in .splide__track>.splide__list>.splide__slide:focus{border-color:#0bf}}.splide__toggle{cursor:pointer}.splide__toggle:focus-visible{outline:#0bf 3px solid;outline-offset:3px}.splide.is-focus-in .splide__toggle:focus{outline:#0bf 3px solid;outline-offset:3px}.splide__track--nav>.splide__list>.splide__slide{border:3px solid rgba(0,0,0,0);cursor:pointer}.splide__track--nav>.splide__list>.splide__slide.is-active{border:3px solid #000}.splide__arrows--rtl .splide__arrow--prev{left:auto;right:1em}.splide__arrows--rtl .splide__arrow--prev svg{transform:scaleX(1)}.splide__arrows--rtl .splide__arrow--next{left:1em;right:auto}.splide__arrows--rtl .splide__arrow--next svg{transform:scaleX(-1)}.splide__arrows--ttb .splide__arrow{left:50%;transform:translate(-50%, 0)}.splide__arrows--ttb .splide__arrow--prev{top:1em}.splide__arrows--ttb .splide__arrow--prev svg{transform:rotateZ(-90deg)}.splide__arrows--ttb .splide__arrow--next{bottom:1em;top:auto}.splide__arrows--ttb .splide__arrow--next svg{transform:rotateZ(90deg)}.splide__pagination--ttb{bottom:0;display:flex;flex-direction:column;left:auto;padding:1em 0;right:.5em;top:0} \ No newline at end of file diff --git a/dist/css/themes/splide-default.min.css b/dist/css/themes/splide-default.min.css index 7e014b47..6fa7c552 100644 --- a/dist/css/themes/splide-default.min.css +++ b/dist/css/themes/splide-default.min.css @@ -1 +1 @@ -.splide__container{box-sizing:border-box;position:relative}.splide__list{backface-visibility:hidden;display:-ms-flexbox;display:flex;height:100%;margin:0!important;padding:0!important}.splide.is-initialized:not(.is-active) .splide__list{display:block}.splide__pagination{-ms-flex-align:center;align-items:center;display:-ms-flexbox;display:flex;-ms-flex-wrap:wrap;flex-wrap:wrap;-ms-flex-pack:center;justify-content:center;margin:0;pointer-events:none}.splide__pagination li{display:inline-block;line-height:1;list-style-type:none;margin:0;pointer-events:auto}.splide:not(.is-overflow) .splide__pagination{display:none}.splide__progress__bar{width:0}.splide{position:relative;visibility:hidden}.splide.is-initialized,.splide.is-rendered{visibility:visible}.splide__slide{backface-visibility:hidden;box-sizing:border-box;-ms-flex-negative:0;flex-shrink:0;list-style-type:none!important;margin:0;position:relative}.splide__slide img{vertical-align:bottom}.splide__spinner{animation:splide-loading 1s linear infinite;border:2px solid #999;border-left-color:transparent;border-radius:50%;bottom:0;contain:strict;display:inline-block;height:20px;left:0;margin:auto;position:absolute;right:0;top:0;width:20px}.splide__sr{clip:rect(0 0 0 0);border:0;height:1px;margin:-1px;overflow:hidden;padding:0;position:absolute;width:1px}.splide__toggle.is-active .splide__toggle__play,.splide__toggle__pause{display:none}.splide__toggle.is-active .splide__toggle__pause{display:inline}.splide__track{overflow:hidden;position:relative;z-index:0}@keyframes splide-loading{0%{transform:rotate(0)}to{transform:rotate(1turn)}}.splide__track--draggable{-webkit-touch-callout:none;-webkit-user-select:none;-ms-user-select:none;user-select:none}.splide__track--fade>.splide__list>.splide__slide{margin:0!important;opacity:0;z-index:0}.splide__track--fade>.splide__list>.splide__slide.is-active{opacity:1;z-index:1}.splide--rtl{direction:rtl}.splide__track--ttb>.splide__list{display:block}.splide__arrow{-ms-flex-align:center;align-items:center;background:#ccc;border:0;border-radius:50%;cursor:pointer;display:-ms-flexbox;display:flex;height:2em;-ms-flex-pack:center;justify-content:center;opacity:.7;padding:0;position:absolute;top:50%;transform:translateY(-50%);width:2em;z-index:1}.splide__arrow svg{fill:#000;height:1.2em;width:1.2em}.splide__arrow:hover:not(:disabled){opacity:.9}.splide__arrow:disabled{opacity:.3}.splide__arrow:focus-visible{outline:3px solid #0bf;outline-offset:3px}.splide__arrow--prev{left:1em}.splide__arrow--prev svg{transform:scaleX(-1)}.splide__arrow--next{right:1em}.splide.is-focus-in .splide__arrow:focus{outline:3px solid #0bf;outline-offset:3px}.splide__pagination{bottom:.5em;left:0;padding:0 1em;position:absolute;right:0;z-index:1}.splide__pagination__page{background:#ccc;border:0;border-radius:50%;display:inline-block;height:8px;margin:3px;opacity:.7;padding:0;position:relative;transition:transform .2s linear;width:8px}.splide__pagination__page.is-active{background:#fff;transform:scale(1.4);z-index:1}.splide__pagination__page:hover{cursor:pointer;opacity:.9}.splide__pagination__page:focus-visible{outline:3px solid #0bf;outline-offset:3px}.splide.is-focus-in .splide__pagination__page:focus{outline:3px solid #0bf;outline-offset:3px}.splide__progress__bar{background:#ccc;height:3px}.splide__slide{-webkit-tap-highlight-color:rgba(0,0,0,0)}.splide__slide:focus{outline:0}@supports(outline-offset:-3px){.splide__slide:focus-visible{outline:3px solid #0bf;outline-offset:-3px}}@media screen and (-ms-high-contrast:none){.splide__slide:focus-visible{border:3px solid #0bf}}@supports(outline-offset:-3px){.splide.is-focus-in .splide__slide:focus{outline:3px solid #0bf;outline-offset:-3px}}@media screen and (-ms-high-contrast:none){.splide.is-focus-in .splide__slide:focus{border:3px solid #0bf}.splide.is-focus-in .splide__track>.splide__list>.splide__slide:focus{border-color:#0bf}}.splide__toggle{cursor:pointer}.splide__toggle:focus-visible{outline:3px solid #0bf;outline-offset:3px}.splide.is-focus-in .splide__toggle:focus{outline:3px solid #0bf;outline-offset:3px}.splide__track--nav>.splide__list>.splide__slide{border:3px solid transparent;cursor:pointer}.splide__track--nav>.splide__list>.splide__slide.is-active{border:3px solid #000}.splide__arrows--rtl .splide__arrow--prev{left:auto;right:1em}.splide__arrows--rtl .splide__arrow--prev svg{transform:scaleX(1)}.splide__arrows--rtl .splide__arrow--next{left:1em;right:auto}.splide__arrows--rtl .splide__arrow--next svg{transform:scaleX(-1)}.splide__arrows--ttb .splide__arrow{left:50%;transform:translate(-50%)}.splide__arrows--ttb .splide__arrow--prev{top:1em}.splide__arrows--ttb .splide__arrow--prev svg{transform:rotate(-90deg)}.splide__arrows--ttb .splide__arrow--next{bottom:1em;top:auto}.splide__arrows--ttb .splide__arrow--next svg{transform:rotate(90deg)}.splide__pagination--ttb{bottom:0;display:-ms-flexbox;display:flex;-ms-flex-direction:column;flex-direction:column;left:auto;padding:1em 0;right:.5em;top:0} \ No newline at end of file +.splide__container{box-sizing:border-box;position:relative}.splide__list{backface-visibility:hidden;display:flex;height:100%;margin:0 !important;padding:0 !important}.splide.is-initialized:not(.is-active) .splide__list{display:block}.splide__pagination{align-items:center;display:flex;flex-wrap:wrap;justify-content:center;margin:0;pointer-events:none}.splide__pagination li{display:inline-block;line-height:1;list-style-type:none;margin:0;pointer-events:auto}.splide:not(.is-overflow) .splide__pagination{display:none}.splide__progress__bar{width:0}.splide{position:relative;visibility:hidden}.splide.is-initialized,.splide.is-rendered{visibility:visible}.splide__slide{backface-visibility:hidden;box-sizing:border-box;flex-shrink:0;list-style-type:none !important;margin:0;position:relative}.splide__slide img{vertical-align:bottom}.splide__spinner{animation:splide-loading 1s infinite linear;border:2px solid #999;border-left-color:rgba(0,0,0,0);border-radius:50%;bottom:0;contain:strict;display:inline-block;height:20px;left:0;margin:auto;position:absolute;right:0;top:0;width:20px}.splide__sr{border:0 !important;clip:rect(0 0 0 0) !important;height:1px !important;margin:-1px !important;overflow:hidden !important;padding:0 !important;position:absolute !important;width:1px !important}.splide__toggle__pause{display:none}.splide__toggle.is-active .splide__toggle__play{display:none}.splide__toggle.is-active .splide__toggle__pause{display:inline}.splide__track{overflow:hidden;position:relative;z-index:0}@keyframes splide-loading{0%{transform:rotateZ(0)}100%{transform:rotateZ(360deg)}}.splide__track--draggable{-webkit-touch-callout:none;user-select:none}.splide__track--fade>.splide__list>.splide__slide{margin:0 !important;opacity:0;z-index:0}.splide__track--fade>.splide__list>.splide__slide.is-active{opacity:1;z-index:1}.splide--rtl{direction:rtl}.splide__track--ttb>.splide__list{display:block}.splide__arrow{background:#ccc;border:0;cursor:pointer;padding:0;position:absolute;top:50%;transform:translateY(-50%);z-index:1;opacity:.7;align-items:center;border-radius:50%;display:flex;height:2em;justify-content:center;width:2em}.splide__arrow svg{fill:#000;height:1.2em;width:1.2em}.splide__arrow:hover:not(:disabled){opacity:.9}.splide__arrow:disabled{opacity:.3}.splide__arrow:focus-visible{outline:#0bf 3px solid;outline-offset:3px}.splide__arrow--prev{left:1em}.splide__arrow--prev svg{transform:scaleX(-1)}.splide__arrow--next{right:1em}.splide.is-focus-in .splide__arrow:focus{outline:#0bf 3px solid;outline-offset:3px}.splide__pagination{bottom:.5em;left:0;padding:0 1em;position:absolute;right:0;z-index:1}.splide__pagination__page{background:#ccc;border:0;border-radius:50%;display:inline-block;height:8px;margin:3px;padding:0;position:relative;transition:transform .2s linear;width:8px;opacity:.7}.splide__pagination__page.is-active{background:#fff;z-index:1;transform:scale(1.4)}.splide__pagination__page:hover{cursor:pointer;opacity:.9}.splide__pagination__page:focus-visible{outline:#0bf 3px solid;outline-offset:3px}.splide.is-focus-in .splide__pagination__page:focus{outline:#0bf 3px solid;outline-offset:3px}.splide__progress__bar{background:#ccc;height:3px}.splide__slide{-webkit-tap-highlight-color:rgba(0,0,0,0)}.splide__slide:focus{outline:0}@supports(outline-offset: -3px){.splide__slide:focus-visible{outline:#0bf 3px solid;outline-offset:-3px}}@media screen and (-ms-high-contrast: none){.splide__slide:focus-visible{border:#0bf 3px solid}}@supports(outline-offset: -3px){.splide.is-focus-in .splide__slide:focus{outline:#0bf 3px solid;outline-offset:-3px}}@media screen and (-ms-high-contrast: none){.splide.is-focus-in .splide__slide:focus{border:#0bf 3px solid}}@media screen and (-ms-high-contrast: none){.splide.is-focus-in .splide__track>.splide__list>.splide__slide:focus{border-color:#0bf}}.splide__toggle{cursor:pointer}.splide__toggle:focus-visible{outline:#0bf 3px solid;outline-offset:3px}.splide.is-focus-in .splide__toggle:focus{outline:#0bf 3px solid;outline-offset:3px}.splide__track--nav>.splide__list>.splide__slide{border:3px solid rgba(0,0,0,0);cursor:pointer}.splide__track--nav>.splide__list>.splide__slide.is-active{border:3px solid #000}.splide__arrows--rtl .splide__arrow--prev{left:auto;right:1em}.splide__arrows--rtl .splide__arrow--prev svg{transform:scaleX(1)}.splide__arrows--rtl .splide__arrow--next{left:1em;right:auto}.splide__arrows--rtl .splide__arrow--next svg{transform:scaleX(-1)}.splide__arrows--ttb .splide__arrow{left:50%;transform:translate(-50%, 0)}.splide__arrows--ttb .splide__arrow--prev{top:1em}.splide__arrows--ttb .splide__arrow--prev svg{transform:rotateZ(-90deg)}.splide__arrows--ttb .splide__arrow--next{bottom:1em;top:auto}.splide__arrows--ttb .splide__arrow--next svg{transform:rotateZ(90deg)}.splide__pagination--ttb{bottom:0;display:flex;flex-direction:column;left:auto;padding:1em 0;right:.5em;top:0} \ No newline at end of file diff --git a/dist/css/themes/splide-sea-green.min.css b/dist/css/themes/splide-sea-green.min.css index 5d29b64b..a77db429 100644 --- a/dist/css/themes/splide-sea-green.min.css +++ b/dist/css/themes/splide-sea-green.min.css @@ -1 +1 @@ -.splide__track--nav>.splide__list>.splide__slide{border:3px solid transparent;border-radius:4px;cursor:pointer;opacity:.7}.splide__track--nav>.splide__list>.splide__slide.is-active{border:3px solid #20b2aa;opacity:1}.splide__arrows--ttb .splide__arrow{left:50%;transform:translate(-50%)}.splide__arrows--ttb .splide__arrow--prev{top:1em}.splide__arrows--ttb .splide__arrow--prev svg{transform:rotate(-90deg)}.splide__arrows--ttb .splide__arrow--next{bottom:1em;top:auto}.splide__arrows--ttb .splide__arrow--next svg{transform:rotate(90deg)}.splide__pagination--ttb{bottom:0;display:-ms-flexbox;display:flex;-ms-flex-direction:column;flex-direction:column;left:auto;padding:1em 0;right:1em;top:0}.splide__pagination--ttb .splide__pagination__page{height:20px;width:5px}.splide__arrow{-ms-flex-align:center;align-items:center;background:transparent;border:0;border-radius:0;cursor:pointer;display:-ms-flexbox;display:flex;height:2.5em;-ms-flex-pack:center;justify-content:center;padding:0;position:absolute;top:50%;transform:translateY(-50%);width:2.5em;z-index:1}.splide__arrow svg{fill:#20b2aa;height:2.5em;transition:fill .2s linear;width:2.5em}.splide__arrow:hover:not(:disabled) svg{fill:#57e1d9}.splide__arrow:disabled{opacity:.3}.splide__arrow:focus-visible{outline:3px solid #20b2aa;outline-offset:3px}.splide__arrow--prev{left:1em}.splide__arrow--prev svg{transform:scaleX(-1)}.splide__arrow--next{right:1em}.splide.is-focus-in .splide__arrow:focus{outline:3px solid #20b2aa;outline-offset:3px}.splide__pagination{bottom:1em;left:0;padding:0 1em;position:absolute;right:0;z-index:1}.splide__pagination__page{background:#ccc;border:0;border-radius:2.5px;display:inline-block;height:5px;margin:3px;padding:0;position:relative;transition:background-color .2s linear;width:20px}.splide__pagination__page.is-active{background:#20b2aa;z-index:1}.splide__pagination__page:hover{background:#57e1d9;cursor:pointer;opacity:.9}.splide__pagination__page:focus-visible{outline:3px solid #20b2aa;outline-offset:3px}.splide.is-focus-in .splide__pagination__page:focus{outline:3px solid #20b2aa;outline-offset:3px}.splide__slide{-webkit-tap-highlight-color:rgba(0,0,0,0);border-radius:4px}.splide__slide:focus{outline:0}@supports(outline-offset:-3px){.splide__slide:focus-visible{outline:3px solid #20b2aa;outline-offset:-3px}}@media screen and (-ms-high-contrast:none){.splide__slide:focus-visible{border:3px solid #20b2aa}}@supports(outline-offset:-3px){.splide.is-focus-in .splide__slide:focus{outline:3px solid #20b2aa;outline-offset:-3px}}@media screen and (-ms-high-contrast:none){.splide.is-focus-in .splide__slide:focus{border:3px solid #20b2aa}.splide.is-focus-in .splide__track>.splide__list>.splide__slide:focus{border-color:#20b2aa}}.splide__container{box-sizing:border-box;position:relative}.splide__list{backface-visibility:hidden;display:-ms-flexbox;display:flex;height:100%;margin:0!important;padding:0!important}.splide.is-initialized:not(.is-active) .splide__list{display:block}.splide__pagination{-ms-flex-align:center;align-items:center;display:-ms-flexbox;display:flex;-ms-flex-wrap:wrap;flex-wrap:wrap;-ms-flex-pack:center;justify-content:center;margin:0;pointer-events:none}.splide__pagination li{display:inline-block;line-height:1;list-style-type:none;margin:0;pointer-events:auto}.splide:not(.is-overflow) .splide__pagination{display:none}.splide__progress__bar{width:0}.splide{position:relative;visibility:hidden}.splide.is-initialized,.splide.is-rendered{visibility:visible}.splide__slide{backface-visibility:hidden;box-sizing:border-box;-ms-flex-negative:0;flex-shrink:0;list-style-type:none!important;margin:0;position:relative}.splide__slide img{vertical-align:bottom}.splide__spinner{animation:splide-loading 1s linear infinite;border:2px solid #20b2aa;border-left-color:transparent;border-radius:50%;bottom:0;contain:strict;display:inline-block;height:20px;left:0;margin:auto;position:absolute;right:0;top:0;width:20px}.splide__sr{clip:rect(0 0 0 0);border:0;height:1px;margin:-1px;overflow:hidden;padding:0;position:absolute;width:1px}.splide__toggle.is-active .splide__toggle__play,.splide__toggle__pause{display:none}.splide__toggle.is-active .splide__toggle__pause{display:inline}.splide__track{overflow:hidden;position:relative;z-index:0}@keyframes splide-loading{0%{transform:rotate(0)}to{transform:rotate(1turn)}}.splide__track--draggable{-webkit-touch-callout:none;-webkit-user-select:none;-ms-user-select:none;user-select:none}.splide__track--fade>.splide__list>.splide__slide{margin:0!important;opacity:0;z-index:0}.splide__track--fade>.splide__list>.splide__slide.is-active{opacity:1;z-index:1}.splide--rtl{direction:rtl}.splide__track--ttb>.splide__list{display:block}.splide__progress__bar{background:#ccc;height:3px}.splide__toggle{cursor:pointer}.splide__toggle:focus-visible{outline:3px solid #20b2aa;outline-offset:3px}.splide.is-focus-in .splide__toggle:focus{outline:3px solid #20b2aa;outline-offset:3px}.splide__arrows--rtl .splide__arrow--prev{left:auto;right:1em}.splide__arrows--rtl .splide__arrow--prev svg{transform:scaleX(1)}.splide__arrows--rtl .splide__arrow--next{left:1em;right:auto}.splide__arrows--rtl .splide__arrow--next svg{transform:scaleX(-1)}.splide__slider>.splide__arrows .splide__arrow--prev{left:-2.5em}.splide__slider>.splide__arrows .splide__arrow--next{right:-2.5em}.splide{padding:3em} \ No newline at end of file +.splide__track--nav>.splide__list>.splide__slide{border:3px solid rgba(0,0,0,0);cursor:pointer;opacity:.7;border-radius:4px}.splide__track--nav>.splide__list>.splide__slide.is-active{border:3px solid #20b2aa;opacity:1}.splide__arrows--ttb .splide__arrow{left:50%;transform:translate(-50%, 0)}.splide__arrows--ttb .splide__arrow--prev{top:1em}.splide__arrows--ttb .splide__arrow--prev svg{transform:rotateZ(-90deg)}.splide__arrows--ttb .splide__arrow--next{bottom:1em;top:auto}.splide__arrows--ttb .splide__arrow--next svg{transform:rotateZ(90deg)}.splide__pagination--ttb{bottom:0;display:flex;flex-direction:column;left:auto;padding:1em 0;right:1em;top:0}.splide__pagination--ttb .splide__pagination__page{width:5px;height:20px}.splide__arrow{background:rgba(0,0,0,0);border:0;cursor:pointer;padding:0;position:absolute;top:50%;transform:translateY(-50%);z-index:1;align-items:center;border-radius:0;display:flex;height:2.5em;justify-content:center;width:2.5em}.splide__arrow svg{fill:#20b2aa;height:2.5em;width:2.5em;transition:fill .2s linear}.splide__arrow:hover:not(:disabled) svg{fill:#57e1d9}.splide__arrow:disabled{opacity:.3}.splide__arrow:focus-visible{outline:#20b2aa 3px solid;outline-offset:3px}.splide__arrow--prev{left:1em}.splide__arrow--prev svg{transform:scaleX(-1)}.splide__arrow--next{right:1em}.splide.is-focus-in .splide__arrow:focus{outline:#20b2aa 3px solid;outline-offset:3px}.splide__pagination{bottom:1em;left:0;padding:0 1em;position:absolute;right:0;z-index:1}.splide__pagination__page{background:#ccc;border:0;border-radius:2.5px;display:inline-block;height:5px;margin:3px;padding:0;position:relative;transition:background-color .2s linear;width:20px}.splide__pagination__page.is-active{background:#20b2aa;z-index:1}.splide__pagination__page:hover{cursor:pointer;opacity:.9;background:#57e1d9}.splide__pagination__page:focus-visible{outline:#20b2aa 3px solid;outline-offset:3px}.splide.is-focus-in .splide__pagination__page:focus{outline:#20b2aa 3px solid;outline-offset:3px}.splide__slide{-webkit-tap-highlight-color:rgba(0,0,0,0);border-radius:4px}.splide__slide:focus{outline:0}@supports(outline-offset: -3px){.splide__slide:focus-visible{outline:#20b2aa 3px solid;outline-offset:-3px}}@media screen and (-ms-high-contrast: none){.splide__slide:focus-visible{border:#20b2aa 3px solid}}@supports(outline-offset: -3px){.splide.is-focus-in .splide__slide:focus{outline:#20b2aa 3px solid;outline-offset:-3px}}@media screen and (-ms-high-contrast: none){.splide.is-focus-in .splide__slide:focus{border:#20b2aa 3px solid}}@media screen and (-ms-high-contrast: none){.splide.is-focus-in .splide__track>.splide__list>.splide__slide:focus{border-color:#20b2aa}}.splide__container{box-sizing:border-box;position:relative}.splide__list{backface-visibility:hidden;display:flex;height:100%;margin:0 !important;padding:0 !important}.splide.is-initialized:not(.is-active) .splide__list{display:block}.splide__pagination{align-items:center;display:flex;flex-wrap:wrap;justify-content:center;margin:0;pointer-events:none}.splide__pagination li{display:inline-block;line-height:1;list-style-type:none;margin:0;pointer-events:auto}.splide:not(.is-overflow) .splide__pagination{display:none}.splide__progress__bar{width:0}.splide{position:relative;visibility:hidden}.splide.is-initialized,.splide.is-rendered{visibility:visible}.splide__slide{backface-visibility:hidden;box-sizing:border-box;flex-shrink:0;list-style-type:none !important;margin:0;position:relative}.splide__slide img{vertical-align:bottom}.splide__spinner{animation:splide-loading 1s infinite linear;border:2px solid #20b2aa;border-left-color:rgba(0,0,0,0);border-radius:50%;bottom:0;contain:strict;display:inline-block;height:20px;left:0;margin:auto;position:absolute;right:0;top:0;width:20px}.splide__sr{border:0 !important;clip:rect(0 0 0 0) !important;height:1px !important;margin:-1px !important;overflow:hidden !important;padding:0 !important;position:absolute !important;width:1px !important}.splide__toggle__pause{display:none}.splide__toggle.is-active .splide__toggle__play{display:none}.splide__toggle.is-active .splide__toggle__pause{display:inline}.splide__track{overflow:hidden;position:relative;z-index:0}@keyframes splide-loading{0%{transform:rotateZ(0)}100%{transform:rotateZ(360deg)}}.splide__track--draggable{-webkit-touch-callout:none;user-select:none}.splide__track--fade>.splide__list>.splide__slide{margin:0 !important;opacity:0;z-index:0}.splide__track--fade>.splide__list>.splide__slide.is-active{opacity:1;z-index:1}.splide--rtl{direction:rtl}.splide__track--ttb>.splide__list{display:block}.splide__progress__bar{background:#ccc;height:3px}.splide__toggle{cursor:pointer}.splide__toggle:focus-visible{outline:#20b2aa 3px solid;outline-offset:3px}.splide.is-focus-in .splide__toggle:focus{outline:#20b2aa 3px solid;outline-offset:3px}.splide__arrows--rtl .splide__arrow--prev{left:auto;right:1em}.splide__arrows--rtl .splide__arrow--prev svg{transform:scaleX(1)}.splide__arrows--rtl .splide__arrow--next{left:1em;right:auto}.splide__arrows--rtl .splide__arrow--next svg{transform:scaleX(-1)}.splide__slider>.splide__arrows .splide__arrow--prev{left:-2.5em}.splide__slider>.splide__arrows .splide__arrow--next{right:-2.5em}.splide{padding:3em} \ No newline at end of file diff --git a/dist/css/themes/splide-skyblue.min.css b/dist/css/themes/splide-skyblue.min.css index f3a4e75f..b1b9750e 100644 --- a/dist/css/themes/splide-skyblue.min.css +++ b/dist/css/themes/splide-skyblue.min.css @@ -1 +1 @@ -.splide__track--nav>.splide__list>.splide__slide{border:3px solid transparent;cursor:pointer;opacity:.7}.splide__track--nav>.splide__list>.splide__slide.is-active{border:3px solid #00bfff;opacity:1}.splide__arrow{-ms-flex-align:center;align-items:center;background:transparent;border:0;border-radius:0;cursor:pointer;display:-ms-flexbox;display:flex;height:2.5em;-ms-flex-pack:center;justify-content:center;padding:0;position:absolute;top:50%;transform:translateY(-50%);width:2.5em;z-index:1}.splide__arrow svg{fill:#00bfff;height:2.5em;transition:fill .2s linear;width:2.5em}.splide__arrow:hover:not(:disabled) svg{fill:#66d9ff}.splide__arrow:disabled{opacity:.3}.splide__arrow:focus-visible{outline:3px solid #00bfff;outline-offset:3px}.splide__arrow--prev{left:1em}.splide__arrow--prev svg{transform:scaleX(-1)}.splide__arrow--next{right:1em}.splide.is-focus-in .splide__arrow:focus{outline:3px solid #00bfff;outline-offset:3px}.splide__pagination{bottom:.5em;left:0;padding:0 1em;position:absolute;right:0;z-index:1}.splide__pagination__page{background:#ccc;border:0;border-radius:50%;display:inline-block;height:10px;margin:3px;padding:0;position:relative;transition:background-color .2s linear,transform .2s linear;width:10px}.splide__pagination__page.is-active{background:#00bfff;transform:scale(1.4);z-index:1}.splide__pagination__page:hover{background:#66d9ff;cursor:pointer;opacity:.9}.splide__pagination__page:focus-visible{outline:3px solid #00bfff;outline-offset:3px}.splide.is-focus-in .splide__pagination__page:focus{outline:3px solid #00bfff;outline-offset:3px}.splide__container{box-sizing:border-box;position:relative}.splide__list{backface-visibility:hidden;display:-ms-flexbox;display:flex;height:100%;margin:0!important;padding:0!important}.splide.is-initialized:not(.is-active) .splide__list{display:block}.splide__pagination{-ms-flex-align:center;align-items:center;display:-ms-flexbox;display:flex;-ms-flex-wrap:wrap;flex-wrap:wrap;-ms-flex-pack:center;justify-content:center;margin:0;pointer-events:none}.splide__pagination li{display:inline-block;line-height:1;list-style-type:none;margin:0;pointer-events:auto}.splide:not(.is-overflow) .splide__pagination{display:none}.splide__progress__bar{width:0}.splide{position:relative;visibility:hidden}.splide.is-initialized,.splide.is-rendered{visibility:visible}.splide__slide{backface-visibility:hidden;box-sizing:border-box;-ms-flex-negative:0;flex-shrink:0;list-style-type:none!important;margin:0;position:relative}.splide__slide img{vertical-align:bottom}.splide__spinner{animation:splide-loading 1s linear infinite;border:2px solid #00bfff;border-left-color:transparent;border-radius:50%;bottom:0;contain:strict;display:inline-block;height:20px;left:0;margin:auto;position:absolute;right:0;top:0;width:20px}.splide__sr{clip:rect(0 0 0 0);border:0;height:1px;margin:-1px;overflow:hidden;padding:0;position:absolute;width:1px}.splide__toggle.is-active .splide__toggle__play,.splide__toggle__pause{display:none}.splide__toggle.is-active .splide__toggle__pause{display:inline}.splide__track{overflow:hidden;position:relative;z-index:0}@keyframes splide-loading{0%{transform:rotate(0)}to{transform:rotate(1turn)}}.splide__track--draggable{-webkit-touch-callout:none;-webkit-user-select:none;-ms-user-select:none;user-select:none}.splide__track--fade>.splide__list>.splide__slide{margin:0!important;opacity:0;z-index:0}.splide__track--fade>.splide__list>.splide__slide.is-active{opacity:1;z-index:1}.splide--rtl{direction:rtl}.splide__track--ttb>.splide__list{display:block}.splide__progress__bar{background:#ccc;height:3px}.splide__slide{-webkit-tap-highlight-color:rgba(0,0,0,0)}.splide__slide:focus{outline:0}@supports(outline-offset:-3px){.splide__slide:focus-visible{outline:3px solid #00bfff;outline-offset:-3px}}@media screen and (-ms-high-contrast:none){.splide__slide:focus-visible{border:3px solid #00bfff}}@supports(outline-offset:-3px){.splide.is-focus-in .splide__slide:focus{outline:3px solid #00bfff;outline-offset:-3px}}@media screen and (-ms-high-contrast:none){.splide.is-focus-in .splide__slide:focus{border:3px solid #00bfff}.splide.is-focus-in .splide__track>.splide__list>.splide__slide:focus{border-color:#00bfff}}.splide__toggle{cursor:pointer}.splide__toggle:focus-visible{outline:3px solid #00bfff;outline-offset:3px}.splide.is-focus-in .splide__toggle:focus{outline:3px solid #00bfff;outline-offset:3px}.splide__arrows--rtl .splide__arrow--prev{left:auto;right:1em}.splide__arrows--rtl .splide__arrow--prev svg{transform:scaleX(1)}.splide__arrows--rtl .splide__arrow--next{left:1em;right:auto}.splide__arrows--rtl .splide__arrow--next svg{transform:scaleX(-1)}.splide__arrows--ttb .splide__arrow{left:50%;transform:translate(-50%)}.splide__arrows--ttb .splide__arrow--prev{top:1em}.splide__arrows--ttb .splide__arrow--prev svg{transform:rotate(-90deg)}.splide__arrows--ttb .splide__arrow--next{bottom:1em;top:auto}.splide__arrows--ttb .splide__arrow--next svg{transform:rotate(90deg)}.splide__pagination--ttb{bottom:0;display:-ms-flexbox;display:flex;-ms-flex-direction:column;flex-direction:column;left:auto;padding:1em 0;right:.5em;top:0} \ No newline at end of file +.splide__track--nav>.splide__list>.splide__slide{border:3px solid rgba(0,0,0,0);cursor:pointer;opacity:.7}.splide__track--nav>.splide__list>.splide__slide.is-active{border:3px solid #00bfff;opacity:1}.splide__arrow{background:rgba(0,0,0,0);border:0;cursor:pointer;padding:0;position:absolute;top:50%;transform:translateY(-50%);z-index:1;align-items:center;border-radius:0;display:flex;height:2.5em;justify-content:center;width:2.5em}.splide__arrow svg{fill:#00bfff;height:2.5em;width:2.5em;transition:fill .2s linear}.splide__arrow:hover:not(:disabled) svg{fill:#66d9ff}.splide__arrow:disabled{opacity:.3}.splide__arrow:focus-visible{outline:#00bfff 3px solid;outline-offset:3px}.splide__arrow--prev{left:1em}.splide__arrow--prev svg{transform:scaleX(-1)}.splide__arrow--next{right:1em}.splide.is-focus-in .splide__arrow:focus{outline:#00bfff 3px solid;outline-offset:3px}.splide__pagination{bottom:.5em;left:0;padding:0 1em;position:absolute;right:0;z-index:1}.splide__pagination__page{background:#ccc;border:0;border-radius:50%;display:inline-block;height:10px;margin:3px;padding:0;position:relative;transition:background-color .2s linear,transform .2s linear;width:10px}.splide__pagination__page.is-active{background:#00bfff;z-index:1;transform:scale(1.4)}.splide__pagination__page:hover{cursor:pointer;opacity:.9;background:#66d9ff}.splide__pagination__page:focus-visible{outline:#00bfff 3px solid;outline-offset:3px}.splide.is-focus-in .splide__pagination__page:focus{outline:#00bfff 3px solid;outline-offset:3px}.splide__container{box-sizing:border-box;position:relative}.splide__list{backface-visibility:hidden;display:flex;height:100%;margin:0 !important;padding:0 !important}.splide.is-initialized:not(.is-active) .splide__list{display:block}.splide__pagination{align-items:center;display:flex;flex-wrap:wrap;justify-content:center;margin:0;pointer-events:none}.splide__pagination li{display:inline-block;line-height:1;list-style-type:none;margin:0;pointer-events:auto}.splide:not(.is-overflow) .splide__pagination{display:none}.splide__progress__bar{width:0}.splide{position:relative;visibility:hidden}.splide.is-initialized,.splide.is-rendered{visibility:visible}.splide__slide{backface-visibility:hidden;box-sizing:border-box;flex-shrink:0;list-style-type:none !important;margin:0;position:relative}.splide__slide img{vertical-align:bottom}.splide__spinner{animation:splide-loading 1s infinite linear;border:2px solid #00bfff;border-left-color:rgba(0,0,0,0);border-radius:50%;bottom:0;contain:strict;display:inline-block;height:20px;left:0;margin:auto;position:absolute;right:0;top:0;width:20px}.splide__sr{border:0 !important;clip:rect(0 0 0 0) !important;height:1px !important;margin:-1px !important;overflow:hidden !important;padding:0 !important;position:absolute !important;width:1px !important}.splide__toggle__pause{display:none}.splide__toggle.is-active .splide__toggle__play{display:none}.splide__toggle.is-active .splide__toggle__pause{display:inline}.splide__track{overflow:hidden;position:relative;z-index:0}@keyframes splide-loading{0%{transform:rotateZ(0)}100%{transform:rotateZ(360deg)}}.splide__track--draggable{-webkit-touch-callout:none;user-select:none}.splide__track--fade>.splide__list>.splide__slide{margin:0 !important;opacity:0;z-index:0}.splide__track--fade>.splide__list>.splide__slide.is-active{opacity:1;z-index:1}.splide--rtl{direction:rtl}.splide__track--ttb>.splide__list{display:block}.splide__progress__bar{background:#ccc;height:3px}.splide__slide{-webkit-tap-highlight-color:rgba(0,0,0,0)}.splide__slide:focus{outline:0}@supports(outline-offset: -3px){.splide__slide:focus-visible{outline:#00bfff 3px solid;outline-offset:-3px}}@media screen and (-ms-high-contrast: none){.splide__slide:focus-visible{border:#00bfff 3px solid}}@supports(outline-offset: -3px){.splide.is-focus-in .splide__slide:focus{outline:#00bfff 3px solid;outline-offset:-3px}}@media screen and (-ms-high-contrast: none){.splide.is-focus-in .splide__slide:focus{border:#00bfff 3px solid}}@media screen and (-ms-high-contrast: none){.splide.is-focus-in .splide__track>.splide__list>.splide__slide:focus{border-color:#00bfff}}.splide__toggle{cursor:pointer}.splide__toggle:focus-visible{outline:#00bfff 3px solid;outline-offset:3px}.splide.is-focus-in .splide__toggle:focus{outline:#00bfff 3px solid;outline-offset:3px}.splide__arrows--rtl .splide__arrow--prev{left:auto;right:1em}.splide__arrows--rtl .splide__arrow--prev svg{transform:scaleX(1)}.splide__arrows--rtl .splide__arrow--next{left:1em;right:auto}.splide__arrows--rtl .splide__arrow--next svg{transform:scaleX(-1)}.splide__arrows--ttb .splide__arrow{left:50%;transform:translate(-50%, 0)}.splide__arrows--ttb .splide__arrow--prev{top:1em}.splide__arrows--ttb .splide__arrow--prev svg{transform:rotateZ(-90deg)}.splide__arrows--ttb .splide__arrow--next{bottom:1em;top:auto}.splide__arrows--ttb .splide__arrow--next svg{transform:rotateZ(90deg)}.splide__pagination--ttb{bottom:0;display:flex;flex-direction:column;left:auto;padding:1em 0;right:.5em;top:0} \ No newline at end of file diff --git a/dist/js/splide-renderer.min.js b/dist/js/splide-renderer.min.js deleted file mode 100644 index acd581f5..00000000 --- a/dist/js/splide-renderer.min.js +++ /dev/null @@ -1,8 +0,0 @@ -/*! - * Splide.js - * Version : 4.1.3 - * License : MIT - * Copyright: 2022 Naotoshi Fujita - */ -var t,n;t=this,n=function(){"use strict";var s="rtl",u="ttb",o={width:["height"],left:["top","right"],right:["bottom","left"],x:["y"],X:["Y"],Y:["X"],ArrowLeft:["ArrowUp","ArrowRight"],ArrowRight:["ArrowDown","ArrowLeft"]};function e(t,n,e){return{resolve:function(t,n,i){var r=(i=i||e.direction)!==s||n?i===u?0:-1:1;return o[t]&&o[t][r]||t.replace(/width|left|right/i,function(t,n){t=o[t.toLowerCase()][r]||t;return 0 img","display",t.cover?"none":"inline",n)})},n.buildTranslate=function(t){var n=this.Direction,i=n.resolve,n=n.orient,r=[];return r.push(this.cssOffsetClones(t)),r.push(this.cssOffsetGaps(t)),this.isCenter(t)&&(r.push(this.buildCssValue(n(-50),"%")),r.push.apply(r,this.cssOffsetCenter(t))),r.filter(Boolean).map(function(t){return"translate"+i("X")+"("+t+")"}).join(" ")},n.cssOffsetClones=function(t){var n,i=this.Direction,r=i.resolve,i=i.orient,e=this.getCloneCount();return this.isFixedWidth(t)?(n=(r=this.parseCssValue(t[r("fixedWidth")])).value,r=r.unit,this.buildCssValue(i(n)*e,r)):i(100*e/t.perPage)+"%"},n.cssOffsetCenter=function(t){var n,i,r=this.Direction,e=r.resolve,r=r.orient;return this.isFixedWidth(t)?(n=(e=this.parseCssValue(t[e("fixedWidth")])).value,e=e.unit,[this.buildCssValue(r(n/2),e)]):(n=t.perPage,e=t.gap,(t=[]).push(r(50/n)+"%"),e&&(i=(e=this.parseCssValue(e)).value,e=e.unit,t.push(this.buildCssValue(r((i/n-i)/2),e))),t)},n.cssOffsetGaps=function(t){var n,i,r,e=this.getCloneCount();return e&&t.gap?(n=this.Direction.orient,i=(r=this.parseCssValue(t.gap)).value,r=r.unit,this.isFixedWidth(t)?this.buildCssValue(n(i*e),r):(t=t.perPage,this.buildCssValue(n(e/t*i),r))):""},n.resolve=function(t){return T(this.Direction.resolve(t))},n.cssPadding=function(t,n){t=t.padding,n=this.Direction.resolve(n?"right":"left",!0);return t&&G(t[n]||(b(t)?0:t))||"0px"},n.cssTrackHeight=function(t){var n="";return this.isVertical()&&(O(n=this.cssHeight(t),'"height" is missing.'),n="calc("+n+" - "+this.cssPadding(t,!1)+" - "+this.cssPadding(t,!0)+")"),n},n.cssHeight=function(t){return G(t.height)},n.cssSlideWidth=function(t){return t.autoWidth?"":G(t.fixedWidth)||(this.isVertical()?"":this.cssSlideSize(t))},n.cssSlideHeight=function(t){return G(t.fixedHeight)||(this.isVertical()?t.autoHeight?"":this.cssSlideSize(t):this.cssHeight(t))},n.cssSlideSize=function(t){var n=G(t.gap);return"calc((100%"+(n&&" + "+n)+")/"+(t.perPage||1)+(n&&" - "+n)+")"},n.cssAspectRatio=function(t){t=t.heightRatio;return t?""+1/t:""},n.buildCssValue=function(t,n){return""+t+n},n.parseCssValue=function(t){return y(t)?{value:parseFloat(t)||0,unit:t.replace(/\d*(\.\d*)?/,"")||"px"}:{value:t,unit:"px"}},n.parseBreakpoints=function(){var i=this,t=this.options.breakpoints;this.breakpoints.push(["default",this.options]),t&&P(t,function(t,n){i.breakpoints.push([n,X(X({},i.options),t)])})},n.isFixedWidth=function(t){return!!t[this.Direction.resolve("fixedWidth")]},n.isLoop=function(){return"loop"===this.options.type},n.isCenter=function(t){if("center"===t.focus){if(this.isLoop())return!0;if("slide"===this.options.type)return!this.options.trimSpace}return!1},n.isVertical=function(){return this.options.direction===u},n.buildClasses=function(){var t=this.options;return[r,r+"--"+t.type,r+"--"+t.direction,t.drag&&r+"--draggable",t.isNavigation&&r+"--nav",d,!this.config.hidden&&"is-rendered"].filter(Boolean).join(" ")},n.buildAttrs=function(t){var i="";return P(t,function(t,n){i+=t?" "+T(n)+'="'+t+'"':""}),i.trim()},n.buildStyles=function(t){var i="";return P(t,function(t,n){i+=" "+T(n)+":"+t+";"}),i.trim()},n.renderSlides=function(){var n=this,i=this.config.slideTag;return this.slides.map(function(t){return"<"+i+" "+n.buildAttrs(t.attrs)+">"+(t.html||"")+""}).join("")},n.cover=function(t){var n=t.styles,t=t.html,t=void 0===t?"":t;this.options.cover&&!this.options.lazyLoad&&(t=t.match(//))&&t[2]&&(n.background="center/cover no-repeat url('"+t[2]+"')")},n.generateClones=function(r){for(var e=this.options.classes,s=this.getCloneCount(),t=r.slice();t.length')+this.renderArrow(!0)+this.renderArrow(!1)+"
"},n.renderArrow=function(t){var n=this.options,i=n.classes,n=n.i18n,i={class:i.arrow+" "+(t?i.prev:i.next),type:"button",ariaLabel:t?n.prev:n.next};return"'},n.html=function(){var t=this.config,n=t.rootClass,i=t.listTag,r=t.arrows,e=t.beforeTrack,s=t.afterTrack,u=t.slider,o=t.beforeSlider,t=t.afterSlider,a="";return a=(a+='
')+(""),u&&(a=a+(o||"")+'
'),a+=e||"",r&&(a+=this.renderArrows()),a=(a=(a=a+'
'+("<"+i+' class="splide__list">'))+this.renderSlides()+(""))+"
"+(s||""),u&&(a=a+"
"+(t||"")),a+="
"},t}()},"object"==typeof exports&&"undefined"!=typeof module?module.exports=n():"function"==typeof define&&define.amd?define(n):(t="undefined"!=typeof globalThis?globalThis:t||self).SplideRenderer=n(); -//# sourceMappingURL=splide-renderer.min.js.map diff --git a/dist/js/splide-renderer.min.js.map b/dist/js/splide-renderer.min.js.map deleted file mode 100644 index 4c3cfa44..00000000 --- a/dist/js/splide-renderer.min.js.map +++ /dev/null @@ -1 +0,0 @@ -{"version":3,"file":"splide-renderer.min.js","sources":["../../src/js/components/Arrows/path.ts","../../src/js/constants/directions.ts","../../src/js/components/Direction/Direction.ts","../../src/js/constants/arrows.ts","../../src/js/constants/project.ts","../../src/js/constants/classes.ts","../../src/js/constants/defaults.ts","../../src/js/constants/i18n.ts","../../src/js/utils/arrayLike/slice/slice.ts","../../src/js/utils/function/apply/apply.ts","../../src/js/utils/type/type.ts","../../src/js/utils/array/toArray/toArray.ts","../../src/js/utils/array/forEach/forEach.ts","../../src/js/utils/array/push/push.ts","../../src/js/utils/dom/matches/matches.ts","../../src/js/utils/dom/child/child.ts","../../src/js/utils/dom/children/children.ts","../../src/js/utils/object/ownKeys/ownKeys.ts","../../src/js/utils/object/forOwn/forOwn.ts","../../src/js/utils/object/assign/assign.ts","../../src/js/utils/object/merge/merge.ts","../../src/js/utils/dom/remove/remove.ts","../../src/js/utils/dom/unit/unit.ts","../../src/js/utils/error/assert/assert.ts","../../src/js/utils/math/math/math.ts","../../src/js/utils/string/camelToKebab/camelToKebab.ts","../../src/js/utils/string/uniqueId/uniqueId.ts","../../src/js/constructors/EventBinder/EventBinder.ts","../../src/js/utils/array/empty/empty.ts","../../src/js/constructors/EventInterface/EventInterface.ts","../../src/js/constants/events.ts","../../src/js/renderer/constants/classes.ts","../../src/js/renderer/constants/defaults.ts","../../src/js/renderer/Style/Style.ts","../../src/js/renderer/SplideRenderer/SplideRenderer.ts","../../src/js/utils/string/pad/pad.ts","../../src/js/utils/dom/queryAll/queryAll.ts","../../src/js/constants/types.ts"],"sourcesContent":["/**\r\n * The namespace for SVG elements.\r\n */\r\nexport const XML_NAME_SPACE = 'http://www.w3.org/2000/svg';\r\n\r\n/**\r\n * The arrow path.\r\n */\r\nexport const PATH = 'm15.5 0.932-4.3 4.38 14.5 14.6-14.5 14.5 4.3 4.4 14.6-14.6 4.4-4.3-4.4-4.4-14.6-14.6z';\r\n\r\n/**\r\n * SVG width and height.\r\n */\r\nexport const SIZE = 40;\r\n","/**\r\n * Enumerates slides from left to right.\r\n */\r\nexport const LTR = 'ltr';\r\n\r\n/**\r\n * Enumerates slides from right to left.\r\n */\r\nexport const RTL = 'rtl';\r\n\r\n/**\r\n * Enumerates slides in a col.\r\n */\r\nexport const TTB = 'ttb';\r\n","import { ARROW_DOWN, ARROW_LEFT, ARROW_RIGHT, ARROW_UP } from '../../constants/arrows';\r\nimport { RTL, TTB } from '../../constants/directions';\r\nimport { Splide } from '../../core/Splide/Splide';\r\nimport { BaseComponent, Components, Options } from '../../types';\r\n\r\n\r\n/**\r\n * The interface for the Direction component.\r\n *\r\n * @since 3.0.0\r\n */\r\nexport interface DirectionComponent extends BaseComponent {\r\n resolve( prop: string, axisOnly?: boolean, direction?: Options['direction'] ): string;\r\n orient( value: number ): number;\r\n}\r\n\r\n/**\r\n * The translation map for directions.\r\n *\r\n * @since 3.0.0\r\n */\r\nexport const ORIENTATION_MAP = {\r\n width : [ 'height' ],\r\n left : [ 'top', 'right' ],\r\n right : [ 'bottom', 'left' ],\r\n x : [ 'y' ],\r\n X : [ 'Y' ],\r\n Y : [ 'X' ],\r\n ArrowLeft : [ ARROW_UP, ARROW_RIGHT ],\r\n ArrowRight: [ ARROW_DOWN, ARROW_LEFT ],\r\n};\r\n\r\n/**\r\n * The component that absorbs the difference among directions.\r\n *\r\n * @since 3.0.0\r\n *\r\n * @param Splide - A Splide instance.\r\n * @param Components - A collection of components.\r\n * @param options - Options.\r\n *\r\n * @return A Direction component object.\r\n */\r\nexport function Direction( Splide: Splide, Components: Components, options: Options ): DirectionComponent {\r\n /**\r\n * Resolves the provided property name.\r\n *\r\n * @param prop - A property name to translate.\r\n * @param axisOnly - Optional. If `ture`, returns the same property for LTR and RTL.\r\n * @param direction - Optional. Specify the direction. The default value is the `direction` option.\r\n */\r\n function resolve( prop: string, axisOnly?: boolean, direction?: Options['direction'] ): string {\r\n direction = direction || options.direction;\r\n const index = direction === RTL && ! axisOnly ? 1 : direction === TTB ? 0 : -1;\r\n\r\n return ORIENTATION_MAP[ prop ] && ORIENTATION_MAP[ prop ][ index ]\r\n || prop.replace( /width|left|right/i, ( match, offset ) => {\r\n const replacement = ORIENTATION_MAP[ match.toLowerCase() ][ index ] || match;\r\n return offset > 0 ? replacement.charAt( 0 ).toUpperCase() + replacement.slice( 1 ) : replacement;\r\n } );\r\n }\r\n\r\n /**\r\n * Orients the value towards the current direction.\r\n *\r\n * @param value - A value to orient.\r\n *\r\n * @return The oriented value.\r\n */\r\n function orient( value: number ): number {\r\n return value * ( options.direction === RTL ? 1 : -1 );\r\n }\r\n\r\n return {\r\n resolve,\r\n orient,\r\n };\r\n}\r\n","const ARROW = 'Arrow';\r\nexport const ARROW_LEFT = `${ ARROW }Left`;\r\nexport const ARROW_RIGHT = `${ ARROW }Right`;\r\nexport const ARROW_UP = `${ ARROW }Up`;\r\nexport const ARROW_DOWN = `${ ARROW }Down`;","/**\r\n * The project code.\r\n *\r\n * @since 3.0.0\r\n */\r\nexport const PROJECT_CODE = 'splide';\r\n\r\n/**\r\n * The data attribute prefix.\r\n *\r\n * @since 3.0.0\r\n */\r\nexport const DATA_ATTRIBUTE = `data-${ PROJECT_CODE }`;\r\n","import { PROJECT_CODE } from './project';\r\n\r\n/**\r\n * The prefix for classes.\r\n *\r\n * @since 4.1.0\r\n */\r\nconst CLASS_PREFIX = `${ PROJECT_CODE }__`;\r\n\r\n/**\r\n * The prefix for status classes.\r\n *\r\n * @since 4.1.0\r\n */\r\nconst STATUS_CLASS_PREFIX = 'is-';\r\n\r\n/**\r\n * All classes as constants.\r\n */\r\nexport const CLASS_ROOT = PROJECT_CODE;\r\nexport const CLASS_TRACK = `${ CLASS_PREFIX }track`;\r\nexport const CLASS_LIST = `${ CLASS_PREFIX }list`;\r\nexport const CLASS_SLIDE = `${ CLASS_PREFIX }slide`;\r\nexport const CLASS_CLONE = `${ CLASS_SLIDE }--clone`;\r\nexport const CLASS_CONTAINER = `${ CLASS_SLIDE }__container`;\r\nexport const CLASS_ARROWS = `${ CLASS_PREFIX }arrows`;\r\nexport const CLASS_ARROW = `${ CLASS_PREFIX }arrow`;\r\nexport const CLASS_ARROW_PREV = `${ CLASS_ARROW }--prev`;\r\nexport const CLASS_ARROW_NEXT = `${ CLASS_ARROW }--next`;\r\nexport const CLASS_PAGINATION = `${ CLASS_PREFIX }pagination`;\r\nexport const CLASS_PAGINATION_PAGE = `${ CLASS_PAGINATION }__page`;\r\nexport const CLASS_PROGRESS = `${ CLASS_PREFIX }progress`;\r\nexport const CLASS_PROGRESS_BAR = `${ CLASS_PROGRESS }__bar`;\r\nexport const CLASS_TOGGLE = `${ CLASS_PREFIX }toggle`;\r\nexport const CLASS_TOGGLE_PLAY = `${ CLASS_TOGGLE }__play`;\r\nexport const CLASS_TOGGLE_PAUSE = `${ CLASS_TOGGLE }__pause`;\r\nexport const CLASS_SPINNER = `${ CLASS_PREFIX }spinner`;\r\nexport const CLASS_SR = `${ CLASS_PREFIX }sr`;\r\nexport const CLASS_INITIALIZED = `${ STATUS_CLASS_PREFIX }initialized`;\r\nexport const CLASS_ACTIVE = `${ STATUS_CLASS_PREFIX }active`;\r\nexport const CLASS_PREV = `${ STATUS_CLASS_PREFIX }prev`;\r\nexport const CLASS_NEXT = `${ STATUS_CLASS_PREFIX }next`;\r\nexport const CLASS_VISIBLE = `${ STATUS_CLASS_PREFIX }visible`;\r\nexport const CLASS_LOADING = `${ STATUS_CLASS_PREFIX }loading`;\r\nexport const CLASS_FOCUS_IN = `${ STATUS_CLASS_PREFIX }focus-in`;\r\nexport const CLASS_OVERFLOW = `${ STATUS_CLASS_PREFIX }overflow`;\r\n\r\n/**\r\n * The array with all status classes except for `is-initialized`.\r\n *\r\n * @since 3.0.0\r\n */\r\nexport const STATUS_CLASSES = [\r\n CLASS_ACTIVE,\r\n CLASS_VISIBLE,\r\n CLASS_PREV,\r\n CLASS_NEXT,\r\n CLASS_LOADING,\r\n CLASS_FOCUS_IN,\r\n CLASS_OVERFLOW,\r\n];\r\n\r\n/**\r\n * The collection of classes for elements that Splide dynamically creates.\r\n *\r\n * @since 3.0.0\r\n */\r\nexport const CLASSES = {\r\n slide : CLASS_SLIDE,\r\n clone : CLASS_CLONE,\r\n arrows : CLASS_ARROWS,\r\n arrow : CLASS_ARROW,\r\n prev : CLASS_ARROW_PREV,\r\n next : CLASS_ARROW_NEXT,\r\n pagination: CLASS_PAGINATION,\r\n page : CLASS_PAGINATION_PAGE,\r\n spinner : CLASS_SPINNER,\r\n};\r\n","import { Options } from '../types';\r\nimport { CLASSES } from './classes';\r\nimport { I18N } from './i18n';\r\n\r\n\r\n/**\r\n * The collection of default options.\r\n * Note that this collection does not contain all options.\r\n *\r\n * @since 3.0.0\r\n */\r\nexport const DEFAULTS: Options = {\r\n type : 'slide',\r\n role : 'region',\r\n speed : 400,\r\n perPage : 1,\r\n cloneStatus : true,\r\n arrows : true,\r\n pagination : true,\r\n paginationKeyboard: true,\r\n interval : 5000,\r\n pauseOnHover : true,\r\n pauseOnFocus : true,\r\n resetProgress : true,\r\n easing : 'cubic-bezier(0.25, 1, 0.5, 1)',\r\n drag : true,\r\n direction : 'ltr',\r\n trimSpace : true,\r\n focusableNodes : 'a, button, textarea, input, select, iframe',\r\n live : true,\r\n classes : CLASSES,\r\n i18n : I18N,\r\n reducedMotion: {\r\n speed : 0,\r\n rewindSpeed: 0,\r\n autoplay : 'pause',\r\n },\r\n};","/**\r\n * The collection of i18n strings.\r\n *\r\n * @since 3.0.0\r\n */\r\nexport const I18N = {\r\n prev : 'Previous slide',\r\n next : 'Next slide',\r\n first : 'Go to first slide',\r\n last : 'Go to last slide',\r\n slideX : 'Go to slide %s',\r\n pageX : 'Go to page %s',\r\n play : 'Start autoplay',\r\n pause : 'Pause autoplay',\r\n carousel : 'carousel',\r\n slide : 'slide',\r\n select : 'Select a slide to show',\r\n slideLabel: '%s of %s', // [ slide number ] / [ slide size ]\r\n};\r\n","/**\r\n * The slice method for an array-like object.\r\n *\r\n * @param arrayLike - An array-like object.\r\n * @param start - Optional. A start index.\r\n * @param end - Optional. A end index.\r\n *\r\n * @return An array with sliced elements.\r\n */\r\nexport function slice( arrayLike: ArrayLike, start?: number, end?: number ): T[] {\r\n return Array.prototype.slice.call( arrayLike, start, end );\r\n}\r\n","import { AnyFunction, ShiftN } from '../../../types';\r\nimport { slice } from '../../arrayLike';\r\n\r\n\r\n/**\r\n * Create a function where provided arguments are bound.\r\n * `this` parameter will be always null.\r\n *\r\n * @param func - A function.\r\n * @param args - Arguments to bind to the function.\r\n *\r\n * @return A function where arguments are bound.\r\n */\r\nexport function apply(\r\n func: F,\r\n ...args: A\r\n): ( ...args: ShiftN, A[\"length\"]> ) => ReturnType;\r\n\r\n/**\r\n * Create a function where provided arguments are bound.\r\n * `this` parameter will be always null.\r\n *\r\n * @param func - A function.\r\n */\r\nexport function apply( func: AnyFunction ): any {\r\n // eslint-disable-next-line prefer-rest-params, prefer-spread\r\n return func.bind( null, ...slice( arguments, 1 ) );\r\n}\r\n","import { AnyFunction } from '../../types';\r\nimport { apply } from '../function';\r\n\r\n\r\n/**\r\n * The alias of the type check function.\r\n *\r\n * @param type - A type.\r\n * @param subject - A subject to check.\r\n *\r\n * @return `true` if the subject is the specified type.\r\n */\r\nfunction typeOf( type: string, subject: unknown ): boolean {\r\n return typeof subject === type;\r\n}\r\n\r\n/**\r\n * Checks if the given subject is an object or not.\r\n *\r\n * @param subject - A subject to check.\r\n *\r\n * @return `true` if the subject is an object, or otherwise `false`.\r\n */\r\nexport function isObject( subject: unknown ): subject is object {\r\n return ! isNull( subject ) && typeOf( 'object', subject );\r\n}\r\n\r\n/**\r\n * Checks if the given subject is an array or not.\r\n *\r\n * @param subject - A subject to check.\r\n *\r\n * @return `true` if the subject is an array, or otherwise `false`.\r\n */\r\nexport const isArray: ( subject: unknown ) => subject is T[] = Array.isArray;\r\n\r\n/**\r\n * Checks if the given subject is a function or not.\r\n *\r\n * @param subject - A subject to check.\r\n *\r\n * @return `true` if the subject is a function, or otherwise `false`.\r\n */\r\nexport const isFunction = <( subject: unknown ) => subject is AnyFunction>apply( typeOf, 'function' );\r\n\r\n/**\r\n * Checks if the given subject is a string or not.\r\n *\r\n * @param subject - A subject to check.\r\n *\r\n * @return `true` if the subject is a string, or otherwise `false`.\r\n */\r\nexport const isString = <( subject: unknown ) => subject is string>apply( typeOf, 'string' );\r\n\r\n/**\r\n * Checks if the given subject is `undefined` or not.\r\n *\r\n * @param subject - A subject to check.\r\n *\r\n * @return `true` if the subject is `undefined`, or otherwise `false`.\r\n */\r\nexport const isUndefined = <( subject: unknown ) => subject is undefined>apply( typeOf, 'undefined' );\r\n\r\n/**\r\n * Checks if the given subject is `null` or not.\r\n *\r\n * @param subject - A subject to check.\r\n *\r\n * @return `true` if the subject is `null`, or otherwise `false`.\r\n */\r\nexport function isNull( subject: unknown ): subject is null {\r\n return subject === null;\r\n}\r\n\r\n/**\r\n * Checks if the given subject is an HTMLElement instance or not.\r\n * This method takes into account which `window` the node belongs to.\r\n *\r\n * @param subject - A subject to check.\r\n *\r\n * @return `true` if the subject is an HTMLElement instance, or otherwise `false`.\r\n */\r\nexport function isHTMLElement( subject: unknown ): subject is HTMLElement {\r\n try {\r\n return subject instanceof ( ( subject as Node ).ownerDocument.defaultView || window ).HTMLElement;\r\n } catch ( e ) {\r\n return false;\r\n }\r\n}","import { isArray } from '../../type/type';\r\n\r\n\r\n/**\r\n * Push the provided value to an array if the value is not an array.\r\n *\r\n * @param value - A value to push.\r\n *\r\n * @return An array containing the value, or the value itself if it is already an array.\r\n */\r\nexport function toArray( value: T | T[] ): T[] {\r\n return isArray( value ) ? value : [ value ];\r\n}\r\n","import { toArray } from '../toArray/toArray';\r\n\r\n\r\n/**\r\n * The extended `Array#forEach` method that accepts a single value as an argument.\r\n *\r\n * @param values - A value or values to iterate over.\r\n * @param iteratee - An iteratee function.\r\n */\r\nexport function forEach( values: T | T[], iteratee: ( value: T, index: number, array: T[] ) => void ): void {\r\n toArray( values ).forEach( iteratee );\r\n}\r\n","import { toArray } from '../toArray/toArray';\r\n\r\n\r\n/**\r\n * Extended `Array#push()` that accepts an item or an array with items.\r\n *\r\n * @param array - An array to push items.\r\n * @param items - An item or items to push.\r\n *\r\n * @return A provided array itself.\r\n */\r\nexport function push( array: T[], items: T | T[] ): T[] {\r\n array.push( ...toArray( items ) );\r\n return array;\r\n}\r\n","import { isHTMLElement } from '../../type/type';\r\n\r\n\r\n/**\r\n * Checks if the element can be selected by the provided selector or not.\r\n *\r\n * @param elm - An element to check.\r\n * @param selector - A selector to test.\r\n *\r\n * @return `true` if the selector matches the element, or otherwise `false`.\r\n */\r\nexport function matches( elm: Element | EventTarget, selector: string ): boolean {\r\n return isHTMLElement( elm ) && ( elm[ 'msMatchesSelector' ] || elm.matches ).call( elm, selector );\r\n}\r\n","import { children } from '../children/children';\r\n\r\n\r\n/**\r\n * Returns a child element that matches the specified tag or class name.\r\n *\r\n * @param parent - A parent element.\r\n * @param selector - A selector to filter children.\r\n *\r\n * @return A matched child element if available, or otherwise `undefined`.\r\n */\r\nexport function child( parent: HTMLElement, selector?: string ): E | undefined {\r\n return selector ? children( parent, selector )[ 0 ] : parent.firstElementChild as E;\r\n}\r\n","import { slice } from '../../arrayLike';\r\nimport { matches } from '../matches/matches';\r\n\r\n\r\n/**\r\n * Finds children that has the specified tag or class name.\r\n *\r\n * @param parent - A parent element.\r\n * @param selector - Optional. A selector to filter children.\r\n *\r\n * @return An array with filtered children.\r\n */\r\nexport function children( parent: HTMLElement, selector?: string ): E[] {\r\n const children = parent ? slice( parent.children ) as E[] : [];\r\n return selector ? children.filter( child => matches( child, selector ) ) : children;\r\n}\r\n","/**\r\n * An alias of `Object.keys()`\r\n */\r\nexport const ownKeys = Object.keys;","import { ownKeys } from '../ownKeys/ownKeys';\r\n\r\n\r\n/**\r\n * Iterates over the provided object by own enumerable keys with calling the iteratee function.\r\n *\r\n * @param object - An object to iterate over.\r\n * @param iteratee - An iteratee function that takes `value` and `key` as arguments.\r\n * @param right - If `true`, the method iterates over the object from the end like `forEachRight()`.\r\n *\r\n * @return A provided object itself.\r\n */\r\nexport function forOwn(\r\n object: T,\r\n iteratee: ( value: T[ keyof T ], key: string ) => boolean | void,\r\n right?: boolean\r\n): T {\r\n if ( object ) {\r\n ( right ? ownKeys( object ).reverse() : ownKeys( object ) ).forEach( key => {\r\n key !== '__proto__' && iteratee( object[ key ], key );\r\n } );\r\n }\r\n\r\n return object;\r\n}\r\n","import { Cast, Head, Push, Resolve, Shift } from '../../../types';\r\nimport { slice } from '../../arrayLike';\r\nimport { forOwn } from '../forOwn/forOwn';\r\n\r\n\r\n/**\r\n * Assigns U to T.\r\n *\r\n * @typeParam T - An object to assign to.\r\n * @typeParam U - An object to assign.\r\n *\r\n * @return An assigned object type.\r\n */\r\nexport type Assign = Omit & U;\r\n\r\n/**\r\n * Recursively assigns U[] to T.\r\n *\r\n * @typeParam T - An object to assign to.\r\n * @typeParam U - A tuple contains objects.\r\n *\r\n * @return An assigned object type.\r\n */\r\nexport type Assigned = {\r\n 0: T,\r\n 1: Assigned>, Shift, N, Push>,\r\n}[ C['length'] extends N ? 0 : 1 ] extends infer A ? Cast : never;\r\n\r\nexport function assign( object: T ): T;\r\n\r\nexport function assign(\r\n object: T,\r\n ...sources: U\r\n): Resolve>\r\n\r\n/**\r\n * Assigns all own enumerable properties of all source objects to the provided object.\r\n *\r\n * @param object - An object to assign properties to.\r\n *\r\n * @return An object assigned properties of the sources to.\r\n */\r\nexport function assign( object: T ): any {\r\n // eslint-disable-next-line prefer-rest-params, prefer-spread\r\n slice( arguments, 1 ).forEach( source => {\r\n forOwn( source, ( value, key ) => {\r\n object[ key ] = source[ key ];\r\n } );\r\n } );\r\n\r\n return object;\r\n}\r\n","import { Cast, Head, Push, Resolve, Shift } from '../../../types';\r\nimport { slice } from '../../arrayLike';\r\nimport { isArray, isObject } from '../../type/type';\r\nimport { forOwn } from '../forOwn/forOwn';\r\n\r\n\r\n/**\r\n * Merges U to T.\r\n *\r\n * @typeParam T - An object to merge U into.\r\n * @typeParam U - An object to merge properties from.\r\n *\r\n * @return A merged object type.\r\n */\r\nexport type Merge = Omit & {\r\n [ K in ( keyof T & keyof U ) ]: U[ K ] extends object\r\n ? U[ K ] extends any[]\r\n ? U[ K ]\r\n : T[ K ] extends object\r\n ? Merge extends infer A ? Resolve> : never\r\n : U[ K ]\r\n : U[ K ];\r\n} & Omit;\r\n\r\n/**\r\n * Recursively merges U[] to T.\r\n *\r\n * @typeParam T - An object to assign to.\r\n * @typeParam U - A tuple contains objects.\r\n *\r\n * @return An assigned object type.\r\n */\r\nexport type Merged = {\r\n 0: T,\r\n 1: Merged>, Shift, N, Push>,\r\n}[ C['length'] extends N ? 0 : 1 ] extends infer A ? Cast : never;\r\n\r\nexport function merge( object: T ): T;\r\n\r\nexport function merge(\r\n object: T,\r\n ...sources: U\r\n): Resolve>\r\n\r\n/**\r\n * Recursively merges source properties to the object.\r\n * Be aware that this method does not merge arrays. They are just duplicated by `slice()`.\r\n *\r\n * @param object - An object to merge properties to.\r\n *\r\n * @return A new object with merged properties.\r\n */\r\nexport function merge( object: T ): any {\r\n // eslint-disable-next-line prefer-rest-params\r\n slice( arguments, 1 ).forEach( source => {\r\n forOwn( source, ( value, key ) => {\r\n if ( isArray( value ) ) {\r\n object[ key ] = value.slice();\r\n } else if ( isObject( value ) ) {\r\n object[ key ] = merge( {}, isObject( object[ key ] ) ? object[ key ] : {}, value );\r\n } else {\r\n object[ key ] = value;\r\n }\r\n } );\r\n } );\r\n\r\n return object;\r\n}\r\n","import { forEach } from '../../array';\r\n\r\n\r\n/**\r\n * Removes the provided node from its parent.\r\n *\r\n * @param nodes - A node or nodes to remove.\r\n */\r\nexport function remove( nodes: Node | Node[] ): void {\r\n forEach( nodes, node => {\r\n if ( node && node.parentNode ) {\r\n node.parentNode.removeChild( node );\r\n }\r\n } );\r\n}\r\n","import { isString } from '../../type/type';\r\n\r\n\r\n/**\r\n * Appends `px` to the provided number.\r\n * If the value is already string, just returns it.\r\n *\r\n * @param value - A value to append `px` to.\r\n *\r\n * @return A string with the CSS unit.\r\n */\r\nexport function unit( value: number | string ): string {\r\n return isString( value ) ? value : value ? `${ value }px` : '';\r\n}\r\n","import { PROJECT_CODE } from '../../../constants/project';\r\n\r\n\r\n/**\r\n * Throws an error if the provided condition is falsy.\r\n *\r\n * @param condition - If falsy, an error is thrown.\r\n * @param message - Optional. A message to display.\r\n */\r\nexport function assert( condition: any, message?: string ): void {\r\n if ( ! condition ) {\r\n throw new Error( `[${ PROJECT_CODE }] ${ message || '' }` );\r\n }\r\n}\r\n","export const { min, max, floor, ceil, abs } = Math;\r\n","/**\r\n * Converts the provided string in the camel case to the kebab case.\r\n *\r\n * @param string - A string to convert.\r\n */\r\nexport function camelToKebab( string: string ): string {\r\n return string.replace( /([a-z0-9])([A-Z])/g, '$1-$2' ).toLowerCase();\r\n}\r\n","import { pad } from '../pad/pad';\r\n\r\n\r\n/**\r\n * Stores unique IDs.\r\n *\r\n * @since 3.0.0\r\n */\r\nconst ids: Record = {};\r\n\r\n/**\r\n * Returns a sequential unique ID as \"{ prefix }-{ number }\".\r\n *\r\n * @param prefix - A prefix for the ID.\r\n */\r\nexport function uniqueId( prefix: string ): string {\r\n return `${ prefix }${ pad( ( ids[ prefix ] = ( ids[ prefix ] || 0 ) + 1 ) ) }`;\r\n}\r\n","import { AnyFunction } from '../../types';\r\nimport { empty, forEach } from '../../utils';\r\n\r\n\r\n/**\r\n * The type for an EventTarget or an array with EventTarget objects.\r\n *\r\n * @since 4.0.0\r\n */\r\ntype EventTargets = EventTarget | EventTarget[];\r\n\r\n/**\r\n * The interface for the EventBinder object.\r\n *\r\n * @since 3.0.0\r\n */\r\nexport interface EventBinderObject {\r\n bind( target: EventTargets, events: string | string[], callback: AnyFunction, options?: AddEventListenerOptions ): void\r\n unbind( target: EventTarget | EventTarget[], events: string | string[], callback?: AnyFunction ): void;\r\n dispatch( target: EventTarget, event: string, detail?: T ): void;\r\n destroy(): void;\r\n}\r\n\r\n/**\r\n * The constructor function to provide methods to subscribe native events.\r\n *\r\n * @since 4.0.0\r\n * @constructor\r\n *\r\n * @return An EventBinder object.\r\n */\r\nexport function EventBinder(): EventBinderObject {\r\n /**\r\n * Stores all handlers that listen to native events.\r\n * `[ target, event, namespace, callback, remover ]`\r\n */\r\n let listeners: [ EventTarget, string, string | undefined, AnyFunction, () => void ][] = [];\r\n\r\n /**\r\n * Listens to native events.\r\n * - `destroy()` can unsubscribe all events.\r\n * - In IE, mediaQueryList does not inherit EventTarget,\r\n * and only supports deprecated `addListener` and `removeListener`.\r\n *\r\n * @link https://developer.mozilla.org/en-US/docs/Web/API/MediaQueryList/addListener\r\n *\r\n * @param targets - A target element, the window object or the document object.\r\n * @param events - An event or events to listen to.\r\n * @param callback - A callback function.\r\n * @param options - Optional. The options to pass to the `addEventListener` function.\r\n */\r\n function bind(\r\n targets: EventTargets,\r\n events: string | string[],\r\n callback: AnyFunction,\r\n options?: AddEventListenerOptions\r\n ): void {\r\n forEachEvent( targets, events, ( target, event, namespace ) => {\r\n const isEventTarget = 'addEventListener' in target;\r\n const remover = isEventTarget\r\n ? target.removeEventListener.bind( target, event, callback, options )\r\n : target[ 'removeListener' ].bind( target, callback );\r\n\r\n isEventTarget ? target.addEventListener( event, callback, options ) : target[ 'addListener' ]( callback );\r\n listeners.push( [ target, event, namespace, callback, remover ] );\r\n } );\r\n }\r\n\r\n /**\r\n * Removes the event handler.\r\n *\r\n * @param targets - A target element, the window object or the document object.\r\n * @param events - An event name or names to remove.\r\n * @param callback - Optional. Specify the callback to remove.\r\n */\r\n function unbind( targets: EventTargets, events: string | string[], callback?: AnyFunction ): void {\r\n forEachEvent( targets, events, ( target, event, namespace ) => {\r\n listeners = listeners.filter( listener => {\r\n if ( listener[ 0 ] === target\r\n && listener[ 1 ] === event\r\n && listener[ 2 ] === namespace\r\n && ( ! callback || listener[ 3 ] === callback )\r\n ) {\r\n listener[ 4 ]();\r\n return false;\r\n }\r\n\r\n return true;\r\n } );\r\n } );\r\n }\r\n\r\n /**\r\n * Dispatches a custom event of the target.\r\n *\r\n * @param target - An event target.\r\n * @param type - An event type.\r\n * @param detail - Optional. The `detail` object of the event.\r\n *\r\n * @return An event object.\r\n */\r\n function dispatch( target: EventTarget, type: string, detail?: T ): CustomEvent {\r\n let e: CustomEvent;\r\n const bubbles = true;\r\n\r\n if ( typeof CustomEvent === 'function' ) {\r\n e = new CustomEvent( type, { bubbles, detail } );\r\n } else {\r\n e = document.createEvent( 'CustomEvent' );\r\n e.initCustomEvent( type, bubbles, false, detail );\r\n }\r\n\r\n target.dispatchEvent( e );\r\n return e;\r\n }\r\n\r\n /**\r\n * Iterates over each target and event.\r\n *\r\n * @param targets - A target element, the window object or the document object.\r\n * @param events - An event name or names.\r\n * @param iteratee - An iteratee function.\r\n */\r\n function forEachEvent(\r\n targets: EventTargets,\r\n events: string | string[],\r\n iteratee: ( target: EventTarget, event: string, namespace: string | undefined ) => void\r\n ): void {\r\n forEach( targets, target => {\r\n target && forEach( events, events => {\r\n events.split( ' ' ).forEach( eventNS => {\r\n const fragment = eventNS.split( '.' );\r\n iteratee( target, fragment[ 0 ], fragment[ 1 ] );\r\n } );\r\n } );\r\n } );\r\n }\r\n\r\n /**\r\n * Removes all listeners.\r\n */\r\n function destroy(): void {\r\n listeners.forEach( data => { data[ 4 ]() } );\r\n empty( listeners );\r\n }\r\n\r\n return {\r\n bind,\r\n unbind,\r\n dispatch,\r\n destroy,\r\n };\r\n}\r\n","/**\r\n * Empties the array.\r\n *\r\n * @param array - A array to empty.\r\n */\r\nexport function empty( array: any[] ): void {\r\n array.length = 0;\r\n}\r\n","import { EVENT_DESTROY } from '../../constants/events';\r\nimport { Splide } from '../../core/Splide/Splide';\r\nimport { AnyFunction, EventMap } from '../../types';\r\nimport { apply, assign, isArray, slice, toArray } from '../../utils';\r\nimport { EventBinder, EventBinderObject } from '../EventBinder/EventBinder';\r\n\r\n\r\n/**\r\n * The interface for the EventInterface object.\r\n *\r\n * @since 3.0.0\r\n */\r\nexport interface EventInterfaceObject extends EventBinderObject {\r\n on( event: K, callback: EventMap[ K ] ): void;\r\n on( events: string | string[], callback: AnyFunction ): void;\r\n off( events: K | K[] | string | string[] ): void;\r\n emit( event: K, ...args: Parameters ): void\r\n emit( event: string, ...args: any[] ): void;\r\n\r\n /** @internal */\r\n bus: DocumentFragment;\r\n}\r\n\r\n/**\r\n * The constructor function that provides interface for internal and native events.\r\n *\r\n * @since 3.0.0\r\n * @constructor\r\n *\r\n * @param Splide - A Splide instance.\r\n *\r\n * @return A collection of interface functions.\r\n */\r\nexport function EventInterface( Splide?: Splide ): EventInterfaceObject {\r\n /**\r\n * The document fragment for internal events.\r\n * Provide the Splide instance to share the bus.\r\n */\r\n const bus = Splide ? Splide.event.bus : document.createDocumentFragment();\r\n\r\n /**\r\n * An event binder object.\r\n */\r\n const binder = EventBinder();\r\n\r\n /**\r\n * Listens to an internal event or events.\r\n *\r\n * @param events - An event name or names separated by spaces. Use a dot(.) to add a namespace.\r\n * @param callback - A callback function to register.\r\n */\r\n function on( events: string | string[], callback: AnyFunction ): void {\r\n binder.bind( bus, toArray( events ).join( ' ' ), e => {\r\n callback.apply( callback, isArray( e.detail ) ? e.detail : [] );\r\n } );\r\n }\r\n\r\n /**\r\n * Triggers callback functions.\r\n * This accepts additional arguments and passes them to callbacks.\r\n *\r\n * @param event - An event name.\r\n */\r\n function emit( event: string ): void {\r\n // eslint-disable-next-line prefer-rest-params, prefer-spread\r\n binder.dispatch( bus, event, slice( arguments, 1 ) );\r\n }\r\n\r\n if ( Splide ) {\r\n Splide.event.on( EVENT_DESTROY, binder.destroy );\r\n }\r\n\r\n return assign( binder, {\r\n bus,\r\n on,\r\n off: apply( binder.unbind, bus ),\r\n emit,\r\n } );\r\n}","export const EVENT_MOUNTED = 'mounted';\r\nexport const EVENT_READY = 'ready';\r\nexport const EVENT_MOVE = 'move';\r\nexport const EVENT_MOVED = 'moved';\r\nexport const EVENT_CLICK = 'click';\r\nexport const EVENT_ACTIVE = 'active';\r\nexport const EVENT_INACTIVE = 'inactive';\r\nexport const EVENT_VISIBLE = 'visible';\r\nexport const EVENT_HIDDEN = 'hidden';\r\nexport const EVENT_REFRESH = 'refresh';\r\nexport const EVENT_UPDATED = 'updated';\r\nexport const EVENT_RESIZE = 'resize';\r\nexport const EVENT_RESIZED = 'resized';\r\nexport const EVENT_DRAG = 'drag';\r\nexport const EVENT_DRAGGING = 'dragging';\r\nexport const EVENT_DRAGGED = 'dragged';\r\nexport const EVENT_SCROLL = 'scroll';\r\nexport const EVENT_SCROLLED = 'scrolled';\r\nexport const EVENT_OVERFLOW = 'overflow';\r\nexport const EVENT_DESTROY = 'destroy';\r\nexport const EVENT_ARROWS_MOUNTED = 'arrows:mounted';\r\nexport const EVENT_ARROWS_UPDATED = 'arrows:updated';\r\nexport const EVENT_PAGINATION_MOUNTED = 'pagination:mounted';\r\nexport const EVENT_PAGINATION_UPDATED = 'pagination:updated';\r\nexport const EVENT_NAVIGATION_MOUNTED = 'navigation:mounted';\r\nexport const EVENT_AUTOPLAY_PLAY = 'autoplay:play';\r\nexport const EVENT_AUTOPLAY_PLAYING = 'autoplay:playing';\r\nexport const EVENT_AUTOPLAY_PAUSE = 'autoplay:pause';\r\nexport const EVENT_LAZYLOAD_LOADED = 'lazyload:loaded';\r\n\r\n/** @internal */\r\nexport const EVENT_SLIDE_KEYDOWN = 'sk';\r\nexport const EVENT_SHIFTED = 'sh';\r\nexport const EVENT_END_INDEX_CHANGED = 'ei';\r\n","export const CLASS_RENDERED = 'is-rendered';\r\n","import { RendererConfig } from '../types/types';\r\n\r\n\r\n/**\r\n * Default options for generating static HTML.\r\n *\r\n * @since 3.0.0\r\n */\r\nexport const RENDERER_DEFAULT_CONFIG: RendererConfig = {\r\n listTag : 'ul',\r\n slideTag: 'li',\r\n};\r\n","import { Options } from '../../types';\r\nimport { forOwn } from '../../utils';\r\n\r\n\r\ninterface Styles {\r\n [ breakpoint: string ]: {\r\n [ selector: string ]: Record\r\n };\r\n}\r\n\r\n/**\r\n * The class for generating styles as a string.\r\n *\r\n * @since 3.0.0\r\n */\r\nexport class Style {\r\n /**\r\n * The collection of registered styles categorized by each breakpoint.\r\n */\r\n private readonly styles: Styles = {};\r\n\r\n /**\r\n * The ID of the slider.\r\n */\r\n private readonly id: string;\r\n\r\n /**\r\n * Holds options.\r\n */\r\n private readonly options: Options;\r\n\r\n /**\r\n * The Style constructor.\r\n *\r\n * @param id - A slider ID.\r\n * @param options - Options.\r\n */\r\n constructor( id: string, options: Options ) {\r\n this.id = id;\r\n this.options = options;\r\n }\r\n\r\n /**\r\n * Registers a CSS rule.\r\n *\r\n * @param selector - A selector.\r\n * @param prop\r\n * @param value\r\n * @param breakpoint\r\n */\r\n rule( selector: string, prop: string, value: string | number, breakpoint?: string ): void {\r\n breakpoint = breakpoint || 'default';\r\n const selectors = ( this.styles[ breakpoint ] = this.styles[ breakpoint ] || {} );\r\n const styles = ( selectors[ selector ] = selectors[ selector ] || {} );\r\n styles[ prop ] = value;\r\n }\r\n\r\n /**\r\n * Builds styles as a single string.\r\n *\r\n * @return Built styles.\r\n */\r\n build(): string {\r\n let css = '';\r\n\r\n if ( this.styles.default ) {\r\n css += this.buildSelectors( this.styles.default );\r\n }\r\n\r\n Object.keys( this.styles )\r\n .sort( ( n, m ) => this.options.mediaQuery === 'min' ? +n - +m : +m - +n )\r\n .forEach( breakpoint => {\r\n if ( breakpoint !== 'default' ) {\r\n css += `@media screen and (max-width: ${ breakpoint }px) {`;\r\n css += this.buildSelectors( this.styles[ breakpoint ] );\r\n css += `}`;\r\n }\r\n } );\r\n\r\n return css;\r\n }\r\n\r\n /**\r\n * Builds styles for each breakpoint.\r\n *\r\n * @param selectors - An object with styles.\r\n *\r\n * @return Built styles.\r\n */\r\n private buildSelectors( selectors: Record> ): string {\r\n let css = '';\r\n\r\n forOwn( selectors, ( styles, selector ) => {\r\n selector = `#${ this.id } ${ selector }`.trim();\r\n css += `${ selector } {`;\r\n\r\n forOwn( styles, ( value, prop ) => {\r\n if ( value || value === 0 ) {\r\n css += `${ prop }: ${ value };`;\r\n }\r\n } );\r\n\r\n css += '}';\r\n } );\r\n\r\n return css;\r\n }\r\n}\r\n","import { PATH, SIZE, XML_NAME_SPACE } from '../../components/Arrows/path';\r\nimport { Direction, DirectionComponent } from '../../components/Direction/Direction';\r\nimport { CLASS_ACTIVE, CLASS_CLONE, CLASS_LIST, CLASS_ROOT, CLASS_SLIDE, CLASS_TRACK } from '../../constants/classes';\r\nimport { DEFAULTS } from '../../constants/defaults';\r\nimport { TTB } from '../../constants/directions';\r\nimport { EVENT_MOUNTED } from '../../constants/events';\r\nimport { LOOP, SLIDE } from '../../constants/types';\r\nimport { EventInterface } from '../../constructors';\r\nimport { Splide } from '../../core/Splide/Splide';\r\nimport { Options } from '../../types';\r\nimport {\r\n assert,\r\n assign,\r\n camelToKebab,\r\n child,\r\n forOwn,\r\n isObject,\r\n isString,\r\n max,\r\n merge,\r\n push,\r\n queryAll,\r\n remove,\r\n uniqueId,\r\n unit,\r\n} from '../../utils';\r\nimport { CLASS_RENDERED } from '../constants/classes';\r\nimport { RENDERER_DEFAULT_CONFIG } from '../constants/defaults';\r\nimport { Style } from '../Style/Style';\r\nimport { RendererConfig, SlideContent } from '../types/types';\r\n\r\n\r\n/**\r\n * The class to generate static HTML of the slider for the first view.\r\n *\r\n * @since 3.0.0\r\n */\r\nexport class SplideRenderer {\r\n /**\r\n * Removes a style element and clones.\r\n *\r\n * @param splide - A Splide instance.\r\n */\r\n static clean( splide: Splide ): void {\r\n const { on } = EventInterface( splide );\r\n const { root } = splide;\r\n const clones = queryAll( root, `.${ CLASS_CLONE }` );\r\n\r\n on( EVENT_MOUNTED, () => {\r\n remove( child( root, 'style' ) );\r\n } );\r\n\r\n remove( clones );\r\n }\r\n\r\n /**\r\n * Holds slide contents.\r\n */\r\n private readonly contents: string[] | SlideContent[];\r\n\r\n /**\r\n * Stores data of slides.\r\n */\r\n private readonly slides: SlideContent[] = [];\r\n\r\n /**\r\n * The Direction component.\r\n */\r\n private readonly Direction: DirectionComponent;\r\n\r\n /**\r\n * Holds the Style instance.\r\n */\r\n private readonly Style: Style;\r\n\r\n /**\r\n * Holds options.\r\n */\r\n private readonly options: Options = {};\r\n\r\n /**\r\n * Holds options for this instance.\r\n */\r\n private readonly config: RendererConfig;\r\n\r\n /**\r\n * The slider ID.\r\n */\r\n private readonly id: string;\r\n\r\n /**\r\n * An array with options for each breakpoint.\r\n */\r\n private readonly breakpoints: [ string, Options ][] = [];\r\n\r\n /**\r\n * The SplideRenderer constructor.\r\n *\r\n * @param contents - An array with slide contents. Each item must be an HTML or a plain text.\r\n * @param options - Optional. Slider options.\r\n * @param config - Static default options.\r\n * @param defaults - Default options for the slider. Pass `Splide.defaults` if you are using it.\r\n */\r\n constructor( contents: string[] | SlideContent[], options?: Options, config?: RendererConfig, defaults?: Options ) {\r\n merge( DEFAULTS, defaults || {} );\r\n merge( merge( this.options, DEFAULTS ), options || {} );\r\n\r\n this.contents = contents;\r\n this.config = assign( {}, RENDERER_DEFAULT_CONFIG, config || {} );\r\n this.id = this.config.id || uniqueId( 'splide' );\r\n this.Style = new Style( this.id, this.options );\r\n this.Direction = Direction( null, null, this.options );\r\n\r\n assert( this.contents.length, 'Provide at least 1 content.' );\r\n\r\n this.init();\r\n }\r\n\r\n /**\r\n * Initializes the instance.\r\n */\r\n private init(): void {\r\n this.parseBreakpoints();\r\n this.initSlides();\r\n this.registerRootStyles();\r\n this.registerTrackStyles();\r\n this.registerSlideStyles();\r\n this.registerListStyles();\r\n }\r\n\r\n /**\r\n * Initializes slides.\r\n */\r\n private initSlides(): void {\r\n push( this.slides, this.contents.map( ( content, index ) => {\r\n content = isString( content ) ? { html: content } : content;\r\n content.styles = content.styles || {};\r\n content.attrs = content.attrs || {};\r\n\r\n this.cover( content );\r\n\r\n const classes = `${ this.options.classes.slide } ${ index === 0 ? CLASS_ACTIVE : '' }`;\r\n\r\n assign( content.attrs, {\r\n class: `${ classes } ${ content.attrs.class || '' }`.trim(),\r\n style: this.buildStyles( content.styles ),\r\n } );\r\n\r\n return content;\r\n } ) );\r\n\r\n if ( this.isLoop() ) {\r\n this.generateClones( this.slides );\r\n }\r\n }\r\n\r\n /**\r\n * Registers styles for the root element.\r\n */\r\n private registerRootStyles(): void {\r\n this.breakpoints.forEach( ( [ width, options ] ) => {\r\n this.Style.rule( ' ', 'max-width', unit( options.width ), width );\r\n } );\r\n }\r\n\r\n /**\r\n * Registers styles for the track element.\r\n */\r\n private registerTrackStyles(): void {\r\n const { Style } = this;\r\n const selector = `.${ CLASS_TRACK }`;\r\n\r\n this.breakpoints.forEach( ( [ width, options ] ) => {\r\n Style.rule( selector, this.resolve( 'paddingLeft' ), this.cssPadding( options, false ), width );\r\n Style.rule( selector, this.resolve( 'paddingRight' ), this.cssPadding( options, true ), width );\r\n Style.rule( selector, 'height', this.cssTrackHeight( options ), width );\r\n } );\r\n }\r\n\r\n /**\r\n * Registers styles for the list element.\r\n */\r\n private registerListStyles(): void {\r\n const { Style } = this;\r\n const selector = `.${ CLASS_LIST }`;\r\n\r\n this.breakpoints.forEach( ( [ width, options ] ) => {\r\n Style.rule( selector, 'transform', this.buildTranslate( options ), width );\r\n\r\n if ( ! this.cssSlideHeight( options ) ) {\r\n Style.rule( selector, 'aspect-ratio', this.cssAspectRatio( options ), width );\r\n }\r\n } );\r\n }\r\n\r\n /**\r\n * Registers styles for slides and clones.\r\n */\r\n private registerSlideStyles(): void {\r\n const { Style } = this;\r\n const selector = `.${ CLASS_SLIDE }`;\r\n\r\n this.breakpoints.forEach( ( [ width, options ] ) => {\r\n Style.rule( selector, 'width', this.cssSlideWidth( options ), width );\r\n Style.rule( selector, 'height', this.cssSlideHeight( options ) || '100%', width );\r\n Style.rule( selector, this.resolve( 'marginRight' ), unit( options.gap ) || '0px', width );\r\n Style.rule( `${ selector } > img`, 'display', options.cover ? 'none' : 'inline', width );\r\n } );\r\n }\r\n\r\n /**\r\n * Builds multiple `translateX` for the list element.\r\n *\r\n * @param options - Options for each breakpoint.\r\n *\r\n * @return A string with multiple translate functions.\r\n */\r\n private buildTranslate( options: Options ): string {\r\n const { resolve, orient } = this.Direction;\r\n const values = [];\r\n\r\n values.push( this.cssOffsetClones( options ) );\r\n values.push( this.cssOffsetGaps( options ) );\r\n\r\n if ( this.isCenter( options ) ) {\r\n values.push( this.buildCssValue( orient( -50 ), '%' ) );\r\n values.push( ...this.cssOffsetCenter( options ) );\r\n }\r\n\r\n return values\r\n .filter( Boolean )\r\n .map( value => `translate${ resolve( 'X' ) }(${ value })` )\r\n .join( ' ' );\r\n }\r\n\r\n /**\r\n * Returns offset for the list element.\r\n * This does not include gaps because it can not be converted into percent.\r\n *\r\n * @param options - Options for each breakpoint.\r\n *\r\n * @return The offset.\r\n */\r\n private cssOffsetClones( options: Options ): string {\r\n const { resolve, orient } = this.Direction;\r\n const cloneCount = this.getCloneCount();\r\n\r\n if ( this.isFixedWidth( options ) ) {\r\n const { value, unit } = this.parseCssValue( options[ resolve( 'fixedWidth' ) ] );\r\n return this.buildCssValue( orient( value ) * cloneCount, unit );\r\n }\r\n\r\n const percent = 100 * cloneCount / options.perPage;\r\n return `${ orient( percent ) }%`;\r\n }\r\n\r\n /**\r\n * Returns offset for centering the active slide.\r\n *\r\n * Note:\r\n * ( 100% + gap ) / perPage - gap\r\n * 100% / perPage + gap / perPage - gap;\r\n * 50% / perPage + ( gap / perPage - gap ) / 2;\r\n *\r\n * @param options - Options for each breakpoint.\r\n *\r\n * @return The offset.\r\n */\r\n private cssOffsetCenter( options: Options ): string[] {\r\n const { resolve, orient } = this.Direction;\r\n\r\n if ( this.isFixedWidth( options ) ) {\r\n const { value, unit } = this.parseCssValue( options[ resolve( 'fixedWidth' ) ] );\r\n return [ this.buildCssValue( orient( value / 2 ), unit ) ];\r\n }\r\n\r\n const values = [];\r\n const { perPage, gap } = options;\r\n\r\n values.push( `${ orient( 50 / perPage ) }%` );\r\n\r\n if ( gap ) {\r\n const { value, unit } = this.parseCssValue( gap );\r\n const gapOffset = ( value / perPage - value ) / 2;\r\n values.push( this.buildCssValue( orient( gapOffset ), unit ) );\r\n }\r\n\r\n return values;\r\n }\r\n\r\n /**\r\n * Returns offset for gaps.\r\n *\r\n * @param options - Options for each breakpoint.\r\n *\r\n * @return The offset as `calc()`.\r\n */\r\n private cssOffsetGaps( options: Options ): string {\r\n const cloneCount = this.getCloneCount();\r\n\r\n if ( cloneCount && options.gap ) {\r\n const { orient } = this.Direction;\r\n const { value, unit } = this.parseCssValue( options.gap );\r\n\r\n if ( this.isFixedWidth( options ) ) {\r\n return this.buildCssValue( orient( value * cloneCount ), unit );\r\n }\r\n\r\n const { perPage } = options;\r\n const gaps = cloneCount / perPage;\r\n return this.buildCssValue( orient( gaps * value ), unit );\r\n }\r\n\r\n return '';\r\n }\r\n\r\n /**\r\n * Resolves the prop for the current direction and converts it into the Kebab case.\r\n *\r\n * @param prop - A property name to resolve.\r\n *\r\n * @return A resolved property name in the Kebab case.\r\n */\r\n private resolve( prop: string ): string {\r\n return camelToKebab( this.Direction.resolve( prop ) );\r\n }\r\n\r\n /**\r\n * Returns padding in the CSS format.\r\n *\r\n * @param options - Options.\r\n * @param right - Determines whether to get padding right or left.\r\n *\r\n * @return Padding in the CSS format.\r\n */\r\n private cssPadding( options: Options, right: boolean ): string {\r\n const { padding } = options;\r\n const prop = this.Direction.resolve( right ? 'right' : 'left', true );\r\n return padding && unit( padding[ prop ] || ( isObject( padding ) ? 0 : padding ) ) || '0px';\r\n }\r\n\r\n /**\r\n * Returns height of the track element in the CSS format.\r\n *\r\n * @param options - Options.\r\n *\r\n * @return Height in the CSS format.\r\n */\r\n private cssTrackHeight( options: Options ): string {\r\n let height = '';\r\n\r\n if ( this.isVertical() ) {\r\n height = this.cssHeight( options );\r\n assert( height, '\"height\" is missing.' );\r\n height = `calc(${ height } - ${ this.cssPadding( options, false ) } - ${ this.cssPadding( options, true ) })`;\r\n }\r\n\r\n return height;\r\n }\r\n\r\n /**\r\n * Returns height provided though options in the CSS format.\r\n *\r\n * @param options - Options.\r\n *\r\n * @return Height in the CSS format.\r\n */\r\n private cssHeight( options: Options ): string {\r\n return unit( options.height );\r\n }\r\n\r\n /**\r\n * Returns width of each slide in the CSS format.\r\n *\r\n * @param options - Options.\r\n *\r\n * @return Width in the CSS format.\r\n */\r\n private cssSlideWidth( options: Options ): string {\r\n return options.autoWidth\r\n ? ''\r\n : unit( options.fixedWidth ) || ( this.isVertical() ? '' : this.cssSlideSize( options ) );\r\n }\r\n\r\n /**\r\n * Returns height of each slide in the CSS format.\r\n *\r\n * @param options - Options.\r\n *\r\n * @return Height in the CSS format.\r\n */\r\n private cssSlideHeight( options: Options ): string {\r\n return unit( options.fixedHeight )\r\n || ( this.isVertical()\r\n ? ( options.autoHeight ? '' : this.cssSlideSize( options ) )\r\n : this.cssHeight( options )\r\n );\r\n }\r\n\r\n /**\r\n * Returns width or height of each slide in the CSS format, considering the current direction.\r\n *\r\n * @param options - Options.\r\n *\r\n * @return Width or height in the CSS format.\r\n */\r\n private cssSlideSize( options: Options ): string {\r\n const gap = unit( options.gap );\r\n return `calc((100%${ gap && ` + ${ gap }` })/${ options.perPage || 1 }${ gap && ` - ${ gap }` })`;\r\n }\r\n\r\n /**\r\n * Returns the aspectRatio value to simulate the `heightRatio` option.\r\n *\r\n * @param options - Options.\r\n *\r\n * @return aspectRatio in the CSS format.\r\n */\r\n private cssAspectRatio( options: Options ): string {\r\n const { heightRatio } = options;\r\n return heightRatio ? `${ 1 / heightRatio }` : '';\r\n }\r\n\r\n /**\r\n * Builds the css value by the provided value and unit.\r\n *\r\n * @param value - A value.\r\n * @param unit - A CSS unit.\r\n *\r\n * @return A built value for a CSS value.\r\n */\r\n private buildCssValue( value: number, unit: string ): string {\r\n return `${ value }${ unit }`;\r\n }\r\n\r\n /**\r\n * Parses the CSS value into number and unit.\r\n *\r\n * @param value - A value to parse.\r\n *\r\n * @return An object with value and unit.\r\n */\r\n private parseCssValue( value: string | number ): { value: number, unit: string } {\r\n if ( isString( value ) ) {\r\n const number = parseFloat( value ) || 0;\r\n const unit = value.replace( /\\d*(\\.\\d*)?/, '' ) || 'px';\r\n return { value: number, unit };\r\n }\r\n\r\n return { value, unit: 'px' };\r\n }\r\n\r\n /**\r\n * Parses breakpoints and generate options for each breakpoint.\r\n */\r\n private parseBreakpoints(): void {\r\n const { breakpoints } = this.options;\r\n\r\n this.breakpoints.push( [ 'default', this.options ] );\r\n\r\n if ( breakpoints ) {\r\n forOwn( breakpoints, ( options, width ) => {\r\n this.breakpoints.push( [ width, merge( merge( {}, this.options ), options ) ] );\r\n } );\r\n }\r\n }\r\n\r\n /**\r\n * Checks if the slide width is fixed or not.\r\n *\r\n * @return `true` if the slide width is fixed, or otherwise `false`.\r\n */\r\n private isFixedWidth( options: Options ): boolean {\r\n return !! options[ this.Direction.resolve( 'fixedWidth' ) ];\r\n }\r\n\r\n /**\r\n * Checks if the slider type is loop or not.\r\n *\r\n * @return `true` if the slider type is loop, or otherwise `false`.\r\n */\r\n private isLoop(): boolean {\r\n return this.options.type === LOOP;\r\n }\r\n\r\n /**\r\n * Checks if the active slide should be centered or not.\r\n *\r\n * @return `true` if the slide should be centered, or otherwise `false`.\r\n */\r\n private isCenter( options: Options ): boolean {\r\n if( options.focus === 'center' ) {\r\n if ( this.isLoop() ) {\r\n return true;\r\n }\r\n\r\n if ( this.options.type === SLIDE ) {\r\n return ! this.options.trimSpace;\r\n }\r\n }\r\n\r\n return false;\r\n }\r\n\r\n /**\r\n * Checks if the direction is TTB or not.\r\n *\r\n * @return `true` if the direction is TTB, or otherwise `false`.\r\n */\r\n private isVertical(): boolean {\r\n return this.options.direction === TTB;\r\n }\r\n\r\n /**\r\n * Builds classes of the root element.\r\n *\r\n * @return Classes for the root element as a single string.\r\n */\r\n private buildClasses(): string {\r\n const { options } = this;\r\n\r\n return [\r\n CLASS_ROOT,\r\n `${ CLASS_ROOT }--${ options.type }`,\r\n `${ CLASS_ROOT }--${ options.direction }`,\r\n options.drag && `${ CLASS_ROOT }--draggable`,\r\n options.isNavigation && `${ CLASS_ROOT }--nav`,\r\n CLASS_ACTIVE,\r\n ! this.config.hidden && CLASS_RENDERED,\r\n ].filter( Boolean ).join( ' ' );\r\n }\r\n\r\n /**\r\n * Converts provided attributes into a single string.\r\n *\r\n * @param attrs - An object with attributes.\r\n *\r\n * @return A built string.\r\n */\r\n private buildAttrs( attrs: Record ): string {\r\n let attr = '';\r\n\r\n forOwn( attrs, ( value, key ) => {\r\n attr += value ? ` ${ camelToKebab( key ) }=\"${ value }\"` : '';\r\n } );\r\n\r\n return attr.trim();\r\n }\r\n\r\n /**\r\n * Converts provided styles into a single string.\r\n *\r\n * @param styles - An object with styles.\r\n *\r\n * @return A built string.\r\n */\r\n private buildStyles( styles: Record ): string {\r\n let style = '';\r\n\r\n forOwn( styles, ( value, key ) => {\r\n style += ` ${ camelToKebab( key ) }:${ value };`;\r\n } );\r\n\r\n return style.trim();\r\n }\r\n\r\n /**\r\n * Generates HTML of slides with inserting provided contents.\r\n *\r\n * @return The HTML for all slides and clones.\r\n */\r\n private renderSlides(): string {\r\n const { slideTag: tag } = this.config;\r\n\r\n return this.slides.map( content => {\r\n return `<${ tag } ${ this.buildAttrs( content.attrs ) }>${ content.html || '' }`;\r\n } ).join( '' );\r\n }\r\n\r\n /**\r\n * Add the `background` style for the cover mode.\r\n *\r\n * @param content - A slide content.\r\n */\r\n private cover( content: SlideContent ): void {\r\n const { styles, html = '' } = content;\r\n\r\n if ( this.options.cover && ! this.options.lazyLoad ) {\r\n const src = html.match( // );\r\n\r\n if ( src && src[ 2 ] ) {\r\n styles.background = `center/cover no-repeat url('${ src[ 2 ] }')`;\r\n }\r\n }\r\n }\r\n\r\n /**\r\n * Generates clones.\r\n *\r\n * @param contents - An array with SlideContent objects.\r\n */\r\n private generateClones( contents: SlideContent[] ): void {\r\n const { classes } = this.options;\r\n const count = this.getCloneCount();\r\n const slides = contents.slice();\r\n\r\n while ( slides.length < count ) {\r\n push( slides, slides );\r\n }\r\n\r\n push( slides.slice( -count ).reverse(), slides.slice( 0, count ) ).forEach( ( content, index ) => {\r\n const attrs = assign( {}, content.attrs, { class: `${ content.attrs.class } ${ classes.clone }` } );\r\n const clone = assign( {}, content, { attrs } );\r\n index < count ? contents.unshift( clone ) : contents.push( clone );\r\n } );\r\n }\r\n\r\n /**\r\n * Returns the number of clones to generate.\r\n *\r\n * @return A number of clones.\r\n */\r\n private getCloneCount(): number {\r\n if ( this.isLoop() ) {\r\n const { options } = this;\r\n\r\n if ( options.clones ) {\r\n return options.clones;\r\n }\r\n\r\n const perPage = max( ...this.breakpoints.map( ( [ , options ] ) => options.perPage ) );\r\n return perPage * ( ( options.flickMaxPages || 1 ) + 1 );\r\n }\r\n\r\n return 0;\r\n }\r\n\r\n /**\r\n * Generates arrows and the wrapper element.\r\n *\r\n * @return The HTML for arrows.\r\n */\r\n private renderArrows(): string {\r\n let html = '';\r\n\r\n html += `
`;\r\n html += this.renderArrow( true );\r\n html += this.renderArrow( false );\r\n html += `
`;\r\n\r\n return html;\r\n }\r\n\r\n /**\r\n * Generates an arrow HTML.\r\n * Some attributes are temporary, and Splide changes them after mount.\r\n *\r\n * @param prev - Options for each breakpoint.\r\n *\r\n * @return The HTML for the prev or next arrow.\r\n */\r\n private renderArrow( prev: boolean ): string {\r\n const { classes, i18n } = this.options;\r\n const attrs = {\r\n class : `${ classes.arrow } ${ prev ? classes.prev : classes.next }`,\r\n type : 'button',\r\n ariaLabel: prev ? i18n.prev : i18n.next,\r\n };\r\n\r\n return ``;\r\n }\r\n\r\n /**\r\n * Returns the HTML of the slider.\r\n *\r\n * @return The generated HTML.\r\n */\r\n html(): string {\r\n const { rootClass, listTag, arrows, beforeTrack, afterTrack, slider, beforeSlider, afterSlider } = this.config;\r\n\r\n let html = '';\r\n\r\n html += `
`;\r\n html += ``;\r\n\r\n if ( slider ) {\r\n html += beforeSlider || '';\r\n html += `
`;\r\n }\r\n\r\n html += beforeTrack || '';\r\n\r\n if ( arrows ) {\r\n html += this.renderArrows();\r\n }\r\n\r\n html += `
`;\r\n html += `<${ listTag } class=\"splide__list\">`;\r\n\r\n html += this.renderSlides();\r\n\r\n html += ``;\r\n html += `
`; // .track\r\n\r\n html += afterTrack || '';\r\n\r\n if ( slider ) {\r\n html += `
`;\r\n html += afterSlider || '';\r\n }\r\n\r\n html += `
`; // .splide\r\n\r\n return html;\r\n }\r\n}\r\n","/**\r\n * Pads the number with 0.\r\n *\r\n * @param number - A number to pad.\r\n *\r\n * @return string - Padded number.\r\n */\r\nexport function pad( number: number ): string {\r\n return number < 10 ? `0${ number }` : `${ number }`;\r\n}\r\n","import { slice } from '../../arrayLike';\r\n\r\n\r\n/**\r\n * Returns elements that match the provided selector.\r\n *\r\n * @param parent - A parent element to start searching from.\r\n * @param selector - A selector to query.\r\n *\r\n * @return An array with matched elements.\r\n */\r\nexport function queryAll( parent: Element | Document, selector?: string ): E[] {\r\n return selector ? slice( parent.querySelectorAll( selector ) ) : [];\r\n}\r\n","/**\r\n * The type for the regular slider.\r\n *\r\n * @since 3.0.0\r\n */\r\nexport const SLIDE = 'slide';\r\n\r\n/**\r\n * The type for the carousel slider.\r\n *\r\n * @since 3.0.0\r\n */\r\nexport const LOOP = 'loop';\r\n\r\n/**\r\n * The type for the fade slider that can not have multiple slides in a page.\r\n *\r\n * @since 3.0.0\r\n */\r\nexport const FADE = 'fade';\r\n"],"names":["RTL","TTB","ORIENTATION_MAP","width","left","right","x","X","Y","ArrowLeft","ARROW","ArrowRight","Direction","Splide","Components","options","resolve","prop","axisOnly","direction","index","replace","match","offset","replacement","toLowerCase","charAt","toUpperCase","slice","orient","value","PROJECT_CODE","CLASS_PREFIX","CLASS_ROOT","CLASS_TRACK","CLASS_LIST","CLASS_SLIDE","CLASS_CLONE","CLASS_ARROW","CLASS_PAGINATION","CLASS_ACTIVE","STATUS_CLASS_PREFIX","DEFAULTS","type","role","speed","perPage","cloneStatus","arrows","pagination","paginationKeyboard","interval","pauseOnHover","pauseOnFocus","resetProgress","easing","drag","trimSpace","focusableNodes","live","classes","slide","clone","arrow","prev","next","page","spinner","i18n","first","last","slideX","pageX","play","pause","carousel","select","slideLabel","reducedMotion","rewindSpeed","autoplay","arrayLike","start","end","Array","prototype","call","apply","func","bind","arguments","typeOf","subject","isObject","isArray","isString","toArray","forEach","values","iteratee","push","array","items","matches","elm","selector","ownerDocument","defaultView","window","HTMLElement","e","child","parent","children","filter","firstElementChild","ownKeys","Object","keys","forOwn","object","reverse","key","assign","source","merge","remove","nodes","node","parentNode","removeChild","unit","assert","condition","message","Error","Math","min","max","floor","ceil","abs","camelToKebab","string","ids","EventBinder","listeners","forEachEvent","targets","events","target","split","eventNS","fragment","callback","event","namespace","isEventTarget","remover","removeEventListener","addEventListener","unbind","listener","dispatch","detail","CustomEvent","bubbles","document","createEvent","initCustomEvent","dispatchEvent","destroy","data","length","EventInterface","bus","createDocumentFragment","binder","on","join","off","emit","RENDERER_DEFAULT_CONFIG","listTag","slideTag","Style","id","this","styles","rule","breakpoint","selectors","build","_this","css","default","buildSelectors","sort","n","m","mediaQuery","_this2","trim","SplideRenderer","contents","config","defaults","slides","breakpoints","prefix","number","init","clean","splide","root","clones","querySelectorAll","parseBreakpoints","initSlides","registerRootStyles","registerTrackStyles","registerSlideStyles","registerListStyles","_this3","map","content","html","attrs","cover","class","style","buildStyles","isLoop","generateClones","_this4","_ref","_this5","_ref2","cssPadding","cssTrackHeight","_this6","_ref3","buildTranslate","cssSlideHeight","cssAspectRatio","_this7","_ref4","cssSlideWidth","gap","_this$Direction","cssOffsetClones","cssOffsetGaps","isCenter","buildCssValue","cssOffsetCenter","Boolean","_this$Direction2","cloneCount","getCloneCount","isFixedWidth","_this$parseCssValue","parseCssValue","_this$Direction3","_this$parseCssValue2","_this$parseCssValue3","_this$parseCssValue4","padding","height","isVertical","cssHeight","autoWidth","fixedWidth","cssSlideSize","fixedHeight","autoHeight","heightRatio","parseFloat","_this8","focus","buildClasses","isNavigation","hidden","buildAttrs","attr","renderSlides","_this9","tag","_content$html","lazyLoad","src","background","count","unshift","_ref5","flickMaxPages","renderArrows","renderArrow","_this$options","ariaLabel","arrowPath","_this$config","rootClass","beforeTrack","afterTrack","slider","beforeSlider","afterSlider"],"mappings":";;;;;;yCAGO,ICKMA,EAAM,MAKNC,EAAM,MCQNC,EAAkB,CAC7BC,MAAY,CAAE,UACdC,KAAY,CAAE,MAAO,SACrBC,MAAY,CAAE,SAAU,QACxBC,EAAY,CAAE,KACdC,EAAY,CAAE,KACdC,EAAY,CAAE,KACdC,UAAY,CCzBiBC,UADAA,cD2B7BC,WAAY,CCzBiBD,YAHAA,YDoBA,EAsBf,SAAAE,EAAWC,EAAgBC,EAAwBC,GA8B1D,MAAA,CACLC,QAvBO,SAASC,EAAcC,EAAoBC,GAE5C,IAAAC,GADND,EAAYA,GAAaJ,EAAQI,aACLnB,GAASkB,EAAeC,IAAclB,EAAM,EAAI,CAAA,EAA5B,EAEzC,OAAAC,EAAiBe,IAAUf,EAAiBe,GAAQG,IACtDH,EAAKI,QAAS,oBAAqB,SAAEC,EAAOC,GACvCC,EAActB,EAAiBoB,EAAMG,YAAN,GAAuBL,IAAWE,EAChE,OAAS,EAATC,EAAaC,EAAYE,OAAQ,CAApB,EAAwBC,YAAxB,EAAwCH,EAAYI,MAAO,CAAnB,EAAyBJ,CACrF,CAHC,CAIP,EAeEK,OANF,SAAiBC,GACf,OAAOA,GAAUf,EAAQI,YAAcnB,EAAM,EAAI,CAAA,EACnD,CAEO,CAIT,CExEO,IAAM+B,EAAe,SCEtBC,EAAmBD,EAAzB,KAYaE,EAAwBF,EACxBG,EAA4BF,EAAlC,QACMG,EAA4BH,EAAlC,OACMI,EAA4BJ,EAAlC,QACMK,EAA4BD,EAAlC,UAGME,EAA4BN,EAAlC,QAGMO,EAA4BP,EAAlC,aAUMQ,EAA4BC,YC5B5BC,EAAoB,CAC/BC,KAAoB,QACpBC,KAAoB,SACpBC,MAAoB,IACpBC,QAAoB,EACpBC,YAAoB,CAAA,EACpBC,OAAoB,CAAA,EACpBC,WAAoB,CAAA,EACpBC,mBAAoB,CAAA,EACpBC,SAAoB,IACpBC,aAAoB,CAAA,EACpBC,aAAoB,CAAA,EACpBC,cAAoB,CAAA,EACpBC,OAAoB,gCACpBC,KAAoB,CAAA,EACpBrC,UAAoB,MACpBsC,UAAoB,CAAA,EACpBC,eAAoB,6CACpBC,KAAoB,CAAA,EACpBC,QDqCqB,CACrBC,MAAYzB,EACZ0B,MAAYzB,EACZW,OA7CuChB,EAAlC,SA8CL+B,MAAYzB,EACZ0B,KA7CuC1B,EAAlC,SA8CL2B,KA7CuC3B,EAAlC,SA8CLW,WAAYV,EACZ2B,KA7CuC3B,EAAlC,SA8CL4B,QAxCuCnC,EAAlC,SA+BgB,ECpCrBoC,KC1BkB,CAClBJ,KAAY,iBACZC,KAAY,aACZI,MAAY,oBACZC,KAAY,mBACZC,OAAY,iBACZC,MAAY,gBACZC,KAAY,iBACZC,MAAY,iBACZC,SAAY,WACZd,MAAY,QACZe,OAAY,yBACZC,WAAY,UAZM,ED2BlBC,cAAe,CACbjC,MAAa,EACbkC,YAAa,EACbC,SAAa,OAHA,CArBgB,EEFjB,SAAApD,EAAUqD,EAAyBC,EAAgBC,GACjE,OAAOC,MAAMC,UAAUzD,MAAM0D,KAAML,EAAWC,EAAOC,CAA9C,CACT,CCaO,SAASI,EAAOC,GAErB,OAAOA,EAAKC,KAALF,MAAAC,EAAW,CAAA,MAAS5D,OAAAA,EAAO8D,UAAW,CAAX,EAAlC,CACF,CCfA,SAASC,EAAQhD,EAAciD,GAC7B,OAAO,OAAOA,IAAYjD,CAC5B,CASO,SAASkD,EAAUD,GACxB,OA+CmB,OA/CFA,GAAaD,EAAQ,SAAUC,CAAlB,CAChC,CASO,IAAME,EAAqDV,MAAMU,QAkB3DC,GAT6DR,EAAOI,EAAQ,UAAR,EASdJ,EAAOI,EAAQ,QAAR,GC1CnE,SAASK,EAAYlE,GAC1B,OAAOgE,EAAShE,CAAA,EAAUA,EAAQ,CAAEA,EACtC,CCHgB,SAAAmE,EAAYC,EAAiBC,GAClCH,EAAAE,CAAA,EAASD,QAASE,CAAlB,CACX,CCAgB,SAAAC,EAASC,EAAYC,GAE5B,OADPD,EAAMD,KAANC,MAAAA,EAAeL,EAASM,CAAA,CAAxB,EACOD,CACT,CCHgB,SAAAE,EAASC,EAA4BC,GAC5C,OJsEF,SAAwBb,GACzB,IACF,OAAOA,aAAuBA,EAAkBc,cAAcC,aAAeC,QAASC,WAGxF,OAFUC,GACD,MAAA,CAAA,CACT,CACF,EI5EwBN,CAAf,IAA0BA,EAAA,mBAA8BA,EAAID,SAAUjB,KAAMkB,EAAKC,CAAvD,CACnC,CCFgB,SAAAM,EAA8BC,EAAqBP,GACjE,OAAOA,GCA6DA,EDA7BA,ECCjCQ,GADyCD,EDAhBA,GCCLpF,EAAOoF,EAAOC,QAAd,EAAkC,IACrDR,EAAWQ,EAASC,OAAQ,SAAAH,GAAA,OAASR,EAASQ,EAAON,EAAzB,CAAjBQ,EAAyDA,GDFxB,IAAMD,EAAOG,kBCAlD,IAAsDV,CDCtE,CLgDyElB,EAAOI,EAAQ,WAAR,EO1DzE,IAAMyB,EAAUC,OAAOC,KCSd,SAAAC,EACdC,EACArB,EACA9F,GAEKmH,IACDnH,EAAQ+G,EAASI,CAAA,EAASC,QAAlB,EAA8BL,EAASI,CAAA,GAAWvB,QAAS,SAAOyB,GAClE,cAARA,GAAuBvB,EAAUqB,EAAQE,GAAOA,CAAzB,CACvB,CAFA,CAMN,CCkBO,SAASC,EAA0BH,GAQjC,OANP5F,EAAO8D,UAAW,CAAlB,EAAsBO,QAAS,SAAU2B,GAC/BL,EAAAK,EAAQ,SAAE9F,EAAO4F,GACvBF,EAAQE,GAAQE,EAAQF,EACxB,CAFM,CAGR,CAJF,EAMOF,CACT,CCCO,SAASK,EAAyBL,GAchC,OAZP5F,EAAO8D,UAAW,CAAlB,EAAsBO,QAAS,SAAU2B,GAC/BL,EAAAK,EAAQ,SAAE9F,EAAO4F,GAClB5B,EAAShE,CAAT,EACK0F,EAAAE,GAAQ5F,EAAMF,MAAd,EACEiE,EAAU/D,CAAA,EACpB0F,EAAQE,GAAQG,EAAO,GAAIhC,EAAU2B,EAAQE,EAAR,EAAkBF,EAAQE,GAAQ,GAAI5F,CAA3D,EAEhB0F,EAAQE,GAAQ5F,CAElB,CARM,CASR,CAVF,EAYO0F,CACT,CC3DO,SAASM,EAAQC,GACtB9B,EAAS8B,EAAO,SAAQC,GACjBA,GAAQA,EAAKC,YACXD,EAAAC,WAAWC,YAAaF,CAAxB,CAEP,CAJF,CAKF,CCHO,SAASG,EAAMrG,GACpB,OAAOiE,EAAUjE,GAAUA,EAAQA,EAAYA,EAAZ,KAAyB,EAC9D,CCJgB,SAAAsG,EAAQC,EAAgBC,GACtC,GAAK,CAAED,EACL,MAAM,IAAIE,MAAYxG,IAAAA,QAAmBuG,GAAW,GAApD,CAEJ,CCb8CE,KAA/BC,IAAR,IAAaC,EAA0BF,KAA1BE,IAA0BF,KAArBG,MAAqBH,KAAdI,KAAcJ,KAARK,ICK/B,SAASC,EAAcC,GAC5B,OAAOA,EAAO1H,QAAS,qBAAsB,OAAtC,EAAgDI,YAAvD,CACF,CCCA,IAAMuH,EAA8B,GCuB7B,SAASC,IAKd,IAAIC,EAAoF,GAuF/E,SAAAC,EACPC,EACAC,EACAlD,GAEAF,EAASmD,EAAS,SAAUE,GAChBA,GAAArD,EAASoD,EAAQ,SAAAA,GACzBA,EAAOE,MAAO,GAAdF,EAAoBpD,QAAS,SAAWuD,GAChCC,EAAWD,EAAQD,MAAO,GAAf,EACjBpD,EAAUmD,EAAQG,EAAU,GAAKA,EAAU,EAA3C,CACA,CAHFJ,CAIA,CALQ,CAMV,CAPF,CAQF,CAUO,MAAA,CACL5D,KAhGF,SACE2D,EACAC,EACAK,EACA3I,GAEAoI,EAAcC,EAASC,EAAQ,SAAEC,EAAQK,EAAOC,GAC9C,IAAMC,EAAgB,qBAAsBP,EACtCQ,EAAUD,EACZP,EAAOS,oBAAoBtE,KAAM6D,EAAQK,EAAOD,EAAU3I,CAA1D,EACAuI,EAAA,eAA2B7D,KAAM6D,EAAQI,CAAzC,EAEYG,EAAAP,EAAOU,iBAAkBL,EAAOD,EAAU3I,CAA1C,EAAsDuI,EAAA,YAAyBI,CAAzB,EACtER,EAAU9C,KAAM,CAAEkD,EAAQK,EAAOC,EAAWF,EAAUI,EAAtD,CACA,CARF,CASF,EAkFEG,OAzEO,SAAQb,EAAuBC,EAA2BK,GACjEP,EAAcC,EAASC,EAAQ,SAAEC,EAAQK,EAAOC,GAClCV,EAAAA,EAAUhC,OAAQ,SAAYgD,GACxC,MAAKA,CAAAA,EAAAA,EAAU,KAAQZ,GAClBY,EAAU,KAAQP,GAClBO,EAAU,KAAQN,GACdF,GAAYQ,EAAU,KAAQR,KAErCQ,EAAU,GAAV,EACO,CAAA,EAIT,CAXU,CAYZ,CAbF,CAcF,EA2DEC,SAhDO,SAAab,EAAqB3G,EAAcyH,GACnD,IAAAtD,EAWG,MARqB,YAAvB,OAAOuD,YACVvD,EAAI,IAAIuD,YAAa1H,EAAM,CAAE2H,QAHf,CAAA,EAGwBF,OAAAA,CAAX,CAAvB,GAEAtD,EAAAyD,SAASC,YAAa,aAAtB,GACFC,gBAAiB9H,EANL,CAAA,EAMoB,CAAA,EAAOyH,CAAzC,EAGFd,EAAOoB,cAAe5D,CAAtB,EACOA,CACT,EAoCE6D,QATF,WACEzB,EAAUjD,QAAS,SAAQ2E,GAAEA,EAAM,GAAN,CAAc,CAA3C,EACO1B,ECzIH2B,OAAS,CD0If,CAEO,CAMT,CEvHO,SAASC,EAAgBjK,GAK9B,IAAMkK,EAAMlK,EAASA,EAAO8I,MAAMoB,IAAMR,SAASS,uBAAjD,EAKMC,EAAShC,EAAf,EA6BA,OAJKpI,GACHA,EAAO8I,MAAMuB,GClDuB,UDkDJD,EAAON,OAAvC9J,EAGK8G,EAAQsD,EAAQ,CACrBF,IAAAA,EACAG,GAvBO,SAAI7B,EAA2BK,GAC/BuB,EAAAxF,KAAMsF,EAAK/E,EAASqD,CAAA,EAAS8B,KAAM,GAAxB,EAA+B,SAAKrE,GAC3C4C,EAAAnE,MAAOmE,EAAU5D,EAASgB,EAAEsD,MAAF,EAAatD,EAAEsD,OAAS,EAAlD,CACT,CAFK,CAGT,EAoBEgB,IAAK7F,EAAO0F,EAAOhB,OAAQc,CAAtB,EACLM,KAbF,SAAe1B,GAEbsB,EAAOd,SAAUY,EAAKpB,EAAO/H,EAAO8D,UAAW,CAAX,CAApC,CACF,CAMuB,EAMzB,CE9EO,ICQM4F,EAA0C,CACrDC,QAAU,KACVC,SAAU,IAF2C,ECO1CC,aAsBX,SAAaC,EAAAA,EAAY3K,GAlBzB4K,KAAiBC,OAAiB,GAmBhCD,KAAKD,GAAUA,EACfC,KAAK5K,QAAUA,CACjB,4BAUA8K,KAAA,SAAMpF,EAAkBxF,EAAca,EAAwBgK,GAEtDC,EAAcJ,KAAKC,OADzBE,EAAaA,GAAc,WACqBH,KAAKC,OAAQE,IAAgB,IACzDC,EAAWtF,GAAasF,EAAWtF,IAAc,IAC7DxF,GAASa,CACnB,IAOAkK,MAAA,WAAgB,IAAAC,EAAAN,KACVO,EAAM,GAgBH,OAdFP,KAAKC,OAAOO,UACfD,GAAOP,KAAKS,eAAgBT,KAAKC,OAAOO,OAAjC,GAGF9E,OAAAC,KAAMqE,KAAKC,MAAX,EACJS,KAAM,SAAEC,EAAGC,GAAL,MAAwC,QAA5BN,EAAKlL,QAAQyL,WAAuB,CAACF,EAAI,CAACC,EAAI,CAACA,EAAI,CAACD,CAAhE,CADF,EAEJrG,QAAS,SAAc6F,GACF,YAAfA,IAGII,GAFPA,GAAA,iCAAyCJ,EAAzC,SACOG,EAAKG,eAAgBH,EAAKL,OAAQE,EAAlC,EACA,IAET,CARG,EAUAI,CACT,IASQE,eAAA,SAAgBL,GAAqE,IAAAU,EAAAd,KACvFO,EAAM,GAeH,OAbC3E,EAAAwE,EAAW,SAAEH,EAAQnF,GAC3BA,OAAgBgG,EAAKf,GAAQjF,IAAAA,GAAYiG,KAAzC,EACAR,GAAWzF,EAAX,KAEQc,EAAAqE,EAAQ,SAAE9J,EAAOb,GAClBa,CAAAA,GAAmB,IAAVA,IACZoK,GAAWjL,EAAWa,KAAAA,EAAtB,IAEF,CAJM,EAMDoK,GAAA,GACP,CAXM,EAaDA,CACT,yBCHA,SAAAS,EAAaC,EAAqC7L,EAAmB8L,EAAyBC,GAxC9FnB,KAAiBoB,OAAyB,GAe1CpB,KAAiB5K,QAAmB,GAepC4K,KAAiBqB,YAAqC,GAW7CnF,EAAAnF,EAAUoK,GAAY,EAAtB,EACPjF,EAAOA,EAAO8D,KAAK5K,QAAS2B,GAAY3B,GAAW,EAAnD,EAEA4K,KAAKiB,SAAYA,EACjBjB,KAAKkB,OAAYlF,EAAQ,GAAI2D,EAAyBuB,GAAU,EAAvC,EACzBlB,KAAKD,GAAYC,KAAKkB,OAAOnB,IR7FxB,IADiBuB,EQ8FuB,YCtG5BC,ETSUlE,EAAKiE,IAAajE,EAAKiE,IAAY,GAAM,GSRtD,GAAUC,IAAAA,KAAgBA,GDsGxCvB,KAAKF,MAAY,IAAIA,EAAOE,KAAKD,GAAIC,KAAK5K,OAAzB,EACjB4K,KAAK/K,UAAYA,EAAW,EAAM,EAAM+K,KAAK5K,OAA5B,EAETqH,EAAAuD,KAAKiB,SAAS/B,OAAQ,6BAAtB,EAERc,KAAKwB,KAAL,CACF,GAzEOC,MAAP,SAAcC,GACZ,IEjC+E5G,EFiCvEyE,EAAOJ,EAAgBuC,CAAhB,EAAPnC,GACAoC,EAASD,EAATC,KACFC,GEnC6CvG,EFmC1BsG,GEnCsD7G,EFmChE,IAAqBpE,GElCpBT,EAAUoF,EAAOwG,iBAAkB/G,CAAzB,CAAA,EAAwC,IFoClEyE,EJhDoC,UIgDjB,WACTpD,EAAAf,EAAOuG,EAAM,OAAb,CAAA,CACR,CAFF,EAIAxF,EAAQyF,CAAR,CACF,6BAoEQJ,KAAA,WACNxB,KAAK8B,iBAAL,EACA9B,KAAK+B,WAAL,EACA/B,KAAKgC,mBAAL,EACAhC,KAAKiC,oBAAL,EACAjC,KAAKkC,oBAAL,EACAlC,KAAKmC,mBAAL,CACF,IAKQJ,WAAA,WAAmB,IAAAK,EAAApC,KACzBvF,EAAMuF,KAAKoB,OAAQpB,KAAKiB,SAASoB,IAAK,SAAEC,EAAS7M,IAC/C6M,EAAUlI,EAAUkI,GAAY,CAAEC,KAAMD,CAAR,EAAoBA,GAC5CrC,OAASqC,EAAQrC,QAAU,GAC3BqC,EAAAE,MAASF,EAAQE,OAAS,GAElCJ,EAAKK,MAAOH,CAAZ,EAEMrK,EAAcmK,EAAKhN,QAAQ6C,QAAQC,MAAnC,KAAwD,IAAVzC,E7BtGjBqB,Y6BsG8C,IAO1E,OALPkF,EAAQsG,EAAQE,MAAO,CACrBE,OAAWzK,EAAJ,KAAiBqK,EAAQE,MAAME,OAAS,KAAM3B,KADhC,EAErB4B,MAAOP,EAAKQ,YAAaN,EAAQrC,MAA1B,CAFc,CAAvB,EAKOqC,CACP,CAfiB,CAAnB,EAiBKtC,KAAK6C,OAAL,GACE7C,KAAA8C,eAAgB9C,KAAKoB,MAArB,CAET,IAKQY,mBAAA,WAA2B,IAAAe,EAAA/C,KACjCA,KAAKqB,YAAY/G,QAAS,SAA0B0I,GAAA,IAAtBxO,EAAsBwO,EAAA,GAAf5N,EAAe4N,EAAA,GAC7CD,EAAAjD,MAAMI,KAAM,IAAK,YAAa1D,EAAMpH,EAAQZ,OAASA,CAArD,CACL,CAFF,CAGF,IAKQyN,oBAAA,WAA4B,IAAAgB,EAAAjD,KAC1BF,EAAUE,KAAVF,MACFhF,MAAgBvE,EAEtByJ,KAAKqB,YAAY/G,QAAS,SAA0B4I,GAAA,IAAtB1O,EAAsB0O,EAAA,GAAf9N,EAAe8N,EAAA,GAClDpD,EAAMI,KAAMpF,EAAUmI,EAAK5N,QAAS,aAAd,EAA+B4N,EAAKE,WAAY/N,EAAS,CAAA,CAA1B,EAAmCZ,CAAxFsL,EACAA,EAAMI,KAAMpF,EAAUmI,EAAK5N,QAAS,cAAd,EAAgC4N,EAAKE,WAAY/N,EAAS,CAAA,CAA1B,EAAkCZ,CAAxFsL,EACAA,EAAMI,KAAMpF,EAAU,SAAUmI,EAAKG,eAAgBhO,CAArB,EAAgCZ,CAAhEsL,CACA,CAJF,CAKF,IAKQqC,mBAAA,WAA2B,IAAAkB,EAAArD,KACzBF,EAAUE,KAAVF,MACFhF,MAAgBtE,EAEtBwJ,KAAKqB,YAAY/G,QAAS,SAA0BgJ,GAAA,IAAtB9O,EAAsB8O,EAAA,GAAflO,EAAekO,EAAA,GAClDxD,EAAMI,KAAMpF,EAAU,YAAauI,EAAKE,eAAgBnO,CAArB,EAAgCZ,CAAnEsL,EAEOuD,EAAKG,eAAgBpO,CAArB,GACL0K,EAAMI,KAAMpF,EAAU,eAAgBuI,EAAKI,eAAgBrO,CAArB,EAAgCZ,CAAtEsL,CAEF,CANF,CAOF,IAKQoC,oBAAA,WAA4B,IAAAwB,EAAA1D,KAC1BF,EAAUE,KAAVF,MACFhF,MAAgBrE,EAEtBuJ,KAAKqB,YAAY/G,QAAS,SAA0BqJ,GAAA,IAAtBnP,EAAsBmP,EAAA,GAAfvO,EAAeuO,EAAA,GAClD7D,EAAMI,KAAMpF,EAAU,QAAS4I,EAAKE,cAAexO,CAApB,EAA+BZ,CAA9DsL,EACAA,EAAMI,KAAMpF,EAAU,SAAU4I,EAAKF,eAAgBpO,CAArB,GAAkC,OAAQZ,CAA1EsL,EACAA,EAAMI,KAAMpF,EAAU4I,EAAKrO,QAAS,aAAd,EAA+BmH,EAAMpH,EAAQyO,GAAd,GAAuB,MAAOrP,CAAnFsL,EACAA,EAAMI,KAAUpF,WAAmB,UAAW1F,EAAQqN,MAAQ,OAAS,SAAUjO,CAAjFsL,CACA,CALF,CAMF,IASQyD,eAAA,SAAgBnO,GACtB,IAAA0O,EAA4B9D,KAAK/K,UAAzBI,IAAAA,QAASa,IAAAA,OACXqE,EAAS,GAUf,OARAA,EAAOE,KAAMuF,KAAK+D,gBAAiB3O,CAAtB,CAAb,EACAmF,EAAOE,KAAMuF,KAAKgE,cAAe5O,CAApB,CAAb,EAEK4K,KAAKiE,SAAU7O,CAAf,IACHmF,EAAOE,KAAMuF,KAAKkE,cAAehO,EAAQ,CAAI,IAAG,GAAnC,CAAb,EACAqE,EAAOE,KAAPb,MAAAW,EAAgByF,KAAKmE,gBAAiB/O,CAAtB,CAAhB,GAGKmF,EACJgB,OAAQ6I,OADJ,EAEJ/B,IAAK,SAAAlM,GAAA,MAAA,YAAsBd,EAAS,GAAT,MAAoBc,EAA1C,GAAA,CAFD,EAGJqJ,KAAM,GAHF,CAIT,IAUQuE,gBAAA,SAAiB3O,GACvB,IAIUe,EAJVkO,EAA4BrE,KAAK/K,UAAzBI,IAAAA,QAASa,IAAAA,OACXoO,EAAatE,KAAKuE,cAAlB,EAED,OAAAvE,KAAKwE,aAAcpP,CAAnB,GACKe,GAAgBsO,EAAAzE,KAAK0E,cAAetP,EAASC,EAAS,YAAA,EAAtC,GAAhBc,MAAOqG,IAAAA,KACRwD,KAAKkE,cAAehO,EAAQC,CAAR,EAAkBmO,EAAY9H,CAAlD,GAIEtG,EADK,IAAMoO,EAAalP,EAAQ+B,SACpC,GACT,IAcQgN,gBAAA,SAAiB/O,GACvB,IAQQ+B,EAKEhB,EAbVwO,EAA4B3E,KAAK/K,UAAzBI,IAAAA,QAASa,IAAAA,OAEZ,OAAA8J,KAAKwE,aAAcpP,CAAnB,GACKe,GAAgByO,EAAA5E,KAAK0E,cAAetP,EAASC,EAAS,YAAA,EAAtC,GAAhBc,MAAOqG,IAAAA,KACR,CAAEwD,KAAKkE,cAAehO,EAAQC,EAAQ,CAAhB,EAAqBqG,CAAzC,KAIHrF,EAAiB/B,EAAjB+B,QAAS0M,EAAQzO,EAARyO,KADXtJ,EAAS,IAGRE,KAAUvE,EAAQ,GAAKiB,CAAL,EAAzB,GAAA,EAEK0M,IACK1N,GAAR0O,EAAwB7E,KAAK0E,cAAeb,CAApB,GAAhB1N,MAAOqG,IAAAA,KAEfjC,EAAOE,KAAMuF,KAAKkE,cAAehO,GADbC,EAAQgB,EAAUhB,GAAU,GACMqG,CAAzC,CAAb,GAGKjC,EACT,IASQyJ,cAAA,SAAe5O,GACf,IAGIc,EACAC,EAAOqG,EAJX8H,EAAatE,KAAKuE,cAAlB,EAED,OAAAD,GAAclP,EAAQyO,KACjB3N,EAAW8J,KAAK/K,UAAhBiB,OACAC,GAAF2O,EAAkB9E,KAAK0E,cAAetP,EAAQyO,GAA5B,GAAhB1N,MAAOqG,IAAAA,KAEVwD,KAAKwE,aAAcpP,CAAnB,EACI4K,KAAKkE,cAAehO,EAAQC,EAAQmO,CAAhB,EAA8B9H,CAAlD,GAGDrF,EAAY/B,EAAZ+B,QAED6I,KAAKkE,cAAehO,EADdoO,EAAanN,EACgBhB,CAAf,EAAwBqG,CAA5C,IAGF,EACT,IASQnH,QAAA,SAASC,GACf,OAAO6H,EAAc6C,KAAK/K,UAAUI,QAASC,CAAxB,CAAA,CACvB,IAUQ6N,WAAA,SAAY/N,EAAkBV,GAC5BqQ,EAAY3P,EAAZ2P,QACFzP,EAAO0K,KAAK/K,UAAUI,QAASX,EAAQ,QAAU,OAAQ,CAAA,CAAlD,EACN,OAAAqQ,GAAWvI,EAAMuI,EAASzP,KAAY4E,EAAU6K,GAAY,EAAIA,KAAe,KACxF,IASQ3B,eAAA,SAAgBhO,GACtB,IAAI4P,EAAS,GAQN,OANFhF,KAAKiF,WAAL,IAEHxI,EADSuI,EAAAhF,KAAKkF,UAAW9P,CAAhB,EACO,sBAAhB,EACS4P,UAASA,EAAT,MAAuBhF,KAAKmD,WAAY/N,EAAS,CAAA,CAA1B,EAAvB,MAAgE4K,KAAKmD,WAAY/N,EAAS,CAAA,CAA1B,EAAhE,KAGJ4P,CACT,IASQE,UAAA,SAAW9P,GACV,OAAAoH,EAAMpH,EAAQ4P,MAAd,CACT,IASQpB,cAAA,SAAexO,GACrB,OAAOA,EAAQ+P,UACX,GACA3I,EAAMpH,EAAQgQ,UAAd,IAAgCpF,KAAKiF,WAAL,EAAoB,GAAKjF,KAAKqF,aAAcjQ,CAAnB,EAC/D,IASQoO,eAAA,SAAgBpO,GACtB,OAAOoH,EAAMpH,EAAQkQ,eACdtF,KAAKiF,WACJ7P,EAAAA,EAAQmQ,WAAa,GAAKvF,KAAKqF,aAAcjQ,CAAnB,EAC5B4K,KAAKkF,UAAW9P,CAAhB,EAER,IASQiQ,aAAA,SAAcjQ,GACd,IAAAyO,EAAMrH,EAAMpH,EAAQyO,GAAR,EACX,MAAA,cAAcA,SAAcA,GAA5B,MAAyCzO,EAAQ+B,SAAW,IAAM0M,SAAcA,GAAhF,GACT,IASQJ,eAAA,SAAgBrO,GACdoQ,EAAgBpQ,EAAhBoQ,YACD,OAAAA,EAAA,GAAkB,EAAIA,EAAiB,EAChD,IAUQtB,cAAA,SAAe/N,EAAeqG,GACpC,MAAWrG,GAAAA,EAAUqG,CACvB,IASQkI,cAAA,SAAevO,GAChB,OAAAiE,EAAUjE,CAAV,EAGI,CAAEA,MAFMsP,WAAYtP,CAAA,GAAW,EAEdqG,KADTrG,EAAMT,QAAS,cAAe,EAA9B,GAAsC,IAC9C,EAGF,CAAES,MAAAA,EAAOqG,KAAM,IAAf,CACT,IAKQsF,iBAAA,WAAyB,IAAA4D,EAAA1F,KACvBqB,EAAgBrB,KAAK5K,QAArBiM,YAERrB,KAAKqB,YAAY5G,KAAM,CAAE,UAAWuF,KAAK5K,QAAzC,EAEKiM,GACKzF,EAAAyF,EAAa,SAAEjM,EAASZ,GAC9BkR,EAAKrE,YAAY5G,KAAM,CAAEjG,EAAO0H,EAAOA,EAAO,GAAIwJ,EAAKtQ,OAAhB,EAA2BA,CAA3B,EAAvC,CACA,CAFM,CAIZ,IAOQoP,aAAA,SAAcpP,GACpB,MAAO,CAAC,CAAEA,EAAS4K,KAAK/K,UAAUI,QAAS,YAAxB,EACrB,IAOQwN,OAAA,WACC,MGtdS,SHsdT7C,KAAK5K,QAAQ4B,IACtB,IAOQiN,SAAA,SAAU7O,GACZ,GAAkB,WAAlBA,EAAQuQ,MAAqB,CAC1B,GAAA3F,KAAK6C,OAAL,EACI,MAAA,CAAA,EAGJ,GG3eU,UH2eV7C,KAAK5K,QAAQ4B,KACT,MAAA,CAAEgJ,KAAK5K,QAAQ0C,SAE1B,CAEO,MAAA,CAAA,CACT,IAOQmN,WAAA,WACC,OAAAjF,KAAK5K,QAAQI,YAAclB,CACpC,IAOQsR,aAAA,WACA,IAAExQ,EAAY4K,KAAZ5K,QAED,MAAA,CACLkB,EACIA,OAAiBlB,EAAQ4B,KACzBV,OAAiBlB,EAAQI,UAC7BJ,EAAQyC,MAAYvB,EAApB,cACAlB,EAAQyQ,cAAoBvP,EALvB,QAMLO,EACA,CAAEmJ,KAAKkB,OAAO4E,QHhhBU,eGihBxBvK,OAAQ6I,OARH,EAQa5E,KAAM,GARnB,CAST,IASQuG,WAAA,SAAYvD,GAClB,IAAIwD,EAAO,GAMX,OAJQpK,EAAA4G,EAAO,SAAErM,EAAO4F,GACtBiK,GAAQ7P,EAAQ,IAAKgH,EAAcpB,CAAA,EAAnB,KAA+B5F,EAA/B,IAA2C,EAC3D,CAFM,EAID6P,EAAKjF,KAAZ,CACF,IASQ6B,YAAA,SAAa3C,GACnB,IAAI0C,EAAQ,GAMZ,OAJQ/G,EAAAqE,EAAQ,SAAE9J,EAAO4F,GACd4G,OAAKxF,EAAcpB,CAAA,EAAnB,IAA8B5F,EAA9B,GACT,CAFM,EAIDwM,EAAM5B,KAAb,CACF,IAOQkF,aAAA,WAAuB,IAAAC,EAAAlG,KACXmG,EAAQnG,KAAKkB,OAAvBrB,SAED,OAAAG,KAAKoB,OAAOiB,IAAK,SAAWC,GAC1B,MAAA,IAAK6D,EAAS,IAAAD,EAAKH,WAAYzD,EAAQE,KAAzB,OAAsCF,EAAQC,MAAQ,SAAS4D,EAA7E,GACP,CAFK,EAEH3G,KAAM,EAFH,CAGT,IAOQiD,MAAA,SAAOH,GACb,IAAQrC,EAAsBqC,EAAtBrC,OAAsBqC,EAAAA,EAAdC,KAAAA,aAAO,GAAvB6D,EAEKpG,KAAK5K,QAAQqN,OAAWzC,CAAAA,KAAK5K,QAAQiR,WAClCC,EAAM/D,EAAK5M,MAAO,oCAAZ,IAEA2Q,EAAK,KACRrG,EAAAsG,WAAA,+BAA6CD,EAAK,GAAlD,KAGb,IAOQxD,eAAA,SAAgB7B,GAKd,IAJF,IAAEhJ,EAAY+H,KAAK5K,QAAjB6C,QACFuO,EAASxG,KAAKuE,cAAd,EACAnD,EAASH,EAAShL,MAAlB,EAEEmL,EAAOlC,OAASsH,GACtB/L,EAAM2G,EAAQA,CAAd,EAGF3G,EAAM2G,EAAOnL,MAAO,CAACuQ,CAAf,EAAuB1K,QAA7B,EAAwCsF,EAAOnL,MAAO,EAAGuQ,CAAjB,CAAxC,EAAmElM,QAAS,SAAEgI,EAAS7M,GACrF,IAAM+M,EAAQxG,EAAQ,GAAIsG,EAAQE,MAAO,CAAEE,MAAWJ,EAAQE,MAAME,MAAlB,IAA6BzK,EAAQE,KAA9C,CAA3B,EACRA,EAAQ6D,EAAQ,GAAIsG,EAAS,CAAEE,MAAAA,CAAF,CAAb,EACtB/M,EAAQ+Q,EAAQvF,EAASwF,QAAStO,CAAlB,EAA4B8I,EAASxG,KAAMtC,CAAf,CAC5C,CAJF,CAKF,IAOQoM,cAAA,WACD,IACKnP,EADL,OAAA4K,KAAK6C,OAAL,GACKzN,EAAY4K,KAAZ5K,SAEKwM,QAIG7E,EAAAnD,aAAQoG,KAAKqB,YAAYgB,IAAK,SAAAqE,GAAA,OAAAA,EAAA,GAA6BvP,OAA7B,CAAtB,CAAR,IACK/B,EAAQuR,eAAiB,GAAM,GAG/C,CACT,IAOQC,aAAA,WACN,IAAIrE,EAAO,GAOJ,OALCA,kBAAgBvC,KAAK5K,QAAQ6C,QAAQZ,OAArC,MACA2I,KAAK6G,YAAa,CAAA,CAAlB,EACA7G,KAAK6G,YAAa,CAAA,CAAlB,EACA,QAGV,IAUQA,YAAA,SAAaxO,GACnB,IAAAyO,EAA0B9G,KAAK5K,QAAvB6C,IAAAA,QAASQ,IAAAA,KACX+J,EAAQ,CACZE,MAAezK,EAAQG,WAAWC,EAAOJ,EAAQI,KAAOJ,EAAQK,MAChEtB,KAAW,SACX+P,UAAW1O,EAAOI,EAAKJ,KAAOI,EAAKH,IAHvB,EAMd,MAAmB,WAAA0H,KAAK+F,WAAYvD,CAAjB,EAAnB,iGAEiBxC,KAAK5K,QAAQ4R,WlCvpBd,yFkCqpBhB,qBAKF,IAOAzE,KAAA,WACQ,IAAA0E,EAA6FjH,KAAKkB,OAAhGgG,IAAAA,UAAWtH,IAAAA,QAASvI,IAAAA,OAAQ8P,IAAAA,YAAaC,IAAAA,WAAYC,IAAAA,OAAQC,IAAAA,aAAcC,IAAAA,YAE/EhF,EAAO,GAiCJ,OA9BCA,GADRA,GAAA,YAAqBvC,KAAKD,GAAgB,YAAAC,KAAK4F,aAAL,EAAyBsB,KAAAA,GAAa,IAAhF,iBACmBlH,KAAKF,MAAMO,QAAtB,YAEHgH,IAEK9E,EADRA,GAAQ+E,GAAgB,IAChB,gCAGV/E,GAAQ4E,GAAe,GAElB9P,IACHkL,GAAQvC,KAAK4G,aAAb,GAWFrE,GAHAA,GAJAA,EADQA,EAAA,+BACR,IAAa3C,EAAb,2BAEQI,KAAKiG,aAAb,GAEA,KAAcrG,EAAd,MACQ,UAEAwH,GAAc,IAEjBC,IAEH9E,EADQA,EAAA,UACAgF,GAAe,KAGjBhF,GAAA,QAGV"} \ No newline at end of file diff --git a/dist/js/splide.cjs.js b/dist/js/splide.cjs.js index 0f08d1e2..3e4901a8 100644 --- a/dist/js/splide.cjs.js +++ b/dist/js/splide.cjs.js @@ -1,73 +1,58 @@ /*! - * Splide.js + * @splidejs/splide * Version : 4.1.3 * License : MIT * Copyright: 2022 Naotoshi Fujita */ 'use strict'; -function _defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } - -function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); Object.defineProperty(Constructor, "prototype", { writable: false }); return Constructor; } - -Object.defineProperty(exports, '__esModule', { - value: true -}); -var MEDIA_PREFERS_REDUCED_MOTION = "(prefers-reduced-motion: reduce)"; -var CREATED = 1; -var MOUNTED = 2; -var IDLE = 3; -var MOVING = 4; -var SCROLLING = 5; -var DRAGGING = 6; -var DESTROYED = 7; -var STATES = { - CREATED: CREATED, - MOUNTED: MOUNTED, - IDLE: IDLE, - MOVING: MOVING, - SCROLLING: SCROLLING, - DRAGGING: DRAGGING, - DESTROYED: DESTROYED +Object.defineProperties(exports, { __esModule: { value: true }, [Symbol.toStringTag]: { value: 'Module' } }); + +const MEDIA_PREFERS_REDUCED_MOTION = "(prefers-reduced-motion: reduce)"; + +const CREATED = 1; +const MOUNTED = 2; +const IDLE = 3; +const MOVING = 4; +const SCROLLING = 5; +const DRAGGING = 6; +const DESTROYED = 7; +const STATES = { + CREATED, + MOUNTED, + IDLE, + MOVING, + SCROLLING, + DRAGGING, + DESTROYED }; function empty(array) { array.length = 0; } - -function slice(arrayLike, start, end) { - return Array.prototype.slice.call(arrayLike, start, end); -} - -function apply(func) { - return func.bind.apply(func, [null].concat(slice(arguments, 1))); +function apply(func, ...args) { + return func.bind(null, ...args); } - -var nextTick = setTimeout; - -var noop = function noop() {}; - +const nextTick = setTimeout; +const noop = () => { +}; function raf(func) { return requestAnimationFrame(func); } - function typeOf(type, subject) { return typeof subject === type; } - function isObject(subject) { return !isNull(subject) && typeOf("object", subject); } - -var isArray = Array.isArray; -var isFunction = apply(typeOf, "function"); -var isString = apply(typeOf, "string"); -var isUndefined = apply(typeOf, "undefined"); - +const isArray = Array.isArray; +const isFunction = apply(typeOf, "function"); +const isString = apply(typeOf, "string"); +apply(typeOf, "boolean"); +const isUndefined = apply(typeOf, "undefined"); function isNull(subject) { return subject === null; } - function isHTMLElement(subject) { try { return subject instanceof (subject.ownerDocument.defaultView || window).HTMLElement; @@ -75,573 +60,472 @@ function isHTMLElement(subject) { return false; } } - function toArray(value) { return isArray(value) ? value : [value]; } - function forEach(values, iteratee) { toArray(values).forEach(iteratee); } - -function includes(array, value) { - return array.indexOf(value) > -1; -} - function push(array, items) { - array.push.apply(array, toArray(items)); + array.push(...toArray(items)); return array; } - -function toggleClass(elm, classes, add) { - if (elm) { - forEach(classes, function (name) { - if (name) { - elm.classList[add ? "add" : "remove"](name); - } - }); - } -} - -function addClass(elm, classes) { - toggleClass(elm, isString(classes) ? classes.split(" ") : classes, true); -} - -function append(parent, children) { - forEach(children, parent.appendChild.bind(parent)); -} - -function before(nodes, ref) { - forEach(nodes, function (node) { - var parent = (ref || node).parentNode; - - if (parent) { - parent.insertBefore(node, ref); - } - }); +const arrayProto = Array.prototype; +function slice(arrayLike, start, end) { + return arrayProto.slice.call(arrayLike, start, end); } - -function matches(elm, selector) { - return isHTMLElement(elm) && (elm["msMatchesSelector"] || elm.matches).call(elm, selector); +function includes(arrayLike, value) { + return arrayProto.includes.call(arrayLike, value); } - -function children(parent, selector) { - var children2 = parent ? slice(parent.children) : []; - return selector ? children2.filter(function (child) { - return matches(child, selector); - }) : children2; +function toNumber(value) { + return Number(value) || 0; } - -function child(parent, selector) { - return selector ? children(parent, selector)[0] : parent.firstElementChild; +function assert$1(assertion, message) { + if (!assertion) { + throw new Error(message); + } } - -var ownKeys = Object.keys; - +const assign = Object.assign; +const ownKeys = Object.keys; function forOwn(object, iteratee, right) { if (object) { - (right ? ownKeys(object).reverse() : ownKeys(object)).forEach(function (key) { + (right ? ownKeys(object).reverse() : ownKeys(object)).forEach((key) => { key !== "__proto__" && iteratee(object[key], key); }); } - - return object; -} - -function assign(object) { - slice(arguments, 1).forEach(function (source) { - forOwn(source, function (value, key) { - object[key] = source[key]; - }); - }); return object; } - -function merge(object) { - slice(arguments, 1).forEach(function (source) { - forOwn(source, function (value, key) { +function merge(object, ...sources) { + sources.forEach((source) => { + forOwn(source, (value, key) => { if (isArray(value)) { - object[key] = value.slice(); + value = value.slice(); } else if (isObject(value)) { - object[key] = merge({}, isObject(object[key]) ? object[key] : {}, value); - } else { - object[key] = value; + value = merge({}, isObject(object[key]) ? object[key] : {}, value); } + object[key] = value; }); }); return object; } - function omit(object, keys) { - forEach(keys || ownKeys(object), function (key) { + forEach(keys || ownKeys(object), (key) => { delete object[key]; }); + return object; +} +function toggleClass(elm, classes, force) { + if (elm) { + forEach(isString(classes) ? classes.split(" ") : classes, (className) => { + className && elm.classList.toggle(className, force); + }); + } +} +function addClass(elm, classes) { + toggleClass(elm, classes, true); +} +function append(parent, ...children2) { + parent && parent.append(...children2); +} +function before(ref, ...nodes) { + ref && ref.before(...nodes); +} +function matches(elm, selector) { + return isHTMLElement(elm) && elm.matches(selector); +} +function children(parent, selector) { + const children2 = parent ? slice(parent.children) : []; + return selector ? children2.filter((child2) => matches(child2, selector)) : children2; +} +function child(parent, selector) { + return selector ? children(parent, selector)[0] : parent.firstElementChild; +} +function closest(from, selector) { + return from.closest(selector); } - function removeAttribute(elms, attrs) { - forEach(elms, function (elm) { - forEach(attrs, function (attr) { + forEach(elms, (elm) => { + forEach(attrs, (attr) => { elm && elm.removeAttribute(attr); }); }); } - function setAttribute(elms, attrs, value) { if (isObject(attrs)) { - forOwn(attrs, function (value2, name) { + forOwn(attrs, (value2, name) => { setAttribute(elms, name, value2); }); } else { - forEach(elms, function (elm) { - isNull(value) || value === "" ? removeAttribute(elm, attrs) : elm.setAttribute(attrs, String(value)); + forEach(elms, (elm) => { + isNull(value) || isUndefined(value) || value === "" ? removeAttribute(elm, attrs) : elm.setAttribute(attrs, String(value)); }); } } - -function create(tag, attrs, parent) { - var elm = document.createElement(tag); - +function create(tag2, attrs, parent) { + const elm = document.createElement(tag2); if (attrs) { isString(attrs) ? addClass(elm, attrs) : setAttribute(elm, attrs); } - parent && append(parent, elm); return elm; } - function style(elm, prop, value) { if (isUndefined(value)) { return getComputedStyle(elm)[prop]; } - if (!isNull(value)) { - elm.style[prop] = "" + value; + elm.style[prop] = `${value}`; } } - function display(elm, display2) { style(elm, "display", display2); } - function focus(elm) { - elm["setActive"] && elm["setActive"]() || elm.focus({ - preventScroll: true - }); + isHTMLElement(elm) && elm.focus({ preventScroll: true }); } - function getAttribute(elm, attr) { return elm.getAttribute(attr); } - function hasClass(elm, className) { - return elm && elm.classList.contains(className); + return !!elm && elm.classList.contains(className); } - function rect(target) { return target.getBoundingClientRect(); } - -function remove(nodes) { - forEach(nodes, function (node) { +function removeNode(nodes) { + forEach(nodes, (node) => { if (node && node.parentNode) { node.parentNode.removeChild(node); } }); } - function parseHtml(html) { return child(new DOMParser().parseFromString(html, "text/html").body); } - function prevent(e, stopPropagation) { e.preventDefault(); - if (stopPropagation) { e.stopPropagation(); e.stopImmediatePropagation(); } } - function query(parent, selector) { return parent && parent.querySelector(selector); } - function queryAll(parent, selector) { - return selector ? slice(parent.querySelectorAll(selector)) : []; + return selector && parent ? slice(parent.querySelectorAll(selector)) : []; } - function removeClass(elm, classes) { toggleClass(elm, classes, false); } - function timeOf(e) { return e.timeStamp; } - function unit(value) { - return isString(value) ? value : value ? value + "px" : ""; + return isString(value) ? value : value ? `${value}px` : ""; } - -var PROJECT_CODE = "splide"; -var DATA_ATTRIBUTE = "data-" + PROJECT_CODE; - -function assert(condition, message) { - if (!condition) { - throw new Error("[" + PROJECT_CODE + "] " + (message || "")); - } +function classNames(...args) { + return args.reduce((classes, value) => { + return `${classes} ${isArray(value) ? classNames(...value) : value || ""}`.trim(); + }, ""); } - -var min = Math.min, - max = Math.max, - floor = Math.floor, - ceil = Math.ceil, - abs = Math.abs; - +const { min, max, floor, ceil, abs, sign } = Math; function approximatelyEqual(x, y, epsilon) { return abs(x - y) < epsilon; } - function between(number, x, y, exclusive) { - var minimum = min(x, y); - var maximum = max(x, y); + const minimum = min(x, y); + const maximum = max(x, y); return exclusive ? minimum < number && number < maximum : minimum <= number && number <= maximum; } - function clamp(number, x, y) { - var minimum = min(x, y); - var maximum = max(x, y); + const minimum = min(x, y); + const maximum = max(x, y); return min(max(minimum, number), maximum); } - -function sign(x) { - return +(x > 0) - +(x < 0); -} - function camelToKebab(string) { return string.replace(/([a-z0-9])([A-Z])/g, "$1-$2").toLowerCase(); } - -function format(string, replacements) { - forEach(replacements, function (replacement) { - string = string.replace("%s", "" + replacement); - }); - return string; +function format(string, ...replacements) { + return replacements.reduce((prev, curr) => prev.replace("%s", `${curr}`), string); } - -function pad(number) { - return number < 10 ? "0" + number : "" + number; +function pad(number, length = 2) { + return `${number}`.padStart(length, "0"); } - -var ids = {}; - +const ids = {}; function uniqueId(prefix) { - return "" + prefix + pad(ids[prefix] = (ids[prefix] || 0) + 1); + return `${prefix}${pad(ids[prefix] = (ids[prefix] || 0) + 1)}`; } - -function EventBinder() { - var listeners = []; - - function bind(targets, events, callback, options) { - forEachEvent(targets, events, function (target, event, namespace) { - var isEventTarget = ("addEventListener" in target); - var remover = isEventTarget ? target.removeEventListener.bind(target, event, callback, options) : target["removeListener"].bind(target, callback); - isEventTarget ? target.addEventListener(event, callback, options) : target["addListener"](callback); - listeners.push([target, event, namespace, callback, remover]); +function forEachEvent(events, iteratee) { + forEach(events, (event) => { + isString(event) && event.split(" ").forEach(iteratee); + }); +} +function EventBinder(removersRef) { + const removers = removersRef || /* @__PURE__ */ new Set(); + const key = removersRef ? {} : void 0; + let destroyed; + function bind(target, events, callback, options) { + assert$1(!destroyed); + forEachEvent(events, (event) => { + target.addEventListener(event, callback, options); + removers.add([target.removeEventListener.bind(target, event, callback, options), key]); }); } - - function unbind(targets, events, callback) { - forEachEvent(targets, events, function (target, event, namespace) { - listeners = listeners.filter(function (listener) { - if (listener[0] === target && listener[1] === event && listener[2] === namespace && (!callback || listener[3] === callback)) { - listener[4](); - return false; - } - - return true; - }); + function destroy(hard) { + removers.forEach((remover) => { + if (!key || remover[1] === key) { + remover[0](); + removers.delete(remover); + } }); + destroyed = hard; } - - function dispatch(target, type, detail) { - var e; - var bubbles = true; - - if (typeof CustomEvent === "function") { - e = new CustomEvent(type, { - bubbles: bubbles, - detail: detail - }); - } else { - e = document.createEvent("CustomEvent"); - e.initCustomEvent(type, bubbles, false, detail); - } - - target.dispatchEvent(e); - return e; + return { + bind, + lock: apply(EventBinder, removers), + destroy + }; +} +function EventBus(listenersRef) { + const listeners = listenersRef || {}; + const key = listenersRef ? {} : void 0; + let destroyed; + function on(events, callback) { + assert$1(!destroyed); + forEachEvent(events, (event) => { + listeners[event] = push(get(event), [[callback, key]]); + }); } - - function forEachEvent(targets, events, iteratee) { - forEach(targets, function (target) { - target && forEach(events, function (events2) { - events2.split(" ").forEach(function (eventNS) { - var fragment = eventNS.split("."); - iteratee(target, fragment[0], fragment[1]); - }); - }); + function off(events, callback) { + forEachEvent(events, (event) => { + listeners[event] = get(event).filter((listener) => !((!callback || listener[0] === callback) && listener[1] === key)); }); } - - function destroy() { - listeners.forEach(function (data) { - data[4](); + function emit(event, ...args) { + get(event).forEach((listener) => listener[0] && listener[0](...args)); + } + function get(event) { + return listeners[event] || []; + } + function destroy(hard) { + forOwn(listeners, (entries, event) => { + listeners[event] = entries.filter((listener) => { + const unlocked = !key || listener[1] === key; + unlocked && empty(listener); + return !unlocked; + }); }); - empty(listeners); + !key && omit(listeners); + destroyed = hard; } - return { - bind: bind, - unbind: unbind, - dispatch: dispatch, - destroy: destroy + on, + off, + emit, + lock: apply(EventBus, listeners), + destroy }; } - -var EVENT_MOUNTED = "mounted"; -var EVENT_READY = "ready"; -var EVENT_MOVE = "move"; -var EVENT_MOVED = "moved"; -var EVENT_CLICK = "click"; -var EVENT_ACTIVE = "active"; -var EVENT_INACTIVE = "inactive"; -var EVENT_VISIBLE = "visible"; -var EVENT_HIDDEN = "hidden"; -var EVENT_REFRESH = "refresh"; -var EVENT_UPDATED = "updated"; -var EVENT_RESIZE = "resize"; -var EVENT_RESIZED = "resized"; -var EVENT_DRAG = "drag"; -var EVENT_DRAGGING = "dragging"; -var EVENT_DRAGGED = "dragged"; -var EVENT_SCROLL = "scroll"; -var EVENT_SCROLLED = "scrolled"; -var EVENT_OVERFLOW = "overflow"; -var EVENT_DESTROY = "destroy"; -var EVENT_ARROWS_MOUNTED = "arrows:mounted"; -var EVENT_ARROWS_UPDATED = "arrows:updated"; -var EVENT_PAGINATION_MOUNTED = "pagination:mounted"; -var EVENT_PAGINATION_UPDATED = "pagination:updated"; -var EVENT_NAVIGATION_MOUNTED = "navigation:mounted"; -var EVENT_AUTOPLAY_PLAY = "autoplay:play"; -var EVENT_AUTOPLAY_PLAYING = "autoplay:playing"; -var EVENT_AUTOPLAY_PAUSE = "autoplay:pause"; -var EVENT_LAZYLOAD_LOADED = "lazyload:loaded"; -var EVENT_SLIDE_KEYDOWN = "sk"; -var EVENT_SHIFTED = "sh"; -var EVENT_END_INDEX_CHANGED = "ei"; - -function EventInterface(Splide2) { - var bus = Splide2 ? Splide2.event.bus : document.createDocumentFragment(); - var binder = EventBinder(); - - function on(events, callback) { - binder.bind(bus, toArray(events).join(" "), function (e) { - callback.apply(callback, isArray(e.detail) ? e.detail : []); - }); - } - - function emit(event) { - binder.dispatch(bus, event, slice(arguments, 1)); +function EventInterface(binder = EventBinder(), bus = EventBus()) { + function lock() { + return EventInterface(binder.lock(), bus.lock()); } - - if (Splide2) { - Splide2.event.on(EVENT_DESTROY, binder.destroy); + function destroy(hard) { + binder.destroy(hard); + bus.destroy(hard); } - - return assign(binder, { - bus: bus, - on: on, - off: apply(binder.unbind, bus), - emit: emit - }); + return assign({}, binder, bus, { lock, destroy }); } - function RequestInterval(interval, onInterval, onUpdate, limit) { - var now = Date.now; - var startTime; - var rate = 0; - var id; - var paused = true; - var count = 0; - + const { now } = Date; + let startTime; + let rate = 0; + let id; + let paused = true; + let count = 0; function update() { if (!paused) { rate = interval ? min((now() - startTime) / interval, 1) : 1; onUpdate && onUpdate(rate); - if (rate >= 1) { onInterval(); startTime = now(); - if (limit && ++count >= limit) { return pause(); } } - id = raf(update); } } - function start(resume) { resume || cancel(); startTime = now() - (resume ? rate * interval : 0); paused = false; id = raf(update); } - function pause() { paused = true; } - function rewind() { startTime = now(); rate = 0; - if (onUpdate) { onUpdate(rate); } } - function cancel() { id && cancelAnimationFrame(id); rate = 0; id = 0; paused = true; } - function set(time) { interval = time; } - function isPaused() { return paused; } - return { - start: start, - rewind: rewind, - pause: pause, - cancel: cancel, - set: set, - isPaused: isPaused + start, + rewind, + pause, + cancel, + set, + isPaused }; } - function State(initialState) { - var state = initialState; - + let state = initialState; function set(value) { state = value; } - function is(states) { return includes(toArray(states), state); } - - return { - set: set, - is: is - }; + return { set, is }; } - function Throttle(func, duration) { - var interval = RequestInterval(duration || 0, func, null, 1); - return function () { + const interval = RequestInterval(duration || 0, func, void 0, 1); + return () => { interval.isPaused() && interval.start(); }; } -function Media(Splide2, Components2, options) { - var state = Splide2.state; - var breakpoints = options.breakpoints || {}; - var reducedMotion = options.reducedMotion || {}; - var binder = EventBinder(); - var queries = []; - +const EVENT_MOUNTED = "mounted"; +const EVENT_READY = "ready"; +const EVENT_MOVE = "move"; +const EVENT_MOVED = "moved"; +const EVENT_CLICK = "click"; +const EVENT_ACTIVE = "active"; +const EVENT_INACTIVE = "inactive"; +const EVENT_VISIBLE = "visible"; +const EVENT_HIDDEN = "hidden"; +const EVENT_REFRESH = "refresh"; +const EVENT_UPDATED = "updated"; +const EVENT_RESIZE = "resize"; +const EVENT_RESIZED = "resized"; +const EVENT_DRAG = "drag"; +const EVENT_DRAGGING = "dragging"; +const EVENT_DRAGGED = "dragged"; +const EVENT_SCROLL = "scroll"; +const EVENT_SCROLLING = "scrolling"; +const EVENT_SCROLLED = "scrolled"; +const EVENT_OVERFLOW = "overflow"; +const EVENT_DESTROY = "destroy"; +const EVENT_ARROWS_MOUNTED = "arrows:mounted"; +const EVENT_ARROWS_UPDATED = "arrows:updated"; +const EVENT_PAGINATION_MOUNTED = "pagination:mounted"; +const EVENT_PAGINATION_UPDATED = "pagination:updated"; +const EVENT_NAVIGATION_MOUNTED = "navigation:mounted"; +const EVENT_AUTOPLAY_PLAY = "autoplay:play"; +const EVENT_AUTOPLAY_PLAYING = "autoplay:playing"; +const EVENT_AUTOPLAY_PAUSE = "autoplay:pause"; +const EVENT_LAZYLOAD_LOADED = "lazyload:loaded"; +const EVENT_LAZYLOAD_ERROR = "lazyload:error"; +const EVENT_SLIDE_KEYDOWN = "_sk"; +const EVENT_SHIFTED = "_sh"; +const EVENT_END_INDEX_CHANGED = "_ei"; + +const NOT_OVERFLOW_KEY = "!overflow"; +const Breakpoints = (Splide, Components, options, event) => { + const { state } = Splide; + const breakpoints = options.breakpoints || {}; + const reducedMotion = options.reducedMotion || {}; + const binder = EventBinder(); + const entries = []; function setup() { - var isMin = options.mediaQuery === "min"; - ownKeys(breakpoints).sort(function (n, m) { - return isMin ? +n - +m : +m - +n; - }).forEach(function (key) { - register(breakpoints[key], "(" + (isMin ? "min" : "max") + "-width:" + key + "px)"); + const isMin = options.mediaQuery === "min"; + ownKeys(breakpoints).sort((n, m) => isMin ? +n - +m : +m - +n).forEach((key) => { + if (key !== NOT_OVERFLOW_KEY) { + register(breakpoints[key], `(${isMin ? "min" : "max"}-width:${key}px)`); + } }); + if (breakpoints[NOT_OVERFLOW_KEY]) { + entries.push([breakpoints[NOT_OVERFLOW_KEY], () => Components.Layout && !Components.Layout.isOverflow()]); + event.on(EVENT_OVERFLOW, update); + } register(reducedMotion, MEDIA_PREFERS_REDUCED_MOTION); update(); } - function destroy(completely) { if (completely) { binder.destroy(); } } - function register(options2, query) { - var queryList = matchMedia(query); + const queryList = matchMedia(query); binder.bind(queryList, "change", update); - queries.push([options2, queryList]); + entries.push([options2, () => queryList.matches]); } - function update() { - var destroyed = state.is(DESTROYED); - var direction = options.direction; - var merged = queries.reduce(function (merged2, entry) { - return merge(merged2, entry[1].matches ? entry[0] : {}); + const destroyed = state.is(DESTROYED); + const direction = options.direction; + const merged = entries.reduce((merged2, entry) => { + return merge(merged2, entry[1]() ? entry[0] : {}); }, {}); omit(options); - set(merged); - + set(merged, false, !state.is(CREATED)); if (options.destroy) { - Splide2.destroy(options.destroy === "completely"); + Splide.destroy(options.destroy === "completely"); } else if (destroyed) { destroy(true); - Splide2.mount(); + Splide.mount(); } else { - direction !== options.direction && Splide2.refresh(); + direction !== options.direction && Splide.refresh(); } } - function reduce(enable) { if (matchMedia(MEDIA_PREFERS_REDUCED_MOTION).matches) { enable ? merge(options, reducedMotion) : omit(options, ownKeys(reducedMotion)); } } - function set(opts, base, notify) { merge(options, opts); base && merge(Object.getPrototypeOf(options), opts); - - if (notify || !state.is(CREATED)) { - Splide2.emit(EVENT_UPDATED, options); + if (notify) { + Splide.emit(EVENT_UPDATED, options); } } - return { - setup: setup, - destroy: destroy, - reduce: reduce, - set: set + setup, + destroy, + reduce, + set }; -} +}; + +const ARROW = "Arrow"; +const ARROW_LEFT = `${ARROW}Left`; +const ARROW_RIGHT = `${ARROW}Right`; +const ARROW_UP = `${ARROW}Up`; +const ARROW_DOWN = `${ARROW}Down`; -var ARROW = "Arrow"; -var ARROW_LEFT = ARROW + "Left"; -var ARROW_RIGHT = ARROW + "Right"; -var ARROW_UP = ARROW + "Up"; -var ARROW_DOWN = ARROW + "Down"; -var LTR = "ltr"; -var RTL = "rtl"; -var TTB = "ttb"; -var ORIENTATION_MAP = { +const LTR = "ltr"; +const RTL = "rtl"; +const TTB = "ttb"; + +const ORIENTATION_MAP = { width: ["height"], left: ["top", "right"], right: ["bottom", "left"], @@ -651,74 +535,100 @@ var ORIENTATION_MAP = { ArrowLeft: [ARROW_UP, ARROW_RIGHT], ArrowRight: [ARROW_DOWN, ARROW_LEFT] }; - -function Direction(Splide2, Components2, options) { - function resolve(prop, axisOnly, direction) { - direction = direction || options.direction; - var index = direction === RTL && !axisOnly ? 1 : direction === TTB ? 0 : -1; - return ORIENTATION_MAP[prop] && ORIENTATION_MAP[prop][index] || prop.replace(/width|left|right/i, function (match, offset) { - var replacement = ORIENTATION_MAP[match.toLowerCase()][index] || match; +const Direction = (Splide, Components, options) => { + function resolve(prop, axisOnly, direction = options.direction) { + const index = direction === RTL && !axisOnly ? 1 : direction === TTB ? 0 : -1; + return find(prop, index) || prop.replace(/width|left|right/i, (match, offset) => { + const replacement = find(match.toLowerCase(), index) || match; return offset > 0 ? replacement.charAt(0).toUpperCase() + replacement.slice(1) : replacement; }); } - - function orient(value) { - return value * (options.direction === RTL ? 1 : -1); + function find(prop, index) { + const props = ORIENTATION_MAP[prop]; + return props && index > -1 ? props[index] : ""; + } + function orient(value, direction = options.direction) { + return value * (direction === RTL ? 1 : -1); } - return { - resolve: resolve, - orient: orient + resolve, + orient, + left: apply(resolve, "left"), + right: apply(resolve, "right"), + width: apply(resolve, "width") }; -} +}; -var ROLE = "role"; -var TAB_INDEX = "tabindex"; -var DISABLED = "disabled"; -var ARIA_PREFIX = "aria-"; -var ARIA_CONTROLS = ARIA_PREFIX + "controls"; -var ARIA_CURRENT = ARIA_PREFIX + "current"; -var ARIA_SELECTED = ARIA_PREFIX + "selected"; -var ARIA_LABEL = ARIA_PREFIX + "label"; -var ARIA_LABELLEDBY = ARIA_PREFIX + "labelledby"; -var ARIA_HIDDEN = ARIA_PREFIX + "hidden"; -var ARIA_ORIENTATION = ARIA_PREFIX + "orientation"; -var ARIA_ROLEDESCRIPTION = ARIA_PREFIX + "roledescription"; -var ARIA_LIVE = ARIA_PREFIX + "live"; -var ARIA_BUSY = ARIA_PREFIX + "busy"; -var ARIA_ATOMIC = ARIA_PREFIX + "atomic"; -var ALL_ATTRIBUTES = [ROLE, TAB_INDEX, DISABLED, ARIA_CONTROLS, ARIA_CURRENT, ARIA_LABEL, ARIA_LABELLEDBY, ARIA_HIDDEN, ARIA_ORIENTATION, ARIA_ROLEDESCRIPTION]; -var CLASS_PREFIX = PROJECT_CODE + "__"; -var STATUS_CLASS_PREFIX = "is-"; -var CLASS_ROOT = PROJECT_CODE; -var CLASS_TRACK = CLASS_PREFIX + "track"; -var CLASS_LIST = CLASS_PREFIX + "list"; -var CLASS_SLIDE = CLASS_PREFIX + "slide"; -var CLASS_CLONE = CLASS_SLIDE + "--clone"; -var CLASS_CONTAINER = CLASS_SLIDE + "__container"; -var CLASS_ARROWS = CLASS_PREFIX + "arrows"; -var CLASS_ARROW = CLASS_PREFIX + "arrow"; -var CLASS_ARROW_PREV = CLASS_ARROW + "--prev"; -var CLASS_ARROW_NEXT = CLASS_ARROW + "--next"; -var CLASS_PAGINATION = CLASS_PREFIX + "pagination"; -var CLASS_PAGINATION_PAGE = CLASS_PAGINATION + "__page"; -var CLASS_PROGRESS = CLASS_PREFIX + "progress"; -var CLASS_PROGRESS_BAR = CLASS_PROGRESS + "__bar"; -var CLASS_TOGGLE = CLASS_PREFIX + "toggle"; -var CLASS_TOGGLE_PLAY = CLASS_TOGGLE + "__play"; -var CLASS_TOGGLE_PAUSE = CLASS_TOGGLE + "__pause"; -var CLASS_SPINNER = CLASS_PREFIX + "spinner"; -var CLASS_SR = CLASS_PREFIX + "sr"; -var CLASS_INITIALIZED = STATUS_CLASS_PREFIX + "initialized"; -var CLASS_ACTIVE = STATUS_CLASS_PREFIX + "active"; -var CLASS_PREV = STATUS_CLASS_PREFIX + "prev"; -var CLASS_NEXT = STATUS_CLASS_PREFIX + "next"; -var CLASS_VISIBLE = STATUS_CLASS_PREFIX + "visible"; -var CLASS_LOADING = STATUS_CLASS_PREFIX + "loading"; -var CLASS_FOCUS_IN = STATUS_CLASS_PREFIX + "focus-in"; -var CLASS_OVERFLOW = STATUS_CLASS_PREFIX + "overflow"; -var STATUS_CLASSES = [CLASS_ACTIVE, CLASS_VISIBLE, CLASS_PREV, CLASS_NEXT, CLASS_LOADING, CLASS_FOCUS_IN, CLASS_OVERFLOW]; -var CLASSES = { +const ROLE = "role"; +const TAB_INDEX = "tabindex"; +const DISABLED = "disabled"; +const ARIA_PREFIX = "aria-"; +const ARIA_CONTROLS = `${ARIA_PREFIX}controls`; +const ARIA_CURRENT = `${ARIA_PREFIX}current`; +const ARIA_SELECTED = `${ARIA_PREFIX}selected`; +const ARIA_LABEL = `${ARIA_PREFIX}label`; +const ARIA_LABELLEDBY = `${ARIA_PREFIX}labelledby`; +const ARIA_HIDDEN = `${ARIA_PREFIX}hidden`; +const ARIA_ORIENTATION = `${ARIA_PREFIX}orientation`; +const ARIA_ROLEDESCRIPTION = `${ARIA_PREFIX}roledescription`; +const ARIA_LIVE = `${ARIA_PREFIX}live`; +const ARIA_BUSY = `${ARIA_PREFIX}busy`; +const ARIA_ATOMIC = `${ARIA_PREFIX}atomic`; +const ALL_ATTRIBUTES = [ + ROLE, + TAB_INDEX, + DISABLED, + ARIA_CONTROLS, + ARIA_CURRENT, + ARIA_LABEL, + ARIA_LABELLEDBY, + ARIA_HIDDEN, + ARIA_ORIENTATION, + ARIA_ROLEDESCRIPTION +]; + +const PROJECT_CODE = "splide"; +const DATA_ATTRIBUTE = `data-${PROJECT_CODE}`; + +const CLASS_PREFIX = `${PROJECT_CODE}__`; +const STATUS_CLASS_PREFIX = "is-"; +const CLASS_ROOT = PROJECT_CODE; +const CLASS_TRACK = `${CLASS_PREFIX}track`; +const CLASS_LIST = `${CLASS_PREFIX}list`; +const CLASS_SLIDE = `${CLASS_PREFIX}slide`; +const CLASS_CLONE = `${CLASS_SLIDE}--clone`; +const CLASS_CONTAINER = `${CLASS_SLIDE}__container`; +const CLASS_ARROWS = `${CLASS_PREFIX}arrows`; +const CLASS_ARROW = `${CLASS_PREFIX}arrow`; +const CLASS_ARROW_PREV = `${CLASS_ARROW}--prev`; +const CLASS_ARROW_NEXT = `${CLASS_ARROW}--next`; +const CLASS_PAGINATION = `${CLASS_PREFIX}pagination`; +const CLASS_PAGINATION_PAGE = `${CLASS_PAGINATION}__page`; +const CLASS_PROGRESS = `${CLASS_PREFIX}progress`; +const CLASS_PROGRESS_BAR = `${CLASS_PROGRESS}__bar`; +const CLASS_TOGGLE = `${CLASS_PREFIX}toggle`; +const CLASS_TOGGLE_PLAY = `${CLASS_TOGGLE}__play`; +const CLASS_TOGGLE_PAUSE = `${CLASS_TOGGLE}__pause`; +const CLASS_SPINNER = `${CLASS_PREFIX}spinner`; +const CLASS_SR = `${CLASS_PREFIX}sr`; +const CLASS_INITIALIZED = `${STATUS_CLASS_PREFIX}initialized`; +const CLASS_ACTIVE = `${STATUS_CLASS_PREFIX}active`; +const CLASS_PREV = `${STATUS_CLASS_PREFIX}prev`; +const CLASS_NEXT = `${STATUS_CLASS_PREFIX}next`; +const CLASS_VISIBLE = `${STATUS_CLASS_PREFIX}visible`; +const CLASS_LOADING = `${STATUS_CLASS_PREFIX}loading`; +const CLASS_FOCUS_IN = `${STATUS_CLASS_PREFIX}focus-in`; +const CLASS_OVERFLOW = `${STATUS_CLASS_PREFIX}overflow`; +const STATUS_CLASSES = [ + CLASS_ACTIVE, + CLASS_VISIBLE, + CLASS_PREV, + CLASS_NEXT, + CLASS_LOADING, + CLASS_FOCUS_IN, + CLASS_OVERFLOW +]; +const CLASSES = { slide: CLASS_SLIDE, clone: CLASS_CLONE, arrows: CLASS_ARROWS, @@ -730,74 +640,52 @@ var CLASSES = { spinner: CLASS_SPINNER }; -function closest(from, selector) { - if (isFunction(from.closest)) { - return from.closest(selector); - } - - var elm = from; - - while (elm && elm.nodeType === 1) { - if (matches(elm, selector)) { - break; - } - - elm = elm.parentElement; - } - - return elm; -} - -var FRICTION = 5; -var LOG_INTERVAL = 200; -var POINTER_DOWN_EVENTS = "touchstart mousedown"; -var POINTER_MOVE_EVENTS = "touchmove mousemove"; -var POINTER_UP_EVENTS = "touchend touchcancel mouseup click"; - -function Elements(Splide2, Components2, options) { - var _EventInterface = EventInterface(Splide2), - on = _EventInterface.on, - bind = _EventInterface.bind; - - var root = Splide2.root; - var i18n = options.i18n; - var elements = {}; - var slides = []; - var rootClasses = []; - var trackClasses = []; - var track; - var list; - var isUsingKey; - +function assert(condition, message) { + if (!condition) { + throw new Error(`[${PROJECT_CODE}] ${message || ""}`); + } +} + +const FRICTION = 5; +const LOG_INTERVAL = 200; +const POINTER_DOWN_EVENTS = "touchstart mousedown"; +const POINTER_MOVE_EVENTS = "touchmove mousemove"; +const POINTER_UP_EVENTS = "touchend touchcancel mouseup click"; + +const Elements = (Splide, Components, options, event) => { + const { on, bind } = event; + const { root } = Splide; + const elements = {}; + const slides = []; + let rootClasses; + let trackClasses; + let track; + let list; + let isUsingKey; function setup() { collect(); init(); update(); } - function mount() { on(EVENT_REFRESH, destroy); on(EVENT_REFRESH, setup); on(EVENT_UPDATED, update); - bind(document, POINTER_DOWN_EVENTS + " keydown", function (e) { + bind(document, `${POINTER_DOWN_EVENTS} keydown`, (e) => { isUsingKey = e.type === "keydown"; - }, { - capture: true - }); - bind(root, "focusin", function () { - toggleClass(root, CLASS_FOCUS_IN, !!isUsingKey); + }, { capture: true }); + bind(root, "focusin", () => { + toggleClass(root, CLASS_FOCUS_IN, isUsingKey); }); } - function destroy(completely) { - var attrs = ALL_ATTRIBUTES.concat("style"); + const attrs = ALL_ATTRIBUTES.concat("style"); empty(slides); removeClass(root, rootClasses); removeClass(track, trackClasses); removeAttribute([track, list], attrs); removeAttribute(root, completely ? attrs : ["style", ARIA_ROLEDESCRIPTION]); } - function update() { removeClass(root, rootClasses); removeClass(track, trackClasses); @@ -808,107 +696,95 @@ function Elements(Splide2, Components2, options) { setAttribute(root, ARIA_LABEL, options.label); setAttribute(root, ARIA_LABELLEDBY, options.labelledby); } - function collect() { - track = find("." + CLASS_TRACK); - list = child(track, "." + CLASS_LIST); - assert(track && list, "A track/list element is missing."); - push(slides, children(list, "." + CLASS_SLIDE + ":not(." + CLASS_CLONE + ")")); - forOwn({ - arrows: CLASS_ARROWS, - pagination: CLASS_PAGINATION, - prev: CLASS_ARROW_PREV, - next: CLASS_ARROW_NEXT, - bar: CLASS_PROGRESS_BAR, - toggle: CLASS_TOGGLE - }, function (className, key) { - elements[key] = find("." + className); - }); - assign(elements, { - root: root, - track: track, - list: list, - slides: slides - }); + const trackElm = find(CLASS_TRACK); + const listElm = trackElm && child(trackElm, `.${CLASS_LIST}`); + if (trackElm && listElm) { + track = trackElm; + list = listElm; + push(slides, children(list, `.${CLASS_SLIDE}:not(.${CLASS_CLONE})`)); + assign(elements, { + root, + track, + list, + slides, + arrows: find(CLASS_ARROWS), + pagination: find(CLASS_PAGINATION), + prev: find(CLASS_ARROW_PREV), + next: find(CLASS_ARROW_NEXT), + bar: find(CLASS_PROGRESS_BAR), + toggle: find(CLASS_TOGGLE) + }); + } else { + assert(0, "A track/list element is missing."); + } } - function init() { - var id = root.id || uniqueId(PROJECT_CODE); - var role = options.role; + const { role = "region" } = options; + const id = root.id || uniqueId(PROJECT_CODE); root.id = id; - track.id = track.id || id + "-track"; - list.id = list.id || id + "-list"; - + track.id = track.id || `${id}-track`; + list.id = list.id || `${id}-list`; if (!getAttribute(root, ROLE) && root.tagName !== "SECTION" && role) { setAttribute(root, ROLE, role); } - - setAttribute(root, ARIA_ROLEDESCRIPTION, i18n.carousel); + setAttribute(root, ARIA_ROLEDESCRIPTION, Splide.i18n("carousel")); setAttribute(list, ROLE, "presentation"); } - - function find(selector) { - var elm = query(root, selector); - return elm && closest(elm, "." + CLASS_ROOT) === root ? elm : void 0; + function find(className) { + const elm = query(root, `.${className}`); + return elm && closest(elm, `.${CLASS_ROOT}`) === root ? elm : void 0; } - function getClasses(base) { - return [base + "--" + options.type, base + "--" + options.direction, options.drag && base + "--draggable", options.isNavigation && base + "--nav", base === CLASS_ROOT && CLASS_ACTIVE]; + return classNames( + `${base}--${options.type}`, + `${base}--${options.direction}`, + options.drag && `${base}--draggable`, + options.isNavigation && `${base}--nav`, + base === CLASS_ROOT && CLASS_ACTIVE + ); } - return assign(elements, { - setup: setup, - mount: mount, - destroy: destroy + setup, + mount, + destroy }); -} - -var SLIDE = "slide"; -var LOOP = "loop"; -var FADE = "fade"; - -function Slide$1(Splide2, index, slideIndex, slide) { - var event = EventInterface(Splide2); - var on = event.on, - emit = event.emit, - bind = event.bind; - var Components = Splide2.Components, - root = Splide2.root, - options = Splide2.options; - var isNavigation = options.isNavigation, - updateOnMove = options.updateOnMove, - i18n = options.i18n, - pagination = options.pagination, - slideFocus = options.slideFocus; - var resolve = Components.Direction.resolve; - var styles = getAttribute(slide, "style"); - var label = getAttribute(slide, ARIA_LABEL); - var isClone = slideIndex > -1; - var container = child(slide, "." + CLASS_CONTAINER); - var destroyed; +}; +const SLIDE = "slide"; +const LOOP = "loop"; +const FADE = "fade"; + +const Slide$1 = (Splide2, index, slideIndex, slide) => { + const event = Splide2.event.lock(); + const { on, emit, bind } = event; + const { Components, root, options } = Splide2; + const { isNavigation, updateOnMove, pagination, slideFocus } = options; + const { Elements } = Components; + const { resolve } = Components.Direction; + const styles = getAttribute(slide, "style"); + const label = getAttribute(slide, ARIA_LABEL); + const isClone = slideIndex > -1; + const container = child(slide, `.${CLASS_CONTAINER}`); + let destroyed; function mount() { if (!isClone) { - slide.id = root.id + "-slide" + pad(index + 1); + slide.id = `${root.id}-slide${pad(index + 1)}`; setAttribute(slide, ROLE, pagination ? "tabpanel" : "group"); - setAttribute(slide, ARIA_ROLEDESCRIPTION, i18n.slide); - setAttribute(slide, ARIA_LABEL, label || format(i18n.slideLabel, [index + 1, Splide2.length])); + setAttribute(slide, ARIA_ROLEDESCRIPTION, Splide2.i18n("slide")); + setAttribute(slide, ARIA_LABEL, label || format(Splide2.i18n("slideLabel"), index + 1, Splide2.length)); } - listen(); } - function listen() { bind(slide, "click", apply(emit, EVENT_CLICK, self)); bind(slide, "keydown", apply(emit, EVENT_SLIDE_KEYDOWN, self)); on([EVENT_MOVED, EVENT_SHIFTED, EVENT_SCROLLED], update); on(EVENT_NAVIGATION_MOUNTED, initNavigation); - if (updateOnMove) { on(EVENT_MOVE, onMove); } } - function destroy() { destroyed = true; event.destroy(); @@ -917,226 +793,171 @@ function Slide$1(Splide2, index, slideIndex, slide) { setAttribute(slide, "style", styles); setAttribute(slide, ARIA_LABEL, label || ""); } - function initNavigation() { - var controls = Splide2.splides.map(function (target) { - var Slide2 = target.splide.Components.Slides.getAt(index); + const controls = Splide2.splides.map((target) => { + const Slide2 = target.splide.Components.Slides.getAt(index); return Slide2 ? Slide2.slide.id : ""; }).join(" "); - setAttribute(slide, ARIA_LABEL, format(i18n.slideX, (isClone ? slideIndex : index) + 1)); + setAttribute(slide, ARIA_LABEL, format(Splide2.i18n("slideX"), (isClone ? slideIndex : index) + 1)); setAttribute(slide, ARIA_CONTROLS, controls); setAttribute(slide, ROLE, slideFocus ? "button" : ""); slideFocus && removeAttribute(slide, ARIA_ROLEDESCRIPTION); } - function onMove() { if (!destroyed) { update(); } } - function update() { if (!destroyed) { - var curr = Splide2.index; + const { index: curr } = Splide2; updateActivity(); updateVisibility(); toggleClass(slide, CLASS_PREV, index === curr - 1); toggleClass(slide, CLASS_NEXT, index === curr + 1); } } - function updateActivity() { - var active = isActive(); - + const active = isActive(); if (active !== hasClass(slide, CLASS_ACTIVE)) { toggleClass(slide, CLASS_ACTIVE, active); setAttribute(slide, ARIA_CURRENT, isNavigation && active || ""); emit(active ? EVENT_ACTIVE : EVENT_INACTIVE, self); } } - function updateVisibility() { - var visible = isVisible(); - var hidden = !visible && (!isActive() || isClone); - + const visible = isVisible(); + const hidden = !visible && (!isActive() || isClone); if (!Splide2.state.is([MOVING, SCROLLING])) { setAttribute(slide, ARIA_HIDDEN, hidden || ""); } - setAttribute(queryAll(slide, options.focusableNodes || ""), TAB_INDEX, hidden ? -1 : ""); - if (slideFocus) { setAttribute(slide, TAB_INDEX, hidden ? -1 : 0); } - if (visible !== hasClass(slide, CLASS_VISIBLE)) { toggleClass(slide, CLASS_VISIBLE, visible); emit(visible ? EVENT_VISIBLE : EVENT_HIDDEN, self); } - if (!visible && document.activeElement === slide) { - var Slide2 = Components.Slides.getAt(Splide2.index); + const Slide2 = Components.Slides.getAt(Splide2.index); Slide2 && focus(Slide2.slide); } } - function style$1(prop, value, useContainer) { style(useContainer && container || slide, prop, value); } - function isActive() { - var curr = Splide2.index; - return curr === index || options.cloneStatus && curr === slideIndex; + const { index: curr } = Splide2; + const { cloneStatus = true } = options; + return curr === index || cloneStatus && curr === slideIndex; } - - function isVisible() { + function isVisible(partial) { if (Splide2.is(FADE)) { return isActive(); } - - var trackRect = rect(Components.Elements.track); - var slideRect = rect(slide); - var left = resolve("left", true); - var right = resolve("right", true); - return floor(trackRect[left]) <= ceil(slideRect[left]) && floor(slideRect[right]) <= ceil(trackRect[right]); + const trackRect = rect(Elements.track); + const slideRect = rect(slide); + const left = resolve("left", true); + const right = resolve("right", true); + return floor(trackRect[left]) <= ceil(slideRect[partial ? right : left]) && floor(slideRect[partial ? left : right]) <= ceil(trackRect[right]); } - function isWithin(from, distance) { - var diff = abs(from - index); - + let diff = abs(from - index); if (!isClone && (options.rewind || Splide2.is(LOOP))) { diff = min(diff, Splide2.length - diff); } - return diff <= distance; } - - var self = { - index: index, - slideIndex: slideIndex, - slide: slide, - container: container, - isClone: isClone, - mount: mount, - destroy: destroy, - update: update, + const self = { + index, + slideIndex, + slide, + container, + isClone, + mount, + destroy, + update, style: style$1, - isWithin: isWithin + isVisible, + isWithin }; return self; -} - -function Slides(Splide2, Components2, options) { - var _EventInterface2 = EventInterface(Splide2), - on = _EventInterface2.on, - emit = _EventInterface2.emit, - bind = _EventInterface2.bind; - - var _Components2$Elements = Components2.Elements, - slides = _Components2$Elements.slides, - list = _Components2$Elements.list; - var Slides2 = []; +}; +const Slides = (Splide, Components, options, event) => { + const { on, emit, bind } = event; + const { slides, list } = Components.Elements; + const Slides2 = []; function mount() { init(); on(EVENT_REFRESH, destroy); on(EVENT_REFRESH, init); } - function init() { - slides.forEach(function (slide, index) { - register(slide, index, -1); - }); + slides.forEach((slide, index) => register(slide, index, -1)); } - function destroy() { - forEach$1(function (Slide2) { - Slide2.destroy(); - }); + forEach$1((Slide2) => Slide2.destroy()); empty(Slides2); } - function update() { - forEach$1(function (Slide2) { - Slide2.update(); - }); + forEach$1((Slide2) => Slide2.update()); } - function register(slide, index, slideIndex) { - var object = Slide$1(Splide2, index, slideIndex, slide); - object.mount(); - Slides2.push(object); - Slides2.sort(function (Slide1, Slide2) { - return Slide1.index - Slide2.index; - }); + const instance = Slide$1(Splide, index, slideIndex, slide); + instance.mount(); + Slides2.push(instance); + Slides2.sort((Slide1, Slide2) => Slide1.index - Slide2.index); } - function get(excludeClones) { - return excludeClones ? filter(function (Slide2) { - return !Slide2.isClone; - }) : Slides2; + return excludeClones ? filter((Slide2) => !Slide2.isClone) : Slides2; } - function getIn(page) { - var Controller = Components2.Controller; - var index = Controller.toIndex(page); - var max = Controller.hasFocus() ? 1 : options.perPage; - return filter(function (Slide2) { - return between(Slide2.index, index, index + max - 1); - }); + const { Controller } = Components; + const index = Controller.toIndex(page); + const max = Controller.hasFocus() ? 1 : options.perPage || 1; + return filter((Slide2) => between(Slide2.index, index, index + max - 1)); } - function getAt(index) { return filter(index)[0]; } - function add(items, index) { - forEach(items, function (slide) { + forEach(items, (slide) => { if (isString(slide)) { - slide = parseHtml(slide); + slide = parseHtml(slide) || ""; } - if (isHTMLElement(slide)) { - var ref = slides[index]; - ref ? before(slide, ref) : append(list, slide); - addClass(slide, options.classes.slide); + const ref = slides[index || -1]; + ref ? before(ref, slide) : append(list, slide); + addClass(slide, Splide.classes("slide")); observeImages(slide, apply(emit, EVENT_RESIZE)); } }); emit(EVENT_REFRESH); } - - function remove$1(matcher) { - remove(filter(matcher).map(function (Slide2) { - return Slide2.slide; - })); + function remove(matcher) { + removeNode(filter(matcher).map((Slide2) => Slide2.slide)); emit(EVENT_REFRESH); } - function forEach$1(iteratee, excludeClones) { get(excludeClones).forEach(iteratee); } - function filter(matcher) { - return Slides2.filter(isFunction(matcher) ? matcher : function (Slide2) { - return isString(matcher) ? matches(Slide2.slide, matcher) : includes(toArray(matcher), Slide2.index); - }); + return Slides2.filter( + isFunction(matcher) ? matcher : (Slide2) => isString(matcher) ? matches(Slide2.slide, matcher) : includes(toArray(matcher), Slide2.index) + ); } - function style(prop, value, useContainer) { - forEach$1(function (Slide2) { - Slide2.style(prop, value, useContainer); - }); + forEach$1((Slide2) => Slide2.style(prop, value, useContainer)); } - function observeImages(elm, callback) { - var images = queryAll(elm, "img"); - var length = images.length; - + const images = queryAll(elm, "img"); + let { length } = images; if (length) { - images.forEach(function (img) { - bind(img, "load error", function () { - if (! --length) { + images.forEach((img) => { + bind(img, "load error", () => { + if (!--length) { callback(); } }); @@ -1145,58 +966,45 @@ function Slides(Splide2, Components2, options) { callback(); } } - function getLength(excludeClones) { return excludeClones ? slides.length : Slides2.length; } - function isEnough() { - return Slides2.length > options.perPage; + return Slides2.length > (options.perPage || 1); } - return { - mount: mount, - destroy: destroy, - update: update, - register: register, - get: get, - getIn: getIn, - getAt: getAt, - add: add, - remove: remove$1, + mount, + destroy, + update, + register, + get, + getIn, + getAt, + add, + remove, forEach: forEach$1, - filter: filter, - style: style, - getLength: getLength, - isEnough: isEnough + filter, + style, + getLength, + isEnough }; -} - -function Layout(Splide2, Components2, options) { - var _EventInterface3 = EventInterface(Splide2), - on = _EventInterface3.on, - bind = _EventInterface3.bind, - emit = _EventInterface3.emit; - - var Slides = Components2.Slides; - var resolve = Components2.Direction.resolve; - var _Components2$Elements2 = Components2.Elements, - root = _Components2$Elements2.root, - track = _Components2$Elements2.track, - list = _Components2$Elements2.list; - var getAt = Slides.getAt, - styleSlides = Slides.style; - var vertical; - var rootRect; - var overflow; +}; +const Layout = (Splide, Components, options, event) => { + const { on, bind, emit } = event; + const { Slides } = Components; + const { resolve, left, right, width } = Components.Direction; + const { root, track, list } = Components.Elements; + const { getAt, style: styleSlides } = Slides; + let vertical; + let rootRect; + let overflow; function mount() { init(); bind(window, "resize load", Throttle(apply(emit, EVENT_RESIZE))); on([EVENT_UPDATED, EVENT_REFRESH], init); on(EVENT_RESIZE, resize); } - function init() { vertical = options.direction === TTB; style(root, "maxWidth", unit(options.width)); @@ -1204,10 +1012,8 @@ function Layout(Splide2, Components2, options) { style(track, resolve("paddingRight"), cssPadding(true)); resize(true); } - function resize(force) { - var newRect = rect(root); - + const newRect = rect(root); if (force || rootRect.width !== newRect.width || rootRect.height !== newRect.height) { style(track, "height", cssTrackHeight()); styleSlides(resolve("marginRight"), unit(options.gap)); @@ -1215,282 +1021,238 @@ function Layout(Splide2, Components2, options) { styleSlides("height", cssSlideHeight(), true); rootRect = newRect; emit(EVENT_RESIZED); - if (overflow !== (overflow = isOverflow())) { toggleClass(root, CLASS_OVERFLOW, overflow); emit(EVENT_OVERFLOW, overflow); } } } - - function cssPadding(right) { - var padding = options.padding; - var prop = resolve(right ? "right" : "left"); - return padding && unit(padding[prop] || (isObject(padding) ? 0 : padding)) || "0px"; + function cssPadding(rightPadding) { + const { padding } = options; + const prop = rightPadding ? right() : left(); + return unit(isObject(padding) ? padding[prop] : padding) || "0px"; } - function cssTrackHeight() { - var height = ""; - + let height = ""; if (vertical) { height = cssHeight(); assert(height, "height or heightRatio is missing."); - height = "calc(" + height + " - " + cssPadding(false) + " - " + cssPadding(true) + ")"; + height = `calc(${height} - ${cssPadding(false)} - ${cssPadding(true)})`; } - return height; } - function cssHeight() { - return unit(options.height || rect(list).width * options.heightRatio); + return unit(options.height || rect(list).width * (options.heightRatio || 0)); } - function cssSlideWidth() { return options.autoWidth ? null : unit(options.fixedWidth) || (vertical ? "" : cssSlideSize()); } - function cssSlideHeight() { return unit(options.fixedHeight) || (vertical ? options.autoHeight ? null : cssSlideSize() : cssHeight()); } - function cssSlideSize() { - var gap = unit(options.gap); - return "calc((100%" + (gap && " + " + gap) + ")/" + (options.perPage || 1) + (gap && " - " + gap) + ")"; + const gap = unit(options.gap); + return `calc((100%${gap && ` + ${gap}`})/${options.perPage || 1}${gap && ` - ${gap}`})`; } - - function listSize() { - return rect(list)[resolve("width")]; + function trackSize() { + return rect(track)[width()]; } - - function slideSize(index, withoutGap) { - var Slide = getAt(index || 0); - return Slide ? rect(Slide.slide)[resolve("width")] + (withoutGap ? 0 : getGap()) : 0; + function listSize(full) { + return full ? list[resolve("scrollWidth")] : rect(list)[width()]; + } + function slideSize(index = 0, withoutGap) { + const slide = getAt(index); + return (slide ? rect(slide.slide)[width()] : 0) + (withoutGap ? 0 : getGap()); } - function totalSize(index, withoutGap) { - var Slide = getAt(index); - - if (Slide) { - var right = rect(Slide.slide)[resolve("right")]; - var left = rect(list)[resolve("left")]; - return abs(right - left) + (withoutGap ? 0 : getGap()); - } - - return 0; + const first = Components.Slides.get()[0]; + const target = getAt(index); + return first && target ? abs(rect(target.slide)[right()] - rect(first.slide)[left()]) + (withoutGap ? 0 : getGap()) : 0; } - function sliderSize(withoutGap) { - return totalSize(Splide2.length - 1) - totalSize(0) + slideSize(0, withoutGap); + return totalSize(Splide.length - 1) - totalSize(0) + slideSize(0, withoutGap); } - function getGap() { - var Slide = getAt(0); - return Slide && parseFloat(style(Slide.slide, resolve("marginRight"))) || 0; + const first = getAt(0); + const second = getAt(1); + if (first && second) { + const firstRect = rect(first.slide); + return abs(rect(second.slide)[left()] - firstRect[left()]) - firstRect[width()]; + } + return 0; } - - function getPadding(right) { - return parseFloat(style(track, resolve("padding" + (right ? "Right" : "Left")))) || 0; + function getPadding(right2) { + return parseFloat(style( + track, + resolve(`padding${right2 ? "Right" : "Left"}`) + )) || 0; } - function isOverflow() { - return Splide2.is(FADE) || sliderSize(true) > listSize(); + return Splide.is(FADE) || sliderSize(true) > listSize(); } - return { - mount: mount, - resize: resize, - listSize: listSize, - slideSize: slideSize, - sliderSize: sliderSize, - totalSize: totalSize, - getPadding: getPadding, - isOverflow: isOverflow + mount, + resize, + trackSize, + listSize, + slideSize, + sliderSize, + totalSize, + getPadding, + isOverflow }; -} - -var MULTIPLIER = 2; - -function Clones(Splide2, Components2, options) { - var event = EventInterface(Splide2); - var on = event.on; - var Elements = Components2.Elements, - Slides = Components2.Slides; - var resolve = Components2.Direction.resolve; - var clones = []; - var cloneCount; +}; +const MULTIPLIER = 2; +const Clones = (Splide, Components, options, event) => { + const { on } = event; + const { Elements, Slides, Layout: { resize, trackSize } } = Components; + const { resolve } = Components.Direction; + const clones = []; + let cloneCount; function mount() { on(EVENT_REFRESH, remount); on([EVENT_UPDATED, EVENT_RESIZE], observe); - if (cloneCount = computeCloneCount()) { generate(cloneCount); - Components2.Layout.resize(true); + resize(true); } } - function remount() { destroy(); mount(); + resize(true); } - function destroy() { - remove(clones); + removeNode(clones); empty(clones); event.destroy(); } - function observe() { - var count = computeCloneCount(); - + const count = computeCloneCount(); if (cloneCount !== count) { if (cloneCount < count || !count) { + !count && Splide.go(0); event.emit(EVENT_REFRESH); } } } - function generate(count) { - var slides = Slides.get().slice(); - var length = slides.length; - + const slides = Slides.get().slice(); + const { length } = slides; if (length) { while (slides.length < count) { push(slides, slides); } - - push(slides.slice(-count), slides.slice(0, count)).forEach(function (Slide, index) { - var isHead = index < count; - var clone = cloneDeep(Slide.slide, index); - isHead ? before(clone, slides[0].slide) : append(Elements.list, clone); + push(slides.slice(-count), slides.slice(0, count)).forEach((Slide, index) => { + const isHead = index < count; + const clone = cloneDeep(Slide.slide, index); + isHead ? before(slides[0].slide, clone) : append(Elements.list, clone); push(clones, clone); Slides.register(clone, index - count + (isHead ? 0 : length), Slide.index); }); } } - function cloneDeep(elm, index) { - var clone = elm.cloneNode(true); - addClass(clone, options.classes.clone); - clone.id = Splide2.root.id + "-clone" + pad(index + 1); + const clone = elm.cloneNode(true); + addClass(clone, Splide.classes("clone")); + clone.id = `${Splide.root.id}-clone${pad(index + 1)}`; return clone; } - function computeCloneCount() { - var clones2 = options.clones; - - if (!Splide2.is(LOOP)) { + let { clones: clones2 } = options; + if (!Splide.is(LOOP)) { clones2 = 0; } else if (isUndefined(clones2)) { - var fixedSize = options[resolve("fixedWidth")] && Components2.Layout.slideSize(0); - var fixedCount = fixedSize && ceil(rect(Elements.track)[resolve("width")] / fixedSize); - clones2 = fixedCount || options[resolve("autoWidth")] && Splide2.length || options.perPage * MULTIPLIER; + const { perPage = 1 } = options; + const fixedSize = options[resolve("fixedWidth")] && Components.Layout.slideSize(0); + const fixedCount = fixedSize && ceil(trackSize() / fixedSize); + clones2 = fixedCount || options[resolve("autoWidth")] && Splide.length || perPage * MULTIPLIER; } - return clones2; } - return { - mount: mount, - destroy: destroy + mount, + destroy }; -} - -function Move(Splide2, Components2, options) { - var _EventInterface4 = EventInterface(Splide2), - on = _EventInterface4.on, - emit = _EventInterface4.emit; - - var set = Splide2.state.set; - var _Components2$Layout = Components2.Layout, - slideSize = _Components2$Layout.slideSize, - getPadding = _Components2$Layout.getPadding, - totalSize = _Components2$Layout.totalSize, - listSize = _Components2$Layout.listSize, - sliderSize = _Components2$Layout.sliderSize; - var _Components2$Directio = Components2.Direction, - resolve = _Components2$Directio.resolve, - orient = _Components2$Directio.orient; - var _Components2$Elements3 = Components2.Elements, - list = _Components2$Elements3.list, - track = _Components2$Elements3.track; - var Transition; +}; +const Move = (Splide, Components, options, event) => { + const { on, emit } = event; + const { set, is } = Splide.state; + const { Slides } = Components; + const { slideSize, getPadding, listSize, sliderSize, totalSize, trackSize } = Components.Layout; + const { resolve, orient } = Components.Direction; + const { list, track } = Components.Elements; + let Transition; + let indices; + let callback; function mount() { - Transition = Components2.Transition; + Transition = Components.Transition; on([EVENT_MOUNTED, EVENT_RESIZED, EVENT_UPDATED, EVENT_REFRESH], reposition); } - function reposition() { - if (!Components2.Controller.isBusy()) { - Components2.Scroll.cancel(); - jump(Splide2.index); - Components2.Slides.update(); - } - } - - function move(dest, index, prev, callback) { - if (dest !== index && canShift(dest > prev)) { - cancel(); - translate(shift(getPosition(), dest > prev), true); - } - + if (!Components.Controller.isBusy()) { + Components.Scroll.cancel(); + jump(Splide.index); + Slides.update(); + } + } + function move(dest, index, prev, forwards, onMoved) { + cancel(); + const shiftBackwards = dest !== index ? dest > index : forwards; + const shouldShift = (dest !== index || exceededLimit(forwards)) && canShift(shiftBackwards); + shouldShift && translate(shift(getPosition(), shiftBackwards), true); + indices = [index, prev, dest]; + callback = onMoved; set(MOVING); emit(EVENT_MOVE, index, prev, dest); - Transition.start(index, function () { - set(IDLE); - emit(EVENT_MOVED, index, prev, dest); - callback && callback(); - }); + Transition.start(index, onTransitionEnd); + } + function onTransitionEnd() { + set(IDLE); + emit(EVENT_MOVED, ...indices); + callback && callback(); + } + function cancel() { + if (is(MOVING) && indices) { + translate(getPosition(), true); + Transition.cancel(); + onTransitionEnd(); + } } - function jump(index) { - translate(toPosition(index, true)); + translate(toPosition(index)); } - function translate(position, preventLoop) { - if (!Splide2.is(FADE)) { - var destination = preventLoop ? position : loop(position); - style(list, "transform", "translate" + resolve("X") + "(" + destination + "px)"); + if (!Splide.is(FADE)) { + const destination = preventLoop ? position : loop(position); + style(list, "transform", `translate${resolve("X")}(${destination}px)`); position !== destination && emit(EVENT_SHIFTED); } } - function loop(position) { - if (Splide2.is(LOOP)) { - var index = toIndex(position); - var exceededMax = index > Components2.Controller.getEnd(); - var exceededMin = index < 0; - - if (exceededMin || exceededMax) { - position = shift(position, exceededMax); + if (Splide.is(LOOP)) { + const diff = orient(position) - orient(getPosition()); + if (diff && exceededLimit(diff > 0, position)) { + position = shift(position, diff > 0); } } - return position; } - function shift(position, backwards) { - var excess = position - getLimit(backwards); - var size = sliderSize(); + const excess = position - getLimit(backwards); + const size = sliderSize(); position -= orient(size * (ceil(abs(excess) / size) || 1)) * (backwards ? 1 : -1); return position; } - - function cancel() { - translate(getPosition(), true); - Transition.cancel(); - } - function toIndex(position) { - var Slides = Components2.Slides.get(); - var index = 0; - var minDistance = Infinity; - - for (var i = 0; i < Slides.length; i++) { - var slideIndex = Slides[i].index; - var distance = abs(toPosition(slideIndex, true) - position); - + const slides = Slides.get(); + let index = 0; + let minDistance = Infinity; + for (let i = 0; i < slides.length; i++) { + const slideIndex = slides[i].index; + const distance = abs(toPosition(slideIndex) - position); if (distance <= minDistance) { minDistance = distance; index = slideIndex; @@ -1498,179 +1260,177 @@ function Move(Splide2, Components2, options) { break; } } - return index; } - - function toPosition(index, trimming) { - var position = orient(totalSize(index - 1) - offset(index)); - return trimming ? trim(position) : position; + function toPosition(index) { + let position = orient(totalSize(index - 1) - offset(index)); + if (options.trimSpace && Splide.is(SLIDE)) { + position = clamp(position, 0, orient(sliderSize(true) - listSize())); + } + return position; } - function getPosition() { - var left = resolve("left"); + const left = resolve("left"); return rect(list)[left] - rect(track)[left] + orient(getPadding(false)); } - - function trim(position) { - if (options.trimSpace && Splide2.is(SLIDE)) { - position = clamp(position, 0, orient(sliderSize(true) - listSize())); + function getRate(index) { + const useIndex = !isUndefined(index); + let rate; + if (Splide.is(FADE)) { + rate = (useIndex ? index : Splide.index) / (Splide.length - 1); + } else { + const isLoop = Splide.is(LOOP); + const position = orient(useIndex ? toPosition(index) : getPosition()); + const min = orient(getLimit(false)); + const max = orient(getLimit(true)); + const size = sliderSize(); + const curr = (position - min) % size; + const base = isLoop ? size : max - min; + rate = curr / base || 0; + if (isLoop && rate < 0) { + rate += 1; + } } - - return position; + return clamp(rate, 0, 1); } - function offset(index) { - var focus = options.focus; - return focus === "center" ? (listSize() - slideSize(index, true)) / 2 : +focus * slideSize(index) || 0; + const { focus } = options; + return focus === "center" ? (listSize() - slideSize(index, true)) / 2 : toNumber(focus) * slideSize(index); } - function getLimit(max) { - return toPosition(max ? Components2.Controller.getEnd() : 0, !!options.trimSpace); + return toPosition(max ? Components.Controller.getEnd() : 0); } - function canShift(backwards) { - var shifted = orient(shift(getPosition(), backwards)); - return backwards ? shifted >= 0 : shifted <= list[resolve("scrollWidth")] - rect(track)[resolve("width")]; + const padding = getPadding(false); + const shifted = orient(shift(getPosition(), backwards)); + return backwards ? shifted >= padding : shifted <= listSize(true) - trackSize() + padding; } - - function exceededLimit(max, position) { - position = isUndefined(position) ? getPosition() : position; - var exceededMin = max !== true && orient(position) < orient(getLimit(false)); - var exceededMax = max !== false && orient(position) > orient(getLimit(true)); + function exceededLimit(max, position = getPosition()) { + const exceededMin = max !== true && orient(position) < orient(getLimit(false)); + const exceededMax = max !== false && orient(position) > orient(getLimit(true)); return exceededMin || exceededMax; } - return { - mount: mount, - move: move, - jump: jump, - translate: translate, - shift: shift, - cancel: cancel, - toIndex: toIndex, - toPosition: toPosition, - getPosition: getPosition, - getLimit: getLimit, - exceededLimit: exceededLimit, - reposition: reposition + mount, + move, + jump, + translate, + shift, + cancel, + toIndex, + toPosition, + getPosition, + getRate, + getLimit, + exceededLimit, + reposition, + canShift }; -} - -function Controller(Splide2, Components2, options) { - var _EventInterface5 = EventInterface(Splide2), - on = _EventInterface5.on, - emit = _EventInterface5.emit; - - var Move = Components2.Move; - var getPosition = Move.getPosition, - getLimit = Move.getLimit, - toPosition = Move.toPosition; - var _Components2$Slides = Components2.Slides, - isEnough = _Components2$Slides.isEnough, - getLength = _Components2$Slides.getLength; - var omitEnd = options.omitEnd; - var isLoop = Splide2.is(LOOP); - var isSlide = Splide2.is(SLIDE); - var getNext = apply(getAdjacent, false); - var getPrev = apply(getAdjacent, true); - var currIndex = options.start || 0; - var endIndex; - var prevIndex = currIndex; - var slideCount; - var perMove; - var perPage; +}; +const Controller = (Splide, Components, options, event) => { + const { on, emit } = event; + const { Move, Scroll } = Components; + const { getPosition, getLimit, toPosition } = Move; + const { isEnough, getLength } = Components.Slides; + const { omitEnd } = options; + const isLoop = Splide.is(LOOP); + const isSlide = Splide.is(SLIDE); + const getNext = apply(getAdjacent, false); + const getPrev = apply(getAdjacent, true); + let currIndex = options.start || 0; + let endIndex; + let prevIndex = currIndex; + let slideCount; + let perMove; + let perPage; function mount() { init(); on([EVENT_UPDATED, EVENT_REFRESH, EVENT_END_INDEX_CHANGED], init); on(EVENT_RESIZED, onResized); } - function init() { slideCount = getLength(true); perMove = options.perMove; - perPage = options.perPage; + perPage = options.perPage || 1; endIndex = getEnd(); - var index = clamp(currIndex, 0, omitEnd ? endIndex : slideCount - 1); - + const end = omitEnd ? endIndex : slideCount - 1; + const index = clamp(currIndex, 0, end); + prevIndex = index; if (index !== currIndex) { currIndex = index; Move.reposition(); } } - function onResized() { if (endIndex !== getEnd()) { emit(EVENT_END_INDEX_CHANGED); } } - - function go(control, allowSameIndex, callback) { + function go(control, callback) { if (!isBusy()) { - var dest = parse(control); - var index = loop(dest); - - if (index > -1 && (allowSameIndex || index !== currIndex)) { + const [dest, forwards] = parse(control); + const index = loop(dest); + const canGo = dest === index || Move.exceededLimit(!forwards) || Move.canShift(forwards); + const heading = isMoving() && currIndex === index; + if (index > -1 && canGo && !heading) { + Scroll.cancel(); setIndex(index); - Move.move(dest, index, prevIndex, callback); + Move.move(dest, index, prevIndex, forwards, callback); } } } - + function jump(control) { + const { set } = Components.Breakpoints; + const { speed } = options; + set({ speed: 0 }); + go(control); + set({ speed }); + } function scroll(destination, duration, snap, callback) { - Components2.Scroll.scroll(destination, duration, snap, function () { - var index = loop(Move.toIndex(getPosition())); + Scroll.scroll(destination, duration, snap, () => { + const index = loop(Move.toIndex(getPosition())); setIndex(omitEnd ? min(index, endIndex) : index); callback && callback(); }); } - function parse(control) { - var index = currIndex; - + let dest = currIndex; + let forwards = true; if (isString(control)) { - var _ref = control.match(/([+\-<>])(\d+)?/) || [], - indicator = _ref[1], - number = _ref[2]; - - if (indicator === "+" || indicator === "-") { - index = computeDestIndex(currIndex + +("" + indicator + (+number || 1)), currIndex); - } else if (indicator === ">") { - index = number ? toIndex(+number) : getNext(true); - } else if (indicator === "<") { - index = getPrev(true); + const [, indicator, number] = control.match(/([+-]|>>?|< includes(indicators, indicator); + forwards = oneOf("+", ">", ">>"); + if (oneOf("+", "-")) { + dest = computeDestIndex(currIndex + +`${indicator}${+number || 1}`, currIndex); + } else if (oneOf(">", "<")) { + dest = number ? toIndex(+number) : getAdjacent(!forwards, true); + } else if (oneOf(">>", "<<")) { + dest = number ? +number || 0 : forwards ? endIndex : 0; } } else { - index = isLoop ? control : clamp(control, 0, endIndex); + dest = isLoop ? control : clamp(control, 0, endIndex); } - - return index; + return [dest, forwards]; } - function getAdjacent(prev, destination) { - var number = perMove || (hasFocus() ? 1 : perPage); - var dest = computeDestIndex(currIndex + number * (prev ? -1 : 1), currIndex, !(perMove || hasFocus())); - + const number = perMove || (hasFocus() ? 1 : perPage); + const dest = computeDestIndex(currIndex + number * (prev ? -1 : 1), currIndex, !(perMove || hasFocus())); if (dest === -1 && isSlide) { if (!approximatelyEqual(getPosition(), getLimit(!prev), 1)) { return prev ? 0 : endIndex; } } - return destination ? dest : loop(dest); } - function computeDestIndex(dest, from, snapPage) { if (isEnough() || hasFocus()) { - var index = computeMovableDestIndex(dest); - + const index = computeMovableDestIndex(dest); if (index !== dest) { from = dest; dest = index; snapPage = false; } - if (dest < 0 || dest > endIndex) { if (!perMove && (between(0, dest, from, true) || between(endIndex, from, dest, true))) { dest = toIndex(toPage(dest)); @@ -1691,502 +1451,390 @@ function Controller(Splide2, Components2, options) { } else { dest = -1; } - return dest; } - function computeMovableDestIndex(dest) { if (isSlide && options.trimSpace === "move" && dest !== currIndex) { - var position = getPosition(); - - while (position === toPosition(dest, true) && between(dest, 0, Splide2.length - 1, !options.rewind)) { + const position = getPosition(); + while (position === toPosition(dest) && between(dest, 0, Splide.length - 1, !options.rewind)) { dest < currIndex ? --dest : ++dest; } } - return dest; } - function loop(index) { - return isLoop ? (index + slideCount) % slideCount || 0 : index; + if (isLoop) { + while (slideCount && index < 0) { + index += slideCount; + } + index = index % slideCount; + } + return index; } - function getEnd() { - var end = slideCount - (hasFocus() || isLoop && perMove ? 1 : perPage); - + let end = slideCount - (hasFocus() || isLoop && perMove ? 1 : perPage); while (omitEnd && end-- > 0) { - if (toPosition(slideCount - 1, true) !== toPosition(end, true)) { + if (!approximatelyEqual(toPosition(slideCount - 1), toPosition(end), 0.01)) { end++; break; } } - return clamp(end, 0, slideCount - 1); } - function toIndex(page) { return clamp(hasFocus() ? page : perPage * page, 0, endIndex); } - function toPage(index) { return hasFocus() ? min(index, endIndex) : floor((index >= endIndex ? slideCount - 1 : index) / perPage); } - function toDest(destination) { - var closest = Move.toIndex(destination); + const closest = Move.toIndex(destination); return isSlide ? clamp(closest, 0, endIndex) : closest; } - function setIndex(index) { if (index !== currIndex) { prevIndex = currIndex; currIndex = index; } } - function getIndex(prev) { return prev ? prevIndex : currIndex; } - function hasFocus() { - return !isUndefined(options.focus) || options.isNavigation; + return !isUndefined(options.focus) || !!options.isNavigation; + } + function isMoving() { + return Splide.state.is([MOVING, SCROLLING]); } - function isBusy() { - return Splide2.state.is([MOVING, SCROLLING]) && !!options.waitForTransition; + return isMoving() && !!options.waitForTransition; } - return { - mount: mount, - go: go, - scroll: scroll, - getNext: getNext, - getPrev: getPrev, - getAdjacent: getAdjacent, - getEnd: getEnd, - setIndex: setIndex, - getIndex: getIndex, - toIndex: toIndex, - toPage: toPage, - toDest: toDest, - hasFocus: hasFocus, - isBusy: isBusy + mount, + go, + jump, + scroll, + getNext, + getPrev, + getAdjacent, + getEnd, + setIndex, + getIndex, + toIndex, + toPage, + toDest, + hasFocus, + isBusy }; -} +}; -var XML_NAME_SPACE = "http://www.w3.org/2000/svg"; -var PATH = "m15.5 0.932-4.3 4.38 14.5 14.6-14.5 14.5 4.3 4.4 14.6-14.6 4.4-4.3-4.4-4.4-14.6-14.6z"; -var SIZE = 40; +const XML_NAME_SPACE = "http://www.w3.org/2000/svg"; +const PATH = "m15.5 0.932-4.3 4.38 14.5 14.6-14.5 14.5 4.3 4.4 14.6-14.6 4.4-4.3-4.4-4.4-14.6-14.6z"; +const SIZE = 40; -function Arrows(Splide2, Components2, options) { - var event = EventInterface(Splide2); - var on = event.on, - bind = event.bind, - emit = event.emit; - var classes = options.classes, - i18n = options.i18n; - var Elements = Components2.Elements, - Controller = Components2.Controller; - var placeholder = Elements.arrows, - track = Elements.track; - var wrapper = placeholder; - var prev = Elements.prev; - var next = Elements.next; - var created; - var wrapperClasses; - var arrows = {}; +const I18N = { + prev: "Previous slide", + next: "Next slide", + first: "Go to first slide", + last: "Go to last slide", + slideX: "Go to slide %s", + pageX: "Go to page %s", + play: "Start autoplay", + pause: "Pause autoplay", + carousel: "carousel", + slide: "slide", + select: "Select a slide to show", + slideLabel: "%s of %s" +}; +const Arrows = (Splide, Components, options, event) => { + const { on, bind, emit } = event; + const { classes = CLASSES, i18n = I18N } = options; + const { Elements, Controller } = Components; + const { arrows: placeholder, track } = Elements; + const wrapper = placeholder || create("div", classes.arrows); + const prev = Elements.prev || createArrow(true); + const next = Elements.next || createArrow(false); + const arrows = { prev, next }; + let wrapperClasses; function mount() { init(); - on(EVENT_UPDATED, remount); - } - - function remount() { - destroy(); - mount(); + on(EVENT_UPDATED, () => { + destroy(); + mount(); + }); } - function init() { - var enabled = options.arrows; - - if (enabled && !(prev && next)) { - createArrows(); - } - - if (prev && next) { - assign(arrows, { - prev: prev, - next: next - }); - display(wrapper, enabled ? "" : "none"); - addClass(wrapper, wrapperClasses = CLASS_ARROWS + "--" + options.direction); - - if (enabled) { - listen(); - update(); - setAttribute([prev, next], ARIA_CONTROLS, track.id); - emit(EVENT_ARROWS_MOUNTED, prev, next); - } + const { arrows: enabled = true } = options; + wrapperClasses = `${CLASS_ARROWS}--${options.direction}`; + addClass(wrapper, wrapperClasses); + if (enabled) { + display(wrapper, ""); + append(wrapper, prev, next); + !placeholder && before(track, wrapper); + listen(); + update(); + setAttribute([prev, next], ARIA_CONTROLS, track.id); + emit(EVENT_ARROWS_MOUNTED, prev, next); + } else { + display(wrapper, "none"); } } - function destroy() { event.destroy(); removeClass(wrapper, wrapperClasses); - - if (created) { - remove(placeholder ? [prev, next] : wrapper); - prev = next = null; - } else { + if (Elements.prev) { removeAttribute([prev, next], ALL_ATTRIBUTES); + } else { + removeNode(placeholder ? [prev, next] : wrapper); } } - function listen() { + const { go } = Controller; on([EVENT_MOUNTED, EVENT_MOVED, EVENT_REFRESH, EVENT_SCROLLED, EVENT_END_INDEX_CHANGED], update); - bind(next, "click", apply(go, ">")); - bind(prev, "click", apply(go, "<")); - } - - function go(control) { - Controller.go(control, true); - } - - function createArrows() { - wrapper = placeholder || create("div", classes.arrows); - prev = createArrow(true); - next = createArrow(false); - created = true; - append(wrapper, [prev, next]); - !placeholder && before(wrapper, track); + bind(next, "click", () => go(">")); + bind(prev, "click", () => go("<")); } - function createArrow(prev2) { - var arrow = ""; - }; - - _proto3.html = function html() { - var _this$config = this.config, - rootClass = _this$config.rootClass, - listTag = _this$config.listTag, - arrows = _this$config.arrows, - beforeTrack = _this$config.beforeTrack, - afterTrack = _this$config.afterTrack, - slider = _this$config.slider, - beforeSlider = _this$config.beforeSlider, - afterSlider = _this$config.afterSlider; - var html = ""; - html += "
"; - html += ""; - + return ``; + } + html() { + const { rootClass, listTag, arrows, beforeTrack, afterTrack, slider, beforeSlider, afterSlider } = this.config; + let html = ""; + html += `
`; + html += ``; if (slider) { html += beforeSlider || ""; - html += "
"; + html += `
`; } - html += beforeTrack || ""; - if (arrows) { html += this.renderArrows(); } - - html += "
"; - html += "<" + listTag + " class=\"splide__list\">"; + html += `
`; + html += `<${listTag} class="splide__list">`; html += this.renderSlides(); - html += ""; - html += "
"; + html += ``; + html += `
`; html += afterTrack || ""; - if (slider) { - html += "
"; + html += `
`; html += afterSlider || ""; } - - html += "
"; + html += `
`; return html; - }; - - return SplideRenderer; -}(); + } +} exports.CLASSES = CLASSES; exports.CLASS_ACTIVE = CLASS_ACTIVE; @@ -3694,6 +2950,7 @@ exports.CLASS_NEXT = CLASS_NEXT; exports.CLASS_OVERFLOW = CLASS_OVERFLOW; exports.CLASS_PAGINATION = CLASS_PAGINATION; exports.CLASS_PAGINATION_PAGE = CLASS_PAGINATION_PAGE; +exports.CLASS_PREFIX = CLASS_PREFIX; exports.CLASS_PREV = CLASS_PREV; exports.CLASS_PROGRESS = CLASS_PROGRESS; exports.CLASS_PROGRESS_BAR = CLASS_PROGRESS_BAR; @@ -3721,6 +2978,7 @@ exports.EVENT_DRAGGING = EVENT_DRAGGING; exports.EVENT_END_INDEX_CHANGED = EVENT_END_INDEX_CHANGED; exports.EVENT_HIDDEN = EVENT_HIDDEN; exports.EVENT_INACTIVE = EVENT_INACTIVE; +exports.EVENT_LAZYLOAD_ERROR = EVENT_LAZYLOAD_ERROR; exports.EVENT_LAZYLOAD_LOADED = EVENT_LAZYLOAD_LOADED; exports.EVENT_MOUNTED = EVENT_MOUNTED; exports.EVENT_MOVE = EVENT_MOVE; @@ -3735,22 +2993,20 @@ exports.EVENT_RESIZE = EVENT_RESIZE; exports.EVENT_RESIZED = EVENT_RESIZED; exports.EVENT_SCROLL = EVENT_SCROLL; exports.EVENT_SCROLLED = EVENT_SCROLLED; +exports.EVENT_SCROLLING = EVENT_SCROLLING; exports.EVENT_SHIFTED = EVENT_SHIFTED; exports.EVENT_SLIDE_KEYDOWN = EVENT_SLIDE_KEYDOWN; exports.EVENT_UPDATED = EVENT_UPDATED; exports.EVENT_VISIBLE = EVENT_VISIBLE; -exports.EventBinder = EventBinder; -exports.EventInterface = EventInterface; exports.FADE = FADE; exports.LOOP = LOOP; exports.LTR = LTR; exports.RTL = RTL; -exports.RequestInterval = RequestInterval; exports.SLIDE = SLIDE; +exports.STATES = STATES; exports.STATUS_CLASSES = STATUS_CLASSES; +exports.STATUS_CLASS_PREFIX = STATUS_CLASS_PREFIX; exports.Splide = Splide; exports.SplideRenderer = SplideRenderer; -exports.State = State; exports.TTB = TTB; -exports.Throttle = Throttle; -exports["default"] = Splide; +exports.default = Splide; diff --git a/dist/js/splide.esm.js b/dist/js/splide.esm.js index 76f8d1a4..3c304095 100644 --- a/dist/js/splide.esm.js +++ b/dist/js/splide.esm.js @@ -1,68 +1,54 @@ -function _defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } - -function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); Object.defineProperty(Constructor, "prototype", { writable: false }); return Constructor; } - /*! - * Splide.js + * @splidejs/splide * Version : 4.1.3 * License : MIT * Copyright: 2022 Naotoshi Fujita */ -var MEDIA_PREFERS_REDUCED_MOTION = "(prefers-reduced-motion: reduce)"; -var CREATED = 1; -var MOUNTED = 2; -var IDLE = 3; -var MOVING = 4; -var SCROLLING = 5; -var DRAGGING = 6; -var DESTROYED = 7; -var STATES = { - CREATED: CREATED, - MOUNTED: MOUNTED, - IDLE: IDLE, - MOVING: MOVING, - SCROLLING: SCROLLING, - DRAGGING: DRAGGING, - DESTROYED: DESTROYED +const MEDIA_PREFERS_REDUCED_MOTION = "(prefers-reduced-motion: reduce)"; + +const CREATED = 1; +const MOUNTED = 2; +const IDLE = 3; +const MOVING = 4; +const SCROLLING = 5; +const DRAGGING = 6; +const DESTROYED = 7; +const STATES = { + CREATED, + MOUNTED, + IDLE, + MOVING, + SCROLLING, + DRAGGING, + DESTROYED }; function empty(array) { array.length = 0; } - -function slice(arrayLike, start, end) { - return Array.prototype.slice.call(arrayLike, start, end); -} - -function apply(func) { - return func.bind.apply(func, [null].concat(slice(arguments, 1))); +function apply(func, ...args) { + return func.bind(null, ...args); } - -var nextTick = setTimeout; - -var noop = function noop() {}; - +const nextTick = setTimeout; +const noop = () => { +}; function raf(func) { return requestAnimationFrame(func); } - function typeOf(type, subject) { return typeof subject === type; } - function isObject(subject) { return !isNull(subject) && typeOf("object", subject); } - -var isArray = Array.isArray; -var isFunction = apply(typeOf, "function"); -var isString = apply(typeOf, "string"); -var isUndefined = apply(typeOf, "undefined"); - +const isArray = Array.isArray; +const isFunction = apply(typeOf, "function"); +const isString = apply(typeOf, "string"); +apply(typeOf, "boolean"); +const isUndefined = apply(typeOf, "undefined"); function isNull(subject) { return subject === null; } - function isHTMLElement(subject) { try { return subject instanceof (subject.ownerDocument.defaultView || window).HTMLElement; @@ -70,573 +56,472 @@ function isHTMLElement(subject) { return false; } } - function toArray(value) { return isArray(value) ? value : [value]; } - function forEach(values, iteratee) { toArray(values).forEach(iteratee); } - -function includes(array, value) { - return array.indexOf(value) > -1; -} - function push(array, items) { - array.push.apply(array, toArray(items)); + array.push(...toArray(items)); return array; } - -function toggleClass(elm, classes, add) { - if (elm) { - forEach(classes, function (name) { - if (name) { - elm.classList[add ? "add" : "remove"](name); - } - }); - } -} - -function addClass(elm, classes) { - toggleClass(elm, isString(classes) ? classes.split(" ") : classes, true); -} - -function append(parent, children) { - forEach(children, parent.appendChild.bind(parent)); -} - -function before(nodes, ref) { - forEach(nodes, function (node) { - var parent = (ref || node).parentNode; - - if (parent) { - parent.insertBefore(node, ref); - } - }); +const arrayProto = Array.prototype; +function slice(arrayLike, start, end) { + return arrayProto.slice.call(arrayLike, start, end); } - -function matches(elm, selector) { - return isHTMLElement(elm) && (elm["msMatchesSelector"] || elm.matches).call(elm, selector); +function includes(arrayLike, value) { + return arrayProto.includes.call(arrayLike, value); } - -function children(parent, selector) { - var children2 = parent ? slice(parent.children) : []; - return selector ? children2.filter(function (child) { - return matches(child, selector); - }) : children2; +function toNumber(value) { + return Number(value) || 0; } - -function child(parent, selector) { - return selector ? children(parent, selector)[0] : parent.firstElementChild; +function assert$1(assertion, message) { + if (!assertion) { + throw new Error(message); + } } - -var ownKeys = Object.keys; - +const assign = Object.assign; +const ownKeys = Object.keys; function forOwn(object, iteratee, right) { if (object) { - (right ? ownKeys(object).reverse() : ownKeys(object)).forEach(function (key) { + (right ? ownKeys(object).reverse() : ownKeys(object)).forEach((key) => { key !== "__proto__" && iteratee(object[key], key); }); } - - return object; -} - -function assign(object) { - slice(arguments, 1).forEach(function (source) { - forOwn(source, function (value, key) { - object[key] = source[key]; - }); - }); return object; } - -function merge(object) { - slice(arguments, 1).forEach(function (source) { - forOwn(source, function (value, key) { +function merge(object, ...sources) { + sources.forEach((source) => { + forOwn(source, (value, key) => { if (isArray(value)) { - object[key] = value.slice(); + value = value.slice(); } else if (isObject(value)) { - object[key] = merge({}, isObject(object[key]) ? object[key] : {}, value); - } else { - object[key] = value; + value = merge({}, isObject(object[key]) ? object[key] : {}, value); } + object[key] = value; }); }); return object; } - function omit(object, keys) { - forEach(keys || ownKeys(object), function (key) { + forEach(keys || ownKeys(object), (key) => { delete object[key]; }); + return object; +} +function toggleClass(elm, classes, force) { + if (elm) { + forEach(isString(classes) ? classes.split(" ") : classes, (className) => { + className && elm.classList.toggle(className, force); + }); + } +} +function addClass(elm, classes) { + toggleClass(elm, classes, true); +} +function append(parent, ...children2) { + parent && parent.append(...children2); +} +function before(ref, ...nodes) { + ref && ref.before(...nodes); +} +function matches(elm, selector) { + return isHTMLElement(elm) && elm.matches(selector); +} +function children(parent, selector) { + const children2 = parent ? slice(parent.children) : []; + return selector ? children2.filter((child2) => matches(child2, selector)) : children2; +} +function child(parent, selector) { + return selector ? children(parent, selector)[0] : parent.firstElementChild; +} +function closest(from, selector) { + return from.closest(selector); } - function removeAttribute(elms, attrs) { - forEach(elms, function (elm) { - forEach(attrs, function (attr) { + forEach(elms, (elm) => { + forEach(attrs, (attr) => { elm && elm.removeAttribute(attr); }); }); } - function setAttribute(elms, attrs, value) { if (isObject(attrs)) { - forOwn(attrs, function (value2, name) { + forOwn(attrs, (value2, name) => { setAttribute(elms, name, value2); }); } else { - forEach(elms, function (elm) { - isNull(value) || value === "" ? removeAttribute(elm, attrs) : elm.setAttribute(attrs, String(value)); + forEach(elms, (elm) => { + isNull(value) || isUndefined(value) || value === "" ? removeAttribute(elm, attrs) : elm.setAttribute(attrs, String(value)); }); } } - -function create(tag, attrs, parent) { - var elm = document.createElement(tag); - +function create(tag2, attrs, parent) { + const elm = document.createElement(tag2); if (attrs) { isString(attrs) ? addClass(elm, attrs) : setAttribute(elm, attrs); } - parent && append(parent, elm); return elm; } - function style(elm, prop, value) { if (isUndefined(value)) { return getComputedStyle(elm)[prop]; } - if (!isNull(value)) { - elm.style[prop] = "" + value; + elm.style[prop] = `${value}`; } } - function display(elm, display2) { style(elm, "display", display2); } - function focus(elm) { - elm["setActive"] && elm["setActive"]() || elm.focus({ - preventScroll: true - }); + isHTMLElement(elm) && elm.focus({ preventScroll: true }); } - function getAttribute(elm, attr) { return elm.getAttribute(attr); } - function hasClass(elm, className) { - return elm && elm.classList.contains(className); + return !!elm && elm.classList.contains(className); } - function rect(target) { return target.getBoundingClientRect(); } - -function remove(nodes) { - forEach(nodes, function (node) { +function removeNode(nodes) { + forEach(nodes, (node) => { if (node && node.parentNode) { node.parentNode.removeChild(node); } }); } - function parseHtml(html) { return child(new DOMParser().parseFromString(html, "text/html").body); } - function prevent(e, stopPropagation) { e.preventDefault(); - if (stopPropagation) { e.stopPropagation(); e.stopImmediatePropagation(); } } - function query(parent, selector) { return parent && parent.querySelector(selector); } - function queryAll(parent, selector) { - return selector ? slice(parent.querySelectorAll(selector)) : []; + return selector && parent ? slice(parent.querySelectorAll(selector)) : []; } - function removeClass(elm, classes) { toggleClass(elm, classes, false); } - function timeOf(e) { return e.timeStamp; } - function unit(value) { - return isString(value) ? value : value ? value + "px" : ""; + return isString(value) ? value : value ? `${value}px` : ""; } - -var PROJECT_CODE = "splide"; -var DATA_ATTRIBUTE = "data-" + PROJECT_CODE; - -function assert(condition, message) { - if (!condition) { - throw new Error("[" + PROJECT_CODE + "] " + (message || "")); - } +function classNames(...args) { + return args.reduce((classes, value) => { + return `${classes} ${isArray(value) ? classNames(...value) : value || ""}`.trim(); + }, ""); } - -var min = Math.min, - max = Math.max, - floor = Math.floor, - ceil = Math.ceil, - abs = Math.abs; - +const { min, max, floor, ceil, abs, sign } = Math; function approximatelyEqual(x, y, epsilon) { return abs(x - y) < epsilon; } - function between(number, x, y, exclusive) { - var minimum = min(x, y); - var maximum = max(x, y); + const minimum = min(x, y); + const maximum = max(x, y); return exclusive ? minimum < number && number < maximum : minimum <= number && number <= maximum; } - function clamp(number, x, y) { - var minimum = min(x, y); - var maximum = max(x, y); + const minimum = min(x, y); + const maximum = max(x, y); return min(max(minimum, number), maximum); } - -function sign(x) { - return +(x > 0) - +(x < 0); -} - function camelToKebab(string) { return string.replace(/([a-z0-9])([A-Z])/g, "$1-$2").toLowerCase(); } - -function format(string, replacements) { - forEach(replacements, function (replacement) { - string = string.replace("%s", "" + replacement); - }); - return string; +function format(string, ...replacements) { + return replacements.reduce((prev, curr) => prev.replace("%s", `${curr}`), string); } - -function pad(number) { - return number < 10 ? "0" + number : "" + number; +function pad(number, length = 2) { + return `${number}`.padStart(length, "0"); } - -var ids = {}; - +const ids = {}; function uniqueId(prefix) { - return "" + prefix + pad(ids[prefix] = (ids[prefix] || 0) + 1); + return `${prefix}${pad(ids[prefix] = (ids[prefix] || 0) + 1)}`; } - -function EventBinder() { - var listeners = []; - - function bind(targets, events, callback, options) { - forEachEvent(targets, events, function (target, event, namespace) { - var isEventTarget = ("addEventListener" in target); - var remover = isEventTarget ? target.removeEventListener.bind(target, event, callback, options) : target["removeListener"].bind(target, callback); - isEventTarget ? target.addEventListener(event, callback, options) : target["addListener"](callback); - listeners.push([target, event, namespace, callback, remover]); +function forEachEvent(events, iteratee) { + forEach(events, (event) => { + isString(event) && event.split(" ").forEach(iteratee); + }); +} +function EventBinder(removersRef) { + const removers = removersRef || /* @__PURE__ */ new Set(); + const key = removersRef ? {} : void 0; + let destroyed; + function bind(target, events, callback, options) { + assert$1(!destroyed); + forEachEvent(events, (event) => { + target.addEventListener(event, callback, options); + removers.add([target.removeEventListener.bind(target, event, callback, options), key]); }); } - - function unbind(targets, events, callback) { - forEachEvent(targets, events, function (target, event, namespace) { - listeners = listeners.filter(function (listener) { - if (listener[0] === target && listener[1] === event && listener[2] === namespace && (!callback || listener[3] === callback)) { - listener[4](); - return false; - } - - return true; - }); + function destroy(hard) { + removers.forEach((remover) => { + if (!key || remover[1] === key) { + remover[0](); + removers.delete(remover); + } }); + destroyed = hard; } - - function dispatch(target, type, detail) { - var e; - var bubbles = true; - - if (typeof CustomEvent === "function") { - e = new CustomEvent(type, { - bubbles: bubbles, - detail: detail - }); - } else { - e = document.createEvent("CustomEvent"); - e.initCustomEvent(type, bubbles, false, detail); - } - - target.dispatchEvent(e); - return e; + return { + bind, + lock: apply(EventBinder, removers), + destroy + }; +} +function EventBus(listenersRef) { + const listeners = listenersRef || {}; + const key = listenersRef ? {} : void 0; + let destroyed; + function on(events, callback) { + assert$1(!destroyed); + forEachEvent(events, (event) => { + listeners[event] = push(get(event), [[callback, key]]); + }); } - - function forEachEvent(targets, events, iteratee) { - forEach(targets, function (target) { - target && forEach(events, function (events2) { - events2.split(" ").forEach(function (eventNS) { - var fragment = eventNS.split("."); - iteratee(target, fragment[0], fragment[1]); - }); - }); + function off(events, callback) { + forEachEvent(events, (event) => { + listeners[event] = get(event).filter((listener) => !((!callback || listener[0] === callback) && listener[1] === key)); }); } - - function destroy() { - listeners.forEach(function (data) { - data[4](); + function emit(event, ...args) { + get(event).forEach((listener) => listener[0] && listener[0](...args)); + } + function get(event) { + return listeners[event] || []; + } + function destroy(hard) { + forOwn(listeners, (entries, event) => { + listeners[event] = entries.filter((listener) => { + const unlocked = !key || listener[1] === key; + unlocked && empty(listener); + return !unlocked; + }); }); - empty(listeners); + !key && omit(listeners); + destroyed = hard; } - return { - bind: bind, - unbind: unbind, - dispatch: dispatch, - destroy: destroy + on, + off, + emit, + lock: apply(EventBus, listeners), + destroy }; } - -var EVENT_MOUNTED = "mounted"; -var EVENT_READY = "ready"; -var EVENT_MOVE = "move"; -var EVENT_MOVED = "moved"; -var EVENT_CLICK = "click"; -var EVENT_ACTIVE = "active"; -var EVENT_INACTIVE = "inactive"; -var EVENT_VISIBLE = "visible"; -var EVENT_HIDDEN = "hidden"; -var EVENT_REFRESH = "refresh"; -var EVENT_UPDATED = "updated"; -var EVENT_RESIZE = "resize"; -var EVENT_RESIZED = "resized"; -var EVENT_DRAG = "drag"; -var EVENT_DRAGGING = "dragging"; -var EVENT_DRAGGED = "dragged"; -var EVENT_SCROLL = "scroll"; -var EVENT_SCROLLED = "scrolled"; -var EVENT_OVERFLOW = "overflow"; -var EVENT_DESTROY = "destroy"; -var EVENT_ARROWS_MOUNTED = "arrows:mounted"; -var EVENT_ARROWS_UPDATED = "arrows:updated"; -var EVENT_PAGINATION_MOUNTED = "pagination:mounted"; -var EVENT_PAGINATION_UPDATED = "pagination:updated"; -var EVENT_NAVIGATION_MOUNTED = "navigation:mounted"; -var EVENT_AUTOPLAY_PLAY = "autoplay:play"; -var EVENT_AUTOPLAY_PLAYING = "autoplay:playing"; -var EVENT_AUTOPLAY_PAUSE = "autoplay:pause"; -var EVENT_LAZYLOAD_LOADED = "lazyload:loaded"; -var EVENT_SLIDE_KEYDOWN = "sk"; -var EVENT_SHIFTED = "sh"; -var EVENT_END_INDEX_CHANGED = "ei"; - -function EventInterface(Splide2) { - var bus = Splide2 ? Splide2.event.bus : document.createDocumentFragment(); - var binder = EventBinder(); - - function on(events, callback) { - binder.bind(bus, toArray(events).join(" "), function (e) { - callback.apply(callback, isArray(e.detail) ? e.detail : []); - }); - } - - function emit(event) { - binder.dispatch(bus, event, slice(arguments, 1)); +function EventInterface(binder = EventBinder(), bus = EventBus()) { + function lock() { + return EventInterface(binder.lock(), bus.lock()); } - - if (Splide2) { - Splide2.event.on(EVENT_DESTROY, binder.destroy); + function destroy(hard) { + binder.destroy(hard); + bus.destroy(hard); } - - return assign(binder, { - bus: bus, - on: on, - off: apply(binder.unbind, bus), - emit: emit - }); + return assign({}, binder, bus, { lock, destroy }); } - function RequestInterval(interval, onInterval, onUpdate, limit) { - var now = Date.now; - var startTime; - var rate = 0; - var id; - var paused = true; - var count = 0; - + const { now } = Date; + let startTime; + let rate = 0; + let id; + let paused = true; + let count = 0; function update() { if (!paused) { rate = interval ? min((now() - startTime) / interval, 1) : 1; onUpdate && onUpdate(rate); - if (rate >= 1) { onInterval(); startTime = now(); - if (limit && ++count >= limit) { return pause(); } } - id = raf(update); } } - function start(resume) { resume || cancel(); startTime = now() - (resume ? rate * interval : 0); paused = false; id = raf(update); } - function pause() { paused = true; } - function rewind() { startTime = now(); rate = 0; - if (onUpdate) { onUpdate(rate); } } - function cancel() { id && cancelAnimationFrame(id); rate = 0; id = 0; paused = true; } - function set(time) { interval = time; } - function isPaused() { return paused; } - return { - start: start, - rewind: rewind, - pause: pause, - cancel: cancel, - set: set, - isPaused: isPaused + start, + rewind, + pause, + cancel, + set, + isPaused }; } - function State(initialState) { - var state = initialState; - + let state = initialState; function set(value) { state = value; } - function is(states) { return includes(toArray(states), state); } - - return { - set: set, - is: is - }; + return { set, is }; } - function Throttle(func, duration) { - var interval = RequestInterval(duration || 0, func, null, 1); - return function () { + const interval = RequestInterval(duration || 0, func, void 0, 1); + return () => { interval.isPaused() && interval.start(); }; } -function Media(Splide2, Components2, options) { - var state = Splide2.state; - var breakpoints = options.breakpoints || {}; - var reducedMotion = options.reducedMotion || {}; - var binder = EventBinder(); - var queries = []; - +const EVENT_MOUNTED = "mounted"; +const EVENT_READY = "ready"; +const EVENT_MOVE = "move"; +const EVENT_MOVED = "moved"; +const EVENT_CLICK = "click"; +const EVENT_ACTIVE = "active"; +const EVENT_INACTIVE = "inactive"; +const EVENT_VISIBLE = "visible"; +const EVENT_HIDDEN = "hidden"; +const EVENT_REFRESH = "refresh"; +const EVENT_UPDATED = "updated"; +const EVENT_RESIZE = "resize"; +const EVENT_RESIZED = "resized"; +const EVENT_DRAG = "drag"; +const EVENT_DRAGGING = "dragging"; +const EVENT_DRAGGED = "dragged"; +const EVENT_SCROLL = "scroll"; +const EVENT_SCROLLING = "scrolling"; +const EVENT_SCROLLED = "scrolled"; +const EVENT_OVERFLOW = "overflow"; +const EVENT_DESTROY = "destroy"; +const EVENT_ARROWS_MOUNTED = "arrows:mounted"; +const EVENT_ARROWS_UPDATED = "arrows:updated"; +const EVENT_PAGINATION_MOUNTED = "pagination:mounted"; +const EVENT_PAGINATION_UPDATED = "pagination:updated"; +const EVENT_NAVIGATION_MOUNTED = "navigation:mounted"; +const EVENT_AUTOPLAY_PLAY = "autoplay:play"; +const EVENT_AUTOPLAY_PLAYING = "autoplay:playing"; +const EVENT_AUTOPLAY_PAUSE = "autoplay:pause"; +const EVENT_LAZYLOAD_LOADED = "lazyload:loaded"; +const EVENT_LAZYLOAD_ERROR = "lazyload:error"; +const EVENT_SLIDE_KEYDOWN = "_sk"; +const EVENT_SHIFTED = "_sh"; +const EVENT_END_INDEX_CHANGED = "_ei"; + +const NOT_OVERFLOW_KEY = "!overflow"; +const Breakpoints = (Splide, Components, options, event) => { + const { state } = Splide; + const breakpoints = options.breakpoints || {}; + const reducedMotion = options.reducedMotion || {}; + const binder = EventBinder(); + const entries = []; function setup() { - var isMin = options.mediaQuery === "min"; - ownKeys(breakpoints).sort(function (n, m) { - return isMin ? +n - +m : +m - +n; - }).forEach(function (key) { - register(breakpoints[key], "(" + (isMin ? "min" : "max") + "-width:" + key + "px)"); + const isMin = options.mediaQuery === "min"; + ownKeys(breakpoints).sort((n, m) => isMin ? +n - +m : +m - +n).forEach((key) => { + if (key !== NOT_OVERFLOW_KEY) { + register(breakpoints[key], `(${isMin ? "min" : "max"}-width:${key}px)`); + } }); + if (breakpoints[NOT_OVERFLOW_KEY]) { + entries.push([breakpoints[NOT_OVERFLOW_KEY], () => Components.Layout && !Components.Layout.isOverflow()]); + event.on(EVENT_OVERFLOW, update); + } register(reducedMotion, MEDIA_PREFERS_REDUCED_MOTION); update(); } - function destroy(completely) { if (completely) { binder.destroy(); } } - function register(options2, query) { - var queryList = matchMedia(query); + const queryList = matchMedia(query); binder.bind(queryList, "change", update); - queries.push([options2, queryList]); + entries.push([options2, () => queryList.matches]); } - function update() { - var destroyed = state.is(DESTROYED); - var direction = options.direction; - var merged = queries.reduce(function (merged2, entry) { - return merge(merged2, entry[1].matches ? entry[0] : {}); + const destroyed = state.is(DESTROYED); + const direction = options.direction; + const merged = entries.reduce((merged2, entry) => { + return merge(merged2, entry[1]() ? entry[0] : {}); }, {}); omit(options); - set(merged); - + set(merged, false, !state.is(CREATED)); if (options.destroy) { - Splide2.destroy(options.destroy === "completely"); + Splide.destroy(options.destroy === "completely"); } else if (destroyed) { destroy(true); - Splide2.mount(); + Splide.mount(); } else { - direction !== options.direction && Splide2.refresh(); + direction !== options.direction && Splide.refresh(); } } - function reduce(enable) { if (matchMedia(MEDIA_PREFERS_REDUCED_MOTION).matches) { enable ? merge(options, reducedMotion) : omit(options, ownKeys(reducedMotion)); } } - function set(opts, base, notify) { merge(options, opts); base && merge(Object.getPrototypeOf(options), opts); - - if (notify || !state.is(CREATED)) { - Splide2.emit(EVENT_UPDATED, options); + if (notify) { + Splide.emit(EVENT_UPDATED, options); } } - return { - setup: setup, - destroy: destroy, - reduce: reduce, - set: set + setup, + destroy, + reduce, + set }; -} +}; + +const ARROW = "Arrow"; +const ARROW_LEFT = `${ARROW}Left`; +const ARROW_RIGHT = `${ARROW}Right`; +const ARROW_UP = `${ARROW}Up`; +const ARROW_DOWN = `${ARROW}Down`; -var ARROW = "Arrow"; -var ARROW_LEFT = ARROW + "Left"; -var ARROW_RIGHT = ARROW + "Right"; -var ARROW_UP = ARROW + "Up"; -var ARROW_DOWN = ARROW + "Down"; -var LTR = "ltr"; -var RTL = "rtl"; -var TTB = "ttb"; -var ORIENTATION_MAP = { +const LTR = "ltr"; +const RTL = "rtl"; +const TTB = "ttb"; + +const ORIENTATION_MAP = { width: ["height"], left: ["top", "right"], right: ["bottom", "left"], @@ -646,74 +531,100 @@ var ORIENTATION_MAP = { ArrowLeft: [ARROW_UP, ARROW_RIGHT], ArrowRight: [ARROW_DOWN, ARROW_LEFT] }; - -function Direction(Splide2, Components2, options) { - function resolve(prop, axisOnly, direction) { - direction = direction || options.direction; - var index = direction === RTL && !axisOnly ? 1 : direction === TTB ? 0 : -1; - return ORIENTATION_MAP[prop] && ORIENTATION_MAP[prop][index] || prop.replace(/width|left|right/i, function (match, offset) { - var replacement = ORIENTATION_MAP[match.toLowerCase()][index] || match; +const Direction = (Splide, Components, options) => { + function resolve(prop, axisOnly, direction = options.direction) { + const index = direction === RTL && !axisOnly ? 1 : direction === TTB ? 0 : -1; + return find(prop, index) || prop.replace(/width|left|right/i, (match, offset) => { + const replacement = find(match.toLowerCase(), index) || match; return offset > 0 ? replacement.charAt(0).toUpperCase() + replacement.slice(1) : replacement; }); } - - function orient(value) { - return value * (options.direction === RTL ? 1 : -1); + function find(prop, index) { + const props = ORIENTATION_MAP[prop]; + return props && index > -1 ? props[index] : ""; + } + function orient(value, direction = options.direction) { + return value * (direction === RTL ? 1 : -1); } - return { - resolve: resolve, - orient: orient + resolve, + orient, + left: apply(resolve, "left"), + right: apply(resolve, "right"), + width: apply(resolve, "width") }; -} +}; -var ROLE = "role"; -var TAB_INDEX = "tabindex"; -var DISABLED = "disabled"; -var ARIA_PREFIX = "aria-"; -var ARIA_CONTROLS = ARIA_PREFIX + "controls"; -var ARIA_CURRENT = ARIA_PREFIX + "current"; -var ARIA_SELECTED = ARIA_PREFIX + "selected"; -var ARIA_LABEL = ARIA_PREFIX + "label"; -var ARIA_LABELLEDBY = ARIA_PREFIX + "labelledby"; -var ARIA_HIDDEN = ARIA_PREFIX + "hidden"; -var ARIA_ORIENTATION = ARIA_PREFIX + "orientation"; -var ARIA_ROLEDESCRIPTION = ARIA_PREFIX + "roledescription"; -var ARIA_LIVE = ARIA_PREFIX + "live"; -var ARIA_BUSY = ARIA_PREFIX + "busy"; -var ARIA_ATOMIC = ARIA_PREFIX + "atomic"; -var ALL_ATTRIBUTES = [ROLE, TAB_INDEX, DISABLED, ARIA_CONTROLS, ARIA_CURRENT, ARIA_LABEL, ARIA_LABELLEDBY, ARIA_HIDDEN, ARIA_ORIENTATION, ARIA_ROLEDESCRIPTION]; -var CLASS_PREFIX = PROJECT_CODE + "__"; -var STATUS_CLASS_PREFIX = "is-"; -var CLASS_ROOT = PROJECT_CODE; -var CLASS_TRACK = CLASS_PREFIX + "track"; -var CLASS_LIST = CLASS_PREFIX + "list"; -var CLASS_SLIDE = CLASS_PREFIX + "slide"; -var CLASS_CLONE = CLASS_SLIDE + "--clone"; -var CLASS_CONTAINER = CLASS_SLIDE + "__container"; -var CLASS_ARROWS = CLASS_PREFIX + "arrows"; -var CLASS_ARROW = CLASS_PREFIX + "arrow"; -var CLASS_ARROW_PREV = CLASS_ARROW + "--prev"; -var CLASS_ARROW_NEXT = CLASS_ARROW + "--next"; -var CLASS_PAGINATION = CLASS_PREFIX + "pagination"; -var CLASS_PAGINATION_PAGE = CLASS_PAGINATION + "__page"; -var CLASS_PROGRESS = CLASS_PREFIX + "progress"; -var CLASS_PROGRESS_BAR = CLASS_PROGRESS + "__bar"; -var CLASS_TOGGLE = CLASS_PREFIX + "toggle"; -var CLASS_TOGGLE_PLAY = CLASS_TOGGLE + "__play"; -var CLASS_TOGGLE_PAUSE = CLASS_TOGGLE + "__pause"; -var CLASS_SPINNER = CLASS_PREFIX + "spinner"; -var CLASS_SR = CLASS_PREFIX + "sr"; -var CLASS_INITIALIZED = STATUS_CLASS_PREFIX + "initialized"; -var CLASS_ACTIVE = STATUS_CLASS_PREFIX + "active"; -var CLASS_PREV = STATUS_CLASS_PREFIX + "prev"; -var CLASS_NEXT = STATUS_CLASS_PREFIX + "next"; -var CLASS_VISIBLE = STATUS_CLASS_PREFIX + "visible"; -var CLASS_LOADING = STATUS_CLASS_PREFIX + "loading"; -var CLASS_FOCUS_IN = STATUS_CLASS_PREFIX + "focus-in"; -var CLASS_OVERFLOW = STATUS_CLASS_PREFIX + "overflow"; -var STATUS_CLASSES = [CLASS_ACTIVE, CLASS_VISIBLE, CLASS_PREV, CLASS_NEXT, CLASS_LOADING, CLASS_FOCUS_IN, CLASS_OVERFLOW]; -var CLASSES = { +const ROLE = "role"; +const TAB_INDEX = "tabindex"; +const DISABLED = "disabled"; +const ARIA_PREFIX = "aria-"; +const ARIA_CONTROLS = `${ARIA_PREFIX}controls`; +const ARIA_CURRENT = `${ARIA_PREFIX}current`; +const ARIA_SELECTED = `${ARIA_PREFIX}selected`; +const ARIA_LABEL = `${ARIA_PREFIX}label`; +const ARIA_LABELLEDBY = `${ARIA_PREFIX}labelledby`; +const ARIA_HIDDEN = `${ARIA_PREFIX}hidden`; +const ARIA_ORIENTATION = `${ARIA_PREFIX}orientation`; +const ARIA_ROLEDESCRIPTION = `${ARIA_PREFIX}roledescription`; +const ARIA_LIVE = `${ARIA_PREFIX}live`; +const ARIA_BUSY = `${ARIA_PREFIX}busy`; +const ARIA_ATOMIC = `${ARIA_PREFIX}atomic`; +const ALL_ATTRIBUTES = [ + ROLE, + TAB_INDEX, + DISABLED, + ARIA_CONTROLS, + ARIA_CURRENT, + ARIA_LABEL, + ARIA_LABELLEDBY, + ARIA_HIDDEN, + ARIA_ORIENTATION, + ARIA_ROLEDESCRIPTION +]; + +const PROJECT_CODE = "splide"; +const DATA_ATTRIBUTE = `data-${PROJECT_CODE}`; + +const CLASS_PREFIX = `${PROJECT_CODE}__`; +const STATUS_CLASS_PREFIX = "is-"; +const CLASS_ROOT = PROJECT_CODE; +const CLASS_TRACK = `${CLASS_PREFIX}track`; +const CLASS_LIST = `${CLASS_PREFIX}list`; +const CLASS_SLIDE = `${CLASS_PREFIX}slide`; +const CLASS_CLONE = `${CLASS_SLIDE}--clone`; +const CLASS_CONTAINER = `${CLASS_SLIDE}__container`; +const CLASS_ARROWS = `${CLASS_PREFIX}arrows`; +const CLASS_ARROW = `${CLASS_PREFIX}arrow`; +const CLASS_ARROW_PREV = `${CLASS_ARROW}--prev`; +const CLASS_ARROW_NEXT = `${CLASS_ARROW}--next`; +const CLASS_PAGINATION = `${CLASS_PREFIX}pagination`; +const CLASS_PAGINATION_PAGE = `${CLASS_PAGINATION}__page`; +const CLASS_PROGRESS = `${CLASS_PREFIX}progress`; +const CLASS_PROGRESS_BAR = `${CLASS_PROGRESS}__bar`; +const CLASS_TOGGLE = `${CLASS_PREFIX}toggle`; +const CLASS_TOGGLE_PLAY = `${CLASS_TOGGLE}__play`; +const CLASS_TOGGLE_PAUSE = `${CLASS_TOGGLE}__pause`; +const CLASS_SPINNER = `${CLASS_PREFIX}spinner`; +const CLASS_SR = `${CLASS_PREFIX}sr`; +const CLASS_INITIALIZED = `${STATUS_CLASS_PREFIX}initialized`; +const CLASS_ACTIVE = `${STATUS_CLASS_PREFIX}active`; +const CLASS_PREV = `${STATUS_CLASS_PREFIX}prev`; +const CLASS_NEXT = `${STATUS_CLASS_PREFIX}next`; +const CLASS_VISIBLE = `${STATUS_CLASS_PREFIX}visible`; +const CLASS_LOADING = `${STATUS_CLASS_PREFIX}loading`; +const CLASS_FOCUS_IN = `${STATUS_CLASS_PREFIX}focus-in`; +const CLASS_OVERFLOW = `${STATUS_CLASS_PREFIX}overflow`; +const STATUS_CLASSES = [ + CLASS_ACTIVE, + CLASS_VISIBLE, + CLASS_PREV, + CLASS_NEXT, + CLASS_LOADING, + CLASS_FOCUS_IN, + CLASS_OVERFLOW +]; +const CLASSES = { slide: CLASS_SLIDE, clone: CLASS_CLONE, arrows: CLASS_ARROWS, @@ -725,74 +636,52 @@ var CLASSES = { spinner: CLASS_SPINNER }; -function closest(from, selector) { - if (isFunction(from.closest)) { - return from.closest(selector); - } - - var elm = from; - - while (elm && elm.nodeType === 1) { - if (matches(elm, selector)) { - break; - } - - elm = elm.parentElement; - } - - return elm; -} - -var FRICTION = 5; -var LOG_INTERVAL = 200; -var POINTER_DOWN_EVENTS = "touchstart mousedown"; -var POINTER_MOVE_EVENTS = "touchmove mousemove"; -var POINTER_UP_EVENTS = "touchend touchcancel mouseup click"; - -function Elements(Splide2, Components2, options) { - var _EventInterface = EventInterface(Splide2), - on = _EventInterface.on, - bind = _EventInterface.bind; - - var root = Splide2.root; - var i18n = options.i18n; - var elements = {}; - var slides = []; - var rootClasses = []; - var trackClasses = []; - var track; - var list; - var isUsingKey; - +function assert(condition, message) { + if (!condition) { + throw new Error(`[${PROJECT_CODE}] ${message || ""}`); + } +} + +const FRICTION = 5; +const LOG_INTERVAL = 200; +const POINTER_DOWN_EVENTS = "touchstart mousedown"; +const POINTER_MOVE_EVENTS = "touchmove mousemove"; +const POINTER_UP_EVENTS = "touchend touchcancel mouseup click"; + +const Elements = (Splide, Components, options, event) => { + const { on, bind } = event; + const { root } = Splide; + const elements = {}; + const slides = []; + let rootClasses; + let trackClasses; + let track; + let list; + let isUsingKey; function setup() { collect(); init(); update(); } - function mount() { on(EVENT_REFRESH, destroy); on(EVENT_REFRESH, setup); on(EVENT_UPDATED, update); - bind(document, POINTER_DOWN_EVENTS + " keydown", function (e) { + bind(document, `${POINTER_DOWN_EVENTS} keydown`, (e) => { isUsingKey = e.type === "keydown"; - }, { - capture: true - }); - bind(root, "focusin", function () { - toggleClass(root, CLASS_FOCUS_IN, !!isUsingKey); + }, { capture: true }); + bind(root, "focusin", () => { + toggleClass(root, CLASS_FOCUS_IN, isUsingKey); }); } - function destroy(completely) { - var attrs = ALL_ATTRIBUTES.concat("style"); + const attrs = ALL_ATTRIBUTES.concat("style"); empty(slides); removeClass(root, rootClasses); removeClass(track, trackClasses); removeAttribute([track, list], attrs); removeAttribute(root, completely ? attrs : ["style", ARIA_ROLEDESCRIPTION]); } - function update() { removeClass(root, rootClasses); removeClass(track, trackClasses); @@ -803,107 +692,95 @@ function Elements(Splide2, Components2, options) { setAttribute(root, ARIA_LABEL, options.label); setAttribute(root, ARIA_LABELLEDBY, options.labelledby); } - function collect() { - track = find("." + CLASS_TRACK); - list = child(track, "." + CLASS_LIST); - assert(track && list, "A track/list element is missing."); - push(slides, children(list, "." + CLASS_SLIDE + ":not(." + CLASS_CLONE + ")")); - forOwn({ - arrows: CLASS_ARROWS, - pagination: CLASS_PAGINATION, - prev: CLASS_ARROW_PREV, - next: CLASS_ARROW_NEXT, - bar: CLASS_PROGRESS_BAR, - toggle: CLASS_TOGGLE - }, function (className, key) { - elements[key] = find("." + className); - }); - assign(elements, { - root: root, - track: track, - list: list, - slides: slides - }); + const trackElm = find(CLASS_TRACK); + const listElm = trackElm && child(trackElm, `.${CLASS_LIST}`); + if (trackElm && listElm) { + track = trackElm; + list = listElm; + push(slides, children(list, `.${CLASS_SLIDE}:not(.${CLASS_CLONE})`)); + assign(elements, { + root, + track, + list, + slides, + arrows: find(CLASS_ARROWS), + pagination: find(CLASS_PAGINATION), + prev: find(CLASS_ARROW_PREV), + next: find(CLASS_ARROW_NEXT), + bar: find(CLASS_PROGRESS_BAR), + toggle: find(CLASS_TOGGLE) + }); + } else { + assert(0, "A track/list element is missing."); + } } - function init() { - var id = root.id || uniqueId(PROJECT_CODE); - var role = options.role; + const { role = "region" } = options; + const id = root.id || uniqueId(PROJECT_CODE); root.id = id; - track.id = track.id || id + "-track"; - list.id = list.id || id + "-list"; - + track.id = track.id || `${id}-track`; + list.id = list.id || `${id}-list`; if (!getAttribute(root, ROLE) && root.tagName !== "SECTION" && role) { setAttribute(root, ROLE, role); } - - setAttribute(root, ARIA_ROLEDESCRIPTION, i18n.carousel); + setAttribute(root, ARIA_ROLEDESCRIPTION, Splide.i18n("carousel")); setAttribute(list, ROLE, "presentation"); } - - function find(selector) { - var elm = query(root, selector); - return elm && closest(elm, "." + CLASS_ROOT) === root ? elm : void 0; + function find(className) { + const elm = query(root, `.${className}`); + return elm && closest(elm, `.${CLASS_ROOT}`) === root ? elm : void 0; } - function getClasses(base) { - return [base + "--" + options.type, base + "--" + options.direction, options.drag && base + "--draggable", options.isNavigation && base + "--nav", base === CLASS_ROOT && CLASS_ACTIVE]; + return classNames( + `${base}--${options.type}`, + `${base}--${options.direction}`, + options.drag && `${base}--draggable`, + options.isNavigation && `${base}--nav`, + base === CLASS_ROOT && CLASS_ACTIVE + ); } - return assign(elements, { - setup: setup, - mount: mount, - destroy: destroy + setup, + mount, + destroy }); -} - -var SLIDE = "slide"; -var LOOP = "loop"; -var FADE = "fade"; - -function Slide$1(Splide2, index, slideIndex, slide) { - var event = EventInterface(Splide2); - var on = event.on, - emit = event.emit, - bind = event.bind; - var Components = Splide2.Components, - root = Splide2.root, - options = Splide2.options; - var isNavigation = options.isNavigation, - updateOnMove = options.updateOnMove, - i18n = options.i18n, - pagination = options.pagination, - slideFocus = options.slideFocus; - var resolve = Components.Direction.resolve; - var styles = getAttribute(slide, "style"); - var label = getAttribute(slide, ARIA_LABEL); - var isClone = slideIndex > -1; - var container = child(slide, "." + CLASS_CONTAINER); - var destroyed; +}; +const SLIDE = "slide"; +const LOOP = "loop"; +const FADE = "fade"; + +const Slide$1 = (Splide2, index, slideIndex, slide) => { + const event = Splide2.event.lock(); + const { on, emit, bind } = event; + const { Components, root, options } = Splide2; + const { isNavigation, updateOnMove, pagination, slideFocus } = options; + const { Elements } = Components; + const { resolve } = Components.Direction; + const styles = getAttribute(slide, "style"); + const label = getAttribute(slide, ARIA_LABEL); + const isClone = slideIndex > -1; + const container = child(slide, `.${CLASS_CONTAINER}`); + let destroyed; function mount() { if (!isClone) { - slide.id = root.id + "-slide" + pad(index + 1); + slide.id = `${root.id}-slide${pad(index + 1)}`; setAttribute(slide, ROLE, pagination ? "tabpanel" : "group"); - setAttribute(slide, ARIA_ROLEDESCRIPTION, i18n.slide); - setAttribute(slide, ARIA_LABEL, label || format(i18n.slideLabel, [index + 1, Splide2.length])); + setAttribute(slide, ARIA_ROLEDESCRIPTION, Splide2.i18n("slide")); + setAttribute(slide, ARIA_LABEL, label || format(Splide2.i18n("slideLabel"), index + 1, Splide2.length)); } - listen(); } - function listen() { bind(slide, "click", apply(emit, EVENT_CLICK, self)); bind(slide, "keydown", apply(emit, EVENT_SLIDE_KEYDOWN, self)); on([EVENT_MOVED, EVENT_SHIFTED, EVENT_SCROLLED], update); on(EVENT_NAVIGATION_MOUNTED, initNavigation); - if (updateOnMove) { on(EVENT_MOVE, onMove); } } - function destroy() { destroyed = true; event.destroy(); @@ -912,226 +789,171 @@ function Slide$1(Splide2, index, slideIndex, slide) { setAttribute(slide, "style", styles); setAttribute(slide, ARIA_LABEL, label || ""); } - function initNavigation() { - var controls = Splide2.splides.map(function (target) { - var Slide2 = target.splide.Components.Slides.getAt(index); + const controls = Splide2.splides.map((target) => { + const Slide2 = target.splide.Components.Slides.getAt(index); return Slide2 ? Slide2.slide.id : ""; }).join(" "); - setAttribute(slide, ARIA_LABEL, format(i18n.slideX, (isClone ? slideIndex : index) + 1)); + setAttribute(slide, ARIA_LABEL, format(Splide2.i18n("slideX"), (isClone ? slideIndex : index) + 1)); setAttribute(slide, ARIA_CONTROLS, controls); setAttribute(slide, ROLE, slideFocus ? "button" : ""); slideFocus && removeAttribute(slide, ARIA_ROLEDESCRIPTION); } - function onMove() { if (!destroyed) { update(); } } - function update() { if (!destroyed) { - var curr = Splide2.index; + const { index: curr } = Splide2; updateActivity(); updateVisibility(); toggleClass(slide, CLASS_PREV, index === curr - 1); toggleClass(slide, CLASS_NEXT, index === curr + 1); } } - function updateActivity() { - var active = isActive(); - + const active = isActive(); if (active !== hasClass(slide, CLASS_ACTIVE)) { toggleClass(slide, CLASS_ACTIVE, active); setAttribute(slide, ARIA_CURRENT, isNavigation && active || ""); emit(active ? EVENT_ACTIVE : EVENT_INACTIVE, self); } } - function updateVisibility() { - var visible = isVisible(); - var hidden = !visible && (!isActive() || isClone); - + const visible = isVisible(); + const hidden = !visible && (!isActive() || isClone); if (!Splide2.state.is([MOVING, SCROLLING])) { setAttribute(slide, ARIA_HIDDEN, hidden || ""); } - setAttribute(queryAll(slide, options.focusableNodes || ""), TAB_INDEX, hidden ? -1 : ""); - if (slideFocus) { setAttribute(slide, TAB_INDEX, hidden ? -1 : 0); } - if (visible !== hasClass(slide, CLASS_VISIBLE)) { toggleClass(slide, CLASS_VISIBLE, visible); emit(visible ? EVENT_VISIBLE : EVENT_HIDDEN, self); } - if (!visible && document.activeElement === slide) { - var Slide2 = Components.Slides.getAt(Splide2.index); + const Slide2 = Components.Slides.getAt(Splide2.index); Slide2 && focus(Slide2.slide); } } - function style$1(prop, value, useContainer) { style(useContainer && container || slide, prop, value); } - function isActive() { - var curr = Splide2.index; - return curr === index || options.cloneStatus && curr === slideIndex; + const { index: curr } = Splide2; + const { cloneStatus = true } = options; + return curr === index || cloneStatus && curr === slideIndex; } - - function isVisible() { + function isVisible(partial) { if (Splide2.is(FADE)) { return isActive(); } - - var trackRect = rect(Components.Elements.track); - var slideRect = rect(slide); - var left = resolve("left", true); - var right = resolve("right", true); - return floor(trackRect[left]) <= ceil(slideRect[left]) && floor(slideRect[right]) <= ceil(trackRect[right]); + const trackRect = rect(Elements.track); + const slideRect = rect(slide); + const left = resolve("left", true); + const right = resolve("right", true); + return floor(trackRect[left]) <= ceil(slideRect[partial ? right : left]) && floor(slideRect[partial ? left : right]) <= ceil(trackRect[right]); } - function isWithin(from, distance) { - var diff = abs(from - index); - + let diff = abs(from - index); if (!isClone && (options.rewind || Splide2.is(LOOP))) { diff = min(diff, Splide2.length - diff); } - return diff <= distance; } - - var self = { - index: index, - slideIndex: slideIndex, - slide: slide, - container: container, - isClone: isClone, - mount: mount, - destroy: destroy, - update: update, + const self = { + index, + slideIndex, + slide, + container, + isClone, + mount, + destroy, + update, style: style$1, - isWithin: isWithin + isVisible, + isWithin }; return self; -} - -function Slides(Splide2, Components2, options) { - var _EventInterface2 = EventInterface(Splide2), - on = _EventInterface2.on, - emit = _EventInterface2.emit, - bind = _EventInterface2.bind; - - var _Components2$Elements = Components2.Elements, - slides = _Components2$Elements.slides, - list = _Components2$Elements.list; - var Slides2 = []; +}; +const Slides = (Splide, Components, options, event) => { + const { on, emit, bind } = event; + const { slides, list } = Components.Elements; + const Slides2 = []; function mount() { init(); on(EVENT_REFRESH, destroy); on(EVENT_REFRESH, init); } - function init() { - slides.forEach(function (slide, index) { - register(slide, index, -1); - }); + slides.forEach((slide, index) => register(slide, index, -1)); } - function destroy() { - forEach$1(function (Slide2) { - Slide2.destroy(); - }); + forEach$1((Slide2) => Slide2.destroy()); empty(Slides2); } - function update() { - forEach$1(function (Slide2) { - Slide2.update(); - }); + forEach$1((Slide2) => Slide2.update()); } - function register(slide, index, slideIndex) { - var object = Slide$1(Splide2, index, slideIndex, slide); - object.mount(); - Slides2.push(object); - Slides2.sort(function (Slide1, Slide2) { - return Slide1.index - Slide2.index; - }); + const instance = Slide$1(Splide, index, slideIndex, slide); + instance.mount(); + Slides2.push(instance); + Slides2.sort((Slide1, Slide2) => Slide1.index - Slide2.index); } - function get(excludeClones) { - return excludeClones ? filter(function (Slide2) { - return !Slide2.isClone; - }) : Slides2; + return excludeClones ? filter((Slide2) => !Slide2.isClone) : Slides2; } - function getIn(page) { - var Controller = Components2.Controller; - var index = Controller.toIndex(page); - var max = Controller.hasFocus() ? 1 : options.perPage; - return filter(function (Slide2) { - return between(Slide2.index, index, index + max - 1); - }); + const { Controller } = Components; + const index = Controller.toIndex(page); + const max = Controller.hasFocus() ? 1 : options.perPage || 1; + return filter((Slide2) => between(Slide2.index, index, index + max - 1)); } - function getAt(index) { return filter(index)[0]; } - function add(items, index) { - forEach(items, function (slide) { + forEach(items, (slide) => { if (isString(slide)) { - slide = parseHtml(slide); + slide = parseHtml(slide) || ""; } - if (isHTMLElement(slide)) { - var ref = slides[index]; - ref ? before(slide, ref) : append(list, slide); - addClass(slide, options.classes.slide); + const ref = slides[index || -1]; + ref ? before(ref, slide) : append(list, slide); + addClass(slide, Splide.classes("slide")); observeImages(slide, apply(emit, EVENT_RESIZE)); } }); emit(EVENT_REFRESH); } - - function remove$1(matcher) { - remove(filter(matcher).map(function (Slide2) { - return Slide2.slide; - })); + function remove(matcher) { + removeNode(filter(matcher).map((Slide2) => Slide2.slide)); emit(EVENT_REFRESH); } - function forEach$1(iteratee, excludeClones) { get(excludeClones).forEach(iteratee); } - function filter(matcher) { - return Slides2.filter(isFunction(matcher) ? matcher : function (Slide2) { - return isString(matcher) ? matches(Slide2.slide, matcher) : includes(toArray(matcher), Slide2.index); - }); + return Slides2.filter( + isFunction(matcher) ? matcher : (Slide2) => isString(matcher) ? matches(Slide2.slide, matcher) : includes(toArray(matcher), Slide2.index) + ); } - function style(prop, value, useContainer) { - forEach$1(function (Slide2) { - Slide2.style(prop, value, useContainer); - }); + forEach$1((Slide2) => Slide2.style(prop, value, useContainer)); } - function observeImages(elm, callback) { - var images = queryAll(elm, "img"); - var length = images.length; - + const images = queryAll(elm, "img"); + let { length } = images; if (length) { - images.forEach(function (img) { - bind(img, "load error", function () { - if (! --length) { + images.forEach((img) => { + bind(img, "load error", () => { + if (!--length) { callback(); } }); @@ -1140,58 +962,45 @@ function Slides(Splide2, Components2, options) { callback(); } } - function getLength(excludeClones) { return excludeClones ? slides.length : Slides2.length; } - function isEnough() { - return Slides2.length > options.perPage; + return Slides2.length > (options.perPage || 1); } - return { - mount: mount, - destroy: destroy, - update: update, - register: register, - get: get, - getIn: getIn, - getAt: getAt, - add: add, - remove: remove$1, + mount, + destroy, + update, + register, + get, + getIn, + getAt, + add, + remove, forEach: forEach$1, - filter: filter, - style: style, - getLength: getLength, - isEnough: isEnough + filter, + style, + getLength, + isEnough }; -} - -function Layout(Splide2, Components2, options) { - var _EventInterface3 = EventInterface(Splide2), - on = _EventInterface3.on, - bind = _EventInterface3.bind, - emit = _EventInterface3.emit; - - var Slides = Components2.Slides; - var resolve = Components2.Direction.resolve; - var _Components2$Elements2 = Components2.Elements, - root = _Components2$Elements2.root, - track = _Components2$Elements2.track, - list = _Components2$Elements2.list; - var getAt = Slides.getAt, - styleSlides = Slides.style; - var vertical; - var rootRect; - var overflow; +}; +const Layout = (Splide, Components, options, event) => { + const { on, bind, emit } = event; + const { Slides } = Components; + const { resolve, left, right, width } = Components.Direction; + const { root, track, list } = Components.Elements; + const { getAt, style: styleSlides } = Slides; + let vertical; + let rootRect; + let overflow; function mount() { init(); bind(window, "resize load", Throttle(apply(emit, EVENT_RESIZE))); on([EVENT_UPDATED, EVENT_REFRESH], init); on(EVENT_RESIZE, resize); } - function init() { vertical = options.direction === TTB; style(root, "maxWidth", unit(options.width)); @@ -1199,10 +1008,8 @@ function Layout(Splide2, Components2, options) { style(track, resolve("paddingRight"), cssPadding(true)); resize(true); } - function resize(force) { - var newRect = rect(root); - + const newRect = rect(root); if (force || rootRect.width !== newRect.width || rootRect.height !== newRect.height) { style(track, "height", cssTrackHeight()); styleSlides(resolve("marginRight"), unit(options.gap)); @@ -1210,282 +1017,238 @@ function Layout(Splide2, Components2, options) { styleSlides("height", cssSlideHeight(), true); rootRect = newRect; emit(EVENT_RESIZED); - if (overflow !== (overflow = isOverflow())) { toggleClass(root, CLASS_OVERFLOW, overflow); emit(EVENT_OVERFLOW, overflow); } } } - - function cssPadding(right) { - var padding = options.padding; - var prop = resolve(right ? "right" : "left"); - return padding && unit(padding[prop] || (isObject(padding) ? 0 : padding)) || "0px"; + function cssPadding(rightPadding) { + const { padding } = options; + const prop = rightPadding ? right() : left(); + return unit(isObject(padding) ? padding[prop] : padding) || "0px"; } - function cssTrackHeight() { - var height = ""; - + let height = ""; if (vertical) { height = cssHeight(); assert(height, "height or heightRatio is missing."); - height = "calc(" + height + " - " + cssPadding(false) + " - " + cssPadding(true) + ")"; + height = `calc(${height} - ${cssPadding(false)} - ${cssPadding(true)})`; } - return height; } - function cssHeight() { - return unit(options.height || rect(list).width * options.heightRatio); + return unit(options.height || rect(list).width * (options.heightRatio || 0)); } - function cssSlideWidth() { return options.autoWidth ? null : unit(options.fixedWidth) || (vertical ? "" : cssSlideSize()); } - function cssSlideHeight() { return unit(options.fixedHeight) || (vertical ? options.autoHeight ? null : cssSlideSize() : cssHeight()); } - function cssSlideSize() { - var gap = unit(options.gap); - return "calc((100%" + (gap && " + " + gap) + ")/" + (options.perPage || 1) + (gap && " - " + gap) + ")"; + const gap = unit(options.gap); + return `calc((100%${gap && ` + ${gap}`})/${options.perPage || 1}${gap && ` - ${gap}`})`; } - - function listSize() { - return rect(list)[resolve("width")]; + function trackSize() { + return rect(track)[width()]; } - - function slideSize(index, withoutGap) { - var Slide = getAt(index || 0); - return Slide ? rect(Slide.slide)[resolve("width")] + (withoutGap ? 0 : getGap()) : 0; + function listSize(full) { + return full ? list[resolve("scrollWidth")] : rect(list)[width()]; + } + function slideSize(index = 0, withoutGap) { + const slide = getAt(index); + return (slide ? rect(slide.slide)[width()] : 0) + (withoutGap ? 0 : getGap()); } - function totalSize(index, withoutGap) { - var Slide = getAt(index); - - if (Slide) { - var right = rect(Slide.slide)[resolve("right")]; - var left = rect(list)[resolve("left")]; - return abs(right - left) + (withoutGap ? 0 : getGap()); - } - - return 0; + const first = Components.Slides.get()[0]; + const target = getAt(index); + return first && target ? abs(rect(target.slide)[right()] - rect(first.slide)[left()]) + (withoutGap ? 0 : getGap()) : 0; } - function sliderSize(withoutGap) { - return totalSize(Splide2.length - 1) - totalSize(0) + slideSize(0, withoutGap); + return totalSize(Splide.length - 1) - totalSize(0) + slideSize(0, withoutGap); } - function getGap() { - var Slide = getAt(0); - return Slide && parseFloat(style(Slide.slide, resolve("marginRight"))) || 0; + const first = getAt(0); + const second = getAt(1); + if (first && second) { + const firstRect = rect(first.slide); + return abs(rect(second.slide)[left()] - firstRect[left()]) - firstRect[width()]; + } + return 0; } - - function getPadding(right) { - return parseFloat(style(track, resolve("padding" + (right ? "Right" : "Left")))) || 0; + function getPadding(right2) { + return parseFloat(style( + track, + resolve(`padding${right2 ? "Right" : "Left"}`) + )) || 0; } - function isOverflow() { - return Splide2.is(FADE) || sliderSize(true) > listSize(); + return Splide.is(FADE) || sliderSize(true) > listSize(); } - return { - mount: mount, - resize: resize, - listSize: listSize, - slideSize: slideSize, - sliderSize: sliderSize, - totalSize: totalSize, - getPadding: getPadding, - isOverflow: isOverflow + mount, + resize, + trackSize, + listSize, + slideSize, + sliderSize, + totalSize, + getPadding, + isOverflow }; -} - -var MULTIPLIER = 2; - -function Clones(Splide2, Components2, options) { - var event = EventInterface(Splide2); - var on = event.on; - var Elements = Components2.Elements, - Slides = Components2.Slides; - var resolve = Components2.Direction.resolve; - var clones = []; - var cloneCount; +}; +const MULTIPLIER = 2; +const Clones = (Splide, Components, options, event) => { + const { on } = event; + const { Elements, Slides, Layout: { resize, trackSize } } = Components; + const { resolve } = Components.Direction; + const clones = []; + let cloneCount; function mount() { on(EVENT_REFRESH, remount); on([EVENT_UPDATED, EVENT_RESIZE], observe); - if (cloneCount = computeCloneCount()) { generate(cloneCount); - Components2.Layout.resize(true); + resize(true); } } - function remount() { destroy(); mount(); + resize(true); } - function destroy() { - remove(clones); + removeNode(clones); empty(clones); event.destroy(); } - function observe() { - var count = computeCloneCount(); - + const count = computeCloneCount(); if (cloneCount !== count) { if (cloneCount < count || !count) { + !count && Splide.go(0); event.emit(EVENT_REFRESH); } } } - function generate(count) { - var slides = Slides.get().slice(); - var length = slides.length; - + const slides = Slides.get().slice(); + const { length } = slides; if (length) { while (slides.length < count) { push(slides, slides); } - - push(slides.slice(-count), slides.slice(0, count)).forEach(function (Slide, index) { - var isHead = index < count; - var clone = cloneDeep(Slide.slide, index); - isHead ? before(clone, slides[0].slide) : append(Elements.list, clone); + push(slides.slice(-count), slides.slice(0, count)).forEach((Slide, index) => { + const isHead = index < count; + const clone = cloneDeep(Slide.slide, index); + isHead ? before(slides[0].slide, clone) : append(Elements.list, clone); push(clones, clone); Slides.register(clone, index - count + (isHead ? 0 : length), Slide.index); }); } } - function cloneDeep(elm, index) { - var clone = elm.cloneNode(true); - addClass(clone, options.classes.clone); - clone.id = Splide2.root.id + "-clone" + pad(index + 1); + const clone = elm.cloneNode(true); + addClass(clone, Splide.classes("clone")); + clone.id = `${Splide.root.id}-clone${pad(index + 1)}`; return clone; } - function computeCloneCount() { - var clones2 = options.clones; - - if (!Splide2.is(LOOP)) { + let { clones: clones2 } = options; + if (!Splide.is(LOOP)) { clones2 = 0; } else if (isUndefined(clones2)) { - var fixedSize = options[resolve("fixedWidth")] && Components2.Layout.slideSize(0); - var fixedCount = fixedSize && ceil(rect(Elements.track)[resolve("width")] / fixedSize); - clones2 = fixedCount || options[resolve("autoWidth")] && Splide2.length || options.perPage * MULTIPLIER; + const { perPage = 1 } = options; + const fixedSize = options[resolve("fixedWidth")] && Components.Layout.slideSize(0); + const fixedCount = fixedSize && ceil(trackSize() / fixedSize); + clones2 = fixedCount || options[resolve("autoWidth")] && Splide.length || perPage * MULTIPLIER; } - return clones2; } - return { - mount: mount, - destroy: destroy + mount, + destroy }; -} - -function Move(Splide2, Components2, options) { - var _EventInterface4 = EventInterface(Splide2), - on = _EventInterface4.on, - emit = _EventInterface4.emit; - - var set = Splide2.state.set; - var _Components2$Layout = Components2.Layout, - slideSize = _Components2$Layout.slideSize, - getPadding = _Components2$Layout.getPadding, - totalSize = _Components2$Layout.totalSize, - listSize = _Components2$Layout.listSize, - sliderSize = _Components2$Layout.sliderSize; - var _Components2$Directio = Components2.Direction, - resolve = _Components2$Directio.resolve, - orient = _Components2$Directio.orient; - var _Components2$Elements3 = Components2.Elements, - list = _Components2$Elements3.list, - track = _Components2$Elements3.track; - var Transition; +}; +const Move = (Splide, Components, options, event) => { + const { on, emit } = event; + const { set, is } = Splide.state; + const { Slides } = Components; + const { slideSize, getPadding, listSize, sliderSize, totalSize, trackSize } = Components.Layout; + const { resolve, orient } = Components.Direction; + const { list, track } = Components.Elements; + let Transition; + let indices; + let callback; function mount() { - Transition = Components2.Transition; + Transition = Components.Transition; on([EVENT_MOUNTED, EVENT_RESIZED, EVENT_UPDATED, EVENT_REFRESH], reposition); } - function reposition() { - if (!Components2.Controller.isBusy()) { - Components2.Scroll.cancel(); - jump(Splide2.index); - Components2.Slides.update(); - } - } - - function move(dest, index, prev, callback) { - if (dest !== index && canShift(dest > prev)) { - cancel(); - translate(shift(getPosition(), dest > prev), true); - } - + if (!Components.Controller.isBusy()) { + Components.Scroll.cancel(); + jump(Splide.index); + Slides.update(); + } + } + function move(dest, index, prev, forwards, onMoved) { + cancel(); + const shiftBackwards = dest !== index ? dest > index : forwards; + const shouldShift = (dest !== index || exceededLimit(forwards)) && canShift(shiftBackwards); + shouldShift && translate(shift(getPosition(), shiftBackwards), true); + indices = [index, prev, dest]; + callback = onMoved; set(MOVING); emit(EVENT_MOVE, index, prev, dest); - Transition.start(index, function () { - set(IDLE); - emit(EVENT_MOVED, index, prev, dest); - callback && callback(); - }); + Transition.start(index, onTransitionEnd); + } + function onTransitionEnd() { + set(IDLE); + emit(EVENT_MOVED, ...indices); + callback && callback(); + } + function cancel() { + if (is(MOVING) && indices) { + translate(getPosition(), true); + Transition.cancel(); + onTransitionEnd(); + } } - function jump(index) { - translate(toPosition(index, true)); + translate(toPosition(index)); } - function translate(position, preventLoop) { - if (!Splide2.is(FADE)) { - var destination = preventLoop ? position : loop(position); - style(list, "transform", "translate" + resolve("X") + "(" + destination + "px)"); + if (!Splide.is(FADE)) { + const destination = preventLoop ? position : loop(position); + style(list, "transform", `translate${resolve("X")}(${destination}px)`); position !== destination && emit(EVENT_SHIFTED); } } - function loop(position) { - if (Splide2.is(LOOP)) { - var index = toIndex(position); - var exceededMax = index > Components2.Controller.getEnd(); - var exceededMin = index < 0; - - if (exceededMin || exceededMax) { - position = shift(position, exceededMax); + if (Splide.is(LOOP)) { + const diff = orient(position) - orient(getPosition()); + if (diff && exceededLimit(diff > 0, position)) { + position = shift(position, diff > 0); } } - return position; } - function shift(position, backwards) { - var excess = position - getLimit(backwards); - var size = sliderSize(); + const excess = position - getLimit(backwards); + const size = sliderSize(); position -= orient(size * (ceil(abs(excess) / size) || 1)) * (backwards ? 1 : -1); return position; } - - function cancel() { - translate(getPosition(), true); - Transition.cancel(); - } - function toIndex(position) { - var Slides = Components2.Slides.get(); - var index = 0; - var minDistance = Infinity; - - for (var i = 0; i < Slides.length; i++) { - var slideIndex = Slides[i].index; - var distance = abs(toPosition(slideIndex, true) - position); - + const slides = Slides.get(); + let index = 0; + let minDistance = Infinity; + for (let i = 0; i < slides.length; i++) { + const slideIndex = slides[i].index; + const distance = abs(toPosition(slideIndex) - position); if (distance <= minDistance) { minDistance = distance; index = slideIndex; @@ -1493,179 +1256,177 @@ function Move(Splide2, Components2, options) { break; } } - return index; } - - function toPosition(index, trimming) { - var position = orient(totalSize(index - 1) - offset(index)); - return trimming ? trim(position) : position; + function toPosition(index) { + let position = orient(totalSize(index - 1) - offset(index)); + if (options.trimSpace && Splide.is(SLIDE)) { + position = clamp(position, 0, orient(sliderSize(true) - listSize())); + } + return position; } - function getPosition() { - var left = resolve("left"); + const left = resolve("left"); return rect(list)[left] - rect(track)[left] + orient(getPadding(false)); } - - function trim(position) { - if (options.trimSpace && Splide2.is(SLIDE)) { - position = clamp(position, 0, orient(sliderSize(true) - listSize())); + function getRate(index) { + const useIndex = !isUndefined(index); + let rate; + if (Splide.is(FADE)) { + rate = (useIndex ? index : Splide.index) / (Splide.length - 1); + } else { + const isLoop = Splide.is(LOOP); + const position = orient(useIndex ? toPosition(index) : getPosition()); + const min = orient(getLimit(false)); + const max = orient(getLimit(true)); + const size = sliderSize(); + const curr = (position - min) % size; + const base = isLoop ? size : max - min; + rate = curr / base || 0; + if (isLoop && rate < 0) { + rate += 1; + } } - - return position; + return clamp(rate, 0, 1); } - function offset(index) { - var focus = options.focus; - return focus === "center" ? (listSize() - slideSize(index, true)) / 2 : +focus * slideSize(index) || 0; + const { focus } = options; + return focus === "center" ? (listSize() - slideSize(index, true)) / 2 : toNumber(focus) * slideSize(index); } - function getLimit(max) { - return toPosition(max ? Components2.Controller.getEnd() : 0, !!options.trimSpace); + return toPosition(max ? Components.Controller.getEnd() : 0); } - function canShift(backwards) { - var shifted = orient(shift(getPosition(), backwards)); - return backwards ? shifted >= 0 : shifted <= list[resolve("scrollWidth")] - rect(track)[resolve("width")]; + const padding = getPadding(false); + const shifted = orient(shift(getPosition(), backwards)); + return backwards ? shifted >= padding : shifted <= listSize(true) - trackSize() + padding; } - - function exceededLimit(max, position) { - position = isUndefined(position) ? getPosition() : position; - var exceededMin = max !== true && orient(position) < orient(getLimit(false)); - var exceededMax = max !== false && orient(position) > orient(getLimit(true)); + function exceededLimit(max, position = getPosition()) { + const exceededMin = max !== true && orient(position) < orient(getLimit(false)); + const exceededMax = max !== false && orient(position) > orient(getLimit(true)); return exceededMin || exceededMax; } - return { - mount: mount, - move: move, - jump: jump, - translate: translate, - shift: shift, - cancel: cancel, - toIndex: toIndex, - toPosition: toPosition, - getPosition: getPosition, - getLimit: getLimit, - exceededLimit: exceededLimit, - reposition: reposition + mount, + move, + jump, + translate, + shift, + cancel, + toIndex, + toPosition, + getPosition, + getRate, + getLimit, + exceededLimit, + reposition, + canShift }; -} - -function Controller(Splide2, Components2, options) { - var _EventInterface5 = EventInterface(Splide2), - on = _EventInterface5.on, - emit = _EventInterface5.emit; - - var Move = Components2.Move; - var getPosition = Move.getPosition, - getLimit = Move.getLimit, - toPosition = Move.toPosition; - var _Components2$Slides = Components2.Slides, - isEnough = _Components2$Slides.isEnough, - getLength = _Components2$Slides.getLength; - var omitEnd = options.omitEnd; - var isLoop = Splide2.is(LOOP); - var isSlide = Splide2.is(SLIDE); - var getNext = apply(getAdjacent, false); - var getPrev = apply(getAdjacent, true); - var currIndex = options.start || 0; - var endIndex; - var prevIndex = currIndex; - var slideCount; - var perMove; - var perPage; +}; +const Controller = (Splide, Components, options, event) => { + const { on, emit } = event; + const { Move, Scroll } = Components; + const { getPosition, getLimit, toPosition } = Move; + const { isEnough, getLength } = Components.Slides; + const { omitEnd } = options; + const isLoop = Splide.is(LOOP); + const isSlide = Splide.is(SLIDE); + const getNext = apply(getAdjacent, false); + const getPrev = apply(getAdjacent, true); + let currIndex = options.start || 0; + let endIndex; + let prevIndex = currIndex; + let slideCount; + let perMove; + let perPage; function mount() { init(); on([EVENT_UPDATED, EVENT_REFRESH, EVENT_END_INDEX_CHANGED], init); on(EVENT_RESIZED, onResized); } - function init() { slideCount = getLength(true); perMove = options.perMove; - perPage = options.perPage; + perPage = options.perPage || 1; endIndex = getEnd(); - var index = clamp(currIndex, 0, omitEnd ? endIndex : slideCount - 1); - + const end = omitEnd ? endIndex : slideCount - 1; + const index = clamp(currIndex, 0, end); + prevIndex = index; if (index !== currIndex) { currIndex = index; Move.reposition(); } } - function onResized() { if (endIndex !== getEnd()) { emit(EVENT_END_INDEX_CHANGED); } } - - function go(control, allowSameIndex, callback) { + function go(control, callback) { if (!isBusy()) { - var dest = parse(control); - var index = loop(dest); - - if (index > -1 && (allowSameIndex || index !== currIndex)) { + const [dest, forwards] = parse(control); + const index = loop(dest); + const canGo = dest === index || Move.exceededLimit(!forwards) || Move.canShift(forwards); + const heading = isMoving() && currIndex === index; + if (index > -1 && canGo && !heading) { + Scroll.cancel(); setIndex(index); - Move.move(dest, index, prevIndex, callback); + Move.move(dest, index, prevIndex, forwards, callback); } } } - + function jump(control) { + const { set } = Components.Breakpoints; + const { speed } = options; + set({ speed: 0 }); + go(control); + set({ speed }); + } function scroll(destination, duration, snap, callback) { - Components2.Scroll.scroll(destination, duration, snap, function () { - var index = loop(Move.toIndex(getPosition())); + Scroll.scroll(destination, duration, snap, () => { + const index = loop(Move.toIndex(getPosition())); setIndex(omitEnd ? min(index, endIndex) : index); callback && callback(); }); } - function parse(control) { - var index = currIndex; - + let dest = currIndex; + let forwards = true; if (isString(control)) { - var _ref = control.match(/([+\-<>])(\d+)?/) || [], - indicator = _ref[1], - number = _ref[2]; - - if (indicator === "+" || indicator === "-") { - index = computeDestIndex(currIndex + +("" + indicator + (+number || 1)), currIndex); - } else if (indicator === ">") { - index = number ? toIndex(+number) : getNext(true); - } else if (indicator === "<") { - index = getPrev(true); + const [, indicator, number] = control.match(/([+-]|>>?|< includes(indicators, indicator); + forwards = oneOf("+", ">", ">>"); + if (oneOf("+", "-")) { + dest = computeDestIndex(currIndex + +`${indicator}${+number || 1}`, currIndex); + } else if (oneOf(">", "<")) { + dest = number ? toIndex(+number) : getAdjacent(!forwards, true); + } else if (oneOf(">>", "<<")) { + dest = number ? +number || 0 : forwards ? endIndex : 0; } } else { - index = isLoop ? control : clamp(control, 0, endIndex); + dest = isLoop ? control : clamp(control, 0, endIndex); } - - return index; + return [dest, forwards]; } - function getAdjacent(prev, destination) { - var number = perMove || (hasFocus() ? 1 : perPage); - var dest = computeDestIndex(currIndex + number * (prev ? -1 : 1), currIndex, !(perMove || hasFocus())); - + const number = perMove || (hasFocus() ? 1 : perPage); + const dest = computeDestIndex(currIndex + number * (prev ? -1 : 1), currIndex, !(perMove || hasFocus())); if (dest === -1 && isSlide) { if (!approximatelyEqual(getPosition(), getLimit(!prev), 1)) { return prev ? 0 : endIndex; } } - return destination ? dest : loop(dest); } - function computeDestIndex(dest, from, snapPage) { if (isEnough() || hasFocus()) { - var index = computeMovableDestIndex(dest); - + const index = computeMovableDestIndex(dest); if (index !== dest) { from = dest; dest = index; snapPage = false; } - if (dest < 0 || dest > endIndex) { if (!perMove && (between(0, dest, from, true) || between(endIndex, from, dest, true))) { dest = toIndex(toPage(dest)); @@ -1686,502 +1447,390 @@ function Controller(Splide2, Components2, options) { } else { dest = -1; } - return dest; } - function computeMovableDestIndex(dest) { if (isSlide && options.trimSpace === "move" && dest !== currIndex) { - var position = getPosition(); - - while (position === toPosition(dest, true) && between(dest, 0, Splide2.length - 1, !options.rewind)) { + const position = getPosition(); + while (position === toPosition(dest) && between(dest, 0, Splide.length - 1, !options.rewind)) { dest < currIndex ? --dest : ++dest; } } - return dest; } - function loop(index) { - return isLoop ? (index + slideCount) % slideCount || 0 : index; + if (isLoop) { + while (slideCount && index < 0) { + index += slideCount; + } + index = index % slideCount; + } + return index; } - function getEnd() { - var end = slideCount - (hasFocus() || isLoop && perMove ? 1 : perPage); - + let end = slideCount - (hasFocus() || isLoop && perMove ? 1 : perPage); while (omitEnd && end-- > 0) { - if (toPosition(slideCount - 1, true) !== toPosition(end, true)) { + if (!approximatelyEqual(toPosition(slideCount - 1), toPosition(end), 0.01)) { end++; break; } } - return clamp(end, 0, slideCount - 1); } - function toIndex(page) { return clamp(hasFocus() ? page : perPage * page, 0, endIndex); } - function toPage(index) { return hasFocus() ? min(index, endIndex) : floor((index >= endIndex ? slideCount - 1 : index) / perPage); } - function toDest(destination) { - var closest = Move.toIndex(destination); + const closest = Move.toIndex(destination); return isSlide ? clamp(closest, 0, endIndex) : closest; } - function setIndex(index) { if (index !== currIndex) { prevIndex = currIndex; currIndex = index; } } - function getIndex(prev) { return prev ? prevIndex : currIndex; } - function hasFocus() { - return !isUndefined(options.focus) || options.isNavigation; + return !isUndefined(options.focus) || !!options.isNavigation; + } + function isMoving() { + return Splide.state.is([MOVING, SCROLLING]); } - function isBusy() { - return Splide2.state.is([MOVING, SCROLLING]) && !!options.waitForTransition; + return isMoving() && !!options.waitForTransition; } - return { - mount: mount, - go: go, - scroll: scroll, - getNext: getNext, - getPrev: getPrev, - getAdjacent: getAdjacent, - getEnd: getEnd, - setIndex: setIndex, - getIndex: getIndex, - toIndex: toIndex, - toPage: toPage, - toDest: toDest, - hasFocus: hasFocus, - isBusy: isBusy + mount, + go, + jump, + scroll, + getNext, + getPrev, + getAdjacent, + getEnd, + setIndex, + getIndex, + toIndex, + toPage, + toDest, + hasFocus, + isBusy }; -} +}; -var XML_NAME_SPACE = "http://www.w3.org/2000/svg"; -var PATH = "m15.5 0.932-4.3 4.38 14.5 14.6-14.5 14.5 4.3 4.4 14.6-14.6 4.4-4.3-4.4-4.4-14.6-14.6z"; -var SIZE = 40; +const XML_NAME_SPACE = "http://www.w3.org/2000/svg"; +const PATH = "m15.5 0.932-4.3 4.38 14.5 14.6-14.5 14.5 4.3 4.4 14.6-14.6 4.4-4.3-4.4-4.4-14.6-14.6z"; +const SIZE = 40; -function Arrows(Splide2, Components2, options) { - var event = EventInterface(Splide2); - var on = event.on, - bind = event.bind, - emit = event.emit; - var classes = options.classes, - i18n = options.i18n; - var Elements = Components2.Elements, - Controller = Components2.Controller; - var placeholder = Elements.arrows, - track = Elements.track; - var wrapper = placeholder; - var prev = Elements.prev; - var next = Elements.next; - var created; - var wrapperClasses; - var arrows = {}; +const I18N = { + prev: "Previous slide", + next: "Next slide", + first: "Go to first slide", + last: "Go to last slide", + slideX: "Go to slide %s", + pageX: "Go to page %s", + play: "Start autoplay", + pause: "Pause autoplay", + carousel: "carousel", + slide: "slide", + select: "Select a slide to show", + slideLabel: "%s of %s" +}; +const Arrows = (Splide, Components, options, event) => { + const { on, bind, emit } = event; + const { classes = CLASSES, i18n = I18N } = options; + const { Elements, Controller } = Components; + const { arrows: placeholder, track } = Elements; + const wrapper = placeholder || create("div", classes.arrows); + const prev = Elements.prev || createArrow(true); + const next = Elements.next || createArrow(false); + const arrows = { prev, next }; + let wrapperClasses; function mount() { init(); - on(EVENT_UPDATED, remount); - } - - function remount() { - destroy(); - mount(); + on(EVENT_UPDATED, () => { + destroy(); + mount(); + }); } - function init() { - var enabled = options.arrows; - - if (enabled && !(prev && next)) { - createArrows(); - } - - if (prev && next) { - assign(arrows, { - prev: prev, - next: next - }); - display(wrapper, enabled ? "" : "none"); - addClass(wrapper, wrapperClasses = CLASS_ARROWS + "--" + options.direction); - - if (enabled) { - listen(); - update(); - setAttribute([prev, next], ARIA_CONTROLS, track.id); - emit(EVENT_ARROWS_MOUNTED, prev, next); - } + const { arrows: enabled = true } = options; + wrapperClasses = `${CLASS_ARROWS}--${options.direction}`; + addClass(wrapper, wrapperClasses); + if (enabled) { + display(wrapper, ""); + append(wrapper, prev, next); + !placeholder && before(track, wrapper); + listen(); + update(); + setAttribute([prev, next], ARIA_CONTROLS, track.id); + emit(EVENT_ARROWS_MOUNTED, prev, next); + } else { + display(wrapper, "none"); } } - function destroy() { event.destroy(); removeClass(wrapper, wrapperClasses); - - if (created) { - remove(placeholder ? [prev, next] : wrapper); - prev = next = null; - } else { + if (Elements.prev) { removeAttribute([prev, next], ALL_ATTRIBUTES); + } else { + removeNode(placeholder ? [prev, next] : wrapper); } } - function listen() { + const { go } = Controller; on([EVENT_MOUNTED, EVENT_MOVED, EVENT_REFRESH, EVENT_SCROLLED, EVENT_END_INDEX_CHANGED], update); - bind(next, "click", apply(go, ">")); - bind(prev, "click", apply(go, "<")); - } - - function go(control) { - Controller.go(control, true); - } - - function createArrows() { - wrapper = placeholder || create("div", classes.arrows); - prev = createArrow(true); - next = createArrow(false); - created = true; - append(wrapper, [prev, next]); - !placeholder && before(wrapper, track); + bind(next, "click", () => go(">")); + bind(prev, "click", () => go("<")); } - function createArrow(prev2) { - var arrow = ""; - }; - - _proto3.html = function html() { - var _this$config = this.config, - rootClass = _this$config.rootClass, - listTag = _this$config.listTag, - arrows = _this$config.arrows, - beforeTrack = _this$config.beforeTrack, - afterTrack = _this$config.afterTrack, - slider = _this$config.slider, - beforeSlider = _this$config.beforeSlider, - afterSlider = _this$config.afterSlider; - var html = ""; - html += "
"; - html += ""; - + return ``; + } + html() { + const { rootClass, listTag, arrows, beforeTrack, afterTrack, slider, beforeSlider, afterSlider } = this.config; + let html = ""; + html += `
`; + html += ``; if (slider) { html += beforeSlider || ""; - html += "
"; + html += `
`; } - html += beforeTrack || ""; - if (arrows) { html += this.renderArrows(); } - - html += "
"; - html += "<" + listTag + " class=\"splide__list\">"; + html += `
`; + html += `<${listTag} class="splide__list">`; html += this.renderSlides(); - html += ""; - html += "
"; + html += ``; + html += `
`; html += afterTrack || ""; - if (slider) { - html += "
"; + html += `
`; html += afterSlider || ""; } - - html += "
"; + html += `
`; return html; - }; - - return SplideRenderer; -}(); + } +} -export { CLASSES, CLASS_ACTIVE, CLASS_ARROW, CLASS_ARROWS, CLASS_ARROW_NEXT, CLASS_ARROW_PREV, CLASS_CLONE, CLASS_CONTAINER, CLASS_FOCUS_IN, CLASS_INITIALIZED, CLASS_LIST, CLASS_LOADING, CLASS_NEXT, CLASS_OVERFLOW, CLASS_PAGINATION, CLASS_PAGINATION_PAGE, CLASS_PREV, CLASS_PROGRESS, CLASS_PROGRESS_BAR, CLASS_ROOT, CLASS_SLIDE, CLASS_SPINNER, CLASS_SR, CLASS_TOGGLE, CLASS_TOGGLE_PAUSE, CLASS_TOGGLE_PLAY, CLASS_TRACK, CLASS_VISIBLE, DEFAULTS, EVENT_ACTIVE, EVENT_ARROWS_MOUNTED, EVENT_ARROWS_UPDATED, EVENT_AUTOPLAY_PAUSE, EVENT_AUTOPLAY_PLAY, EVENT_AUTOPLAY_PLAYING, EVENT_CLICK, EVENT_DESTROY, EVENT_DRAG, EVENT_DRAGGED, EVENT_DRAGGING, EVENT_END_INDEX_CHANGED, EVENT_HIDDEN, EVENT_INACTIVE, EVENT_LAZYLOAD_LOADED, EVENT_MOUNTED, EVENT_MOVE, EVENT_MOVED, EVENT_NAVIGATION_MOUNTED, EVENT_OVERFLOW, EVENT_PAGINATION_MOUNTED, EVENT_PAGINATION_UPDATED, EVENT_READY, EVENT_REFRESH, EVENT_RESIZE, EVENT_RESIZED, EVENT_SCROLL, EVENT_SCROLLED, EVENT_SHIFTED, EVENT_SLIDE_KEYDOWN, EVENT_UPDATED, EVENT_VISIBLE, EventBinder, EventInterface, FADE, LOOP, LTR, RTL, RequestInterval, SLIDE, STATUS_CLASSES, Splide, SplideRenderer, State, TTB, Throttle, Splide as default }; +export { CLASSES, CLASS_ACTIVE, CLASS_ARROW, CLASS_ARROWS, CLASS_ARROW_NEXT, CLASS_ARROW_PREV, CLASS_CLONE, CLASS_CONTAINER, CLASS_FOCUS_IN, CLASS_INITIALIZED, CLASS_LIST, CLASS_LOADING, CLASS_NEXT, CLASS_OVERFLOW, CLASS_PAGINATION, CLASS_PAGINATION_PAGE, CLASS_PREFIX, CLASS_PREV, CLASS_PROGRESS, CLASS_PROGRESS_BAR, CLASS_ROOT, CLASS_SLIDE, CLASS_SPINNER, CLASS_SR, CLASS_TOGGLE, CLASS_TOGGLE_PAUSE, CLASS_TOGGLE_PLAY, CLASS_TRACK, CLASS_VISIBLE, DEFAULTS, EVENT_ACTIVE, EVENT_ARROWS_MOUNTED, EVENT_ARROWS_UPDATED, EVENT_AUTOPLAY_PAUSE, EVENT_AUTOPLAY_PLAY, EVENT_AUTOPLAY_PLAYING, EVENT_CLICK, EVENT_DESTROY, EVENT_DRAG, EVENT_DRAGGED, EVENT_DRAGGING, EVENT_END_INDEX_CHANGED, EVENT_HIDDEN, EVENT_INACTIVE, EVENT_LAZYLOAD_ERROR, EVENT_LAZYLOAD_LOADED, EVENT_MOUNTED, EVENT_MOVE, EVENT_MOVED, EVENT_NAVIGATION_MOUNTED, EVENT_OVERFLOW, EVENT_PAGINATION_MOUNTED, EVENT_PAGINATION_UPDATED, EVENT_READY, EVENT_REFRESH, EVENT_RESIZE, EVENT_RESIZED, EVENT_SCROLL, EVENT_SCROLLED, EVENT_SCROLLING, EVENT_SHIFTED, EVENT_SLIDE_KEYDOWN, EVENT_UPDATED, EVENT_VISIBLE, FADE, LOOP, LTR, RTL, SLIDE, STATES, STATUS_CLASSES, STATUS_CLASS_PREFIX, Splide, SplideRenderer, TTB, Splide as default }; diff --git a/dist/js/splide.js b/dist/js/splide.js deleted file mode 100644 index 0d3e03ee..00000000 --- a/dist/js/splide.js +++ /dev/null @@ -1,3154 +0,0 @@ -function _defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } - -function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); Object.defineProperty(Constructor, "prototype", { writable: false }); return Constructor; } - -/*! - * Splide.js - * Version : 4.1.3 - * License : MIT - * Copyright: 2022 Naotoshi Fujita - */ -(function (global, factory) { - typeof exports === 'object' && typeof module !== 'undefined' ? module.exports = factory() : typeof define === 'function' && define.amd ? define(factory) : (global = typeof globalThis !== 'undefined' ? globalThis : global || self, global.Splide = factory()); -})(this, function () { - 'use strict'; - - var MEDIA_PREFERS_REDUCED_MOTION = "(prefers-reduced-motion: reduce)"; - var CREATED = 1; - var MOUNTED = 2; - var IDLE = 3; - var MOVING = 4; - var SCROLLING = 5; - var DRAGGING = 6; - var DESTROYED = 7; - var STATES = { - CREATED: CREATED, - MOUNTED: MOUNTED, - IDLE: IDLE, - MOVING: MOVING, - SCROLLING: SCROLLING, - DRAGGING: DRAGGING, - DESTROYED: DESTROYED - }; - - function empty(array) { - array.length = 0; - } - - function slice(arrayLike, start, end) { - return Array.prototype.slice.call(arrayLike, start, end); - } - - function apply(func) { - return func.bind.apply(func, [null].concat(slice(arguments, 1))); - } - - var nextTick = setTimeout; - - var noop = function noop() {}; - - function raf(func) { - return requestAnimationFrame(func); - } - - function typeOf(type, subject) { - return typeof subject === type; - } - - function isObject(subject) { - return !isNull(subject) && typeOf("object", subject); - } - - var isArray = Array.isArray; - var isFunction = apply(typeOf, "function"); - var isString = apply(typeOf, "string"); - var isUndefined = apply(typeOf, "undefined"); - - function isNull(subject) { - return subject === null; - } - - function isHTMLElement(subject) { - try { - return subject instanceof (subject.ownerDocument.defaultView || window).HTMLElement; - } catch (e) { - return false; - } - } - - function toArray(value) { - return isArray(value) ? value : [value]; - } - - function forEach(values, iteratee) { - toArray(values).forEach(iteratee); - } - - function includes(array, value) { - return array.indexOf(value) > -1; - } - - function push(array, items) { - array.push.apply(array, toArray(items)); - return array; - } - - function toggleClass(elm, classes, add) { - if (elm) { - forEach(classes, function (name) { - if (name) { - elm.classList[add ? "add" : "remove"](name); - } - }); - } - } - - function addClass(elm, classes) { - toggleClass(elm, isString(classes) ? classes.split(" ") : classes, true); - } - - function append(parent, children) { - forEach(children, parent.appendChild.bind(parent)); - } - - function before(nodes, ref) { - forEach(nodes, function (node) { - var parent = (ref || node).parentNode; - - if (parent) { - parent.insertBefore(node, ref); - } - }); - } - - function matches(elm, selector) { - return isHTMLElement(elm) && (elm["msMatchesSelector"] || elm.matches).call(elm, selector); - } - - function children(parent, selector) { - var children2 = parent ? slice(parent.children) : []; - return selector ? children2.filter(function (child) { - return matches(child, selector); - }) : children2; - } - - function child(parent, selector) { - return selector ? children(parent, selector)[0] : parent.firstElementChild; - } - - var ownKeys = Object.keys; - - function forOwn(object, iteratee, right) { - if (object) { - (right ? ownKeys(object).reverse() : ownKeys(object)).forEach(function (key) { - key !== "__proto__" && iteratee(object[key], key); - }); - } - - return object; - } - - function assign(object) { - slice(arguments, 1).forEach(function (source) { - forOwn(source, function (value, key) { - object[key] = source[key]; - }); - }); - return object; - } - - function merge(object) { - slice(arguments, 1).forEach(function (source) { - forOwn(source, function (value, key) { - if (isArray(value)) { - object[key] = value.slice(); - } else if (isObject(value)) { - object[key] = merge({}, isObject(object[key]) ? object[key] : {}, value); - } else { - object[key] = value; - } - }); - }); - return object; - } - - function omit(object, keys) { - forEach(keys || ownKeys(object), function (key) { - delete object[key]; - }); - } - - function removeAttribute(elms, attrs) { - forEach(elms, function (elm) { - forEach(attrs, function (attr) { - elm && elm.removeAttribute(attr); - }); - }); - } - - function setAttribute(elms, attrs, value) { - if (isObject(attrs)) { - forOwn(attrs, function (value2, name) { - setAttribute(elms, name, value2); - }); - } else { - forEach(elms, function (elm) { - isNull(value) || value === "" ? removeAttribute(elm, attrs) : elm.setAttribute(attrs, String(value)); - }); - } - } - - function create(tag, attrs, parent) { - var elm = document.createElement(tag); - - if (attrs) { - isString(attrs) ? addClass(elm, attrs) : setAttribute(elm, attrs); - } - - parent && append(parent, elm); - return elm; - } - - function style(elm, prop, value) { - if (isUndefined(value)) { - return getComputedStyle(elm)[prop]; - } - - if (!isNull(value)) { - elm.style[prop] = "" + value; - } - } - - function display(elm, display2) { - style(elm, "display", display2); - } - - function focus(elm) { - elm["setActive"] && elm["setActive"]() || elm.focus({ - preventScroll: true - }); - } - - function getAttribute(elm, attr) { - return elm.getAttribute(attr); - } - - function hasClass(elm, className) { - return elm && elm.classList.contains(className); - } - - function rect(target) { - return target.getBoundingClientRect(); - } - - function remove(nodes) { - forEach(nodes, function (node) { - if (node && node.parentNode) { - node.parentNode.removeChild(node); - } - }); - } - - function parseHtml(html) { - return child(new DOMParser().parseFromString(html, "text/html").body); - } - - function prevent(e, stopPropagation) { - e.preventDefault(); - - if (stopPropagation) { - e.stopPropagation(); - e.stopImmediatePropagation(); - } - } - - function query(parent, selector) { - return parent && parent.querySelector(selector); - } - - function queryAll(parent, selector) { - return selector ? slice(parent.querySelectorAll(selector)) : []; - } - - function removeClass(elm, classes) { - toggleClass(elm, classes, false); - } - - function timeOf(e) { - return e.timeStamp; - } - - function unit(value) { - return isString(value) ? value : value ? value + "px" : ""; - } - - var PROJECT_CODE = "splide"; - var DATA_ATTRIBUTE = "data-" + PROJECT_CODE; - - function assert(condition, message) { - if (!condition) { - throw new Error("[" + PROJECT_CODE + "] " + (message || "")); - } - } - - var min = Math.min, - max = Math.max, - floor = Math.floor, - ceil = Math.ceil, - abs = Math.abs; - - function approximatelyEqual(x, y, epsilon) { - return abs(x - y) < epsilon; - } - - function between(number, x, y, exclusive) { - var minimum = min(x, y); - var maximum = max(x, y); - return exclusive ? minimum < number && number < maximum : minimum <= number && number <= maximum; - } - - function clamp(number, x, y) { - var minimum = min(x, y); - var maximum = max(x, y); - return min(max(minimum, number), maximum); - } - - function sign(x) { - return +(x > 0) - +(x < 0); - } - - function format(string, replacements) { - forEach(replacements, function (replacement) { - string = string.replace("%s", "" + replacement); - }); - return string; - } - - function pad(number) { - return number < 10 ? "0" + number : "" + number; - } - - var ids = {}; - - function uniqueId(prefix) { - return "" + prefix + pad(ids[prefix] = (ids[prefix] || 0) + 1); - } - - function EventBinder() { - var listeners = []; - - function bind(targets, events, callback, options) { - forEachEvent(targets, events, function (target, event, namespace) { - var isEventTarget = ("addEventListener" in target); - var remover = isEventTarget ? target.removeEventListener.bind(target, event, callback, options) : target["removeListener"].bind(target, callback); - isEventTarget ? target.addEventListener(event, callback, options) : target["addListener"](callback); - listeners.push([target, event, namespace, callback, remover]); - }); - } - - function unbind(targets, events, callback) { - forEachEvent(targets, events, function (target, event, namespace) { - listeners = listeners.filter(function (listener) { - if (listener[0] === target && listener[1] === event && listener[2] === namespace && (!callback || listener[3] === callback)) { - listener[4](); - return false; - } - - return true; - }); - }); - } - - function dispatch(target, type, detail) { - var e; - var bubbles = true; - - if (typeof CustomEvent === "function") { - e = new CustomEvent(type, { - bubbles: bubbles, - detail: detail - }); - } else { - e = document.createEvent("CustomEvent"); - e.initCustomEvent(type, bubbles, false, detail); - } - - target.dispatchEvent(e); - return e; - } - - function forEachEvent(targets, events, iteratee) { - forEach(targets, function (target) { - target && forEach(events, function (events2) { - events2.split(" ").forEach(function (eventNS) { - var fragment = eventNS.split("."); - iteratee(target, fragment[0], fragment[1]); - }); - }); - }); - } - - function destroy() { - listeners.forEach(function (data) { - data[4](); - }); - empty(listeners); - } - - return { - bind: bind, - unbind: unbind, - dispatch: dispatch, - destroy: destroy - }; - } - - var EVENT_MOUNTED = "mounted"; - var EVENT_READY = "ready"; - var EVENT_MOVE = "move"; - var EVENT_MOVED = "moved"; - var EVENT_CLICK = "click"; - var EVENT_ACTIVE = "active"; - var EVENT_INACTIVE = "inactive"; - var EVENT_VISIBLE = "visible"; - var EVENT_HIDDEN = "hidden"; - var EVENT_REFRESH = "refresh"; - var EVENT_UPDATED = "updated"; - var EVENT_RESIZE = "resize"; - var EVENT_RESIZED = "resized"; - var EVENT_DRAG = "drag"; - var EVENT_DRAGGING = "dragging"; - var EVENT_DRAGGED = "dragged"; - var EVENT_SCROLL = "scroll"; - var EVENT_SCROLLED = "scrolled"; - var EVENT_OVERFLOW = "overflow"; - var EVENT_DESTROY = "destroy"; - var EVENT_ARROWS_MOUNTED = "arrows:mounted"; - var EVENT_ARROWS_UPDATED = "arrows:updated"; - var EVENT_PAGINATION_MOUNTED = "pagination:mounted"; - var EVENT_PAGINATION_UPDATED = "pagination:updated"; - var EVENT_NAVIGATION_MOUNTED = "navigation:mounted"; - var EVENT_AUTOPLAY_PLAY = "autoplay:play"; - var EVENT_AUTOPLAY_PLAYING = "autoplay:playing"; - var EVENT_AUTOPLAY_PAUSE = "autoplay:pause"; - var EVENT_LAZYLOAD_LOADED = "lazyload:loaded"; - var EVENT_SLIDE_KEYDOWN = "sk"; - var EVENT_SHIFTED = "sh"; - var EVENT_END_INDEX_CHANGED = "ei"; - - function EventInterface(Splide2) { - var bus = Splide2 ? Splide2.event.bus : document.createDocumentFragment(); - var binder = EventBinder(); - - function on(events, callback) { - binder.bind(bus, toArray(events).join(" "), function (e) { - callback.apply(callback, isArray(e.detail) ? e.detail : []); - }); - } - - function emit(event) { - binder.dispatch(bus, event, slice(arguments, 1)); - } - - if (Splide2) { - Splide2.event.on(EVENT_DESTROY, binder.destroy); - } - - return assign(binder, { - bus: bus, - on: on, - off: apply(binder.unbind, bus), - emit: emit - }); - } - - function RequestInterval(interval, onInterval, onUpdate, limit) { - var now = Date.now; - var startTime; - var rate = 0; - var id; - var paused = true; - var count = 0; - - function update() { - if (!paused) { - rate = interval ? min((now() - startTime) / interval, 1) : 1; - onUpdate && onUpdate(rate); - - if (rate >= 1) { - onInterval(); - startTime = now(); - - if (limit && ++count >= limit) { - return pause(); - } - } - - id = raf(update); - } - } - - function start(resume) { - resume || cancel(); - startTime = now() - (resume ? rate * interval : 0); - paused = false; - id = raf(update); - } - - function pause() { - paused = true; - } - - function rewind() { - startTime = now(); - rate = 0; - - if (onUpdate) { - onUpdate(rate); - } - } - - function cancel() { - id && cancelAnimationFrame(id); - rate = 0; - id = 0; - paused = true; - } - - function set(time) { - interval = time; - } - - function isPaused() { - return paused; - } - - return { - start: start, - rewind: rewind, - pause: pause, - cancel: cancel, - set: set, - isPaused: isPaused - }; - } - - function State(initialState) { - var state = initialState; - - function set(value) { - state = value; - } - - function is(states) { - return includes(toArray(states), state); - } - - return { - set: set, - is: is - }; - } - - function Throttle(func, duration) { - var interval = RequestInterval(duration || 0, func, null, 1); - return function () { - interval.isPaused() && interval.start(); - }; - } - - function Media(Splide2, Components2, options) { - var state = Splide2.state; - var breakpoints = options.breakpoints || {}; - var reducedMotion = options.reducedMotion || {}; - var binder = EventBinder(); - var queries = []; - - function setup() { - var isMin = options.mediaQuery === "min"; - ownKeys(breakpoints).sort(function (n, m) { - return isMin ? +n - +m : +m - +n; - }).forEach(function (key) { - register(breakpoints[key], "(" + (isMin ? "min" : "max") + "-width:" + key + "px)"); - }); - register(reducedMotion, MEDIA_PREFERS_REDUCED_MOTION); - update(); - } - - function destroy(completely) { - if (completely) { - binder.destroy(); - } - } - - function register(options2, query) { - var queryList = matchMedia(query); - binder.bind(queryList, "change", update); - queries.push([options2, queryList]); - } - - function update() { - var destroyed = state.is(DESTROYED); - var direction = options.direction; - var merged = queries.reduce(function (merged2, entry) { - return merge(merged2, entry[1].matches ? entry[0] : {}); - }, {}); - omit(options); - set(merged); - - if (options.destroy) { - Splide2.destroy(options.destroy === "completely"); - } else if (destroyed) { - destroy(true); - Splide2.mount(); - } else { - direction !== options.direction && Splide2.refresh(); - } - } - - function reduce(enable) { - if (matchMedia(MEDIA_PREFERS_REDUCED_MOTION).matches) { - enable ? merge(options, reducedMotion) : omit(options, ownKeys(reducedMotion)); - } - } - - function set(opts, base, notify) { - merge(options, opts); - base && merge(Object.getPrototypeOf(options), opts); - - if (notify || !state.is(CREATED)) { - Splide2.emit(EVENT_UPDATED, options); - } - } - - return { - setup: setup, - destroy: destroy, - reduce: reduce, - set: set - }; - } - - var ARROW = "Arrow"; - var ARROW_LEFT = ARROW + "Left"; - var ARROW_RIGHT = ARROW + "Right"; - var ARROW_UP = ARROW + "Up"; - var ARROW_DOWN = ARROW + "Down"; - var RTL = "rtl"; - var TTB = "ttb"; - var ORIENTATION_MAP = { - width: ["height"], - left: ["top", "right"], - right: ["bottom", "left"], - x: ["y"], - X: ["Y"], - Y: ["X"], - ArrowLeft: [ARROW_UP, ARROW_RIGHT], - ArrowRight: [ARROW_DOWN, ARROW_LEFT] - }; - - function Direction(Splide2, Components2, options) { - function resolve(prop, axisOnly, direction) { - direction = direction || options.direction; - var index = direction === RTL && !axisOnly ? 1 : direction === TTB ? 0 : -1; - return ORIENTATION_MAP[prop] && ORIENTATION_MAP[prop][index] || prop.replace(/width|left|right/i, function (match, offset) { - var replacement = ORIENTATION_MAP[match.toLowerCase()][index] || match; - return offset > 0 ? replacement.charAt(0).toUpperCase() + replacement.slice(1) : replacement; - }); - } - - function orient(value) { - return value * (options.direction === RTL ? 1 : -1); - } - - return { - resolve: resolve, - orient: orient - }; - } - - var ROLE = "role"; - var TAB_INDEX = "tabindex"; - var DISABLED = "disabled"; - var ARIA_PREFIX = "aria-"; - var ARIA_CONTROLS = ARIA_PREFIX + "controls"; - var ARIA_CURRENT = ARIA_PREFIX + "current"; - var ARIA_SELECTED = ARIA_PREFIX + "selected"; - var ARIA_LABEL = ARIA_PREFIX + "label"; - var ARIA_LABELLEDBY = ARIA_PREFIX + "labelledby"; - var ARIA_HIDDEN = ARIA_PREFIX + "hidden"; - var ARIA_ORIENTATION = ARIA_PREFIX + "orientation"; - var ARIA_ROLEDESCRIPTION = ARIA_PREFIX + "roledescription"; - var ARIA_LIVE = ARIA_PREFIX + "live"; - var ARIA_BUSY = ARIA_PREFIX + "busy"; - var ARIA_ATOMIC = ARIA_PREFIX + "atomic"; - var ALL_ATTRIBUTES = [ROLE, TAB_INDEX, DISABLED, ARIA_CONTROLS, ARIA_CURRENT, ARIA_LABEL, ARIA_LABELLEDBY, ARIA_HIDDEN, ARIA_ORIENTATION, ARIA_ROLEDESCRIPTION]; - var CLASS_PREFIX = PROJECT_CODE + "__"; - var STATUS_CLASS_PREFIX = "is-"; - var CLASS_ROOT = PROJECT_CODE; - var CLASS_TRACK = CLASS_PREFIX + "track"; - var CLASS_LIST = CLASS_PREFIX + "list"; - var CLASS_SLIDE = CLASS_PREFIX + "slide"; - var CLASS_CLONE = CLASS_SLIDE + "--clone"; - var CLASS_CONTAINER = CLASS_SLIDE + "__container"; - var CLASS_ARROWS = CLASS_PREFIX + "arrows"; - var CLASS_ARROW = CLASS_PREFIX + "arrow"; - var CLASS_ARROW_PREV = CLASS_ARROW + "--prev"; - var CLASS_ARROW_NEXT = CLASS_ARROW + "--next"; - var CLASS_PAGINATION = CLASS_PREFIX + "pagination"; - var CLASS_PAGINATION_PAGE = CLASS_PAGINATION + "__page"; - var CLASS_PROGRESS = CLASS_PREFIX + "progress"; - var CLASS_PROGRESS_BAR = CLASS_PROGRESS + "__bar"; - var CLASS_TOGGLE = CLASS_PREFIX + "toggle"; - var CLASS_SPINNER = CLASS_PREFIX + "spinner"; - var CLASS_SR = CLASS_PREFIX + "sr"; - var CLASS_INITIALIZED = STATUS_CLASS_PREFIX + "initialized"; - var CLASS_ACTIVE = STATUS_CLASS_PREFIX + "active"; - var CLASS_PREV = STATUS_CLASS_PREFIX + "prev"; - var CLASS_NEXT = STATUS_CLASS_PREFIX + "next"; - var CLASS_VISIBLE = STATUS_CLASS_PREFIX + "visible"; - var CLASS_LOADING = STATUS_CLASS_PREFIX + "loading"; - var CLASS_FOCUS_IN = STATUS_CLASS_PREFIX + "focus-in"; - var CLASS_OVERFLOW = STATUS_CLASS_PREFIX + "overflow"; - var STATUS_CLASSES = [CLASS_ACTIVE, CLASS_VISIBLE, CLASS_PREV, CLASS_NEXT, CLASS_LOADING, CLASS_FOCUS_IN, CLASS_OVERFLOW]; - var CLASSES = { - slide: CLASS_SLIDE, - clone: CLASS_CLONE, - arrows: CLASS_ARROWS, - arrow: CLASS_ARROW, - prev: CLASS_ARROW_PREV, - next: CLASS_ARROW_NEXT, - pagination: CLASS_PAGINATION, - page: CLASS_PAGINATION_PAGE, - spinner: CLASS_SPINNER - }; - - function closest(from, selector) { - if (isFunction(from.closest)) { - return from.closest(selector); - } - - var elm = from; - - while (elm && elm.nodeType === 1) { - if (matches(elm, selector)) { - break; - } - - elm = elm.parentElement; - } - - return elm; - } - - var FRICTION = 5; - var LOG_INTERVAL = 200; - var POINTER_DOWN_EVENTS = "touchstart mousedown"; - var POINTER_MOVE_EVENTS = "touchmove mousemove"; - var POINTER_UP_EVENTS = "touchend touchcancel mouseup click"; - - function Elements(Splide2, Components2, options) { - var _EventInterface = EventInterface(Splide2), - on = _EventInterface.on, - bind = _EventInterface.bind; - - var root = Splide2.root; - var i18n = options.i18n; - var elements = {}; - var slides = []; - var rootClasses = []; - var trackClasses = []; - var track; - var list; - var isUsingKey; - - function setup() { - collect(); - init(); - update(); - } - - function mount() { - on(EVENT_REFRESH, destroy); - on(EVENT_REFRESH, setup); - on(EVENT_UPDATED, update); - bind(document, POINTER_DOWN_EVENTS + " keydown", function (e) { - isUsingKey = e.type === "keydown"; - }, { - capture: true - }); - bind(root, "focusin", function () { - toggleClass(root, CLASS_FOCUS_IN, !!isUsingKey); - }); - } - - function destroy(completely) { - var attrs = ALL_ATTRIBUTES.concat("style"); - empty(slides); - removeClass(root, rootClasses); - removeClass(track, trackClasses); - removeAttribute([track, list], attrs); - removeAttribute(root, completely ? attrs : ["style", ARIA_ROLEDESCRIPTION]); - } - - function update() { - removeClass(root, rootClasses); - removeClass(track, trackClasses); - rootClasses = getClasses(CLASS_ROOT); - trackClasses = getClasses(CLASS_TRACK); - addClass(root, rootClasses); - addClass(track, trackClasses); - setAttribute(root, ARIA_LABEL, options.label); - setAttribute(root, ARIA_LABELLEDBY, options.labelledby); - } - - function collect() { - track = find("." + CLASS_TRACK); - list = child(track, "." + CLASS_LIST); - assert(track && list, "A track/list element is missing."); - push(slides, children(list, "." + CLASS_SLIDE + ":not(." + CLASS_CLONE + ")")); - forOwn({ - arrows: CLASS_ARROWS, - pagination: CLASS_PAGINATION, - prev: CLASS_ARROW_PREV, - next: CLASS_ARROW_NEXT, - bar: CLASS_PROGRESS_BAR, - toggle: CLASS_TOGGLE - }, function (className, key) { - elements[key] = find("." + className); - }); - assign(elements, { - root: root, - track: track, - list: list, - slides: slides - }); - } - - function init() { - var id = root.id || uniqueId(PROJECT_CODE); - var role = options.role; - root.id = id; - track.id = track.id || id + "-track"; - list.id = list.id || id + "-list"; - - if (!getAttribute(root, ROLE) && root.tagName !== "SECTION" && role) { - setAttribute(root, ROLE, role); - } - - setAttribute(root, ARIA_ROLEDESCRIPTION, i18n.carousel); - setAttribute(list, ROLE, "presentation"); - } - - function find(selector) { - var elm = query(root, selector); - return elm && closest(elm, "." + CLASS_ROOT) === root ? elm : void 0; - } - - function getClasses(base) { - return [base + "--" + options.type, base + "--" + options.direction, options.drag && base + "--draggable", options.isNavigation && base + "--nav", base === CLASS_ROOT && CLASS_ACTIVE]; - } - - return assign(elements, { - setup: setup, - mount: mount, - destroy: destroy - }); - } - - var SLIDE = "slide"; - var LOOP = "loop"; - var FADE = "fade"; - - function Slide$1(Splide2, index, slideIndex, slide) { - var event = EventInterface(Splide2); - var on = event.on, - emit = event.emit, - bind = event.bind; - var Components = Splide2.Components, - root = Splide2.root, - options = Splide2.options; - var isNavigation = options.isNavigation, - updateOnMove = options.updateOnMove, - i18n = options.i18n, - pagination = options.pagination, - slideFocus = options.slideFocus; - var resolve = Components.Direction.resolve; - var styles = getAttribute(slide, "style"); - var label = getAttribute(slide, ARIA_LABEL); - var isClone = slideIndex > -1; - var container = child(slide, "." + CLASS_CONTAINER); - var destroyed; - - function mount() { - if (!isClone) { - slide.id = root.id + "-slide" + pad(index + 1); - setAttribute(slide, ROLE, pagination ? "tabpanel" : "group"); - setAttribute(slide, ARIA_ROLEDESCRIPTION, i18n.slide); - setAttribute(slide, ARIA_LABEL, label || format(i18n.slideLabel, [index + 1, Splide2.length])); - } - - listen(); - } - - function listen() { - bind(slide, "click", apply(emit, EVENT_CLICK, self)); - bind(slide, "keydown", apply(emit, EVENT_SLIDE_KEYDOWN, self)); - on([EVENT_MOVED, EVENT_SHIFTED, EVENT_SCROLLED], update); - on(EVENT_NAVIGATION_MOUNTED, initNavigation); - - if (updateOnMove) { - on(EVENT_MOVE, onMove); - } - } - - function destroy() { - destroyed = true; - event.destroy(); - removeClass(slide, STATUS_CLASSES); - removeAttribute(slide, ALL_ATTRIBUTES); - setAttribute(slide, "style", styles); - setAttribute(slide, ARIA_LABEL, label || ""); - } - - function initNavigation() { - var controls = Splide2.splides.map(function (target) { - var Slide2 = target.splide.Components.Slides.getAt(index); - return Slide2 ? Slide2.slide.id : ""; - }).join(" "); - setAttribute(slide, ARIA_LABEL, format(i18n.slideX, (isClone ? slideIndex : index) + 1)); - setAttribute(slide, ARIA_CONTROLS, controls); - setAttribute(slide, ROLE, slideFocus ? "button" : ""); - slideFocus && removeAttribute(slide, ARIA_ROLEDESCRIPTION); - } - - function onMove() { - if (!destroyed) { - update(); - } - } - - function update() { - if (!destroyed) { - var curr = Splide2.index; - updateActivity(); - updateVisibility(); - toggleClass(slide, CLASS_PREV, index === curr - 1); - toggleClass(slide, CLASS_NEXT, index === curr + 1); - } - } - - function updateActivity() { - var active = isActive(); - - if (active !== hasClass(slide, CLASS_ACTIVE)) { - toggleClass(slide, CLASS_ACTIVE, active); - setAttribute(slide, ARIA_CURRENT, isNavigation && active || ""); - emit(active ? EVENT_ACTIVE : EVENT_INACTIVE, self); - } - } - - function updateVisibility() { - var visible = isVisible(); - var hidden = !visible && (!isActive() || isClone); - - if (!Splide2.state.is([MOVING, SCROLLING])) { - setAttribute(slide, ARIA_HIDDEN, hidden || ""); - } - - setAttribute(queryAll(slide, options.focusableNodes || ""), TAB_INDEX, hidden ? -1 : ""); - - if (slideFocus) { - setAttribute(slide, TAB_INDEX, hidden ? -1 : 0); - } - - if (visible !== hasClass(slide, CLASS_VISIBLE)) { - toggleClass(slide, CLASS_VISIBLE, visible); - emit(visible ? EVENT_VISIBLE : EVENT_HIDDEN, self); - } - - if (!visible && document.activeElement === slide) { - var Slide2 = Components.Slides.getAt(Splide2.index); - Slide2 && focus(Slide2.slide); - } - } - - function style$1(prop, value, useContainer) { - style(useContainer && container || slide, prop, value); - } - - function isActive() { - var curr = Splide2.index; - return curr === index || options.cloneStatus && curr === slideIndex; - } - - function isVisible() { - if (Splide2.is(FADE)) { - return isActive(); - } - - var trackRect = rect(Components.Elements.track); - var slideRect = rect(slide); - var left = resolve("left", true); - var right = resolve("right", true); - return floor(trackRect[left]) <= ceil(slideRect[left]) && floor(slideRect[right]) <= ceil(trackRect[right]); - } - - function isWithin(from, distance) { - var diff = abs(from - index); - - if (!isClone && (options.rewind || Splide2.is(LOOP))) { - diff = min(diff, Splide2.length - diff); - } - - return diff <= distance; - } - - var self = { - index: index, - slideIndex: slideIndex, - slide: slide, - container: container, - isClone: isClone, - mount: mount, - destroy: destroy, - update: update, - style: style$1, - isWithin: isWithin - }; - return self; - } - - function Slides(Splide2, Components2, options) { - var _EventInterface2 = EventInterface(Splide2), - on = _EventInterface2.on, - emit = _EventInterface2.emit, - bind = _EventInterface2.bind; - - var _Components2$Elements = Components2.Elements, - slides = _Components2$Elements.slides, - list = _Components2$Elements.list; - var Slides2 = []; - - function mount() { - init(); - on(EVENT_REFRESH, destroy); - on(EVENT_REFRESH, init); - } - - function init() { - slides.forEach(function (slide, index) { - register(slide, index, -1); - }); - } - - function destroy() { - forEach$1(function (Slide2) { - Slide2.destroy(); - }); - empty(Slides2); - } - - function update() { - forEach$1(function (Slide2) { - Slide2.update(); - }); - } - - function register(slide, index, slideIndex) { - var object = Slide$1(Splide2, index, slideIndex, slide); - object.mount(); - Slides2.push(object); - Slides2.sort(function (Slide1, Slide2) { - return Slide1.index - Slide2.index; - }); - } - - function get(excludeClones) { - return excludeClones ? filter(function (Slide2) { - return !Slide2.isClone; - }) : Slides2; - } - - function getIn(page) { - var Controller = Components2.Controller; - var index = Controller.toIndex(page); - var max = Controller.hasFocus() ? 1 : options.perPage; - return filter(function (Slide2) { - return between(Slide2.index, index, index + max - 1); - }); - } - - function getAt(index) { - return filter(index)[0]; - } - - function add(items, index) { - forEach(items, function (slide) { - if (isString(slide)) { - slide = parseHtml(slide); - } - - if (isHTMLElement(slide)) { - var ref = slides[index]; - ref ? before(slide, ref) : append(list, slide); - addClass(slide, options.classes.slide); - observeImages(slide, apply(emit, EVENT_RESIZE)); - } - }); - emit(EVENT_REFRESH); - } - - function remove$1(matcher) { - remove(filter(matcher).map(function (Slide2) { - return Slide2.slide; - })); - emit(EVENT_REFRESH); - } - - function forEach$1(iteratee, excludeClones) { - get(excludeClones).forEach(iteratee); - } - - function filter(matcher) { - return Slides2.filter(isFunction(matcher) ? matcher : function (Slide2) { - return isString(matcher) ? matches(Slide2.slide, matcher) : includes(toArray(matcher), Slide2.index); - }); - } - - function style(prop, value, useContainer) { - forEach$1(function (Slide2) { - Slide2.style(prop, value, useContainer); - }); - } - - function observeImages(elm, callback) { - var images = queryAll(elm, "img"); - var length = images.length; - - if (length) { - images.forEach(function (img) { - bind(img, "load error", function () { - if (! --length) { - callback(); - } - }); - }); - } else { - callback(); - } - } - - function getLength(excludeClones) { - return excludeClones ? slides.length : Slides2.length; - } - - function isEnough() { - return Slides2.length > options.perPage; - } - - return { - mount: mount, - destroy: destroy, - update: update, - register: register, - get: get, - getIn: getIn, - getAt: getAt, - add: add, - remove: remove$1, - forEach: forEach$1, - filter: filter, - style: style, - getLength: getLength, - isEnough: isEnough - }; - } - - function Layout(Splide2, Components2, options) { - var _EventInterface3 = EventInterface(Splide2), - on = _EventInterface3.on, - bind = _EventInterface3.bind, - emit = _EventInterface3.emit; - - var Slides = Components2.Slides; - var resolve = Components2.Direction.resolve; - var _Components2$Elements2 = Components2.Elements, - root = _Components2$Elements2.root, - track = _Components2$Elements2.track, - list = _Components2$Elements2.list; - var getAt = Slides.getAt, - styleSlides = Slides.style; - var vertical; - var rootRect; - var overflow; - - function mount() { - init(); - bind(window, "resize load", Throttle(apply(emit, EVENT_RESIZE))); - on([EVENT_UPDATED, EVENT_REFRESH], init); - on(EVENT_RESIZE, resize); - } - - function init() { - vertical = options.direction === TTB; - style(root, "maxWidth", unit(options.width)); - style(track, resolve("paddingLeft"), cssPadding(false)); - style(track, resolve("paddingRight"), cssPadding(true)); - resize(true); - } - - function resize(force) { - var newRect = rect(root); - - if (force || rootRect.width !== newRect.width || rootRect.height !== newRect.height) { - style(track, "height", cssTrackHeight()); - styleSlides(resolve("marginRight"), unit(options.gap)); - styleSlides("width", cssSlideWidth()); - styleSlides("height", cssSlideHeight(), true); - rootRect = newRect; - emit(EVENT_RESIZED); - - if (overflow !== (overflow = isOverflow())) { - toggleClass(root, CLASS_OVERFLOW, overflow); - emit(EVENT_OVERFLOW, overflow); - } - } - } - - function cssPadding(right) { - var padding = options.padding; - var prop = resolve(right ? "right" : "left"); - return padding && unit(padding[prop] || (isObject(padding) ? 0 : padding)) || "0px"; - } - - function cssTrackHeight() { - var height = ""; - - if (vertical) { - height = cssHeight(); - assert(height, "height or heightRatio is missing."); - height = "calc(" + height + " - " + cssPadding(false) + " - " + cssPadding(true) + ")"; - } - - return height; - } - - function cssHeight() { - return unit(options.height || rect(list).width * options.heightRatio); - } - - function cssSlideWidth() { - return options.autoWidth ? null : unit(options.fixedWidth) || (vertical ? "" : cssSlideSize()); - } - - function cssSlideHeight() { - return unit(options.fixedHeight) || (vertical ? options.autoHeight ? null : cssSlideSize() : cssHeight()); - } - - function cssSlideSize() { - var gap = unit(options.gap); - return "calc((100%" + (gap && " + " + gap) + ")/" + (options.perPage || 1) + (gap && " - " + gap) + ")"; - } - - function listSize() { - return rect(list)[resolve("width")]; - } - - function slideSize(index, withoutGap) { - var Slide = getAt(index || 0); - return Slide ? rect(Slide.slide)[resolve("width")] + (withoutGap ? 0 : getGap()) : 0; - } - - function totalSize(index, withoutGap) { - var Slide = getAt(index); - - if (Slide) { - var right = rect(Slide.slide)[resolve("right")]; - var left = rect(list)[resolve("left")]; - return abs(right - left) + (withoutGap ? 0 : getGap()); - } - - return 0; - } - - function sliderSize(withoutGap) { - return totalSize(Splide2.length - 1) - totalSize(0) + slideSize(0, withoutGap); - } - - function getGap() { - var Slide = getAt(0); - return Slide && parseFloat(style(Slide.slide, resolve("marginRight"))) || 0; - } - - function getPadding(right) { - return parseFloat(style(track, resolve("padding" + (right ? "Right" : "Left")))) || 0; - } - - function isOverflow() { - return Splide2.is(FADE) || sliderSize(true) > listSize(); - } - - return { - mount: mount, - resize: resize, - listSize: listSize, - slideSize: slideSize, - sliderSize: sliderSize, - totalSize: totalSize, - getPadding: getPadding, - isOverflow: isOverflow - }; - } - - var MULTIPLIER = 2; - - function Clones(Splide2, Components2, options) { - var event = EventInterface(Splide2); - var on = event.on; - var Elements = Components2.Elements, - Slides = Components2.Slides; - var resolve = Components2.Direction.resolve; - var clones = []; - var cloneCount; - - function mount() { - on(EVENT_REFRESH, remount); - on([EVENT_UPDATED, EVENT_RESIZE], observe); - - if (cloneCount = computeCloneCount()) { - generate(cloneCount); - Components2.Layout.resize(true); - } - } - - function remount() { - destroy(); - mount(); - } - - function destroy() { - remove(clones); - empty(clones); - event.destroy(); - } - - function observe() { - var count = computeCloneCount(); - - if (cloneCount !== count) { - if (cloneCount < count || !count) { - event.emit(EVENT_REFRESH); - } - } - } - - function generate(count) { - var slides = Slides.get().slice(); - var length = slides.length; - - if (length) { - while (slides.length < count) { - push(slides, slides); - } - - push(slides.slice(-count), slides.slice(0, count)).forEach(function (Slide, index) { - var isHead = index < count; - var clone = cloneDeep(Slide.slide, index); - isHead ? before(clone, slides[0].slide) : append(Elements.list, clone); - push(clones, clone); - Slides.register(clone, index - count + (isHead ? 0 : length), Slide.index); - }); - } - } - - function cloneDeep(elm, index) { - var clone = elm.cloneNode(true); - addClass(clone, options.classes.clone); - clone.id = Splide2.root.id + "-clone" + pad(index + 1); - return clone; - } - - function computeCloneCount() { - var clones2 = options.clones; - - if (!Splide2.is(LOOP)) { - clones2 = 0; - } else if (isUndefined(clones2)) { - var fixedSize = options[resolve("fixedWidth")] && Components2.Layout.slideSize(0); - var fixedCount = fixedSize && ceil(rect(Elements.track)[resolve("width")] / fixedSize); - clones2 = fixedCount || options[resolve("autoWidth")] && Splide2.length || options.perPage * MULTIPLIER; - } - - return clones2; - } - - return { - mount: mount, - destroy: destroy - }; - } - - function Move(Splide2, Components2, options) { - var _EventInterface4 = EventInterface(Splide2), - on = _EventInterface4.on, - emit = _EventInterface4.emit; - - var set = Splide2.state.set; - var _Components2$Layout = Components2.Layout, - slideSize = _Components2$Layout.slideSize, - getPadding = _Components2$Layout.getPadding, - totalSize = _Components2$Layout.totalSize, - listSize = _Components2$Layout.listSize, - sliderSize = _Components2$Layout.sliderSize; - var _Components2$Directio = Components2.Direction, - resolve = _Components2$Directio.resolve, - orient = _Components2$Directio.orient; - var _Components2$Elements3 = Components2.Elements, - list = _Components2$Elements3.list, - track = _Components2$Elements3.track; - var Transition; - - function mount() { - Transition = Components2.Transition; - on([EVENT_MOUNTED, EVENT_RESIZED, EVENT_UPDATED, EVENT_REFRESH], reposition); - } - - function reposition() { - if (!Components2.Controller.isBusy()) { - Components2.Scroll.cancel(); - jump(Splide2.index); - Components2.Slides.update(); - } - } - - function move(dest, index, prev, callback) { - if (dest !== index && canShift(dest > prev)) { - cancel(); - translate(shift(getPosition(), dest > prev), true); - } - - set(MOVING); - emit(EVENT_MOVE, index, prev, dest); - Transition.start(index, function () { - set(IDLE); - emit(EVENT_MOVED, index, prev, dest); - callback && callback(); - }); - } - - function jump(index) { - translate(toPosition(index, true)); - } - - function translate(position, preventLoop) { - if (!Splide2.is(FADE)) { - var destination = preventLoop ? position : loop(position); - style(list, "transform", "translate" + resolve("X") + "(" + destination + "px)"); - position !== destination && emit(EVENT_SHIFTED); - } - } - - function loop(position) { - if (Splide2.is(LOOP)) { - var index = toIndex(position); - var exceededMax = index > Components2.Controller.getEnd(); - var exceededMin = index < 0; - - if (exceededMin || exceededMax) { - position = shift(position, exceededMax); - } - } - - return position; - } - - function shift(position, backwards) { - var excess = position - getLimit(backwards); - var size = sliderSize(); - position -= orient(size * (ceil(abs(excess) / size) || 1)) * (backwards ? 1 : -1); - return position; - } - - function cancel() { - translate(getPosition(), true); - Transition.cancel(); - } - - function toIndex(position) { - var Slides = Components2.Slides.get(); - var index = 0; - var minDistance = Infinity; - - for (var i = 0; i < Slides.length; i++) { - var slideIndex = Slides[i].index; - var distance = abs(toPosition(slideIndex, true) - position); - - if (distance <= minDistance) { - minDistance = distance; - index = slideIndex; - } else { - break; - } - } - - return index; - } - - function toPosition(index, trimming) { - var position = orient(totalSize(index - 1) - offset(index)); - return trimming ? trim(position) : position; - } - - function getPosition() { - var left = resolve("left"); - return rect(list)[left] - rect(track)[left] + orient(getPadding(false)); - } - - function trim(position) { - if (options.trimSpace && Splide2.is(SLIDE)) { - position = clamp(position, 0, orient(sliderSize(true) - listSize())); - } - - return position; - } - - function offset(index) { - var focus = options.focus; - return focus === "center" ? (listSize() - slideSize(index, true)) / 2 : +focus * slideSize(index) || 0; - } - - function getLimit(max) { - return toPosition(max ? Components2.Controller.getEnd() : 0, !!options.trimSpace); - } - - function canShift(backwards) { - var shifted = orient(shift(getPosition(), backwards)); - return backwards ? shifted >= 0 : shifted <= list[resolve("scrollWidth")] - rect(track)[resolve("width")]; - } - - function exceededLimit(max, position) { - position = isUndefined(position) ? getPosition() : position; - var exceededMin = max !== true && orient(position) < orient(getLimit(false)); - var exceededMax = max !== false && orient(position) > orient(getLimit(true)); - return exceededMin || exceededMax; - } - - return { - mount: mount, - move: move, - jump: jump, - translate: translate, - shift: shift, - cancel: cancel, - toIndex: toIndex, - toPosition: toPosition, - getPosition: getPosition, - getLimit: getLimit, - exceededLimit: exceededLimit, - reposition: reposition - }; - } - - function Controller(Splide2, Components2, options) { - var _EventInterface5 = EventInterface(Splide2), - on = _EventInterface5.on, - emit = _EventInterface5.emit; - - var Move = Components2.Move; - var getPosition = Move.getPosition, - getLimit = Move.getLimit, - toPosition = Move.toPosition; - var _Components2$Slides = Components2.Slides, - isEnough = _Components2$Slides.isEnough, - getLength = _Components2$Slides.getLength; - var omitEnd = options.omitEnd; - var isLoop = Splide2.is(LOOP); - var isSlide = Splide2.is(SLIDE); - var getNext = apply(getAdjacent, false); - var getPrev = apply(getAdjacent, true); - var currIndex = options.start || 0; - var endIndex; - var prevIndex = currIndex; - var slideCount; - var perMove; - var perPage; - - function mount() { - init(); - on([EVENT_UPDATED, EVENT_REFRESH, EVENT_END_INDEX_CHANGED], init); - on(EVENT_RESIZED, onResized); - } - - function init() { - slideCount = getLength(true); - perMove = options.perMove; - perPage = options.perPage; - endIndex = getEnd(); - var index = clamp(currIndex, 0, omitEnd ? endIndex : slideCount - 1); - - if (index !== currIndex) { - currIndex = index; - Move.reposition(); - } - } - - function onResized() { - if (endIndex !== getEnd()) { - emit(EVENT_END_INDEX_CHANGED); - } - } - - function go(control, allowSameIndex, callback) { - if (!isBusy()) { - var dest = parse(control); - var index = loop(dest); - - if (index > -1 && (allowSameIndex || index !== currIndex)) { - setIndex(index); - Move.move(dest, index, prevIndex, callback); - } - } - } - - function scroll(destination, duration, snap, callback) { - Components2.Scroll.scroll(destination, duration, snap, function () { - var index = loop(Move.toIndex(getPosition())); - setIndex(omitEnd ? min(index, endIndex) : index); - callback && callback(); - }); - } - - function parse(control) { - var index = currIndex; - - if (isString(control)) { - var _ref = control.match(/([+\-<>])(\d+)?/) || [], - indicator = _ref[1], - number = _ref[2]; - - if (indicator === "+" || indicator === "-") { - index = computeDestIndex(currIndex + +("" + indicator + (+number || 1)), currIndex); - } else if (indicator === ">") { - index = number ? toIndex(+number) : getNext(true); - } else if (indicator === "<") { - index = getPrev(true); - } - } else { - index = isLoop ? control : clamp(control, 0, endIndex); - } - - return index; - } - - function getAdjacent(prev, destination) { - var number = perMove || (hasFocus() ? 1 : perPage); - var dest = computeDestIndex(currIndex + number * (prev ? -1 : 1), currIndex, !(perMove || hasFocus())); - - if (dest === -1 && isSlide) { - if (!approximatelyEqual(getPosition(), getLimit(!prev), 1)) { - return prev ? 0 : endIndex; - } - } - - return destination ? dest : loop(dest); - } - - function computeDestIndex(dest, from, snapPage) { - if (isEnough() || hasFocus()) { - var index = computeMovableDestIndex(dest); - - if (index !== dest) { - from = dest; - dest = index; - snapPage = false; - } - - if (dest < 0 || dest > endIndex) { - if (!perMove && (between(0, dest, from, true) || between(endIndex, from, dest, true))) { - dest = toIndex(toPage(dest)); - } else { - if (isLoop) { - dest = snapPage ? dest < 0 ? -(slideCount % perPage || perPage) : slideCount : dest; - } else if (options.rewind) { - dest = dest < 0 ? endIndex : 0; - } else { - dest = -1; - } - } - } else { - if (snapPage && dest !== from) { - dest = toIndex(toPage(from) + (dest < from ? -1 : 1)); - } - } - } else { - dest = -1; - } - - return dest; - } - - function computeMovableDestIndex(dest) { - if (isSlide && options.trimSpace === "move" && dest !== currIndex) { - var position = getPosition(); - - while (position === toPosition(dest, true) && between(dest, 0, Splide2.length - 1, !options.rewind)) { - dest < currIndex ? --dest : ++dest; - } - } - - return dest; - } - - function loop(index) { - return isLoop ? (index + slideCount) % slideCount || 0 : index; - } - - function getEnd() { - var end = slideCount - (hasFocus() || isLoop && perMove ? 1 : perPage); - - while (omitEnd && end-- > 0) { - if (toPosition(slideCount - 1, true) !== toPosition(end, true)) { - end++; - break; - } - } - - return clamp(end, 0, slideCount - 1); - } - - function toIndex(page) { - return clamp(hasFocus() ? page : perPage * page, 0, endIndex); - } - - function toPage(index) { - return hasFocus() ? min(index, endIndex) : floor((index >= endIndex ? slideCount - 1 : index) / perPage); - } - - function toDest(destination) { - var closest = Move.toIndex(destination); - return isSlide ? clamp(closest, 0, endIndex) : closest; - } - - function setIndex(index) { - if (index !== currIndex) { - prevIndex = currIndex; - currIndex = index; - } - } - - function getIndex(prev) { - return prev ? prevIndex : currIndex; - } - - function hasFocus() { - return !isUndefined(options.focus) || options.isNavigation; - } - - function isBusy() { - return Splide2.state.is([MOVING, SCROLLING]) && !!options.waitForTransition; - } - - return { - mount: mount, - go: go, - scroll: scroll, - getNext: getNext, - getPrev: getPrev, - getAdjacent: getAdjacent, - getEnd: getEnd, - setIndex: setIndex, - getIndex: getIndex, - toIndex: toIndex, - toPage: toPage, - toDest: toDest, - hasFocus: hasFocus, - isBusy: isBusy - }; - } - - var XML_NAME_SPACE = "http://www.w3.org/2000/svg"; - var PATH = "m15.5 0.932-4.3 4.38 14.5 14.6-14.5 14.5 4.3 4.4 14.6-14.6 4.4-4.3-4.4-4.4-14.6-14.6z"; - var SIZE = 40; - - function Arrows(Splide2, Components2, options) { - var event = EventInterface(Splide2); - var on = event.on, - bind = event.bind, - emit = event.emit; - var classes = options.classes, - i18n = options.i18n; - var Elements = Components2.Elements, - Controller = Components2.Controller; - var placeholder = Elements.arrows, - track = Elements.track; - var wrapper = placeholder; - var prev = Elements.prev; - var next = Elements.next; - var created; - var wrapperClasses; - var arrows = {}; - - function mount() { - init(); - on(EVENT_UPDATED, remount); - } - - function remount() { - destroy(); - mount(); - } - - function init() { - var enabled = options.arrows; - - if (enabled && !(prev && next)) { - createArrows(); - } - - if (prev && next) { - assign(arrows, { - prev: prev, - next: next - }); - display(wrapper, enabled ? "" : "none"); - addClass(wrapper, wrapperClasses = CLASS_ARROWS + "--" + options.direction); - - if (enabled) { - listen(); - update(); - setAttribute([prev, next], ARIA_CONTROLS, track.id); - emit(EVENT_ARROWS_MOUNTED, prev, next); - } - } - } - - function destroy() { - event.destroy(); - removeClass(wrapper, wrapperClasses); - - if (created) { - remove(placeholder ? [prev, next] : wrapper); - prev = next = null; - } else { - removeAttribute([prev, next], ALL_ATTRIBUTES); - } - } - - function listen() { - on([EVENT_MOUNTED, EVENT_MOVED, EVENT_REFRESH, EVENT_SCROLLED, EVENT_END_INDEX_CHANGED], update); - bind(next, "click", apply(go, ">")); - bind(prev, "click", apply(go, "<")); - } - - function go(control) { - Controller.go(control, true); - } - - function createArrows() { - wrapper = placeholder || create("div", classes.arrows); - prev = createArrow(true); - next = createArrow(false); - created = true; - append(wrapper, [prev, next]); - !placeholder && before(wrapper, track); - } - - function createArrow(prev2) { - var arrow = " - - - -`; - -export const HTML_PROGRESS = ` -
-
-
-
-`; - -export const HTML_AUTOPLAY = ` - -`; diff --git a/src/js/test/fixtures/index.ts b/src/js/test/fixtures/index.ts deleted file mode 100644 index f7bfdd14..00000000 --- a/src/js/test/fixtures/index.ts +++ /dev/null @@ -1 +0,0 @@ -export * from './html'; diff --git a/src/js/test/html/index.html b/src/js/test/html/index.html deleted file mode 100644 index 6b3bd7ab..00000000 --- a/src/js/test/html/index.html +++ /dev/null @@ -1,63 +0,0 @@ - - - - - - HTML - - - - - - - - -
-
-
    -
  • - -
  • -
  • - -
  • -
  • - -
  • -
  • - -
  • -
  • - -
  • -
  • - -
  • -
  • - -
  • -
  • - -
  • -
  • - -
  • -
  • - -
  • -
-
-
- - - \ No newline at end of file diff --git a/src/js/test/index.ts b/src/js/test/index.ts deleted file mode 100644 index ce08df95..00000000 --- a/src/js/test/index.ts +++ /dev/null @@ -1,2 +0,0 @@ -export * from './fixtures'; -export * from './utils'; diff --git a/src/js/test/jest/setup.ts b/src/js/test/jest/setup.ts deleted file mode 100644 index 1288a5cc..00000000 --- a/src/js/test/jest/setup.ts +++ /dev/null @@ -1,10 +0,0 @@ -window.matchMedia = () => ( { - matches : false, // All queries match the media string. - media : '', - onchange : null, - addListener : jest.fn(), - removeListener : jest.fn(), - addEventListener : jest.fn(), - removeEventListener: jest.fn(), - dispatchEvent : jest.fn(), -} as MediaQueryList ); \ No newline at end of file diff --git a/src/js/test/php/examples/add.php b/src/js/test/php/examples/add.php deleted file mode 100644 index 47670421..00000000 --- a/src/js/test/php/examples/add.php +++ /dev/null @@ -1,51 +0,0 @@ - - - - - - - - Add / Remove - - - - - - - - - - - - - - - - diff --git a/src/js/test/php/examples/autoHeight.php b/src/js/test/php/examples/autoHeight.php deleted file mode 100644 index cec51de7..00000000 --- a/src/js/test/php/examples/autoHeight.php +++ /dev/null @@ -1,67 +0,0 @@ - - - - - - - - Auto Height - - - - - - - - - - - -
-
-
    -
  • - -
  • -
  • - -
  • -
  • - -
  • -
  • - -
  • -
  • - -
  • -
  • - -
  • -
-
-
- - - diff --git a/src/js/test/php/examples/autoWidth.php b/src/js/test/php/examples/autoWidth.php deleted file mode 100644 index 51ce39f6..00000000 --- a/src/js/test/php/examples/autoWidth.php +++ /dev/null @@ -1,99 +0,0 @@ - - - - - - - - Auto Width - - - - - - - - - -
-
-
    -
  • - -
  • -
  • - -
  • -
  • - -
  • -
  • - -
  • -
  • - -
  • -
  • - -
  • -
-
-
- -
-
-
    -
  • - -
  • -
  • - -
  • -
  • - -
  • -
  • - -
  • -
  • - -
  • -
  • - -
  • -
-
-
- - - diff --git a/src/js/test/php/examples/autoplay.php b/src/js/test/php/examples/autoplay.php deleted file mode 100644 index 8d763dec..00000000 --- a/src/js/test/php/examples/autoplay.php +++ /dev/null @@ -1,91 +0,0 @@ - - - - - - - - Autoplay - - - - - - - - - -
-
-
    -
  • - -
  • -
  • - -
  • -
  • - -
  • -
  • - -
  • - -
-
- -
-
-
- - -
- - - diff --git a/src/js/test/php/examples/body.php b/src/js/test/php/examples/body.php deleted file mode 100644 index 68faa0fe..00000000 --- a/src/js/test/php/examples/body.php +++ /dev/null @@ -1,62 +0,0 @@ - - - - - - - - Body - - - - - - - - - -
- - aa -
- - - - - diff --git a/src/js/test/php/examples/breakpoints.php b/src/js/test/php/examples/breakpoints.php deleted file mode 100644 index 9756477d..00000000 --- a/src/js/test/php/examples/breakpoints.php +++ /dev/null @@ -1,89 +0,0 @@ - - - - - - - - Breakpoints - - - - - - - - - - - -
-
-
- -
-
-
- -
-
-
- -
- -
- - -
- -
-
-
- - - diff --git a/src/js/test/php/examples/container.php b/src/js/test/php/examples/container.php deleted file mode 100644 index e25ca05b..00000000 --- a/src/js/test/php/examples/container.php +++ /dev/null @@ -1,109 +0,0 @@ - - - - - - - - Container/Slider - - - - - - - - - -

Container

- -
-
-
    - '; - - echo '
    '; - printf( '', $i + 1 ); - echo '
    '; - - echo '

    '; - if ( $i % 2 ) { - echo 'Lorem ipsum dolor sit amet, ius cu novum splendide contentiones, vim dolorem delicata explicari no. Posidonium sadipscing delicatissimi ad vix, vim at utamur ponderum. Eu doming verear complectitur vim.'; - } else { - echo 'Lorem ipsum dolor sit amet, in usu facilis philosophia, exerci adolescens honestatis ei eum. Et vis nulla simul, pri cu euismod accusam vulputate.'; - } - echo '

    '; - - echo '' . PHP_EOL; - } - ?> -
-
-
- -

Slider

- -
-
-
-
    - '; - printf( '', $i + 1 ); - echo '' . PHP_EOL; - } - ?> -
-
-
- -
-
- -
-
- -
- - - -
-
- - - diff --git a/src/js/test/php/examples/default.php b/src/js/test/php/examples/default.php deleted file mode 100644 index 14556203..00000000 --- a/src/js/test/php/examples/default.php +++ /dev/null @@ -1,118 +0,0 @@ - - - - - - - - Default - - - - - - - - - - - - - - - -

-
-
-
diff --git a/src/js/test/php/examples/drag-free.php b/src/js/test/php/examples/drag-free.php
deleted file mode 100644
index c50a9593..00000000
--- a/src/js/test/php/examples/drag-free.php
+++ /dev/null
@@ -1,47 +0,0 @@
-
-
-
-
-
-  
-  
-  Drag Free
-
-  
-  
-  
-
-  
-
-  
-
-
-
-
-
-
-
diff --git a/src/js/test/php/examples/events.php b/src/js/test/php/examples/events.php
deleted file mode 100644
index 09c25f9c..00000000
--- a/src/js/test/php/examples/events.php
+++ /dev/null
@@ -1,95 +0,0 @@
-
-
-
-
-
-  
-  
-  Events
-
-  
-  
-  
-
-  
-
-
-
-
-
-
    - '; - printf( '', $i + 1 ); - echo '' . PHP_EOL; - } - ?> -
-
-
- -
-
-
    - '; - printf( '', $i + 1 ); - echo '' . PHP_EOL; - } - ?> -
-
-
- - - diff --git a/src/js/test/php/examples/extension.php b/src/js/test/php/examples/extension.php deleted file mode 100644 index e7bca81c..00000000 --- a/src/js/test/php/examples/extension.php +++ /dev/null @@ -1,45 +0,0 @@ - - - - - - - - Extension - - - - - - - - - - - - - diff --git a/src/js/test/php/examples/fade.php b/src/js/test/php/examples/fade.php deleted file mode 100644 index 0a075de3..00000000 --- a/src/js/test/php/examples/fade.php +++ /dev/null @@ -1,85 +0,0 @@ - - - - - - - - Fade - - - - - - - - - - - -
-
-
    -
  • - -

    - Lorem ipsum dolor sit amet, quod sale at pro, everti iisque tractatos sit ea. Agam alterum sit at. Libris petentium his ne, ne eam detraxit inimicus tractatos. Ius mundi verear ad, at percipit constituto pro, ei possim eirmod quo. Vim laudem aperiam reprehendunt in. -

    -
  • -
  • - -

    - Has cu etiam veniam recusabo, his animal nostrud fabellas ne. Vis suas qualisque eu, eum ei impedit civibus, an solum definiebas pro. -

    -
  • -
  • - -

    - Mollis epicuri laboramus ea qui, his ei meis graecis quaestio. Ius ne suscipit prodesset. Qui at delicata euripidis eloquentiam, eius solum volumus eum eu. Usu eu deserunt abhorreant, errem qualisque nec in. Te has labitur virtute hendrerit, cum quaeque oportere mediocritatem in, eos imperdiet intellegam id. -

    -

    - Has cu etiam veniam recusabo, his animal nostrud fabellas ne. Vis suas qualisque eu, eum ei impedit civibus, an solum definiebas pro. -

    -
  • -
-
-
- - - - diff --git a/src/js/test/php/examples/fixedSize.php b/src/js/test/php/examples/fixedSize.php deleted file mode 100644 index 57a67514..00000000 --- a/src/js/test/php/examples/fixedSize.php +++ /dev/null @@ -1,46 +0,0 @@ - - - - - - - - Fixed Size - - - - - - - - - - - - - - diff --git a/src/js/test/php/examples/json.php b/src/js/test/php/examples/json.php deleted file mode 100644 index 606fe9a6..00000000 --- a/src/js/test/php/examples/json.php +++ /dev/null @@ -1,46 +0,0 @@ - - - - - - - - JSON - - - - - - - - - - 'fade', -// 'perPage' => 2, - ]; -?> - -
-
-
- -
-
-
- -

-
-
-
diff --git a/src/js/test/php/examples/lazyLoad.php b/src/js/test/php/examples/lazyLoad.php
deleted file mode 100644
index f48b3ce4..00000000
--- a/src/js/test/php/examples/lazyLoad.php
+++ /dev/null
@@ -1,92 +0,0 @@
-
-
-
-
-
-  
-  
-  Lazy Load
-
-  
-  
-  
-
-  
-
-
-
-

src & placeholder

- -
-
-
    - '; - printf( '', $i + 1 ); - echo '' . PHP_EOL; - } - ?> -
-
-
- -

srcset

- -
-
-
    - '; - printf( - '', - sprintf( 'https://source.unsplash.com/random/640x360?sig=%s 640w', $i + 1 ), - sprintf( 'https://source.unsplash.com/random/960x540?sig=%s 960w', $i + 1 ) - ); - echo '' . PHP_EOL; - } - ?> -
-
-
- - - diff --git a/src/js/test/php/examples/liveRegions.php b/src/js/test/php/examples/liveRegions.php deleted file mode 100644 index e086bcb9..00000000 --- a/src/js/test/php/examples/liveRegions.php +++ /dev/null @@ -1,88 +0,0 @@ - - - - - - - - Live Regions - - - - - - - - - -
-
-
-
    -
  • -
    - -

    Neptune

    -
    -

    - Neptune is the eighth and farthest-known Solar planet from the Sun. -

    - -
    -
    -
  • -
  • -
    - - -

    Saturn

    -
    -

    - Saturn is the sixth planet from the Sun and the second-largest in the Solar System, after Jupiter. -

    - -
    -
    -
  • -
  • -
    - - -

    Mars

    -
    -

    - Mars is the fourth planet from the Sun and the second-smallest planet in the Solar System. -

    - -
    -
    -
  • -
-
-
-
- - - diff --git a/src/js/test/php/examples/multiple.php b/src/js/test/php/examples/multiple.php deleted file mode 100644 index 93c7cc66..00000000 --- a/src/js/test/php/examples/multiple.php +++ /dev/null @@ -1,140 +0,0 @@ - - - - - - - - Multiple - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/src/js/test/php/examples/nest.php b/src/js/test/php/examples/nest.php deleted file mode 100644 index 25487250..00000000 --- a/src/js/test/php/examples/nest.php +++ /dev/null @@ -1,66 +0,0 @@ - - - - - - - - Nest - - - - - - - - - -
-
-
    - - -
    - -
    - -
    - -
    -
-
-
- - - - diff --git a/src/js/test/php/examples/overflow.php b/src/js/test/php/examples/overflow.php deleted file mode 100644 index dd6bf43e..00000000 --- a/src/js/test/php/examples/overflow.php +++ /dev/null @@ -1,154 +0,0 @@ - - - - - - - - Overflow - - - - - - - - - - - - - - - - - - -
-
-
    -
  • - -
  • -
  • - -
  • -
  • - -
  • -
  • - -
  • -
  • - -
  • -
  • - -
  • -
-
-
- - - diff --git a/src/js/test/php/examples/renderer.php b/src/js/test/php/examples/renderer.php deleted file mode 100644 index 539ca625..00000000 --- a/src/js/test/php/examples/renderer.php +++ /dev/null @@ -1,119 +0,0 @@ - - - - - - - - Renderer - - - - - - - - - - -
-The end of the slider - - - diff --git a/src/js/test/php/examples/rtl.php b/src/js/test/php/examples/rtl.php deleted file mode 100644 index 88d38805..00000000 --- a/src/js/test/php/examples/rtl.php +++ /dev/null @@ -1,46 +0,0 @@ - - - - - - - - RTL - - - - - - - - - - - - - -

-
-
-
diff --git a/src/js/test/php/examples/sync.php b/src/js/test/php/examples/sync.php
deleted file mode 100644
index dc941c16..00000000
--- a/src/js/test/php/examples/sync.php
+++ /dev/null
@@ -1,138 +0,0 @@
-
-
-
-
-
-  
-  
-  Sync
-
-  
-  
-  
-
-  
-
-
-
-
-
-
    - '; - printf( 'Alt Slide %1$d%1$02d', $i + 1 ); - echo '' . PHP_EOL; - } - ?> -
-
- -
-
-
    - '; - printf( 'Thumbnail %1$d', $i + 1 ); - echo '' . PHP_EOL; - } - ?> -
-
-
-
- - - - -'; -// printf( 'Thumbnail %1$d', $i + 1 ); -// echo '' . PHP_EOL; -// } -// ?> - - - - -
-
-
    - '; - printf( 'Thumbnail %1$d', $i + 1 ); - echo '' . PHP_EOL; - } - ?> -
-
-
- - - diff --git a/src/js/test/php/examples/ttb.php b/src/js/test/php/examples/ttb.php deleted file mode 100644 index 226f1e8b..00000000 --- a/src/js/test/php/examples/ttb.php +++ /dev/null @@ -1,46 +0,0 @@ - - - - - - - - Vertical Slider - - - - - - - - - - - - - diff --git a/src/js/test/php/parts.php b/src/js/test/php/parts.php deleted file mode 100644 index 69aa1487..00000000 --- a/src/js/test/php/parts.php +++ /dev/null @@ -1,26 +0,0 @@ -', $id ); - echo '
'; - echo '
    '; - - render_slides( $number, $text ); - - echo '
'; - echo '
'; - echo ''; -} - -function render_slides( $number = 10, $text = false ) { - for ( $i = 0; $i < $number; $i++ ) { - echo '
  • '; - - if ( $text ) { - printf( '%s', $i + 1 ); - } else { - printf( '', $i + 1 ); - } - - echo '
  • ' . PHP_EOL; - } -} diff --git a/src/js/test/php/settings.php b/src/js/test/php/settings.php deleted file mode 100644 index 167a4bdd..00000000 --- a/src/js/test/php/settings.php +++ /dev/null @@ -1,6 +0,0 @@ - 'default', - ]; -} diff --git a/src/js/test/utils/utils.ts b/src/js/test/utils/utils.ts deleted file mode 100644 index 1f7502e4..00000000 --- a/src/js/test/utils/utils.ts +++ /dev/null @@ -1,196 +0,0 @@ -import { CLASS_LIST, CLASS_ROOT, CLASS_SLIDE, CLASS_TRACK } from '../../constants/classes'; -import { Splide } from '../../core/Splide/Splide'; -import { Options } from '../../types'; -import { assign } from '../../utils'; -import { buildHtml, BuildHtmlArgs } from '../fixtures'; -import { SLIDER_WIDTH } from '../fixtures/constants'; - - -interface InitArgs extends BuildHtmlArgs { - mount?: boolean; - html?: string; - insertHtml?: boolean; -} - -const DOM_RECT = { - x : 0, - y : 0, - width : 0, - height: 0, - top : 0, - right : 0, - bottom: 0, - left : 0, - toJSON: () => '', -}; - -/** - * Creates a new splide instance. - * - * @param args - Arguments for initialization. - * @param options - Options for Splide. - * - * @return A created Splide instance. - */ -export function init( options: Options = {}, args: InitArgs = {} ): Splide { - const { width = SLIDER_WIDTH, height = 0 } = options; - const { - id, - length = 10, - arrows, - autoplay, - progress, - mount = true, - html, - src, - dataSrc, - dataSrcset, - json, - insertHtml, - dataInterval, - } = args; - - const slideWidth = +width / ( options.perPage || 1 ); - const slideHeight = +height / ( options.perPage || 1 ); - const innerHtml = html - || buildHtml( { length, arrows, autoplay, progress, src, dataSrc, dataSrcset, json, id, dataInterval } ); - - if ( insertHtml ) { - if ( ! document.body.innerHTML ) { - throw new Error( 'Invalid usage.' ); - } - - document.body.insertAdjacentHTML( 'beforeend', innerHtml ); - } else { - document.head.innerHTML = ''; - document.body.innerHTML = innerHtml; - } - - const root = id ? document.getElementById( id ) : document.querySelector( `.${ CLASS_ROOT }` ); - const track = root.querySelector( `.${ CLASS_TRACK }` ); - const list = root.querySelector( `.${ CLASS_LIST }` ); - const slides = root.querySelectorAll( `.${ CLASS_SLIDE }` ); - - root.getBoundingClientRect = (): DOMRect => { - return assign( {}, DOM_RECT, { width: +width } ); - }; - - track.getBoundingClientRect = (): DOMRect => { - return assign( {}, DOM_RECT, { width: +width, right: +width } ); - }; - - list.getBoundingClientRect = (): DOMRect => { - return assign( {}, DOM_RECT, { - width: +width, - ...parseTransform( list ), - } ); - }; - - setSlidesRect( Array.from( slides ), list, slideWidth, slideHeight ); - - const splide = new Splide( root as HTMLElement, options ); - - if ( mount ) { - splide.mount(); - } - - return splide; -} - -/** - * Forcibly sets dimensions of provided slides. - * - * @param slides - An array with slides. - * @param list - A List element. - * @param width - Width of each slide. - * @param height - Height of each slide. - */ -export function setSlidesRect( slides: HTMLElement[], list: HTMLElement, width: number, height: number ): void { - slides.forEach( ( slide, index ) => { - slide.getBoundingClientRect = (): DOMRect => { - const offsets = parseTransform( list ); - - return assign( {}, DOM_RECT, { - width : width, - height: height, - left : width * index + offsets.left, - right : width * index + width + offsets.left, - } ); - }; - } ); -} - -/** - * Converts translate values to position. - * - * @param elm - An element to parse. - * - * @return An object with left and top offsets. - */ -export function parseTransform( elm: HTMLElement ): { left: number, top: number } { - const position = { left: 0, top: 0 }; - - if ( elm && elm.style.transform ) { - const { transform } = elm.style; - - if ( transform.includes( 'translateX' ) ) { - position.left = parseFloat( transform.replace( /translateX\(|\)/g, '' ) ) || 0; - } - - if ( transform.includes( 'translateY' ) ) { - position.top = parseFloat( transform.replace( /translateY\(|\)/g, '' ) ) || 0; - } - } - - return position; -} - -/** - * Fires any native event manually. - * - * @param target - A target. - * @param type - An event type. - * @param data - Optional. Additional data. - * @param eventInitDict - Optional. An EventInit object. - * - * @return An event object. - */ -export function fire( - target: Window | Document | Element, - type: string, - data: any = {}, - eventInitDict: EventInit = {} -): Event { - const e = new Event( type, eventInitDict ); - - if ( data.timeStamp !== undefined ) { - Object.defineProperty( e, 'timeStamp', { value: data.timeStamp } ); - delete data.timeStamp; - } - - target.dispatchEvent( Object.assign( e, data ) ); - return e; -} - -/** - * Emulates keydown. - * - * @param key - A key to press. - * @param target - A target. - */ -export function keydown( key: string, target: Window | Element = window ): void { - fire( target, 'keydown', { key } ); -} - -/** - * Returns a new Promise resolved after the specified duration. - * - * @param duration - Duration to wait. - * - * @return A Promise instance. - */ -export function wait( duration = 0 ): Promise { - return new Promise( resolve => { - setTimeout( resolve, duration ); - } ); -} diff --git a/src/js/transitions/Fade/Fade.ts b/src/js/transitions/Fade/Fade.ts index 08b0fcb1..ec6a22b2 100644 --- a/src/js/transitions/Fade/Fade.ts +++ b/src/js/transitions/Fade/Fade.ts @@ -1,8 +1,6 @@ import { EVENT_MOUNTED, EVENT_REFRESH } from '../../constants/events'; -import { EventInterface } from '../../constructors'; -import { Splide } from '../../core/Splide/Splide'; -import { Components, Options, TransitionComponent } from '../../types'; -import { nextTick, noop } from '../../utils'; +import { ComponentConstructor, TransitionComponent } from '../../types'; +import { nextTick, noop } from '@splidejs/utils'; /** @@ -13,17 +11,18 @@ import { nextTick, noop } from '../../utils'; * @param Splide - A Splide instance. * @param Components - A collection of components. * @param options - Options. + * @param event - An EventInterface instance. * * @return A Transition component object. */ -export function Fade( Splide: Splide, Components: Components, options: Options ): TransitionComponent { - const { Slides } = Components; +export const Fade: ComponentConstructor = (Splide, Components, options, event) => { + const { Slides, Direction } = Components; /** * Called when the component is mounted. */ function mount(): void { - EventInterface( Splide ).on( [ EVENT_MOUNTED, EVENT_REFRESH ], init ); + event.on([EVENT_MOUNTED, EVENT_REFRESH], init); } /** @@ -32,9 +31,9 @@ export function Fade( Splide: Splide, Components: Components, options: Options ) * The `nextTick` disables the initial fade transition of the first slide. */ function init(): void { - Slides.forEach( Slide => { - Slide.style( 'transform', `translateX(-${ 100 * Slide.index }%)` ); - } ); + Slides.forEach(Slide => { + Slide.style('transform', `translateX(${ Direction.orient(100 * Slide.index) }%)`); + }); } /** @@ -43,9 +42,9 @@ export function Fade( Splide: Splide, Components: Components, options: Options ) * @param index - A slide index to be active. * @param done - The callback function that must be called after the transition ends. */ - function start( index: number, done: () => void ): void { - Slides.style( 'transition', `opacity ${ options.speed }ms ${ options.easing }` ); - nextTick( done ); + function start(index: number, done: () => void): void { + Slides.style('transition', `opacity ${ options.speed }ms ${ options.easing }`); + nextTick(done); } return { @@ -53,4 +52,4 @@ export function Fade( Splide: Splide, Components: Components, options: Options ) start, cancel: noop, }; -} +}; diff --git a/src/js/transitions/Slide/Slide.ts b/src/js/transitions/Slide/Slide.ts index 129a1bd0..29b58ee2 100644 --- a/src/js/transitions/Slide/Slide.ts +++ b/src/js/transitions/Slide/Slide.ts @@ -1,8 +1,6 @@ import { SLIDE } from '../../constants/types'; -import { EventInterface } from '../../constructors'; -import { Splide } from '../../core/Splide/Splide'; -import { Components, Options, TransitionComponent } from '../../types'; -import { abs, apply, style } from '../../utils'; +import { ComponentConstructor, TransitionComponent } from '../../types'; +import { abs, apply, style } from '@splidejs/utils'; /** @@ -13,13 +11,14 @@ import { abs, apply, style } from '../../utils'; * @param Splide - A Splide instance. * @param Components - A collection of components. * @param options - Options. + * @param event - An EventInterface instance. * * @return A Transition component object. */ -export function Slide( Splide: Splide, Components: Components, options: Options ): TransitionComponent { +export const Slide: ComponentConstructor = (Splide, Components, options, event) => { const { Move, Controller, Scroll } = Components; const { list } = Components.Elements; - const transition = apply( style, list, 'transition' ); + const transition = apply(style, list, 'transition'); /** * Holds the `done` callback function. @@ -30,12 +29,12 @@ export function Slide( Splide: Splide, Components: Components, options: Options * Called when the component is mounted. */ function mount(): void { - EventInterface( Splide ).bind( list, 'transitionend', e => { - if ( e.target === list && endCallback ) { + event.bind(list, 'transitionend', e => { + if (e.target === list && endCallback) { cancel(); endCallback(); } - } ); + }); } /** @@ -45,21 +44,21 @@ export function Slide( Splide: Splide, Components: Components, options: Options * @param index - A destination index. * @param done - The callback function that must be called after the transition ends. */ - function start( index: number, done: () => void ): void { - const destination = Move.toPosition( index, true ); - const position = Move.getPosition(); - const speed = getSpeed( index ); + function start(index: number, done: () => void): void { + const destination = Move.toPosition(index); + const position = Move.getPosition(); + const speed = getSpeed(index); - if ( abs( destination - position ) >= 1 && speed >= 1 ) { - if ( options.useScroll ) { - Scroll.scroll( destination, speed, false, done ); + if (abs(destination - position) >= 1 && speed >= 1) { + if (options.useScroll) { + Scroll.scroll(destination, speed, false, done); } else { - transition( `transform ${ speed }ms ${ options.easing }` ); - Move.translate( destination, true ); + transition(`transform ${ speed }ms ${ options.easing }`); + Move.translate(destination, true); endCallback = done; } } else { - Move.jump( index ); + Move.jump(index); done(); } } @@ -68,7 +67,7 @@ export function Slide( Splide: Splide, Components: Components, options: Options * Cancels the transition. */ function cancel(): void { - transition( '' ); + transition(''); Scroll.cancel(); } @@ -77,19 +76,19 @@ export function Slide( Splide: Splide, Components: Components, options: Options * * @param index - A destination index. */ - function getSpeed( index: number ): number { + function getSpeed(index: number): number { const { rewindSpeed } = options; - if ( Splide.is( SLIDE ) && rewindSpeed ) { - const prev = Controller.getIndex( true ); - const end = Controller.getEnd(); + if (Splide.is(SLIDE) && rewindSpeed) { + const prev = Controller.getIndex(true); + const end = Controller.getEnd(); - if ( ( prev === 0 && index >= end ) || ( prev >= end && index === 0 ) ) { + if ((prev === 0 && index >= end) || (prev >= end && index === 0)) { return rewindSpeed; } } - return options.speed; + return options.speed || 0; } return { @@ -97,4 +96,4 @@ export function Slide( Splide: Splide, Components: Components, options: Options start, cancel, }; -} +}; diff --git a/src/js/transitions/index.ts b/src/js/transitions/index.ts index da3c97fa..04d57e61 100644 --- a/src/js/transitions/index.ts +++ b/src/js/transitions/index.ts @@ -1,2 +1,2 @@ -export { Fade } from './Fade/Fade'; +export { Fade } from './Fade/Fade'; export { Slide } from './Slide/Slide'; diff --git a/src/js/types/components.ts b/src/js/types/components.ts index 90ca8b09..39f859e0 100644 --- a/src/js/types/components.ts +++ b/src/js/types/components.ts @@ -8,8 +8,8 @@ import { BaseComponent, TransitionComponent } from './general'; * @since 3.0.0 */ export interface Components { - [ key: string ]: BaseComponent | undefined; - Media: Types.MediaComponent; + [key: string]: BaseComponent | undefined; + Breakpoints: Types.BreakpointsComponent; Direction: Types.DirectionComponent; Elements: Types.ElementsComponent; Slides: Types.SlidesComponent; @@ -19,14 +19,12 @@ export interface Components { Controller: Types.ControllerComponent; Arrows: Types.ArrowsComponent; Autoplay: Types.AutoplayComponent; - Cover: Types.CoverComponent; Scroll: Types.ScrollComponent; Drag: Types.DragComponent; Keyboard: Types.KeyboardComponent; LazyLoad: Types.LazyLoadComponent; Pagination: Types.PaginationComponent; Sync: Types.SyncComponent; - Wheel: Types.WheelComponent; Live: Types.LiveComponent; Transition: TransitionComponent; } diff --git a/src/js/types/events.ts b/src/js/types/events.ts index f869cd71..11f0bb44 100644 --- a/src/js/types/events.ts +++ b/src/js/types/events.ts @@ -2,41 +2,58 @@ import { PaginationData, PaginationItem } from '../components/Pagination/Paginat import { SlideComponent } from '../components/Slides/Slide'; import { Splide } from '../core/Splide/Splide'; import { Options } from './options'; +import * as E from '../constants/events'; +import { EventInterface as EventInterfaceInstance } from '@splidejs/utils'; +import { AnyFunction } from './general'; /** - * The interface for all internal events. + * The interface for all internal E. * * @since 3.0.0 */ export interface EventMap { - 'mounted': () => void; - 'ready': () => void; - 'click': ( Slide: SlideComponent, e: MouseEvent ) => void; - 'move': ( index: number, prev: number, dest: number ) => void; - 'moved': ( index: number, prev: number, dest: number ) => void; - 'active': ( Slide: SlideComponent ) => void; - 'inactive': ( Slide: SlideComponent ) => void; - 'visible': ( Slide: SlideComponent ) => void; - 'hidden': ( Slide: SlideComponent ) => void; - 'refresh': () => void; - 'updated': ( options: Options ) => void; - 'resize': () => void; - 'resized': () => void; - 'drag': () => void; - 'dragging': () => void; - 'dragged': () => void; - 'scroll': () => void; - 'scrolled': () => void; - 'overflow': ( overflow: boolean ) => void; - 'destroy': () => void; - 'arrows:mounted': ( prev: HTMLButtonElement, next: HTMLButtonElement ) => void; - 'arrows:updated': ( prev: HTMLButtonElement, next: HTMLButtonElement, prevIndex: number, nextIndex: number ) => void; - 'pagination:mounted': ( data: PaginationData, item: PaginationItem ) => void; - 'pagination:updated': ( data: PaginationData, prev: PaginationItem, curr: PaginationItem ) => void; - 'navigation:mounted': ( splides: Splide[] ) => void; - 'autoplay:play': () => void; - 'autoplay:playing': ( rate: number ) => void; - 'autoplay:pause': () => void; - 'lazyload:loaded': ( img: HTMLImageElement, Slide: SlideComponent ) => void; + [E.EVENT_MOUNTED]: () => void; + [E.EVENT_READY]: () => void; + [E.EVENT_CLICK]: (Slide: SlideComponent, e: MouseEvent) => void; + [E.EVENT_MOVE]: (index: number, prev: number, dest: number) => void; + [E.EVENT_MOVED]: (index: number, prev: number, dest: number) => void; + [E.EVENT_ACTIVE]: (Slide: SlideComponent) => void; + [E.EVENT_INACTIVE]: (Slide: SlideComponent) => void; + [E.EVENT_VISIBLE]: (Slide: SlideComponent) => void; + [E.EVENT_HIDDEN]: (Slide: SlideComponent) => void; + [E.EVENT_REFRESH]: () => void; + [E.EVENT_UPDATED]: (options: Options) => void; + [E.EVENT_RESIZE]: () => void; + [E.EVENT_RESIZED]: () => void; + [E.EVENT_DRAG]: () => void; + [E.EVENT_DRAGGING]: () => void; + [E.EVENT_DRAGGED]: () => void; + [E.EVENT_SCROLL]: () => void; + [E.EVENT_SCROLLING]: () => void; + [E.EVENT_SCROLLED]: () => void; + [E.EVENT_OVERFLOW]: (overflow: boolean) => void; + [E.EVENT_DESTROY]: () => void; + [E.EVENT_ARROWS_MOUNTED]: (prev: HTMLButtonElement, next: HTMLButtonElement) => void; + [E.EVENT_ARROWS_UPDATED]: (prev: HTMLButtonElement, next: HTMLButtonElement, prevIndex: number, nextIndex: number) => void; + [E.EVENT_PAGINATION_MOUNTED]: (data: PaginationData, item: PaginationItem) => void; + [E.EVENT_PAGINATION_UPDATED]: (data: PaginationData, prev: PaginationItem, curr: PaginationItem) => void; + [E.EVENT_NAVIGATION_MOUNTED]: (splides: Splide[]) => void; + [E.EVENT_AUTOPLAY_PLAY]: () => void; + [E.EVENT_AUTOPLAY_PLAYING]: (rate: number) => void; + [E.EVENT_AUTOPLAY_PAUSE]: () => void; + [E.EVENT_LAZYLOAD_LOADED]: (img: HTMLImageElement, Slide: SlideComponent) => void; + [E.EVENT_LAZYLOAD_ERROR]: (img: HTMLImageElement, Slide: SlideComponent) => void; + + /** @internal */ + [E.EVENT_SLIDE_KEYDOWN]: (Slide: SlideComponent, e: KeyboardEvent) => void; + [E.EVENT_SHIFTED]: () => void; + [E.EVENT_END_INDEX_CHANGED]: () => void; } + +/** + * The EventInterface type with Splide `EventMap`. + * + * @since 5.0.0 + */ +export type EventInterface = EventInterfaceInstance>; \ No newline at end of file diff --git a/src/js/types/general.ts b/src/js/types/general.ts index 5a0ebbbb..24d9b6de 100644 --- a/src/js/types/general.ts +++ b/src/js/types/general.ts @@ -1,6 +1,7 @@ import { Splide } from '../core/Splide/Splide'; import { Components } from './components'; import { Options } from './options'; +import { EventInterface } from './events'; /** @@ -8,14 +9,15 @@ import { Options } from './options'; * * @since 3.0.0 */ -export type AnyFunction = ( ...args: any[] ) => any; +export type AnyFunction = (...args: any[]) => any; /** * The type for a component. * * @since 3.0.0 */ -export type ComponentConstructor = ( Splide: Splide, Components: Components, options: Options ) => BaseComponent; +export type ComponentConstructor + = (Splide: Splide, Components: Components, options: Options, event: EventInterface) => R; /** * The interface for any component. @@ -25,7 +27,7 @@ export type ComponentConstructor = ( Splide: Splide, Components: Components, opt export interface BaseComponent { setup?(): void; mount?(): void; - destroy?( completely?: boolean ): void; + destroy?(completely?: boolean): void; } /** @@ -34,7 +36,7 @@ export interface BaseComponent { * @since 3.0.0 */ export interface TransitionComponent extends BaseComponent { - start( index: number, done: () => void ): void; + start(index: number, done: () => void): void; cancel(): void; } diff --git a/src/js/types/options.ts b/src/js/types/options.ts index 03fabaf8..56da397d 100644 --- a/src/js/types/options.ts +++ b/src/js/types/options.ts @@ -103,26 +103,11 @@ export interface Options extends ResponsiveOptions { keyboard?: boolean | 'global' | 'focused'; /** - * Enables navigation by the mouse wheel. - * Set `waitForTransition` to `ture` or provide the `wheelSleep` duration. + * Determines whether to release the touch event when the carousel reaches the first or last slide. + * If `true`, the bounce effect will not play. + * Note that this does not affect mouse drag events. */ - wheel?: boolean; - - /** - * The threshold to cut off the small delta produced by inertia scroll. - */ - wheelMinThreshold?: number; - - /** - * The sleep time in milliseconds until accepting next wheel. - * The timer starts when the transition begins. - */ - wheelSleep?: number; - - /** - * Determines whether to release the wheel event when the slider reaches the first or last slide. - */ - releaseWheel?: boolean; + releaseTouch?: boolean; /** * The direction of the slider. @@ -132,12 +117,6 @@ export interface Options extends ResponsiveOptions { */ direction?: 'ltr' | 'rtl' | 'ttb'; - /** - * Converts the image `src` to the css `background-image` URL of the parent element. - * This requires `fixedHeight` or `heightRatio` option. - */ - cover?: boolean; - /** * Determines whether to add `tabindex="0"` to visible slides or not. */ @@ -239,7 +218,7 @@ export interface ResponsiveOptions { /** * Accepts arbitrary properties for extensions, although it's not ideal typing. */ - [ key: string ]: any; + [key: string]: any; /** * The label for the root element. @@ -356,8 +335,7 @@ export interface ResponsiveOptions { padding?: | number | string - | { left?: number | string, right?: number | string } - | { top?: number | string, bottom?: number | string }; + | { left?: number | string, right?: number | string, top?: number | string, bottom?: number | string } /** * Determines whether to create/find arrows or not. @@ -390,7 +368,7 @@ export interface ResponsiveOptions { * The easing function for the drag free mode. * The default function is the `easeOutQuart` interpolation. */ - easingFunc?: ( t: number ) => number; + easingFunc?: (t: number) => number; /** * Allows to drag the slider by a mouse or swipe. @@ -420,6 +398,19 @@ export interface ResponsiveOptions { */ flickMaxPages?: number; + /** + * Determines whether to release the touch event when the carousel reaches the first or last slide. + * If `true`, the bounce effect will not play. + * Note that this does not affect mouse drag events. + */ + releaseTouch?: boolean; + + /** + * If `drag` is `'free'`, determines whether to activate the closest slide after drag or not. + * The default value is `true`. + */ + updateOnDragged?: boolean; + /** * Destroys the slider. */ diff --git a/src/js/types/utils.ts b/src/js/types/utils.ts index cd8afb21..8ce664f0 100644 --- a/src/js/types/utils.ts +++ b/src/js/types/utils.ts @@ -9,7 +9,7 @@ export type Cast = T extends U ? T : U; * Makes the T easy to read. */ export type Resolve = { - [ K in keyof T ]: T[ K ]; + [K in keyof T]: T[ K ]; } & unknown; /** @@ -17,14 +17,14 @@ export type Resolve = { * * @internal */ -export type Push = [ ...T, U ]; +export type Push = [...T, U]; /** * Returns the first type of the tuple. * * @internal */ -export type Head = ( ( ...args: T ) => any ) extends ( arg: infer A, ...args: any[] ) => any +export type Head = ((...args: T) => any) extends (arg: infer A, ...args: any[]) => any ? A : never; @@ -33,7 +33,7 @@ export type Head = ( ( ...args: T ) => any ) extends ( arg: inf * * @internal */ -export type Shift = ( ( ...args: T ) => any ) extends ( arg: any, ...args: infer A ) => any +export type Shift = ((...args: T) => any) extends (arg: any, ...args: infer A) => any ? A : never; diff --git a/src/js/utils/array/empty/empty.test.ts b/src/js/utils/array/empty/empty.test.ts deleted file mode 100644 index 399ea764..00000000 --- a/src/js/utils/array/empty/empty.test.ts +++ /dev/null @@ -1,12 +0,0 @@ -import { empty } from './empty'; - - -describe( 'empty', () => { - test( 'can empty an array.', () => { - const array = [ 1, 2, 3 ]; - empty( array ); - - expect( array[ 0 ] ).toBeUndefined(); - expect( array.length ).toBe( 0 ); - } ); -} ); diff --git a/src/js/utils/array/empty/empty.ts b/src/js/utils/array/empty/empty.ts deleted file mode 100644 index 1b720592..00000000 --- a/src/js/utils/array/empty/empty.ts +++ /dev/null @@ -1,8 +0,0 @@ -/** - * Empties the array. - * - * @param array - A array to empty. - */ -export function empty( array: any[] ): void { - array.length = 0; -} diff --git a/src/js/utils/array/forEach/forEach.test.ts b/src/js/utils/array/forEach/forEach.test.ts deleted file mode 100644 index 399f4643..00000000 --- a/src/js/utils/array/forEach/forEach.test.ts +++ /dev/null @@ -1,31 +0,0 @@ -import { forEach } from './forEach'; - - -describe( 'forEach', () => { - test( 'can iterate over an array.', () => { - const array = [ 1, 2, 3 ]; - const callback = jest.fn(); - - forEach( array, ( value, index, current ) => { - expect( value ).toBe( array[ index ] ); - expect( current ).toBe( array ); - - callback(); - } ); - - expect( callback ).toHaveBeenCalledTimes( array.length ); - } ); - - test( 'can push the provided value to a new array and iterate over it.', () => { - const callback = jest.fn(); - - forEach( 1, ( value, index, current ) => { - expect( value ).toBe( 1 ); - expect( current ).toEqual( [ 1 ] ); - - callback(); - } ); - - expect( callback ).toHaveBeenCalledTimes( 1 ); - } ); -} ); diff --git a/src/js/utils/array/forEach/forEach.ts b/src/js/utils/array/forEach/forEach.ts deleted file mode 100644 index 2827f484..00000000 --- a/src/js/utils/array/forEach/forEach.ts +++ /dev/null @@ -1,12 +0,0 @@ -import { toArray } from '../toArray/toArray'; - - -/** - * The extended `Array#forEach` method that accepts a single value as an argument. - * - * @param values - A value or values to iterate over. - * @param iteratee - An iteratee function. - */ -export function forEach( values: T | T[], iteratee: ( value: T, index: number, array: T[] ) => void ): void { - toArray( values ).forEach( iteratee ); -} diff --git a/src/js/utils/array/includes/includes.test.ts b/src/js/utils/array/includes/includes.test.ts deleted file mode 100644 index 29c37743..00000000 --- a/src/js/utils/array/includes/includes.test.ts +++ /dev/null @@ -1,16 +0,0 @@ -import { includes } from './includes'; - - -describe( 'includes', () => { - const array = [ 1, 2, 3 ]; - - test( 'can check if the array includes a certain value or not.', () => { - expect( includes( array, 1 ) ).toBe( true ); - expect( includes( array, 2 ) ).toBe( true ); - expect( includes( array, 3 ) ).toBe( true ); - - expect( includes( array, 5 ) ).toBe( false ); - expect( includes( array, 'a' as any ) ).toBe( false ); - expect( includes( array, true as any ) ).toBe( false ); - } ); -} ); diff --git a/src/js/utils/array/includes/includes.ts b/src/js/utils/array/includes/includes.ts deleted file mode 100644 index 34ceb417..00000000 --- a/src/js/utils/array/includes/includes.ts +++ /dev/null @@ -1,12 +0,0 @@ -/** - * Checks if the array includes the value or not. - * `Array#includes` is not supported by IE. - * - * @param array - An array. - * @param value - A value to search for. - * - * @return `true` if the array includes the value, or otherwise `false`. - */ -export function includes( array: T[], value: T ): boolean { - return array.indexOf( value ) > -1; -} diff --git a/src/js/utils/array/index.ts b/src/js/utils/array/index.ts deleted file mode 100644 index ede88237..00000000 --- a/src/js/utils/array/index.ts +++ /dev/null @@ -1,5 +0,0 @@ -export { empty } from './empty/empty'; -export { forEach } from './forEach/forEach'; -export { includes } from './includes/includes'; -export { push } from './push/push'; -export { toArray } from './toArray/toArray'; \ No newline at end of file diff --git a/src/js/utils/array/push/push.test.ts b/src/js/utils/array/push/push.test.ts deleted file mode 100644 index 58ab6d7c..00000000 --- a/src/js/utils/array/push/push.test.ts +++ /dev/null @@ -1,19 +0,0 @@ -import { push } from './push'; - - -describe( 'push', () => { - test( 'can push an item to an array.', () => { - expect( push( [], 1 ) ).toEqual( [ 1 ] ); - expect( push( [ 1 ], 2 ) ).toEqual( [ 1, 2 ] ); - } ); - - test( 'can push items to an array.', () => { - expect( push( [], [ 1, 2, 3 ] ) ).toEqual( [ 1, 2, 3 ] ); - expect( push( [ 1, 2, 3 ], [ 4, 5, 6 ] ) ).toEqual( [ 1, 2, 3, 4, 5, 6 ] ); - } ); - - test( 'should return the provided array itself.', () => { - const array: number[] = []; - expect( push( array, 1 ) ).toBe( array ); - } ); -} ); diff --git a/src/js/utils/array/push/push.ts b/src/js/utils/array/push/push.ts deleted file mode 100644 index 9e40d00f..00000000 --- a/src/js/utils/array/push/push.ts +++ /dev/null @@ -1,15 +0,0 @@ -import { toArray } from '../toArray/toArray'; - - -/** - * Extended `Array#push()` that accepts an item or an array with items. - * - * @param array - An array to push items. - * @param items - An item or items to push. - * - * @return A provided array itself. - */ -export function push( array: T[], items: T | T[] ): T[] { - array.push( ...toArray( items ) ); - return array; -} diff --git a/src/js/utils/array/toArray/toArray.test.ts b/src/js/utils/array/toArray/toArray.test.ts deleted file mode 100644 index d695e4f6..00000000 --- a/src/js/utils/array/toArray/toArray.test.ts +++ /dev/null @@ -1,15 +0,0 @@ -import { toArray } from './toArray'; - - -describe( 'toArray', () => { - test( 'can push a provided value into an array.', () => { - expect( toArray( 1 ) ).toEqual( [ 1 ] ); - expect( toArray( true ) ).toEqual( [ true ] ); - expect( toArray( { a: 1 } ) ).toStrictEqual( [ { a: 1 } ] ); - } ); - - test( 'should return a provided value itself if it is already an array.', () => { - const array = [ 1 ]; - expect( toArray( array ) ).toBe( array ); - } ); -} ); diff --git a/src/js/utils/array/toArray/toArray.ts b/src/js/utils/array/toArray/toArray.ts deleted file mode 100644 index fb51473a..00000000 --- a/src/js/utils/array/toArray/toArray.ts +++ /dev/null @@ -1,13 +0,0 @@ -import { isArray } from '../../type/type'; - - -/** - * Push the provided value to an array if the value is not an array. - * - * @param value - A value to push. - * - * @return An array containing the value, or the value itself if it is already an array. - */ -export function toArray( value: T | T[] ): T[] { - return isArray( value ) ? value : [ value ]; -} diff --git a/src/js/utils/arrayLike/find/find.test.ts b/src/js/utils/arrayLike/find/find.test.ts deleted file mode 100644 index 19ffbded..00000000 --- a/src/js/utils/arrayLike/find/find.test.ts +++ /dev/null @@ -1,18 +0,0 @@ -import { find } from './find'; - - -describe( 'find', () => { - test( 'can find a value in an array-like object that satisfies the predicate function.', () => { - const arrayLike = { length: 3, 0: '1', 1: '2', 2: '3' }; - - expect( find( arrayLike, value => value === '2' ) ).toBe( '2' ); - expect( find( arrayLike, ( value, index ) => index > 1 ) ).toBe( '3' ); - } ); - - test( 'can find a value in an array that satisfies the predicate function.', () => { - const array = [ 1, 2, 3 ]; - - expect( find( array, value => value === 2 ) ).toBe( 2 ); - expect( find( array, ( value, index ) => index > 1 ) ).toBe( 3 ); - } ); -} ); diff --git a/src/js/utils/arrayLike/find/find.ts b/src/js/utils/arrayLike/find/find.ts deleted file mode 100644 index d44510b6..00000000 --- a/src/js/utils/arrayLike/find/find.ts +++ /dev/null @@ -1,18 +0,0 @@ -import { slice } from '../slice/slice'; - - -/** - * The find method for an array or array-like object, works in IE. - * This method is not performant for a huge array. - * - * @param arrayLike - An array-like object. - * @param predicate - The predicate function to test each element in the object. - * - * @return A found value if available, or otherwise `undefined`. - */ -export function find( - arrayLike: ArrayLike, - predicate: ( value: T, index: number, array: T[] ) => any -): T | undefined { - return slice( arrayLike ).filter( predicate )[ 0 ]; -} diff --git a/src/js/utils/arrayLike/index.ts b/src/js/utils/arrayLike/index.ts deleted file mode 100644 index 893ffcf7..00000000 --- a/src/js/utils/arrayLike/index.ts +++ /dev/null @@ -1,2 +0,0 @@ -export { slice } from './slice/slice'; -export { find } from './find/find'; diff --git a/src/js/utils/arrayLike/slice/slice.test.ts b/src/js/utils/arrayLike/slice/slice.test.ts deleted file mode 100644 index 32fcff51..00000000 --- a/src/js/utils/arrayLike/slice/slice.test.ts +++ /dev/null @@ -1,23 +0,0 @@ -import { slice } from './slice'; - - -describe( 'slice', () => { - const arrayLike = { length: 3, 0: '1', 1: '2', 2: '3' }; - - test( 'can slice an array-like object.', () => { - expect( slice( arrayLike ) ).toEqual( [ '1', '2', '3' ] ); - expect( slice( arrayLike, 1 ) ).toEqual( [ '2', '3' ] ); - expect( slice( arrayLike, 1, 2 ) ).toEqual( [ '2' ] ); - } ); - - test( 'can slice a node list.', () => { - const div = document.createElement( 'div' ); - div.innerHTML = `1234`; - - const spans = slice( div.children ); - - expect( spans.length ).toBe( 4 ); - expect( spans[ 0 ] instanceof HTMLSpanElement ).toBe( true ); - expect( spans[ 3 ].textContent ).toBe( '4' ); - } ); -} ); diff --git a/src/js/utils/arrayLike/slice/slice.ts b/src/js/utils/arrayLike/slice/slice.ts deleted file mode 100644 index 2a6e21d8..00000000 --- a/src/js/utils/arrayLike/slice/slice.ts +++ /dev/null @@ -1,12 +0,0 @@ -/** - * The slice method for an array-like object. - * - * @param arrayLike - An array-like object. - * @param start - Optional. A start index. - * @param end - Optional. A end index. - * - * @return An array with sliced elements. - */ -export function slice( arrayLike: ArrayLike, start?: number, end?: number ): T[] { - return Array.prototype.slice.call( arrayLike, start, end ); -} diff --git a/src/js/utils/dom/addClass/addClass.test.ts b/src/js/utils/dom/addClass/addClass.test.ts deleted file mode 100644 index c3747471..00000000 --- a/src/js/utils/dom/addClass/addClass.test.ts +++ /dev/null @@ -1,23 +0,0 @@ -import { addClass } from './addClass'; - - -describe( 'addClass', () => { - beforeEach( () => { - document.body.innerHTML = '
    '; - } ); - - test( 'can add a class to the element.', () => { - const container = document.getElementById( 'container' ); - addClass( container, 'active' ); - expect( container.classList.contains( 'active' ) ).toBe( true ); - } ); - - test( 'can add classes to the element.', () => { - const container = document.getElementById( 'container' ); - - addClass( container, [ 'active', 'visible' ] ); - - expect( container.classList.contains( 'active' ) ).toBe( true ); - expect( container.classList.contains( 'visible' ) ).toBe( true ); - } ); -} ); diff --git a/src/js/utils/dom/addClass/addClass.ts b/src/js/utils/dom/addClass/addClass.ts deleted file mode 100644 index fa0733fd..00000000 --- a/src/js/utils/dom/addClass/addClass.ts +++ /dev/null @@ -1,13 +0,0 @@ -import { isString } from '../../type/type'; -import { toggleClass } from '../toggleClass/toggleClass'; - - -/** - * Adds classes to the element. - * - * @param elm - An element to add classes to. - * @param classes - Classes to add. - */ -export function addClass( elm: Element, classes: string | string[] ): void { - toggleClass( elm, isString( classes ) ? classes.split( ' ' ) : classes, true ); -} diff --git a/src/js/utils/dom/append/append.test.ts b/src/js/utils/dom/append/append.test.ts deleted file mode 100644 index e26541b0..00000000 --- a/src/js/utils/dom/append/append.test.ts +++ /dev/null @@ -1,25 +0,0 @@ -import { append } from './append'; - - -describe( 'append', () => { - test( 'can append a child element to a parent element.', () => { - const div = document.createElement( 'div' ); - const span = document.createElement( 'span' ); - - append( div, span ); - expect( div.firstElementChild ).toBe( span ); - } ); - - test( 'can append children to a parent element.', () => { - const div = document.createElement( 'div' ); - const span1 = document.createElement( 'span' ); - const span2 = document.createElement( 'span' ); - const span3 = document.createElement( 'span' ); - - append( div, [ span1, span2, span3 ] ); - - expect( div.children[ 0 ] ).toBe( span1 ); - expect( div.children[ 1 ] ).toBe( span2 ); - expect( div.children[ 2 ] ).toBe( span3 ); - } ); -} ); diff --git a/src/js/utils/dom/append/append.ts b/src/js/utils/dom/append/append.ts deleted file mode 100644 index 68a61b75..00000000 --- a/src/js/utils/dom/append/append.ts +++ /dev/null @@ -1,12 +0,0 @@ -import { forEach } from '../../array'; - - -/** - * Appends children to the parent element. - * - * @param parent - A parent element. - * @param children - A child or children to append to the parent. - */ -export function append( parent: Element, children: Node | Node[] ): void { - forEach( children, parent.appendChild.bind( parent ) ); -} diff --git a/src/js/utils/dom/before/before.test.ts b/src/js/utils/dom/before/before.test.ts deleted file mode 100644 index 9728fecc..00000000 --- a/src/js/utils/dom/before/before.test.ts +++ /dev/null @@ -1,41 +0,0 @@ -import { before } from './before'; - - -describe( 'before', () => { - beforeEach( () => { - document.body.textContent = ''; - } ); - - test( 'can insert a node before the reference node.', () => { - const ref = document.createElement( 'a' ); - const span1 = document.createElement( 'span' ); - const span2 = document.createElement( 'span' ); - - document.body.appendChild( ref ); - - before( span1, ref ); - expect( document.body.firstChild ).toBe( span1 ); - expect( span1.nextSibling ).toBe( ref ); - - before( span2, ref ); - expect( document.body.firstChild ).toBe( span1 ); - expect( span1.nextSibling ).toBe( span2 ); - expect( span2.nextSibling ).toBe( ref ); - } ); - - test( 'can insert nodes before the reference node.', () => { - const ref = document.createElement( 'a' ); - const span1 = document.createElement( 'span' ); - const span2 = document.createElement( 'span' ); - const span3 = document.createElement( 'span' ); - - document.body.appendChild( ref ); - - before( [ span1, span2, span3 ], ref ); - - expect( document.body.children[ 0 ] ).toBe( span1 ); - expect( document.body.children[ 1 ] ).toBe( span2 ); - expect( document.body.children[ 2 ] ).toBe( span3 ); - expect( document.body.children[ 3 ] ).toBe( ref ); - } ); -} ); diff --git a/src/js/utils/dom/before/before.ts b/src/js/utils/dom/before/before.ts deleted file mode 100644 index ef541dae..00000000 --- a/src/js/utils/dom/before/before.ts +++ /dev/null @@ -1,18 +0,0 @@ -import { forEach } from '../../array'; - - -/** - * Inserts a node or nodes before the specified reference node. - * - * @param nodes - A node or nodes to insert. - * @param ref - A reference node. - */ -export function before( nodes: Node | Node[], ref: Node | null ): void { - forEach( nodes, node => { - const parent = ( ref || node ).parentNode; - - if ( parent ) { - parent.insertBefore( node, ref ); - } - } ); -} diff --git a/src/js/utils/dom/child/child.test.ts b/src/js/utils/dom/child/child.test.ts deleted file mode 100644 index 02e256fb..00000000 --- a/src/js/utils/dom/child/child.test.ts +++ /dev/null @@ -1,41 +0,0 @@ -import { child } from './child'; - - -describe( 'child', () => { - beforeEach( () => { - document.body.innerHTML = ` -
    - - - - - - -
    - `; - } ); - - test( 'can return the child that matches the specified selector.', () => { - const container = document.getElementById( 'container' ); - const span1 = child( container, 'span' ); - expect( span1.id ).toBe( 'span1' ); - - const span2 = child( container, '#span2' ); - expect( span2.id ).toBe( 'span2' ); - - const active = child( container, '.active' ); - expect( active.id ).toBe( 'span1' ); - } ); - - test( 'can return the firstElementChild if the selector is omitted.', () => { - const container = document.getElementById( 'container' ); - const span1 = child( container ); - expect( span1.id ).toBe( 'span1' ); - } ); - - test( 'should rerun undefined if no element is found.', () => { - const container = document.getElementById( 'container' ); - const elm = child( container, 'nothing' ); - expect( elm ).toBeUndefined(); - } ); -} ); diff --git a/src/js/utils/dom/child/child.ts b/src/js/utils/dom/child/child.ts deleted file mode 100644 index 4e5b5115..00000000 --- a/src/js/utils/dom/child/child.ts +++ /dev/null @@ -1,14 +0,0 @@ -import { children } from '../children/children'; - - -/** - * Returns a child element that matches the specified tag or class name. - * - * @param parent - A parent element. - * @param selector - A selector to filter children. - * - * @return A matched child element if available, or otherwise `undefined`. - */ -export function child( parent: HTMLElement, selector?: string ): E | undefined { - return selector ? children( parent, selector )[ 0 ] : parent.firstElementChild as E; -} diff --git a/src/js/utils/dom/children/children.test.ts b/src/js/utils/dom/children/children.test.ts deleted file mode 100644 index 20f82f2e..00000000 --- a/src/js/utils/dom/children/children.test.ts +++ /dev/null @@ -1,42 +0,0 @@ -import { children } from './children'; - - -describe( 'children', () => { - beforeEach( () => { - document.body.innerHTML = ` -
    - - - - - - -
    - `; - } ); - - test( 'can return children that have the specified tag name.', () => { - const container = document.getElementById( 'container' ); - const spans = children( container, 'span' ); - - expect( spans.length ).toBe( 3 ); - expect( spans[ 0 ].id ).toBe( 'span1' ); - expect( spans[ 1 ].id ).toBe( 'span2' ); - expect( spans[ 2 ].id ).toBe( 'span3' ); - } ); - - test( 'can return children that have the specified class name.', () => { - const container = document.getElementById( 'container' ); - const spans = children( container, '.active' ); - - expect( spans.length ).toBe( 2 ); - expect( spans[ 0 ].id ).toBe( 'span1' ); - expect( spans[ 1 ].id ).toBe( 'button1' ); - } ); - - test( 'should rerun an empty array if no element is found.', () => { - const container = document.getElementById( 'container' ); - const elms = children( container, '.nothing' ); - expect( elms.length ).toBe( 0 ); - } ); -} ); diff --git a/src/js/utils/dom/children/children.ts b/src/js/utils/dom/children/children.ts deleted file mode 100644 index d3abeca1..00000000 --- a/src/js/utils/dom/children/children.ts +++ /dev/null @@ -1,16 +0,0 @@ -import { slice } from '../../arrayLike'; -import { matches } from '../matches/matches'; - - -/** - * Finds children that has the specified tag or class name. - * - * @param parent - A parent element. - * @param selector - Optional. A selector to filter children. - * - * @return An array with filtered children. - */ -export function children( parent: HTMLElement, selector?: string ): E[] { - const children = parent ? slice( parent.children ) as E[] : []; - return selector ? children.filter( child => matches( child, selector ) ) : children; -} diff --git a/src/js/utils/dom/closest/closest.test.ts b/src/js/utils/dom/closest/closest.test.ts deleted file mode 100644 index ca31b7df..00000000 --- a/src/js/utils/dom/closest/closest.test.ts +++ /dev/null @@ -1,54 +0,0 @@ -import { closest } from './closest'; - - -describe.each( [ [ 'native' ], [ 'polyfill' ] ] )( 'closest (%s)', ( env ) => { - if ( env === 'polyfill' ) { - // Forces to disable the native method. - Element.prototype.closest = null as any; - } - - beforeEach( () => { - document.body.innerHTML = ` -
    -
    -
    - start -
    -
    -
    - `; - } ); - - test( 'can find the closest element.', () => { - const from = document.getElementById( 'start' ); - - if ( from ) { - expect( closest( from, '#inner' )?.id ).toBe( 'inner' ); - expect( closest( from, '#outer' )?.id ).toBe( 'outer' ); - expect( closest( from, 'div' )?.id ).toBe( 'inner' ); - expect( closest( from, '.wrapper' )?.id ).toBe( 'outer' ); - } else { - fail(); - } - } ); - - test( 'should include the provided element itself.', () => { - const from = document.getElementById( 'start' ); - - if ( from ) { - expect( closest( from, 'span' )?.id ).toBe( 'start' ); - } else { - fail(); - } - } ); - - test( 'should return null if no element is found.', () => { - const from = document.getElementById( 'start' ); - - if ( from ) { - expect( closest( from, 'invalid' ) ).toBeNull(); - } else { - fail(); - } - } ); -} ); diff --git a/src/js/utils/dom/closest/closest.ts b/src/js/utils/dom/closest/closest.ts deleted file mode 100644 index 9f56158e..00000000 --- a/src/js/utils/dom/closest/closest.ts +++ /dev/null @@ -1,29 +0,0 @@ -import { isFunction } from '../../type/type'; -import { matches } from '../matches/matches'; - - -/** - * Starts from the provided element, searches for the first element that matches the selector in ascendants. - * - * @param from - An element to search from. - * @param selector - A selector. - * - * @return The found element if available, or `null`. - */ -export function closest( from: HTMLElement, selector: string ): HTMLElement | null { - if ( isFunction( from.closest ) ) { - return from.closest( selector ); - } - - let elm: HTMLElement | null = from; - - while ( elm && elm.nodeType === 1 ) { - if ( matches( elm, selector ) ) { - break; - } - - elm = elm.parentElement; - } - - return elm; -} \ No newline at end of file diff --git a/src/js/utils/dom/create/create.test.ts b/src/js/utils/dom/create/create.test.ts deleted file mode 100644 index 6567f6a4..00000000 --- a/src/js/utils/dom/create/create.test.ts +++ /dev/null @@ -1,19 +0,0 @@ -import { create } from './create'; - - -describe( 'create', () => { - test( 'can create an element by a tag name.', () => { - const div = create( 'div' ); - const iframe = create( 'iframe' ); - - expect( div instanceof HTMLDivElement ).toBe( true ); - expect( iframe instanceof HTMLIFrameElement ).toBe( true ); - } ); - - test( 'can create an element with setting attributes.', () => { - const iframe = create( 'iframe', { width: 100, height: 200 } ); - - expect( iframe.getAttribute( 'width' ) ).toBe( '100' ); - expect( iframe.getAttribute( 'height' ) ).toBe( '200' ); - } ); -} ); diff --git a/src/js/utils/dom/create/create.ts b/src/js/utils/dom/create/create.ts deleted file mode 100644 index 5a73df54..00000000 --- a/src/js/utils/dom/create/create.ts +++ /dev/null @@ -1,40 +0,0 @@ -import { isString } from '../../type/type'; -import { addClass } from '../addClass/addClass'; -import { append } from '../append/append'; -import { setAttribute } from '../setAttribute/setAttribute'; - - -export function create( - tag: K, - attrs?: Record | string, - parent?: HTMLElement -): HTMLElementTagNameMap[ K ]; - -export function create( - tag: string, - attrs?: Record | string, - parent?: HTMLElement -): HTMLElement; - -/** - * Creates a HTML element. - * - * @param tag - A tag name. - * @param attrs - Optional. An object with attributes to apply the created element to, or a string with classes. - * @param parent - Optional. A parent element where the created element is appended. - */ -export function create( - tag: K, - attrs?: Record | string, - parent?: HTMLElement -): HTMLElementTagNameMap[ K ] { - const elm = document.createElement( tag ); - - if ( attrs ) { - isString( attrs ) ? addClass( elm, attrs ) : setAttribute( elm, attrs ); - } - - parent && append( parent, elm ); - - return elm; -} diff --git a/src/js/utils/dom/display/display.test.ts b/src/js/utils/dom/display/display.test.ts deleted file mode 100644 index f83ca8cb..00000000 --- a/src/js/utils/dom/display/display.test.ts +++ /dev/null @@ -1,17 +0,0 @@ -import { display } from './display'; - - -describe( 'display', () => { - test( 'can set a new display value.', () => { - const div = document.createElement( 'div' ); - - display( div, 'none' ); - expect( div.style.display ).toBe( 'none' ); - - display( div, 'flex' ); - expect( div.style.display ).toBe( 'flex' ); - - display( div, '' ); - expect( div.style.display ).toBe( '' ); - } ); -} ); diff --git a/src/js/utils/dom/display/display.ts b/src/js/utils/dom/display/display.ts deleted file mode 100644 index b13b96b2..00000000 --- a/src/js/utils/dom/display/display.ts +++ /dev/null @@ -1,12 +0,0 @@ -import { style } from '../style/style'; - - -/** - * Sets the `display` CSS value to the element. - * - * @param elm - An element to set a new value to. - * @param display - A new `display` value. - */ -export function display( elm: HTMLElement, display: string ): void { - style( elm, 'display', display ); -} diff --git a/src/js/utils/dom/focus/focus.test.ts b/src/js/utils/dom/focus/focus.test.ts deleted file mode 100644 index 6cd97c30..00000000 --- a/src/js/utils/dom/focus/focus.test.ts +++ /dev/null @@ -1,17 +0,0 @@ -import { focus } from './focus'; - - -describe( 'focus', () => { - test( 'can make an element focused if it is focusable.', () => { - const div = document.createElement( 'div' ); - - div.tabIndex = 0; - document.body.appendChild( div ); - - expect( document.activeElement ).not.toBe( div ); - - focus( div ); - - expect( document.activeElement ).toBe( div ); - } ); -} ); diff --git a/src/js/utils/dom/focus/focus.ts b/src/js/utils/dom/focus/focus.ts deleted file mode 100644 index 7266a99e..00000000 --- a/src/js/utils/dom/focus/focus.ts +++ /dev/null @@ -1,8 +0,0 @@ -/** - * Focuses the provided element without scrolling the ascendant element. - * - * @param elm - An element to focus. - */ -export function focus( elm: HTMLElement ): void { - elm[ 'setActive' ] && elm[ 'setActive' ]() || elm.focus( { preventScroll: true } ); -} diff --git a/src/js/utils/dom/getAttribute/getAttribute.test.ts b/src/js/utils/dom/getAttribute/getAttribute.test.ts deleted file mode 100644 index d8b8cef4..00000000 --- a/src/js/utils/dom/getAttribute/getAttribute.test.ts +++ /dev/null @@ -1,19 +0,0 @@ -import { getAttribute } from './getAttribute'; - - -describe( 'getAttribute', () => { - beforeEach( () => { - document.body.innerHTML = '
    '; - } ); - - test( 'can set an attribute to an element.', () => { - const container = document.getElementById( 'container' ); - - container.setAttribute( 'aria-hidden', 'true' ); - container.setAttribute( 'tabindex', '-1' ); - - expect( getAttribute( container, 'id' ) ).toBe( 'container' ); - expect( getAttribute( container, 'aria-hidden' ) ).toBe( 'true' ); - expect( getAttribute( container, 'tabindex' ) ).toBe( '-1' ); - } ); -} ); diff --git a/src/js/utils/dom/getAttribute/getAttribute.ts b/src/js/utils/dom/getAttribute/getAttribute.ts deleted file mode 100644 index bec8f06a..00000000 --- a/src/js/utils/dom/getAttribute/getAttribute.ts +++ /dev/null @@ -1,9 +0,0 @@ -/** - * Returns the specified attribute value. - * - * @param elm - An element. - * @param attr - An attribute to get. - */ -export function getAttribute( elm: Element, attr: string ): string | null { - return elm.getAttribute( attr ); -} diff --git a/src/js/utils/dom/hasClass/hasClass.test.ts b/src/js/utils/dom/hasClass/hasClass.test.ts deleted file mode 100644 index ebb273da..00000000 --- a/src/js/utils/dom/hasClass/hasClass.test.ts +++ /dev/null @@ -1,20 +0,0 @@ -import { hasClass } from './hasClass'; - - -describe( 'hasClass', () => { - test( 'can return true if the element contains the specified class.', () => { - const container = document.createElement( 'div' ); - container.classList.add( 'active' ); - container.classList.add( 'visible' ); - - expect( hasClass( container, 'active' ) ).toBe( true ); - expect( hasClass( container, 'visible' ) ).toBe( true ); - } ); - - test( 'can return false if the element does not contain the specified class.', () => { - const container = document.createElement( 'div' ); - - expect( hasClass( container, 'active' ) ).toBe( false ); - expect( hasClass( container, 'visible' ) ).toBe( false ); - } ); -} ); diff --git a/src/js/utils/dom/hasClass/hasClass.ts b/src/js/utils/dom/hasClass/hasClass.ts deleted file mode 100644 index 0d8a3779..00000000 --- a/src/js/utils/dom/hasClass/hasClass.ts +++ /dev/null @@ -1,11 +0,0 @@ -/** - * Checks if the element contains the specified class or not. - * - * @param elm - An element to check. - * @param className - A class name that may be contained by the element. - * - * @return `true` if the element contains the class, or otherwise `false`. - */ -export function hasClass( elm: Element, className: string ): boolean { - return elm && elm.classList.contains( className ); -} diff --git a/src/js/utils/dom/index.ts b/src/js/utils/dom/index.ts deleted file mode 100644 index ca8d19dd..00000000 --- a/src/js/utils/dom/index.ts +++ /dev/null @@ -1,25 +0,0 @@ -export { addClass } from './addClass/addClass'; -export { append } from './append/append'; -export { before } from './before/before'; -export { child } from './child/child'; -export { children } from './children/children'; -export { create } from './create/create'; -export { display } from './display/display'; -export { focus } from './focus/focus'; -export { getAttribute } from './getAttribute/getAttribute'; -export { hasClass } from './hasClass/hasClass'; -export { matches } from './matches/matches'; -export { measure } from './measure/measure'; -export { parseHtml } from './parseHtml/parseHtml'; -export { prevent } from './prevent/prevent'; -export { query } from './query/query'; -export { queryAll } from './queryAll/queryAll'; -export { rect } from './rect/rect'; -export { remove } from './remove/remove'; -export { removeAttribute } from './removeAttribute/removeAttribute'; -export { removeClass } from './removeClass/removeClass'; -export { setAttribute } from './setAttribute/setAttribute'; -export { style } from './style/style'; -export { timeOf } from './timeOf/timeOf'; -export { toggleClass } from './toggleClass/toggleClass'; -export { unit } from './unit/unit'; diff --git a/src/js/utils/dom/matches/matches.test.ts b/src/js/utils/dom/matches/matches.test.ts deleted file mode 100644 index f193fd80..00000000 --- a/src/js/utils/dom/matches/matches.test.ts +++ /dev/null @@ -1,35 +0,0 @@ -import { matches } from './matches'; - - -describe( 'children', () => { - beforeEach( () => { - document.body.innerHTML = ` -
    - - - - - - -
    - `; - } ); - - test( 'can test if the selector matches the element or not.', () => { - const container = document.getElementById( 'container' ); - - expect( matches( container, 'div' ) ).toBe( true ); - expect( matches( container, '#container' ) ).toBe( true ); - expect( matches( container, 'span' ) ).toBe( false ); - - const span = container.firstElementChild; - - expect( matches( span, 'span' ) ).toBe( true ); - expect( matches( span, '#span1' ) ).toBe( true ); - expect( matches( span, '.active' ) ).toBe( true ); - expect( matches( span, '#container .active' ) ).toBe( true ); - - expect( matches( span, '#container' ) ).toBe( false ); - expect( matches( span, '#span2' ) ).toBe( false ); - } ); -} ); diff --git a/src/js/utils/dom/matches/matches.ts b/src/js/utils/dom/matches/matches.ts deleted file mode 100644 index f822257a..00000000 --- a/src/js/utils/dom/matches/matches.ts +++ /dev/null @@ -1,14 +0,0 @@ -import { isHTMLElement } from '../../type/type'; - - -/** - * Checks if the element can be selected by the provided selector or not. - * - * @param elm - An element to check. - * @param selector - A selector to test. - * - * @return `true` if the selector matches the element, or otherwise `false`. - */ -export function matches( elm: Element | EventTarget, selector: string ): boolean { - return isHTMLElement( elm ) && ( elm[ 'msMatchesSelector' ] || elm.matches ).call( elm, selector ); -} diff --git a/src/js/utils/dom/measure/measure.ts b/src/js/utils/dom/measure/measure.ts deleted file mode 100644 index a14e6188..00000000 --- a/src/js/utils/dom/measure/measure.ts +++ /dev/null @@ -1,23 +0,0 @@ -import { isString } from '../../type/type'; -import { create } from '../create/create'; -import { rect } from '../rect/rect'; -import { remove } from '../remove/remove'; - - -/** - * Attempts to convert the provided value to pixel as the relative value to the parent element. - * - * @param parent - A parent element. - * @param value - A value to convert. - * - * @return A converted value in pixel. Unhandled values will become 0. - */ -export function measure( parent: HTMLElement, value: number | string ): number { - if ( isString( value ) ) { - const div = create( 'div', { style: `width: ${ value }; position: absolute;` }, parent ); - value = rect( div ).width; - remove( div ); - } - - return value; -} diff --git a/src/js/utils/dom/normalizeKey/normalizeKey.test.ts b/src/js/utils/dom/normalizeKey/normalizeKey.test.ts deleted file mode 100644 index 885180e7..00000000 --- a/src/js/utils/dom/normalizeKey/normalizeKey.test.ts +++ /dev/null @@ -1,31 +0,0 @@ -import { fire } from '../../../test'; -import { NORMALIZATION_MAP, normalizeKey } from './normalizeKey'; - - -describe( 'normalizeKey', () => { - test( 'can normalize a key into a standard name.', () => { - const keys = Object.keys( NORMALIZATION_MAP ); - const callback = jest.fn(); - - keys.forEach( key => { - expect( normalizeKey( key ) ).toBe( NORMALIZATION_MAP[ key ] ); - callback(); - } ); - - expect( callback ).toHaveBeenCalled(); - } ); - - test( 'can return a normalized key from a Keyboard event object.', done => { - window.addEventListener( 'keydown', e => { - expect( normalizeKey( e ) ).toBe( 'ArrowUp' ); - done(); - } ); - - fire( window, 'keydown', { key: 'Up' } ); - } ); - - test( 'should do the provided key as is if the normalization map does not include the passed key.', () => { - expect( normalizeKey( 'a' ) ).toBe( 'a' ); - expect( normalizeKey( 'F1' ) ).toBe( 'F1' ); - } ); -} ); \ No newline at end of file diff --git a/src/js/utils/dom/normalizeKey/normalizeKey.ts b/src/js/utils/dom/normalizeKey/normalizeKey.ts deleted file mode 100644 index 6dc703b9..00000000 --- a/src/js/utils/dom/normalizeKey/normalizeKey.ts +++ /dev/null @@ -1,28 +0,0 @@ -import { ARROW_DOWN, ARROW_LEFT, ARROW_RIGHT, ARROW_UP } from '../../../constants/arrows'; -import { isString } from '../../type/type'; - - -/** - * The map to associate a non-standard name to the standard one. - * - * @since 4.0.0 - */ -export const NORMALIZATION_MAP = { - Spacebar: ' ', - Right : ARROW_RIGHT, - Left : ARROW_LEFT, - Up : ARROW_UP, - Down : ARROW_DOWN, -}; - -/** - * Normalizes the key. - * - * @param key - A string or a KeyboardEvent object. - * - * @return A normalized key. - */ -export function normalizeKey( key: string | KeyboardEvent ): string { - key = isString( key ) ? key : key.key; - return NORMALIZATION_MAP[ key ] || key; -} \ No newline at end of file diff --git a/src/js/utils/dom/parseHtml/parseHtml.test.ts b/src/js/utils/dom/parseHtml/parseHtml.test.ts deleted file mode 100644 index ebc45889..00000000 --- a/src/js/utils/dom/parseHtml/parseHtml.test.ts +++ /dev/null @@ -1,21 +0,0 @@ -import { parseHtml } from './parseHtml'; - - -describe( 'parseHtml', () => { - test( 'can parse the provided HTML string.', () => { - const div = parseHtml( '
    content
    ' ); - - expect( div.id ).toBe( 'container' ); - expect( div.classList.contains( 'active' ) ).toBe( true ); - expect( div.firstElementChild.tagName.toUpperCase() ).toBe( 'SPAN' ); - expect( div.firstElementChild.textContent ).toBe( 'content' ); - } ); - - test( 'can parse the provided SVG string.', () => { - const svg = parseHtml( '' ); - - expect( svg instanceof SVGElement ).toBe( true ); - expect( svg.id ).toBe( 'icon' ); - expect( svg.firstElementChild.tagName.toUpperCase() ).toBe( 'PATH' ); - } ); -} ); diff --git a/src/js/utils/dom/parseHtml/parseHtml.ts b/src/js/utils/dom/parseHtml/parseHtml.ts deleted file mode 100644 index 21ebd594..00000000 --- a/src/js/utils/dom/parseHtml/parseHtml.ts +++ /dev/null @@ -1,13 +0,0 @@ -import { child } from '../child/child'; - - -/** - * Parses the provided HTML string and returns the first element. - * - * @param html - An HTML string to parse. - * - * @return An Element on success, or otherwise `undefined`. - */ -export function parseHtml( html: string ): E | undefined { - return child( new DOMParser().parseFromString( html, 'text/html' ).body ); -} diff --git a/src/js/utils/dom/prevent/prevent.test.ts b/src/js/utils/dom/prevent/prevent.test.ts deleted file mode 100644 index 1d76ed77..00000000 --- a/src/js/utils/dom/prevent/prevent.test.ts +++ /dev/null @@ -1,15 +0,0 @@ -import { fire } from '../../../test'; -import { prevent } from './prevent'; - - -describe( 'prevent', () => { - test( 'can prevent the default browser action of an event.', done => { - window.addEventListener( 'click', e => { - prevent( e ); - expect( e.defaultPrevented ).toBe( true ); - done(); - } ); - - fire( window, 'click', { timeStamp: 123 }, { cancelable: true } ); - } ); -} ); \ No newline at end of file diff --git a/src/js/utils/dom/prevent/prevent.ts b/src/js/utils/dom/prevent/prevent.ts deleted file mode 100644 index d65c31d9..00000000 --- a/src/js/utils/dom/prevent/prevent.ts +++ /dev/null @@ -1,14 +0,0 @@ -/** - * Call the `preventDefault()` of the provided event. - * - * @param e - An Event object. - * @param stopPropagation - Optional. Whether to stop the event propagation or not. - */ -export function prevent( e: Event, stopPropagation?: boolean ): void { - e.preventDefault(); - - if ( stopPropagation ) { - e.stopPropagation(); - e.stopImmediatePropagation(); - } -} diff --git a/src/js/utils/dom/query/query.test.ts b/src/js/utils/dom/query/query.test.ts deleted file mode 100644 index b991246b..00000000 --- a/src/js/utils/dom/query/query.test.ts +++ /dev/null @@ -1,37 +0,0 @@ -import { query } from './query'; - - -describe( 'query', () => { - beforeEach( () => { - document.body.innerHTML = ` -
    - 1 -
    -
    - 2 -
    -
    - 3 -
    - `; - } ); - - test( 'can return the first element that matches the specified selector.', () => { - const div1 = query( document, 'div' ); - expect( div1.id ).toBe( 'div1' ); - - const div3 = query( document, '#div3' ); - expect( div3.id ).toBe( 'div3' ); - } ); - - test( 'can accept a parent element to start find an element from.', () => { - const div2 = query( document, '#div2' ); - const span2 = query( div2, 'span' ); - - expect( span2.textContent ).toBe( '2' ); - } ); - - test( 'should return `null` if nothing matches the selector.', () => { - expect( query( document, '#nothing' ) ).toBeNull(); - } ); -} ); diff --git a/src/js/utils/dom/query/query.ts b/src/js/utils/dom/query/query.ts deleted file mode 100644 index ab42c4ce..00000000 --- a/src/js/utils/dom/query/query.ts +++ /dev/null @@ -1,11 +0,0 @@ -/** - * Returns an element that matches the provided selector. - * - * @param parent - A parent element to start searching from. - * @param selector - A selector to query. - * - * @return A found element or `null`. - */ -export function query( parent: Element | Document, selector: string ): E | null { - return parent && parent.querySelector( selector ); -} diff --git a/src/js/utils/dom/queryAll/queryAll.test.ts b/src/js/utils/dom/queryAll/queryAll.test.ts deleted file mode 100644 index aa7a1fcf..00000000 --- a/src/js/utils/dom/queryAll/queryAll.test.ts +++ /dev/null @@ -1,31 +0,0 @@ -import { queryAll } from './queryAll'; - - -describe( 'queryAll', () => { - beforeEach( () => { - document.body.innerHTML = ` -
    - 1 -
    -
    - 2 -
    -
    - 3 -
    - `; - } ); - - test( 'can get elements that match the selector.', () => { - const divs = queryAll( document.body, 'div' ); - expect( divs.length ).toBe( 3 ); - expect( divs[ 0 ].id ).toBe( 'div1' ); - expect( divs[ 1 ].id ).toBe( 'div2' ); - expect( divs[ 2 ].id ).toBe( 'div3' ); - - const spans = queryAll( document.body, '#div1 span' ); - - expect( spans.length ).toBe( 1 ); - expect( spans[ 0 ].textContent ).toBe( '1' ); - } ); -} ); diff --git a/src/js/utils/dom/queryAll/queryAll.ts b/src/js/utils/dom/queryAll/queryAll.ts deleted file mode 100644 index c7ed842a..00000000 --- a/src/js/utils/dom/queryAll/queryAll.ts +++ /dev/null @@ -1,14 +0,0 @@ -import { slice } from '../../arrayLike'; - - -/** - * Returns elements that match the provided selector. - * - * @param parent - A parent element to start searching from. - * @param selector - A selector to query. - * - * @return An array with matched elements. - */ -export function queryAll( parent: Element | Document, selector?: string ): E[] { - return selector ? slice( parent.querySelectorAll( selector ) ) : []; -} diff --git a/src/js/utils/dom/rect/rect.test.ts b/src/js/utils/dom/rect/rect.test.ts deleted file mode 100644 index 061921a7..00000000 --- a/src/js/utils/dom/rect/rect.test.ts +++ /dev/null @@ -1,11 +0,0 @@ -import { rect } from './rect'; - - -describe( 'rect', () => { - test( 'can return a DOMRect object.', () => { - const div = document.createElement( 'div' ); - - expect( rect( div ).width ).toBe( 0 ); - expect( rect( div ).left ).toBe( 0 ); - } ); -} ); diff --git a/src/js/utils/dom/rect/rect.ts b/src/js/utils/dom/rect/rect.ts deleted file mode 100644 index cc9f2753..00000000 --- a/src/js/utils/dom/rect/rect.ts +++ /dev/null @@ -1,8 +0,0 @@ -/** - * Returns a DOMRect object of the provided element. - * - * @param target - An element. - */ -export function rect( target: Element ): DOMRect { - return target.getBoundingClientRect(); -} diff --git a/src/js/utils/dom/remove/remove.test.ts b/src/js/utils/dom/remove/remove.test.ts deleted file mode 100644 index 5ae3bf2a..00000000 --- a/src/js/utils/dom/remove/remove.test.ts +++ /dev/null @@ -1,43 +0,0 @@ -import { remove } from './remove'; - - -describe( 'remove', () => { - test( 'can remove an element from its parent.', () => { - const div = document.createElement( 'div' ); - const span = document.createElement( 'span' ); - - div.appendChild( span ); - expect( div.firstElementChild ).toBe( span ); - - remove( span ); - expect( div.children.length ).toBe( 0 ); - } ); - - test( 'can remove elements from its parent.', () => { - const div = document.createElement( 'div' ); - const span1 = document.createElement( 'span' ); - const span2 = document.createElement( 'span' ); - const span3 = document.createElement( 'span' ); - - div.appendChild( span1 ); - div.appendChild( span2 ); - div.appendChild( span3 ); - expect( div.children[ 0 ] ).toBe( span1 ); - expect( div.children[ 1 ] ).toBe( span2 ); - expect( div.children[ 2 ] ).toBe( span3 ); - - remove( [ span1, span2, span3 ] ); - expect( div.children.length ).toBe( 0 ); - } ); - - test( 'can remove a text node from its parent.', () => { - const span = document.createElement( 'span' ); - const node = document.createTextNode( 'sample' ); - - span.appendChild( node ); - expect( span.textContent ).toBe( 'sample' ); - - remove( node ); - expect( span.textContent ).toBe( '' ); - } ); -} ); diff --git a/src/js/utils/dom/remove/remove.ts b/src/js/utils/dom/remove/remove.ts deleted file mode 100644 index 52bca006..00000000 --- a/src/js/utils/dom/remove/remove.ts +++ /dev/null @@ -1,15 +0,0 @@ -import { forEach } from '../../array'; - - -/** - * Removes the provided node from its parent. - * - * @param nodes - A node or nodes to remove. - */ -export function remove( nodes: Node | Node[] ): void { - forEach( nodes, node => { - if ( node && node.parentNode ) { - node.parentNode.removeChild( node ); - } - } ); -} diff --git a/src/js/utils/dom/removeAttribute/removeAttribute.test.ts b/src/js/utils/dom/removeAttribute/removeAttribute.test.ts deleted file mode 100644 index a6c4246f..00000000 --- a/src/js/utils/dom/removeAttribute/removeAttribute.test.ts +++ /dev/null @@ -1,52 +0,0 @@ -import { removeAttribute } from './removeAttribute'; - - -describe( 'removeAttribute', () => { - test( 'can remove an attribute from an element.', () => { - const div = document.createElement( 'div' ); - - div.setAttribute( 'aria-hidden', 'true' ); - div.setAttribute( 'tabindex', '-1' ); - - removeAttribute( div, 'aria-hidden' ); - expect( div.getAttribute( 'aria-hidden' ) ).toBeNull(); - expect( div.getAttribute( 'tabindex' ) ).not.toBeNull(); - - removeAttribute( div, 'tabindex' ); - expect( div.getAttribute( 'tabindex' ) ).toBeNull(); - } ); - - test( 'can remove attributes from an element.', () => { - const div = document.createElement( 'div' ); - - div.setAttribute( 'aria-hidden', 'true' ); - div.setAttribute( 'tabindex', '-1' ); - - removeAttribute( div, [ 'aria-hidden', 'tabindex' ] ); - expect( div.getAttribute( 'aria-hidden' ) ).toBeNull(); - expect( div.getAttribute( 'tabindex' ) ).toBeNull(); - } ); - - test( 'can remove attributes from elements.', () => { - const div1 = document.createElement( 'div1' ); - const div2 = document.createElement( 'div2' ); - const div3 = document.createElement( 'div2' ); - const divs = [ div1, div2, div3 ]; - const callback = jest.fn(); - - divs.forEach( div => { - div.setAttribute( 'aria-hidden', 'true' ); - div.setAttribute( 'tabindex', '-1' ); - } ); - - removeAttribute( divs, [ 'aria-hidden', 'tabindex' ] ); - - divs.forEach( div => { - expect( div.getAttribute( 'aria-hidden' ) ).toBeNull(); - expect( div.getAttribute( 'tabindex' ) ).toBeNull(); - callback(); - } ); - - expect( callback ).toHaveBeenCalledTimes( divs.length ); - } ); -} ); diff --git a/src/js/utils/dom/removeAttribute/removeAttribute.ts b/src/js/utils/dom/removeAttribute/removeAttribute.ts deleted file mode 100644 index 3ec0fad2..00000000 --- a/src/js/utils/dom/removeAttribute/removeAttribute.ts +++ /dev/null @@ -1,16 +0,0 @@ -import { forEach } from '../../array'; - - -/** - * Removes attributes from the element. - * - * @param elms - An element or elements. - * @param attrs - An attribute or attributes to remove. - */ -export function removeAttribute( elms: Element | Element[], attrs: string | string[] ): void { - forEach( elms, elm => { - forEach( attrs, attr => { - elm && elm.removeAttribute( attr ); - } ); - } ); -} diff --git a/src/js/utils/dom/removeClass/removeClass.test.ts b/src/js/utils/dom/removeClass/removeClass.test.ts deleted file mode 100644 index 3e38ab9f..00000000 --- a/src/js/utils/dom/removeClass/removeClass.test.ts +++ /dev/null @@ -1,33 +0,0 @@ -import { removeClass } from './removeClass'; - - -describe( 'removeClass', () => { - beforeEach( () => { - document.body.innerHTML = '
    '; - } ); - - test( 'can remove a class from the element.', () => { - const container = document.getElementById( 'container' ); - - container.classList.add( 'active' ); - expect( container.classList.contains( 'active' ) ).toBe( true ); - - removeClass( container, 'active' ); - expect( container.classList.contains( 'active' ) ).toBe( false ); - } ); - - test( 'can remove classes from the element.', () => { - const container = document.getElementById( 'container' ); - - container.classList.add( 'active' ); - container.classList.add( 'visible' ); - - expect( container.classList.contains( 'active' ) ).toBe( true ); - expect( container.classList.contains( 'visible' ) ).toBe( true ); - - removeClass( container, [ 'active', 'visible' ] ); - - expect( container.classList.contains( 'active' ) ).toBe( false ); - expect( container.classList.contains( 'visible' ) ).toBe( false ); - } ); -} ); diff --git a/src/js/utils/dom/removeClass/removeClass.ts b/src/js/utils/dom/removeClass/removeClass.ts deleted file mode 100644 index 13c2439a..00000000 --- a/src/js/utils/dom/removeClass/removeClass.ts +++ /dev/null @@ -1,12 +0,0 @@ -import { toggleClass } from '../toggleClass/toggleClass'; - - -/** - * Removes classes from the element. - * - * @param elm - An element to remove classes from. - * @param classes - Classes to remove. - */ -export function removeClass( elm: Element, classes: string | string[] ): void { - toggleClass( elm, classes, false ); -} diff --git a/src/js/utils/dom/setAttribute/setAttribute.test.ts b/src/js/utils/dom/setAttribute/setAttribute.test.ts deleted file mode 100644 index e979c668..00000000 --- a/src/js/utils/dom/setAttribute/setAttribute.test.ts +++ /dev/null @@ -1,61 +0,0 @@ -import { setAttribute } from './setAttribute'; - - -describe( 'setAttribute', () => { - test( 'can set an attribute to an element.', () => { - const div = document.createElement( 'div' ); - - setAttribute( div, 'id', 'newId' ); - expect( div.id ).toBe( 'newId' ); - - setAttribute( div, 'aria-hidden', true ); - expect( div.getAttribute( 'aria-hidden' ) ).toBe( 'true' ); - - setAttribute( div, 'tabindex', -1 ); - expect( div.getAttribute( 'tabindex' ) ).toBe( '-1' ); - } ); - - test( 'can set an attribute to elements.', () => { - const div1 = document.createElement( 'div' ); - const div2 = document.createElement( 'div' ); - const div3 = document.createElement( 'div' ); - const divs = [ div1, div2, div3 ]; - const callback = jest.fn(); - - setAttribute( divs, 'aria-hidden', true ); - setAttribute( divs, 'tabindex', -1 ); - - divs.forEach( div => { - expect( div.getAttribute( 'aria-hidden' ) ).toBe( 'true' ); - expect( div.getAttribute( 'tabindex' ) ).toBe( '-1' ); - callback(); - } ); - - expect( callback ).toHaveBeenCalledTimes( divs.length ); - } ); - - test( 'can set attributes by an object.', () => { - const div = document.createElement( 'div' ); - - setAttribute( div, { - 'aria-role' : 'presentation', - 'contenteditable': true, - } ); - - expect( div.getAttribute( 'aria-role' ) ).toBe( 'presentation' ); - expect( div.getAttribute( 'contenteditable' ) ).toBe( 'true' ); - } ); - - test( 'can remove an attribute by null or an empty string.', () => { - const div = document.createElement( 'div' ); - - div.setAttribute( 'aria-hidden', 'true' ); - div.setAttribute( 'tabindex', '-1' ); - - setAttribute( div, 'aria-hidden', '' ); - setAttribute( div, 'tabindex', null ); - - expect( div.getAttribute( 'aria-hidden' ) ).toBeNull(); - expect( div.getAttribute( 'tabindex' ) ).toBeNull(); - } ); -} ); diff --git a/src/js/utils/dom/setAttribute/setAttribute.ts b/src/js/utils/dom/setAttribute/setAttribute.ts deleted file mode 100644 index 16fd31aa..00000000 --- a/src/js/utils/dom/setAttribute/setAttribute.ts +++ /dev/null @@ -1,32 +0,0 @@ -import { forEach } from '../../array'; -import { forOwn } from '../../object'; -import { isNull, isObject } from '../../type/type'; -import { removeAttribute } from '../removeAttribute/removeAttribute'; - - -export function setAttribute( elms: Element | Element[], attr: string, value: string | number | boolean ): void; -export function setAttribute( elms: Element | Element[], attrs: Record ): void; - -/** - * Sets attribute/attributes to the element or elements. - * If the value is `null` or an empty string, the attribute will be removed. - * - * @param elms - An element or an array with elements. - * @param attrs - An attribute name of an object with pairs of a name and a value. - * @param value - A value to set. - */ -export function setAttribute( - elms: Element | Element[], - attrs: string | Record, - value?: string | number | boolean -): void { - if ( isObject( attrs ) ) { - forOwn( attrs, ( value, name ) => { - setAttribute( elms, name, value ); - } ); - } else { - forEach( elms, elm => { - isNull( value ) || value === '' ? removeAttribute( elm, attrs ) : elm.setAttribute( attrs, String( value ) ); - } ); - } -} diff --git a/src/js/utils/dom/style/style.test.ts b/src/js/utils/dom/style/style.test.ts deleted file mode 100644 index 676e9a8b..00000000 --- a/src/js/utils/dom/style/style.test.ts +++ /dev/null @@ -1,21 +0,0 @@ -import { style } from './style'; - - -describe( 'styles', () => { - test( 'can set an inline style', () => { - const div = document.createElement( 'div' ); - style( div, 'color', 'red' ); - style( div, 'backgroundColor', 'white' ); - style( div, 'fontSize', '1rem' ); - - expect( div.style.color ).toBe( 'red' ); - expect( div.style.backgroundColor ).toBe( 'white' ); - expect( div.style.fontSize ).toBe( '1rem' ); - } ); - - test( 'can return a computed style', () => { - const div = document.createElement( 'div' ); - div.style.color = 'red'; - expect( style( div, 'color' ) ).toBe( 'red' ); - } ); -} ); diff --git a/src/js/utils/dom/style/style.ts b/src/js/utils/dom/style/style.ts deleted file mode 100644 index 614ad0c5..00000000 --- a/src/js/utils/dom/style/style.ts +++ /dev/null @@ -1,40 +0,0 @@ -import { isNull, isUndefined } from '../../type/type'; - - -export function style( - elm: HTMLElement, - prop: K, -): CSSStyleDeclaration[ K ]; - -export function style( - elm: HTMLElement, - prop: string, -): string; - -export function style( - elm: HTMLElement, - prop: string, - value: string | number -): void; - - -/** - * Applies inline styles to the provided element by an object literal. - * - * @param elm - An element to apply styles to. - * @param prop - An object literal with styles or a property name. - * @param value - A value to set. - */ -export function style( - elm: HTMLElement, - prop: string, - value?: string | number -): string | void { - if ( isUndefined( value ) ) { - return getComputedStyle( elm )[ prop ]; - } - - if ( ! isNull( value ) ) { - elm.style[ prop ] = `${ value }`; - } -} diff --git a/src/js/utils/dom/timeOf/timeOf.test.ts b/src/js/utils/dom/timeOf/timeOf.test.ts deleted file mode 100644 index 7b040dce..00000000 --- a/src/js/utils/dom/timeOf/timeOf.test.ts +++ /dev/null @@ -1,14 +0,0 @@ -import { fire } from '../../../test'; -import { timeOf } from './timeOf'; - - -describe( 'timeOf', () => { - test( 'can extract a timestamp from an event object.', done => { - window.addEventListener( 'click', e => { - expect( timeOf( e ) ).toBe( 123 ); - done(); - } ); - - fire( window, 'click', { timeStamp: 123 } ); - } ); -} ); \ No newline at end of file diff --git a/src/js/utils/dom/timeOf/timeOf.ts b/src/js/utils/dom/timeOf/timeOf.ts deleted file mode 100644 index 701eb196..00000000 --- a/src/js/utils/dom/timeOf/timeOf.ts +++ /dev/null @@ -1,8 +0,0 @@ -/** - * Extracts the timestamp from the event object. - * - * @param e - An Event object. - */ -export function timeOf( e: Event ): number { - return e.timeStamp; -} \ No newline at end of file diff --git a/src/js/utils/dom/toggleClass/toggleClass.test.ts b/src/js/utils/dom/toggleClass/toggleClass.test.ts deleted file mode 100644 index 82a649e2..00000000 --- a/src/js/utils/dom/toggleClass/toggleClass.test.ts +++ /dev/null @@ -1,46 +0,0 @@ -import { toggleClass } from './toggleClass'; - - -describe( 'toggleClass', () => { - beforeEach( () => { - document.body.innerHTML = '
    '; - } ); - - test( 'can add a class to the element.', () => { - const container = document.getElementById( 'container' ); - toggleClass( container, 'active', true ); - expect( container.classList.contains( 'active' ) ).toBe( true ); - } ); - - test( 'can add classes to the element.', () => { - const container = document.getElementById( 'container' ); - - toggleClass( container, [ 'active', 'visible' ], true ); - - expect( container.classList.contains( 'active' ) ).toBe( true ); - expect( container.classList.contains( 'visible' ) ).toBe( true ); - } ); - - test( 'can remove a class from the element.', () => { - const container = document.getElementById( 'container' ); - container.classList.add( 'active' ); - expect( container.classList.contains( 'active' ) ).toBe( true ); - - toggleClass( container, 'active', false ); - expect( container.classList.contains( 'active' ) ).toBe( false ); - } ); - - test( 'can remove classes from the element.', () => { - const container = document.getElementById( 'container' ); - container.classList.add( 'active' ); - container.classList.add( 'visible' ); - - expect( container.classList.contains( 'active' ) ).toBe( true ); - expect( container.classList.contains( 'visible' ) ).toBe( true ); - - toggleClass( container, [ 'active', 'visible' ], false ); - - expect( container.classList.contains( 'active' ) ).toBe( false ); - expect( container.classList.contains( 'visible' ) ).toBe( false ); - } ); -} ); diff --git a/src/js/utils/dom/toggleClass/toggleClass.ts b/src/js/utils/dom/toggleClass/toggleClass.ts deleted file mode 100644 index 3f70d533..00000000 --- a/src/js/utils/dom/toggleClass/toggleClass.ts +++ /dev/null @@ -1,19 +0,0 @@ -import { forEach } from '../../array'; - - -/** - * Toggles the provided class or classes by following the `add` boolean. - * - * @param elm - An element whose classes are toggled. - * @param classes - A class or class names. - * @param add - Whether to add or remove a class. - */ -export function toggleClass( elm: Element, classes: string | string[], add: boolean ): void { - if ( elm ) { - forEach( classes, name => { - if ( name ) { - elm.classList[ add ? 'add' : 'remove' ]( name ); - } - } ); - } -} diff --git a/src/js/utils/dom/unit/unit.test.ts b/src/js/utils/dom/unit/unit.test.ts deleted file mode 100644 index 4c7835dd..00000000 --- a/src/js/utils/dom/unit/unit.test.ts +++ /dev/null @@ -1,14 +0,0 @@ -import { unit } from './unit'; - - -describe( 'unit', () => { - test( 'can append `px` if the value is number.', () => { - expect( unit( 1 ) ).toBe( '1px' ); - expect( unit( 1.8 ) ).toBe( '1.8px' ); - } ); - - test( 'should return the value itself if it is string.', () => { - expect( unit( '10vh' ) ).toBe( '10vh' ); - expect( unit( '10em' ) ).toBe( '10em' ); - } ); -} ); diff --git a/src/js/utils/dom/unit/unit.ts b/src/js/utils/dom/unit/unit.ts deleted file mode 100644 index 5901c423..00000000 --- a/src/js/utils/dom/unit/unit.ts +++ /dev/null @@ -1,14 +0,0 @@ -import { isString } from '../../type/type'; - - -/** - * Appends `px` to the provided number. - * If the value is already string, just returns it. - * - * @param value - A value to append `px` to. - * - * @return A string with the CSS unit. - */ -export function unit( value: number | string ): string { - return isString( value ) ? value : value ? `${ value }px` : ''; -} diff --git a/src/js/utils/error/assert/assert.ts b/src/js/utils/error/assert/assert.ts index 2bfa830f..bc0c2cbe 100644 --- a/src/js/utils/error/assert/assert.ts +++ b/src/js/utils/error/assert/assert.ts @@ -7,8 +7,8 @@ import { PROJECT_CODE } from '../../../constants/project'; * @param condition - If falsy, an error is thrown. * @param message - Optional. A message to display. */ -export function assert( condition: any, message?: string ): void { - if ( ! condition ) { - throw new Error( `[${ PROJECT_CODE }] ${ message || '' }` ); +export function assert(condition: T, message?: string): asserts condition is NonNullable { + if (!condition) { + throw new Error(`[${ PROJECT_CODE }] ${ message || '' }`); } } diff --git a/src/js/utils/error/error/error.ts b/src/js/utils/error/error/error.ts index 1db35241..35aae35d 100644 --- a/src/js/utils/error/error/error.ts +++ b/src/js/utils/error/error/error.ts @@ -6,6 +6,7 @@ import { PROJECT_CODE } from '../../../constants/project'; * * @param message - A message. */ -export function error( message: string ): void { - console.error( `[${ PROJECT_CODE }] ${ message }` ); +export function error(message: string): void { + // eslint-disable-next-line + console.error(`[${ PROJECT_CODE }] ${ message }`); } diff --git a/src/js/utils/function/apply/apply.test.ts b/src/js/utils/function/apply/apply.test.ts deleted file mode 100644 index 38ebfa10..00000000 --- a/src/js/utils/function/apply/apply.test.ts +++ /dev/null @@ -1,25 +0,0 @@ -import { apply } from './apply'; - - -describe( 'apply', () => { - test( 'can bind arguments to the function.', () => { - function sum( a: number, b: number, c = 0, d = 0 ): number { - return a + b + c + d; - } - - // The type should be ( b: number, c?: number, d?: number ) => number. - const sum1 = apply( sum, 1 ); - const sum2 = apply( sum, 1, 1 ); - const sum3 = apply( sum, 1, 1, 1 ); - const sum4 = apply( sum, 1, 1, 1, 1 ); - - expect( sum1( 1, 1, 1 ) ).toBe( 4 ); - expect( sum2( 1, 1 ) ).toBe( 4 ); - expect( sum3( 1 ) ).toBe( 4 ); - expect( sum4() ).toBe( 4 ); - - expect( sum1( 2 ) ).toBe( 3 ); // 1, 2, 0, 0 - expect( sum1( 2, 2 ) ).toBe( 5 ); // 1, 2, 2, 0 - expect( sum1( 2, 2, 2 ) ).toBe( 7 ); // 1, 2, 2, 2 - } ); -} ); \ No newline at end of file diff --git a/src/js/utils/function/apply/apply.ts b/src/js/utils/function/apply/apply.ts deleted file mode 100644 index 92cecec2..00000000 --- a/src/js/utils/function/apply/apply.ts +++ /dev/null @@ -1,28 +0,0 @@ -import { AnyFunction, ShiftN } from '../../../types'; -import { slice } from '../../arrayLike'; - - -/** - * Create a function where provided arguments are bound. - * `this` parameter will be always null. - * - * @param func - A function. - * @param args - Arguments to bind to the function. - * - * @return A function where arguments are bound. - */ -export function apply( - func: F, - ...args: A -): ( ...args: ShiftN, A["length"]> ) => ReturnType; - -/** - * Create a function where provided arguments are bound. - * `this` parameter will be always null. - * - * @param func - A function. - */ -export function apply( func: AnyFunction ): any { - // eslint-disable-next-line prefer-rest-params, prefer-spread - return func.bind( null, ...slice( arguments, 1 ) ); -} diff --git a/src/js/utils/function/index.ts b/src/js/utils/function/index.ts deleted file mode 100644 index 78b776f0..00000000 --- a/src/js/utils/function/index.ts +++ /dev/null @@ -1,4 +0,0 @@ -export { apply } from './apply/apply'; -export { nextTick } from './nextTick/nextTick'; -export { noop } from './noop/noop'; -export { raf } from './raf/raf'; diff --git a/src/js/utils/function/nextTick/nextTick.ts b/src/js/utils/function/nextTick/nextTick.ts deleted file mode 100644 index 38c90ace..00000000 --- a/src/js/utils/function/nextTick/nextTick.ts +++ /dev/null @@ -1,9 +0,0 @@ -import { AnyFunction } from '../../../types'; - - -/** - * Invokes the callback on the next tick. - * - * @param callback - A callback function. - */ -export const nextTick: ( callback: AnyFunction ) => ReturnType = setTimeout; diff --git a/src/js/utils/function/noop/noop.ts b/src/js/utils/function/noop/noop.ts deleted file mode 100644 index 84b6b859..00000000 --- a/src/js/utils/function/noop/noop.ts +++ /dev/null @@ -1,4 +0,0 @@ -/** - * No operation. - */ -export const noop = (): void => {}; // eslint-disable-line no-empty-function, @typescript-eslint/no-empty-function diff --git a/src/js/utils/function/raf/raf.ts b/src/js/utils/function/raf/raf.ts deleted file mode 100644 index aa9ec202..00000000 --- a/src/js/utils/function/raf/raf.ts +++ /dev/null @@ -1,6 +0,0 @@ -/** - * The alias of `window.requestAnimationFrame()`. - */ -export function raf( func: FrameRequestCallback ): number { - return requestAnimationFrame( func ); -} diff --git a/src/js/utils/index.ts b/src/js/utils/index.ts index d52a8f75..10c2e140 100644 --- a/src/js/utils/index.ts +++ b/src/js/utils/index.ts @@ -1,9 +1 @@ -export * from './array'; -export * from './arrayLike'; -export * from './dom'; -export * from './error'; -export * from './function'; -export * from './math'; -export * from './object'; -export * from './string'; -export * from './type/type'; +export * from './error'; \ No newline at end of file diff --git a/src/js/utils/math/approximatelyEqual/approximatelyEqual.test.ts b/src/js/utils/math/approximatelyEqual/approximatelyEqual.test.ts deleted file mode 100644 index 0364c44a..00000000 --- a/src/js/utils/math/approximatelyEqual/approximatelyEqual.test.ts +++ /dev/null @@ -1,16 +0,0 @@ -import { approximatelyEqual } from './approximatelyEqual'; - - -describe( 'approximatelyEqual', () => { - test( 'can tell if 2 numbers are approximately equal or not.', () => { - expect( approximatelyEqual( 1, 1, 1 ) ).toBe( true ); - expect( approximatelyEqual( 1, 0.9, 1 ) ).toBe( true ); - expect( approximatelyEqual( 1, 1.9, 1 ) ).toBe( true ); - - expect( approximatelyEqual( 1, 2, 1 ) ).toBe( false ); - expect( approximatelyEqual( 1, 0, 1 ) ).toBe( false ); - - expect( approximatelyEqual( 1, 2, 2 ) ).toBe( true ); - expect( approximatelyEqual( 1, 0, 2 ) ).toBe( true ); - } ); -} ); diff --git a/src/js/utils/math/approximatelyEqual/approximatelyEqual.ts b/src/js/utils/math/approximatelyEqual/approximatelyEqual.ts deleted file mode 100644 index bc0a6a5f..00000000 --- a/src/js/utils/math/approximatelyEqual/approximatelyEqual.ts +++ /dev/null @@ -1,15 +0,0 @@ -import { abs } from '../math/math'; - - -/** - * Checks if the provided 2 numbers are approximately equal or not. - * - * @param x - A number. - * @param y - Another number to compare. - * @param epsilon - An accuracy that defines the approximation. - * - * @return `true` if 2 numbers are considered to be equal, or otherwise `false`. - */ -export function approximatelyEqual( x: number, y: number, epsilon: number ): boolean { - return abs( x - y ) < epsilon; -} diff --git a/src/js/utils/math/between/between.test.ts b/src/js/utils/math/between/between.test.ts deleted file mode 100644 index e5b0111e..00000000 --- a/src/js/utils/math/between/between.test.ts +++ /dev/null @@ -1,24 +0,0 @@ -import { between } from './between'; - - -describe( 'between', () => { - test( 'can check a number is between 2 numbers inclusively.', () => { - expect( between( 0, 0, 1 ) ).toBe( true ); - expect( between( 1, 0, 1 ) ).toBe( true ); - - expect( between( 1, 2, 3 ) ).toBe( false ); - - expect( between( 1, 0, 2 ) ).toBe( true ); - expect( between( 1, 2, 0 ) ).toBe( true ); - } ); - - test( 'can check a number is between 2 numbers exclusively.', () => { - expect( between( 0, 0, 1, true ) ).toBe( false ); - expect( between( 1, 0, 1, true ) ).toBe( false ); - - expect( between( 1, 2, 3, true ) ).toBe( false ); - - expect( between( 1, 0, 2, true ) ).toBe( true ); - expect( between( 1, 2, 0, true ) ).toBe( true ); - } ); -} ); diff --git a/src/js/utils/math/between/between.ts b/src/js/utils/math/between/between.ts deleted file mode 100644 index 22fd8a0e..00000000 --- a/src/js/utils/math/between/between.ts +++ /dev/null @@ -1,18 +0,0 @@ -import { max, min } from '../math/math'; - - -/** - * Checks if the subject number is between `x` and `y`. - * - * @param number - A subject number to check. - * @param x - A min or max number. - * @param y - A max or min number. - * @param exclusive - Optional. Whether to exclude `x` or `y`. - */ -export function between( number: number, x: number, y: number, exclusive?: boolean ): boolean { - const minimum = min( x, y ); - const maximum = max( x, y ); - return exclusive - ? minimum < number && number < maximum - : minimum <= number && number <= maximum; -} diff --git a/src/js/utils/math/clamp/clamp.test.ts b/src/js/utils/math/clamp/clamp.test.ts deleted file mode 100644 index 16937515..00000000 --- a/src/js/utils/math/clamp/clamp.test.ts +++ /dev/null @@ -1,15 +0,0 @@ -import { clamp } from './clamp'; - - -describe( 'clamp', () => { - test( 'can clamp a number', () => { - expect( clamp( 0, 0, 1 ) ).toBe( 0 ); - expect( clamp( 1, 0, 1 ) ).toBe( 1 ); - - expect( clamp( 1, 2, 3 ) ).toBe( 2 ); - expect( clamp( 1, 0, 0 ) ).toBe( 0 ); - - expect( clamp( 3, 0, 1 ) ).toBe( 1 ); - expect( clamp( 3, 4, 5 ) ).toBe( 4 ); - } ); -} ); diff --git a/src/js/utils/math/clamp/clamp.ts b/src/js/utils/math/clamp/clamp.ts deleted file mode 100644 index 0662b1f2..00000000 --- a/src/js/utils/math/clamp/clamp.ts +++ /dev/null @@ -1,17 +0,0 @@ -import { max, min } from '../math/math'; - - -/** - * Clamps a number. - * - * @param number - A subject number to check. - * @param x - A min or max number. - * @param y - A min or max number. - * - * @return A clamped number. - */ -export function clamp( number: number, x: number, y: number ): number { - const minimum = min( x, y ); - const maximum = max( x, y ); - return min( max( minimum, number ), maximum ); -} diff --git a/src/js/utils/math/index.ts b/src/js/utils/math/index.ts deleted file mode 100644 index a892eb81..00000000 --- a/src/js/utils/math/index.ts +++ /dev/null @@ -1,6 +0,0 @@ -export { approximatelyEqual } from './approximatelyEqual/approximatelyEqual'; -export { between } from './between/between'; -export { clamp } from './clamp/clamp'; -export { sign } from './sign/sign'; - -export * from './math/math'; diff --git a/src/js/utils/math/math/math.ts b/src/js/utils/math/math/math.ts deleted file mode 100644 index 04b4d6c5..00000000 --- a/src/js/utils/math/math/math.ts +++ /dev/null @@ -1 +0,0 @@ -export const { min, max, floor, ceil, abs } = Math; diff --git a/src/js/utils/math/sign/sign.test.ts b/src/js/utils/math/sign/sign.test.ts deleted file mode 100644 index 887136c5..00000000 --- a/src/js/utils/math/sign/sign.test.ts +++ /dev/null @@ -1,19 +0,0 @@ -import { sign } from './sign'; - - -describe( 'sign', () => { - test( 'can return the sign of the number', () => { - expect( sign( 0 ) ).toBe( 0 ); - expect( sign( 1 ) ).toBe( 1 ); - expect( sign( -1 ) ).toBe( -1 ); - - expect( sign( 100 ) ).toBe( 1 ); - expect( sign( -100 ) ).toBe( -1 ); - - expect( sign( 0.5 ) ).toBe( 1 ); - expect( sign( -0.5 ) ).toBe( -1 ); - - expect( sign( Infinity ) ).toBe( 1 ); - expect( sign( -Infinity ) ).toBe( -1 ); - } ); -} ); diff --git a/src/js/utils/math/sign/sign.ts b/src/js/utils/math/sign/sign.ts deleted file mode 100644 index 819a8f20..00000000 --- a/src/js/utils/math/sign/sign.ts +++ /dev/null @@ -1,10 +0,0 @@ -/** - * Returns the sign of the provided number. - * - * @param x - A number. - * - * @return `1` for positive numbers, `-1` for negative numbers, or `0` for `0`. - */ -export function sign( x: number ): number { - return +( x > 0 ) - +( x < 0 ); -} diff --git a/src/js/utils/object/assign/assign.test.ts b/src/js/utils/object/assign/assign.test.ts deleted file mode 100644 index 5e180b51..00000000 --- a/src/js/utils/object/assign/assign.test.ts +++ /dev/null @@ -1,31 +0,0 @@ -import { assign } from './assign'; - - -describe( 'assign', () => { - test( 'can assign own enumerable properties of the source object to the target.', () => { - const object = { a: 1, b: '2' }; - const source = { a: 2, c: true }; - const assigned = assign( object, source ); - - expect( assigned ).toStrictEqual( { a: 2, b: '2', c: true } ); - } ); - - test( 'can assign properties of multiple sources to the target.', () => { - const object = { a: 1, b: '2' }; - const source1 = { a: 2, c: true }; - const source2 = { d: 3, e: '3' }; - const source3 = { e: Infinity }; - const assigned = assign( object, source1, source2, source3 ); - - expect( assigned ).toStrictEqual( { a: 2, b: '2', c: true, d: 3, e: Infinity } ); - } ); - - test( 'should assign a nested object as a reference.', () => { - const object = { a: { b: 1 } }; - const source = { a: { b: 2 } }; - const assigned = assign( object, source ); - - expect( assigned ).toStrictEqual( { a: { b: 2 } } ); - expect( source.a ).toBe( assigned.a ); - } ); -} ); diff --git a/src/js/utils/object/assign/assign.ts b/src/js/utils/object/assign/assign.ts deleted file mode 100644 index 24c5701d..00000000 --- a/src/js/utils/object/assign/assign.ts +++ /dev/null @@ -1,52 +0,0 @@ -import { Cast, Head, Push, Resolve, Shift } from '../../../types'; -import { slice } from '../../arrayLike'; -import { forOwn } from '../forOwn/forOwn'; - - -/** - * Assigns U to T. - * - * @typeParam T - An object to assign to. - * @typeParam U - An object to assign. - * - * @return An assigned object type. - */ -export type Assign = Omit & U; - -/** - * Recursively assigns U[] to T. - * - * @typeParam T - An object to assign to. - * @typeParam U - A tuple contains objects. - * - * @return An assigned object type. - */ -export type Assigned = { - 0: T, - 1: Assigned>, Shift, N, Push>, -}[ C['length'] extends N ? 0 : 1 ] extends infer A ? Cast : never; - -export function assign( object: T ): T; - -export function assign( - object: T, - ...sources: U -): Resolve> - -/** - * Assigns all own enumerable properties of all source objects to the provided object. - * - * @param object - An object to assign properties to. - * - * @return An object assigned properties of the sources to. - */ -export function assign( object: T ): any { - // eslint-disable-next-line prefer-rest-params, prefer-spread - slice( arguments, 1 ).forEach( source => { - forOwn( source, ( value, key ) => { - object[ key ] = source[ key ]; - } ); - } ); - - return object; -} diff --git a/src/js/utils/object/forOwn/forOwn.test.ts b/src/js/utils/object/forOwn/forOwn.test.ts deleted file mode 100644 index 865a6870..00000000 --- a/src/js/utils/object/forOwn/forOwn.test.ts +++ /dev/null @@ -1,44 +0,0 @@ -import { forOwn } from './forOwn'; - - -describe( 'forOwn', () => { - test( 'can iterate an object by own enumerable properties.', () => { - const object = { a: 1, b: 2, c: 3 }; - let counter = 0; - - forOwn( object, ( value, key ) => { - counter++; - expect( object[ key ] ).toBe( value ); - } ); - - expect( counter ).toBe( Object.keys( object ).length ); - } ); - - test( 'can iterate an object from the end.', () => { - const object = { a: 1, b: 2, c: 3 }; - const values: number[] = []; - - forOwn( object, ( value ) => { - values.push( value ); - }, true ); - - expect( values ).toEqual( [ 3, 2, 1 ] ); - } ); - - test( 'should not handle inherited properties.', () => { - class Constructor { - a = 1; - b = 2; - } - - Constructor.prototype[ 'c' ] = 3; - - const object = {}; - - forOwn( new Constructor(), ( value, key ) => { - object[ key ] = value; - } ); - - expect( object ).toStrictEqual( { a: 1, b: 2 } ); - } ); -} ); diff --git a/src/js/utils/object/forOwn/forOwn.ts b/src/js/utils/object/forOwn/forOwn.ts deleted file mode 100644 index f894a057..00000000 --- a/src/js/utils/object/forOwn/forOwn.ts +++ /dev/null @@ -1,25 +0,0 @@ -import { ownKeys } from '../ownKeys/ownKeys'; - - -/** - * Iterates over the provided object by own enumerable keys with calling the iteratee function. - * - * @param object - An object to iterate over. - * @param iteratee - An iteratee function that takes `value` and `key` as arguments. - * @param right - If `true`, the method iterates over the object from the end like `forEachRight()`. - * - * @return A provided object itself. - */ -export function forOwn( - object: T, - iteratee: ( value: T[ keyof T ], key: string ) => boolean | void, - right?: boolean -): T { - if ( object ) { - ( right ? ownKeys( object ).reverse() : ownKeys( object ) ).forEach( key => { - key !== '__proto__' && iteratee( object[ key ], key ); - } ); - } - - return object; -} diff --git a/src/js/utils/object/index.ts b/src/js/utils/object/index.ts deleted file mode 100644 index 5efe7387..00000000 --- a/src/js/utils/object/index.ts +++ /dev/null @@ -1,5 +0,0 @@ -export { assign } from './assign/assign'; -export { forOwn } from './forOwn/forOwn'; -export { merge } from './merge/merge'; -export { omit } from './omit/omit'; -export { ownKeys } from './ownKeys/ownKeys'; diff --git a/src/js/utils/object/merge/merge.test.ts b/src/js/utils/object/merge/merge.test.ts deleted file mode 100644 index cc0452e7..00000000 --- a/src/js/utils/object/merge/merge.test.ts +++ /dev/null @@ -1,52 +0,0 @@ -import { merge } from './merge'; - - -describe( 'merge', () => { - test( 'can merge 2 objects.', () => { - const object = { a: 1, b: '2' }; - const source = { a: 2, c: true }; - - expect( merge( object, source ) ).toStrictEqual( { a: 2, b: '2', c: true } ); - - // Should not change the source - expect( source ).toStrictEqual( { a: 2, c: true } ); - } ); - - test( 'can merge 2 objects recursively.', () => { - const object = { a: 1, b: { c: 2, d: 3 } }; - const source = { b: { d: 4, e: 5 }, f: true }; - - expect( merge( object, source ) ).toStrictEqual( { - a: 1, - b: { c: 2, d: 4, e: 5 }, - f: true, - } ); - } ); - - test( 'can merge multiple objects recursively.', () => { - const object = { a: 1, b: { c: 2, d: 3 } }; - const source1 = { b: { d: 4, e: 5 }, f: true }; - const source2 = { b: { d: '4', g: 6 }, h: [ 1, 2, 3 ] }; - const source3 = { h: [ 4, 5, 6 ], i: Infinity }; - const source4 = { a: '1' }; - const merged = merge( object, source1, source2, source3, source4 ); - - expect( merged ).toStrictEqual( { - a: '1', - b: { c: 2, d: '4', e: 5, g: 6 }, - f: true, - h: [ 4, 5, 6 ], - i: Infinity, - } ); - } ); - - test( 'should disconnect reference of arrays.', () => { - const array = [ 1, 2, 3 ]; - const object = {}; - const source = { array }; - const merged = merge( object, source ); - - expect( merged ).toStrictEqual( { array: [ 1, 2, 3 ] } ); - expect( merged.array ).not.toBe( array ); - } ); -} ); diff --git a/src/js/utils/object/merge/merge.ts b/src/js/utils/object/merge/merge.ts deleted file mode 100644 index 5d0bbef8..00000000 --- a/src/js/utils/object/merge/merge.ts +++ /dev/null @@ -1,68 +0,0 @@ -import { Cast, Head, Push, Resolve, Shift } from '../../../types'; -import { slice } from '../../arrayLike'; -import { isArray, isObject } from '../../type/type'; -import { forOwn } from '../forOwn/forOwn'; - - -/** - * Merges U to T. - * - * @typeParam T - An object to merge U into. - * @typeParam U - An object to merge properties from. - * - * @return A merged object type. - */ -export type Merge = Omit & { - [ K in ( keyof T & keyof U ) ]: U[ K ] extends object - ? U[ K ] extends any[] - ? U[ K ] - : T[ K ] extends object - ? Merge extends infer A ? Resolve> : never - : U[ K ] - : U[ K ]; -} & Omit; - -/** - * Recursively merges U[] to T. - * - * @typeParam T - An object to assign to. - * @typeParam U - A tuple contains objects. - * - * @return An assigned object type. - */ -export type Merged = { - 0: T, - 1: Merged>, Shift, N, Push>, -}[ C['length'] extends N ? 0 : 1 ] extends infer A ? Cast : never; - -export function merge( object: T ): T; - -export function merge( - object: T, - ...sources: U -): Resolve> - -/** - * Recursively merges source properties to the object. - * Be aware that this method does not merge arrays. They are just duplicated by `slice()`. - * - * @param object - An object to merge properties to. - * - * @return A new object with merged properties. - */ -export function merge( object: T ): any { - // eslint-disable-next-line prefer-rest-params - slice( arguments, 1 ).forEach( source => { - forOwn( source, ( value, key ) => { - if ( isArray( value ) ) { - object[ key ] = value.slice(); - } else if ( isObject( value ) ) { - object[ key ] = merge( {}, isObject( object[ key ] ) ? object[ key ] : {}, value ); - } else { - object[ key ] = value; - } - } ); - } ); - - return object; -} diff --git a/src/js/utils/object/omit/omit.test.ts b/src/js/utils/object/omit/omit.test.ts deleted file mode 100644 index 1953b78b..00000000 --- a/src/js/utils/object/omit/omit.test.ts +++ /dev/null @@ -1,54 +0,0 @@ -import { omit } from './omit'; - - -describe( 'omit', () => { - function hasOwn( object: object, key: string ): boolean { - return Object.prototype.hasOwnProperty.call( object, key ); - } - - test( 'can delete specified key.', () => { - const object = { a: 1, b: 2, c: 3 }; - - expect( hasOwn( object, 'a' ) ).toBe( true ); - expect( hasOwn( object, 'b' ) ).toBe( true ); - - omit( object, 'a' ); - expect( hasOwn( object, 'a' ) ).toBe( false ); - - omit( object, 'b' ); - expect( hasOwn( object, 'b' ) ).toBe( false ); - } ); - - test( 'can delete specified keys.', () => { - const object = { a: 1, b: 2, c: 3 }; - - omit( object, [ 'a', 'b' ] ); - expect( hasOwn( object, 'a' ) ).toBe( false ); - expect( hasOwn( object, 'b' ) ).toBe( false ); - } ); - - test( 'can delete all own enumerable keys.', () => { - const object = { a: 1, b: 2, c: 3 }; - - omit( object ); - expect( hasOwn( object, 'a' ) ).toBe( false ); - expect( hasOwn( object, 'b' ) ).toBe( false ); - expect( hasOwn( object, 'c' ) ).toBe( false ); - expect( Object.keys( object ).length ).toBe( 0 ); - } ); - - test( 'should not delete inherited keys.', () => { - const parent = { a: 1, b: 2, c: 3 }; - const object = Object.create( parent ); - - omit( object ); - - expect( hasOwn( parent, 'a' ) ).toBe( true ); - expect( hasOwn( parent, 'b' ) ).toBe( true ); - expect( hasOwn( parent, 'c' ) ).toBe( true ); - - expect( object.a ).toBe( 1 ); - expect( object.b ).toBe( 2 ); - expect( object.c ).toBe( 3 ); - } ); -} ); diff --git a/src/js/utils/object/omit/omit.ts b/src/js/utils/object/omit/omit.ts deleted file mode 100644 index d3a6b515..00000000 --- a/src/js/utils/object/omit/omit.ts +++ /dev/null @@ -1,15 +0,0 @@ -import { forEach } from '../../array'; -import { ownKeys } from '../ownKeys/ownKeys'; - - -/** - * Deletes specified own keys from the object. - * - * @param object - An object. - * @param keys - A key or keys to delete. If not specified, all own enumerable keys will be deleted. - */ -export function omit( object: object, keys?: string | string[] ): void { - forEach( keys || ownKeys( object ), key => { - delete object[ key ]; - } ); -} \ No newline at end of file diff --git a/src/js/utils/object/ownKeys/ownKeys.ts b/src/js/utils/object/ownKeys/ownKeys.ts deleted file mode 100644 index 64518e5f..00000000 --- a/src/js/utils/object/ownKeys/ownKeys.ts +++ /dev/null @@ -1,4 +0,0 @@ -/** - * An alias of `Object.keys()` - */ -export const ownKeys = Object.keys; \ No newline at end of file diff --git a/src/js/utils/string/camelToKebab/camelToKebab.test.ts b/src/js/utils/string/camelToKebab/camelToKebab.test.ts deleted file mode 100644 index a4904bae..00000000 --- a/src/js/utils/string/camelToKebab/camelToKebab.test.ts +++ /dev/null @@ -1,17 +0,0 @@ -import { camelToKebab } from './camelToKebab'; - - -describe( 'camelToKebab', () => { - test( 'can convert a string in the camel case to the kebab case.', () => { - expect( camelToKebab( 'maxWidth' ) ).toBe( 'max-width' ); - expect( camelToKebab( 'borderLeftWidth' ) ).toBe( 'border-left-width' ); - expect( camelToKebab( 'listStyleType' ) ).toBe( 'list-style-type' ); - - expect( camelToKebab( 'ButtonElement' ) ).toBe( 'button-element' ); - } ); - - test( 'should do nothing if the string is already described in the kebab case.', () => { - expect( camelToKebab( 'max-width' ) ).toBe( 'max-width' ); - expect( camelToKebab( 'border-left-width' ) ).toBe( 'border-left-width' ); - } ); -} ); diff --git a/src/js/utils/string/camelToKebab/camelToKebab.ts b/src/js/utils/string/camelToKebab/camelToKebab.ts deleted file mode 100644 index 9875aabe..00000000 --- a/src/js/utils/string/camelToKebab/camelToKebab.ts +++ /dev/null @@ -1,8 +0,0 @@ -/** - * Converts the provided string in the camel case to the kebab case. - * - * @param string - A string to convert. - */ -export function camelToKebab( string: string ): string { - return string.replace( /([a-z0-9])([A-Z])/g, '$1-$2' ).toLowerCase(); -} diff --git a/src/js/utils/string/format/format.test.ts b/src/js/utils/string/format/format.test.ts deleted file mode 100644 index d4dd10e1..00000000 --- a/src/js/utils/string/format/format.test.ts +++ /dev/null @@ -1,9 +0,0 @@ -import { format } from './format'; - - -describe( 'format', () => { - test( 'can replace %s with provided replacements', () => { - expect( format( '%s results', 10 ) ).toBe( '10 results' ); - expect( format( '%s/%s', [ 1, 10 ] ) ).toBe( '1/10' ); - } ); -} ); diff --git a/src/js/utils/string/format/format.ts b/src/js/utils/string/format/format.ts deleted file mode 100644 index e96f0dc5..00000000 --- a/src/js/utils/string/format/format.ts +++ /dev/null @@ -1,18 +0,0 @@ -import { forEach } from '../../array'; - - -/** - * Formats a string. - * - * @param string - A string to format. - * @param replacements - A replacement or replacements. - * - * @return A formatted string. - */ -export function format( string: string, replacements: string | number | Array ): string { - forEach( replacements, replacement => { - string = string.replace( '%s', `${ replacement }` ); - } ); - - return string; -} diff --git a/src/js/utils/string/index.ts b/src/js/utils/string/index.ts deleted file mode 100644 index 58694ce1..00000000 --- a/src/js/utils/string/index.ts +++ /dev/null @@ -1,4 +0,0 @@ -export { camelToKebab } from './camelToKebab/camelToKebab'; -export { format } from './format/format'; -export { pad } from './pad/pad'; -export { uniqueId } from './uniqueId/uniqueId'; diff --git a/src/js/utils/string/pad/pad.test.ts b/src/js/utils/string/pad/pad.test.ts deleted file mode 100644 index a8c7a4b3..00000000 --- a/src/js/utils/string/pad/pad.test.ts +++ /dev/null @@ -1,14 +0,0 @@ -import { pad } from './pad'; - - -describe( 'pad', () => { - test( 'can pad a number with 0.', () => { - expect( pad( 1 ) ).toBe( '01' ); - expect( pad( 5 ) ).toBe( '05' ); - } ); - - test( 'should not pad if the number is greater than 9.', () => { - expect( pad( 10 ) ).toBe( '10' ); - expect( pad( 11 ) ).toBe( '11' ); - } ); -} ); diff --git a/src/js/utils/string/pad/pad.ts b/src/js/utils/string/pad/pad.ts deleted file mode 100644 index 61e28284..00000000 --- a/src/js/utils/string/pad/pad.ts +++ /dev/null @@ -1,10 +0,0 @@ -/** - * Pads the number with 0. - * - * @param number - A number to pad. - * - * @return string - Padded number. - */ -export function pad( number: number ): string { - return number < 10 ? `0${ number }` : `${ number }`; -} diff --git a/src/js/utils/string/uniqueId/uniqueId.test.ts b/src/js/utils/string/uniqueId/uniqueId.test.ts deleted file mode 100644 index d227614b..00000000 --- a/src/js/utils/string/uniqueId/uniqueId.test.ts +++ /dev/null @@ -1,18 +0,0 @@ -import { uniqueId } from './uniqueId'; - - -describe( 'uniqueId', () => { - test( 'can generate a sequential unique ID.', () => { - expect( uniqueId( 'container-' ) ).toBe( 'container-01' ); - expect( uniqueId( 'container-' ) ).toBe( 'container-02' ); - - expect( uniqueId( 'button-' ) ).toBe( 'button-01' ); - expect( uniqueId( 'button-' ) ).toBe( 'button-02' ); - - expect( uniqueId( 'container-' ) ).toBe( 'container-03' ); - expect( uniqueId( 'container-' ) ).toBe( 'container-04' ); - - expect( uniqueId( 'button-' ) ).toBe( 'button-03' ); - expect( uniqueId( 'button-' ) ).toBe( 'button-04' ); - } ); -} ); diff --git a/src/js/utils/string/uniqueId/uniqueId.ts b/src/js/utils/string/uniqueId/uniqueId.ts deleted file mode 100644 index 2ba55f6c..00000000 --- a/src/js/utils/string/uniqueId/uniqueId.ts +++ /dev/null @@ -1,18 +0,0 @@ -import { pad } from '../pad/pad'; - - -/** - * Stores unique IDs. - * - * @since 3.0.0 - */ -const ids: Record = {}; - -/** - * Returns a sequential unique ID as "{ prefix }-{ number }". - * - * @param prefix - A prefix for the ID. - */ -export function uniqueId( prefix: string ): string { - return `${ prefix }${ pad( ( ids[ prefix ] = ( ids[ prefix ] || 0 ) + 1 ) ) }`; -} diff --git a/src/js/utils/type/type.test.ts b/src/js/utils/type/type.test.ts deleted file mode 100644 index 1cf2d421..00000000 --- a/src/js/utils/type/type.test.ts +++ /dev/null @@ -1,134 +0,0 @@ -import { - isArray, - isFunction, - isHTMLElement, - isNull, - isObject, - isString, - isUndefined, -} from './type'; - - -describe( 'Type methods', () => { - describe( 'isObject', () => { - test( 'can return `true` if a subject is an object.', () => { - [ {}, { a: 1 }, new Date() ].forEach( subject => { - expect( isObject( subject ) ).toBe( true ); - } ); - } ); - - test( 'should return `false` for other subjects.', () => { - [ 1, 'a', true, undefined, null, NaN ].forEach( subject => { - expect( isObject( subject ) ).toBe( false ); - } ); - } ); - } ); - - describe( 'isArray', () => { - test( 'can return `true` if a subject is an array.', () => { - [ [], [ 1 ], new Array( 1 ) ].forEach( subject => { - expect( isArray( subject ) ).toBe( true ); - } ); - } ); - - test( 'should return `false` for other subjects.', () => { - [ 1, 'a', true, undefined, null, { length: 1 }, { a: 1 }, NaN ].forEach( subject => { - expect( isArray( subject ) ).toBe( false ); - } ); - } ); - } ); - - describe( 'isFunction', () => { - test( 'can return `true` if a subject is a function.', () => { - [ () => 1, isString, Date ].forEach( subject => { - expect( isFunction( subject ) ).toBe( true ); - } ); - } ); - - test( 'should return `false` for other subjects.', () => { - [ 1, 'a', true, undefined, null, [ 1 ], { a: 1 }, NaN ].forEach( subject => { - expect( isFunction( subject ) ).toBe( false ); - } ); - } ); - } ); - - describe( 'isString', () => { - test( 'can return `true` if a subject is a string.', () => { - [ '1', String( 1 ) ].forEach( subject => { - expect( isString( subject ) ).toBe( true ); - } ); - } ); - - test( 'should return `false` for other subjects.', () => { - [ 1, true, undefined, null, [ 1 ], { a: 1 }, NaN ].forEach( subject => { - expect( isString( subject ) ).toBe( false ); - } ); - } ); - } ); - - describe( 'isUndefined', () => { - test( 'can return `true` if a subject is `undefined`.', () => { - expect( isUndefined( undefined ) ).toBe( true ); - } ); - - test( 'should return `false` for other subjects.', () => { - [ 1, true, '1', null, [ 1 ], { a: 1 }, NaN ].forEach( subject => { - expect( isUndefined( subject ) ).toBe( false ); - } ); - } ); - } ); - - describe( 'isNull', () => { - test( 'can return `true` if a subject is `null`.', () => { - expect( isNull( null ) ).toBe( true ); - } ); - - test( 'should return `false` for other subjects.', () => { - [ 1, true, '1', undefined, [ 1 ], { a: 1 }, NaN ].forEach( subject => { - expect( isNull( subject ) ).toBe( false ); - } ); - } ); - } ); -} ); - -describe( 'isHTMLElement', () => { - const div = document.createElement( 'div' ); - const text = document.createTextNode( 'test' ); - - document.body.innerHTML = ''; - - test( 'can return `true` if a subject is an HTMLElement.', () => { - expect( isHTMLElement( div ) ).toBe( true ); - } ); - - test( 'should return `false` for other subjects.', () => { - [ document, window, text, 1, true, undefined, '1', null, [ 1 ], { a: 1 }, NaN ].forEach( subject => { - expect( isHTMLElement( subject ) ).toBe( false ); - } ); - } ); - - test( 'should work for nodes coming from other realms.', () => { - const iframe = document.querySelector( 'iframe' ); - - expect( iframe ).toBeTruthy(); - - const { contentDocument, contentWindow } = iframe; - const iDiv = contentDocument.createElement( 'div' ); - - expect( contentWindow ).not.toBe( window ); - - // This should fail since `HTMLElement` is different with the iframe's. - expect( iDiv instanceof HTMLElement ).toBe( false ); - - // But this method will work since checking owners. - expect( isHTMLElement( iDiv ) ).toBe( true ); - } ); - - test( 'should work for nodes that do not belong to a specific window.', () => { - const div = new DOMParser().parseFromString( '
    ', 'text/html' ).body.firstElementChild; - - expect( div ).toBeTruthy(); - expect( div.ownerDocument.defaultView ).toBeNull(); - expect( isHTMLElement( div ) ).toBe( true ); - } ); -} ); \ No newline at end of file diff --git a/src/js/utils/type/type.ts b/src/js/utils/type/type.ts deleted file mode 100644 index 847d1629..00000000 --- a/src/js/utils/type/type.ts +++ /dev/null @@ -1,89 +0,0 @@ -import { AnyFunction } from '../../types'; -import { apply } from '../function'; - - -/** - * The alias of the type check function. - * - * @param type - A type. - * @param subject - A subject to check. - * - * @return `true` if the subject is the specified type. - */ -function typeOf( type: string, subject: unknown ): boolean { - return typeof subject === type; -} - -/** - * Checks if the given subject is an object or not. - * - * @param subject - A subject to check. - * - * @return `true` if the subject is an object, or otherwise `false`. - */ -export function isObject( subject: unknown ): subject is object { - return ! isNull( subject ) && typeOf( 'object', subject ); -} - -/** - * Checks if the given subject is an array or not. - * - * @param subject - A subject to check. - * - * @return `true` if the subject is an array, or otherwise `false`. - */ -export const isArray: ( subject: unknown ) => subject is T[] = Array.isArray; - -/** - * Checks if the given subject is a function or not. - * - * @param subject - A subject to check. - * - * @return `true` if the subject is a function, or otherwise `false`. - */ -export const isFunction = <( subject: unknown ) => subject is AnyFunction>apply( typeOf, 'function' ); - -/** - * Checks if the given subject is a string or not. - * - * @param subject - A subject to check. - * - * @return `true` if the subject is a string, or otherwise `false`. - */ -export const isString = <( subject: unknown ) => subject is string>apply( typeOf, 'string' ); - -/** - * Checks if the given subject is `undefined` or not. - * - * @param subject - A subject to check. - * - * @return `true` if the subject is `undefined`, or otherwise `false`. - */ -export const isUndefined = <( subject: unknown ) => subject is undefined>apply( typeOf, 'undefined' ); - -/** - * Checks if the given subject is `null` or not. - * - * @param subject - A subject to check. - * - * @return `true` if the subject is `null`, or otherwise `false`. - */ -export function isNull( subject: unknown ): subject is null { - return subject === null; -} - -/** - * Checks if the given subject is an HTMLElement instance or not. - * This method takes into account which `window` the node belongs to. - * - * @param subject - A subject to check. - * - * @return `true` if the subject is an HTMLElement instance, or otherwise `false`. - */ -export function isHTMLElement( subject: unknown ): subject is HTMLElement { - try { - return subject instanceof ( ( subject as Node ).ownerDocument.defaultView || window ).HTMLElement; - } catch ( e ) { - return false; - } -} \ No newline at end of file diff --git a/src/js/test/utils/index.ts b/src/test/index.ts similarity index 100% rename from src/js/test/utils/index.ts rename to src/test/index.ts diff --git a/src/test/jest/setup.ts b/src/test/jest/setup.ts new file mode 100644 index 00000000..3f48b5a6 --- /dev/null +++ b/src/test/jest/setup.ts @@ -0,0 +1,10 @@ +window.matchMedia = () => ({ + matches: false, // All queries match the media string. + media: '', + onchange: null, + addListener: jest.fn(), + removeListener: jest.fn(), + addEventListener: jest.fn(), + removeEventListener: jest.fn(), + dispatchEvent: jest.fn(), +} as MediaQueryList); \ No newline at end of file diff --git a/src/test/utils/constants/index.ts b/src/test/utils/constants/index.ts new file mode 100644 index 00000000..1aef9f47 --- /dev/null +++ b/src/test/utils/constants/index.ts @@ -0,0 +1,14 @@ +/** + * The fake url. + */ +export const FAKE_URL = 'https://test.com'; + +/** + * The root and track width. + */ +export const SLIDER_WIDTH = 1280; + +/** + * Random sizes for autoWidth or autoHeight. + */ +export const RANDOM_SIZES = ['300px', '200px', '400px', '600px']; \ No newline at end of file diff --git a/src/test/utils/helpers/index.ts b/src/test/utils/helpers/index.ts new file mode 100644 index 00000000..c50f38a2 --- /dev/null +++ b/src/test/utils/helpers/index.ts @@ -0,0 +1,191 @@ +import { assign, assert } from '@splidejs/utils'; +import { CLASS_LIST, CLASS_ROOT, CLASS_SLIDE, CLASS_TRACK, Options, Splide } from '../../../js'; +import { buildHtml, BuildHtmlConfig } from '../html'; +import { SLIDER_WIDTH } from '../constants'; + + +interface InitConfig extends BuildHtmlConfig { + mount?: boolean; + html?: string; + insertHtml?: boolean; +} + +const DOM_RECT = { + x: 0, + y: 0, + width: 0, + height: 0, + top: 0, + right: 0, + bottom: 0, + left: 0, + toJSON: () => '', +}; + +/** + * Creates a new splide instance. + * + * @param options - Options for Splide. + * @param config - Config for initialization. + * + * @return A created Splide instance. + */ +export function init(options: Options = {}, config: InitConfig = {}): Splide { + const { width = SLIDER_WIDTH, height = 0 } = options; + const { id, mount = true, html, insertHtml } = config; + + const slideWidth = +width / (options.perPage || 1); + const slideHeight = +height / (options.perPage || 1); + const innerHtml = html || buildHtml(config); + + if (insertHtml) { + if (!document.body.innerHTML) { + throw new Error('Invalid usage.'); + } + + document.body.insertAdjacentHTML('beforeend', innerHtml); + } else { + document.head.innerHTML = ''; + document.body.innerHTML = innerHtml; + } + + + const root = id ? document.getElementById(id) : document.querySelector(`.${ CLASS_ROOT }`); + + assert(root); + + const track = root.querySelector(`.${ CLASS_TRACK }`); + const list = root.querySelector(`.${ CLASS_LIST }`); + const slides = root.querySelectorAll(`.${ CLASS_SLIDE }`); + + assert(track); + assert(list); + + root.getBoundingClientRect = (): DOMRect => { + return assign({}, DOM_RECT, { width: +width }); + }; + + track.getBoundingClientRect = (): DOMRect => { + return assign({}, DOM_RECT, { width: +width, right: +width }); + }; + + list.getBoundingClientRect = (): DOMRect => { + return assign({}, DOM_RECT, { + width: +width, + ...parseTransform(list), + }); + }; + + setSlidesRect(Array.from(slides), list, slideWidth, slideHeight); + + const splide = new Splide(root as HTMLElement, options); + + if (mount) { + splide.mount(); + + // Can not simulate this method. + splide.Components.Move.canShift = () => true; + } + + return splide; +} + +/** + * Forcibly sets dimensions of provided slides. + * + * @param slides - An array with slides. + * @param list - A List element. + * @param width - Width of each slide. + * @param height - Height of each slide. + */ +export function setSlidesRect(slides: HTMLElement[], list: HTMLElement, width: number, height: number): void { + slides.forEach((slide, index) => { + slide.getBoundingClientRect = (): DOMRect => { + const offsets = parseTransform(list); + + return assign({}, DOM_RECT, { + width: width, + height: height, + left: width * index + offsets.left, + right: width * index + width + offsets.left, + top: height * index + offsets.top, + bottom: height * index + width + offsets.top, + }); + }; + }); +} + +/** + * Converts translate values to position. + * + * @param elm - An element to parse. + * + * @return An object with left and top offsets. + */ +export function parseTransform(elm: HTMLElement): { left: number, top: number } { + const position = { left: 0, top: 0 }; + + if (elm && elm.style.transform) { + const { transform } = elm.style; + + if (transform.includes('translateX')) { + position.left = parseFloat(transform.replace(/translateX\(|\)/g, '')) || 0; + } + + if (transform.includes('translateY')) { + position.top = parseFloat(transform.replace(/translateY\(|\)/g, '')) || 0; + } + } + + return position; +} + +/** + * Fires any native event manually. + * + * @param target - A target. + * @param type - An event type. + * @param data - Optional. Additional data. + * @param eventInitDict - Optional. An EventInit object. + * + * @return An event object. + */ +export function fire( + target: Window | Document | Element, + type: string, + data: any = {}, + eventInitDict: EventInit = {}, +): Event { + const e = new Event(type, eventInitDict); + + if (data.timeStamp !== undefined) { + Object.defineProperty(e, 'timeStamp', { value: data.timeStamp }); + delete data.timeStamp; + } + + target.dispatchEvent(Object.assign(e, data)); + return e; +} + +/** + * Emulates keydown. + * + * @param key - A key to press. + * @param target - A target. + */ +export function keydown(key: string, target: Window | Element = window): void { + fire(target, 'keydown', { key }); +} + +/** + * Returns a new Promise resolved after the specified duration. + * + * @param duration - Duration to wait. + * + * @return A Promise instance. + */ +export function wait(duration = 0): Promise { + return new Promise(resolve => { + setTimeout(resolve, duration); + }); +} diff --git a/src/test/utils/html/index.ts b/src/test/utils/html/index.ts new file mode 100644 index 00000000..ca71c8b9 --- /dev/null +++ b/src/test/utils/html/index.ts @@ -0,0 +1,153 @@ +import { RANDOM_SIZES, FAKE_URL } from '../constants'; +import { SRC_DATA_ATTRIBUTE, SRCSET_DATA_ATTRIBUTE } from '../../../js/components/LazyLoad/constants'; +import { INTERVAL_DATA_ATTRIBUTE } from '../../../js/components/Autoplay/constants'; +import { buildAttrs, classNames, isArray } from '@splidejs/utils'; +import { customArrows, customPagination, progressBar, toggleButton } from './parts'; +import { DATA_ATTRIBUTE } from '../../../js/constants/project'; + + +export interface BuildHtmlConfig extends GenerateSlidesConfig { + tag?: string; + id?: string; + heading?: string; + hasToggle?: boolean; + hasProgress?: boolean; + hasArrows?: boolean; + hasPagination?: boolean; + json?: string; +} + +/** + * Returns an HTML string for building a slider. + * + * @param config - Config. + * + * @return A built HTML. + */ +export function buildHtml(config: BuildHtmlConfig = {}): string { + const { tag = 'div', id = 'splide01', heading, json } = config; + const attrs: Record = { id }; + attrs[DATA_ATTRIBUTE] = json ? json.replace(/"/g, '"') : ''; + + return ` + ${ heading ? `

    ${ heading }

    ` : '' } + <${ tag } class="splide" ${ buildAttrs(attrs) }> +
    +
      + ${ generateSlides(config) } +
    +
    + + ${ config.hasProgress ? progressBar() : '' } + ${ config.hasToggle ? toggleButton() : '' } + ${ config.hasArrows ? customArrows() : '' } + ${ config.hasPagination ? customPagination() : '' } + + `; +} + +export interface GenerateSlidesConfig { + length?: number; + useImage?: boolean; + autoWidth?: boolean | number[]; + autoHeight?: boolean | number[]; + src?: boolean | string[]; + dataSrc?: boolean | string[]; + dataSrcset?: boolean | string[]; + dataInterval?: Array; + onRenderSlide?: (index: number) => RenderSlideReturnType; +} + +export interface RenderSlideReturnType { + attrs?: Parameters[0], + classes?: string | string[], + content?: string; +} + +/** + * Generates slides. + * + * @param config - A GenerateSlidesConfig object. + * + * @return Built HTML as string. + */ +export function generateSlides(config: GenerateSlidesConfig): string { + const { + length = 10, + useImage, + autoWidth, + autoHeight, + dataInterval, + onRenderSlide, + } = config; + + return Array.from({ length }).reduce((html, item, index) => { + const { attrs = {}, classes, content } = onRenderSlide ? onRenderSlide(index) : {} as RenderSlideReturnType; + + if (dataInterval) { + attrs[INTERVAL_DATA_ATTRIBUTE] = dataInterval[index]; + } + + if (autoWidth) { + const sizes = isArray(autoWidth) ? autoWidth : RANDOM_SIZES; + attrs.style = `width: ${ sizes[index % sizes.length] }`; + } + + if (autoHeight) { + const sizes = isArray(autoHeight) ? autoHeight : RANDOM_SIZES; + attrs.style = `height: ${ sizes[index % sizes.length] }`; + } + + html += `
  • `; + + if (content) { + html += content; + } else { + html += useImage ? generateImage(config, index) : index; + } + html += `
  • `; + return html; + }, ''); +} + +function generateImage(config: GenerateSlidesConfig, index: number): string { + const { src, dataSrc, dataSrcset } = config; + + const attrs: Record = {}; + attrs.src = generateImageUrl(src, index); + attrs[SRC_DATA_ATTRIBUTE] = generateImageUrl(dataSrc, index); + + const srcset = generateImageUrl(dataSrcset, index); + attrs[SRCSET_DATA_ATTRIBUTE] = isArray(dataSrcset) ? srcset : `${ srcset } 320w`; + + return ``; +} + +function generateImageUrl(srcLike: boolean | string[] | undefined, index: number): string | undefined { + if (srcLike) { + return isArray(srcLike) ? srcLike[index] : `${ FAKE_URL }/${ index }.jpg`; + } + + return undefined; +} + +export interface InsertHtmlConfig extends BuildHtmlConfig { + selector?: string; +} + +export function insertHtml(config: InsertHtmlConfig = {}): void { + const { selector = '#app' } = config; + let parent = document.querySelector(selector); + + if (!parent) { + parent = document.getElementById('app'); + } + + if (!parent) { + parent = document.createElement('div'); + parent.id = 'app'; + document.body.append(parent); + } + + parent.insertAdjacentHTML('beforeend', buildHtml(config)); +} \ No newline at end of file diff --git a/src/test/utils/html/parts/index.ts b/src/test/utils/html/parts/index.ts new file mode 100644 index 00000000..8bd2974b --- /dev/null +++ b/src/test/utils/html/parts/index.ts @@ -0,0 +1,34 @@ +export function toggleButton(): string { + return ` + + `; +} + +export function progressBar(): string { + return ` +
    +
    +
    +
    + `; +} + +export function customArrows(): string { + return ` +
    + + +
    + `; +} + +export function customPagination(): string { + return `
    `; +} \ No newline at end of file diff --git a/src/test/utils/index.ts b/src/test/utils/index.ts new file mode 100644 index 00000000..e6813bec --- /dev/null +++ b/src/test/utils/index.ts @@ -0,0 +1,3 @@ +export * from './helpers'; +export * from './constants'; +export * from './html'; diff --git a/tsconfig.dev.json b/tsconfig.dev.json new file mode 100644 index 00000000..228b0156 --- /dev/null +++ b/tsconfig.dev.json @@ -0,0 +1,16 @@ +{ + "extends": "./tsconfig.json", + "compilerOptions": { + "moduleResolution": "node", + "declarationDir": null, + "declaration": false, + "noEmit": true + }, + "include": [ + "src/js/**/*.ts", + "app/**/*.ts" + ], + "exclude": [ + "node_modules" + ], +} diff --git a/tsconfig.json b/tsconfig.json index 8ae658f2..8cbfbdfd 100644 --- a/tsconfig.json +++ b/tsconfig.json @@ -1,21 +1,21 @@ { "compilerOptions": { "outDir": "dist", - "target": "es6", + "target": "ESNext", + "module": "ESNext", + "lib": [ "ESNext", "DOM" ], "sourceMap": true, "mapRoot": "./", "moduleResolution": "node", "esModuleInterop": true, "skipLibCheck": true, "strict": true, - "strictNullChecks": false, - "suppressImplicitAnyIndexErrors": true, "declarationDir": "./dist/types", "declaration": true, - "lib": [ - "dom", - "es6" - ], + "paths": { + "@test": [ "./src/test" ], + "@test/*": [ "./src/test/*" ] + } }, "include": [ "src/js/**/*.ts", @@ -23,5 +23,8 @@ "exclude": [ "node_modules", "src/js/**/*.test.ts" - ] + ], + "ts-node": { + "swc": true + } } diff --git a/vite.config.ts b/vite.config.ts new file mode 100644 index 00000000..1c388614 --- /dev/null +++ b/vite.config.ts @@ -0,0 +1,12 @@ +import { defineConfig } from 'vite'; +import { resolve } from 'path'; + + +export default defineConfig({ + root: './app', + resolve: { + alias: { + "@test": resolve(__dirname, "./src/test"), + }, + }, +}); \ No newline at end of file