index.d.ts 46 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329133013311332133313341335133613371338133913401341134213431344134513461347134813491350135113521353135413551356135713581359136013611362136313641365136613671368136913701371137213731374137513761377137813791380138113821383138413851386138713881389139013911392139313941395139613971398139914001401140214031404140514061407140814091410141114121413141414151416141714181419142014211422142314241425142614271428142914301431143214331434143514361437143814391440144114421443144414451446144714481449145014511452145314541455145614571458145914601461146214631464146514661467146814691470147114721473147414751476147714781479148014811482148314841485148614871488148914901491149214931494149514961497149814991500150115021503150415051506150715081509151015111512151315141515151615171518151915201521152215231524152515261527152815291530153115321533153415351536153715381539154015411542154315441545154615471548154915501551155215531554155515561557155815591560156115621563156415651566156715681569157015711572157315741575157615771578157915801581158215831584158515861587158815891590159115921593159415951596159715981599160016011602160316041605160616071608160916101611161216131614161516161617161816191620162116221623162416251626162716281629163016311632163316341635163616371638163916401641164216431644164516461647164816491650165116521653165416551656165716581659166016611662166316641665166616671668166916701671167216731674
  1. /**
  2. * The interface for the Media component.
  3. *
  4. * @since 4.0.0
  5. */
  6. interface MediaComponent extends BaseComponent {
  7. /** @internal */
  8. reduce(reduced: boolean): void;
  9. set(options: Options, userOptions?: boolean): void;
  10. }
  11. /**
  12. * The interface for the Direction component.
  13. *
  14. * @since 3.0.0
  15. */
  16. interface DirectionComponent extends BaseComponent {
  17. resolve(prop: string, axisOnly?: boolean, direction?: Options['direction']): string;
  18. orient(value: number): number;
  19. }
  20. /**
  21. * The interface for elements which the slider consists of.
  22. *
  23. * @since 3.0.0
  24. */
  25. interface ElementCollection {
  26. root: HTMLElement;
  27. track: HTMLElement;
  28. list: HTMLElement;
  29. slides: HTMLElement[];
  30. arrows?: HTMLElement;
  31. pagination?: HTMLUListElement;
  32. prev?: HTMLButtonElement;
  33. next?: HTMLButtonElement;
  34. bar?: HTMLElement;
  35. toggle?: HTMLElement;
  36. }
  37. /**
  38. * The interface for the Elements component.
  39. *
  40. * @since 3.0.0
  41. */
  42. interface ElementsComponent extends BaseComponent, ElementCollection {
  43. }
  44. /**
  45. * The interface for the Slide sub component.
  46. *
  47. * @since 3.0.0
  48. */
  49. interface SlideComponent extends BaseComponent {
  50. index: number;
  51. slideIndex: number;
  52. slide: HTMLElement;
  53. container: HTMLElement;
  54. isClone: boolean;
  55. update(): void;
  56. style(prop: string, value: string | number, useContainer?: boolean): void;
  57. isWithin(from: number, distance: number): boolean;
  58. }
  59. /**
  60. * The interface for the Layout component.
  61. *
  62. * @since 3.0.0
  63. */
  64. interface LayoutComponent extends BaseComponent {
  65. listSize(): number;
  66. slideSize(index: number, withoutGap?: boolean): number;
  67. sliderSize(): number;
  68. totalSize(index?: number, withoutGap?: boolean): number;
  69. getPadding(right: boolean): number;
  70. }
  71. /**
  72. * The interface for the Clone component.
  73. *
  74. * @since 3.0.0
  75. */
  76. interface ClonesComponent extends BaseComponent {
  77. }
  78. /**
  79. * The interface for the Move component.
  80. *
  81. * @since 3.0.0
  82. */
  83. interface MoveComponent extends BaseComponent {
  84. move(dest: number, index: number, prev: number, callback?: AnyFunction): void;
  85. jump(index: number): void;
  86. translate(position: number, preventLoop?: boolean): void;
  87. shift(position: number, backwards: boolean): number;
  88. cancel(): void;
  89. toIndex(position: number): number;
  90. toPosition(index: number, trimming?: boolean): number;
  91. getPosition(): number;
  92. getLimit(max: boolean): number;
  93. exceededLimit(max?: boolean | undefined, position?: number): boolean;
  94. /** @internal */
  95. reposition(): void;
  96. }
  97. /**
  98. * The interface for the Controller component.
  99. *
  100. * @since 3.0.0
  101. */
  102. interface ControllerComponent extends BaseComponent {
  103. go(control: number | string, allowSameIndex?: boolean, callback?: AnyFunction): void;
  104. scroll(destination: number, duration?: number, snap?: boolean, callback?: AnyFunction): void;
  105. getNext(destination?: boolean): number;
  106. getPrev(destination?: boolean): number;
  107. getEnd(): number;
  108. setIndex(index: number): void;
  109. getIndex(prev?: boolean): number;
  110. toIndex(page: number): number;
  111. toPage(index: number): number;
  112. toDest(position: number): number;
  113. hasFocus(): boolean;
  114. isBusy(): boolean;
  115. /** @internal */
  116. getAdjacent(prev: boolean, destination?: boolean): number;
  117. }
  118. /**
  119. * The interface for the Arrows component.
  120. *
  121. * @since 3.0.0
  122. */
  123. interface ArrowsComponent extends BaseComponent {
  124. arrows: {
  125. prev?: HTMLButtonElement;
  126. next?: HTMLButtonElement;
  127. };
  128. }
  129. /**
  130. * The interface for the Autoplay component.
  131. *
  132. * @since 3.0.0
  133. */
  134. interface AutoplayComponent extends BaseComponent {
  135. play(): void;
  136. pause(): void;
  137. isPaused(): boolean;
  138. }
  139. /**
  140. * The interface for the Cover component.
  141. *
  142. * @since 3.0.0
  143. */
  144. interface CoverComponent extends BaseComponent {
  145. }
  146. /**
  147. * The interface for the Scroll component.
  148. *
  149. * @since 3.0.0
  150. */
  151. interface ScrollComponent extends BaseComponent {
  152. scroll(position: number, duration?: number, snap?: boolean, callback?: AnyFunction): void;
  153. cancel(): void;
  154. }
  155. /**
  156. * The interface for the Drag component.
  157. *
  158. * @since 3.0.0
  159. */
  160. interface DragComponent extends BaseComponent {
  161. disable(disabled: boolean): void;
  162. isDragging(): boolean;
  163. }
  164. /**
  165. * The interface for the Keyboard component.
  166. *
  167. * @since 3.0.0
  168. */
  169. interface KeyboardComponent extends BaseComponent {
  170. disable(disabled: boolean): void;
  171. }
  172. /**
  173. * The interface for the LazyLoad component.
  174. *
  175. * @since 3.0.0
  176. */
  177. interface LazyLoadComponent extends BaseComponent {
  178. }
  179. /**
  180. * The interface for the Pagination component.
  181. *
  182. * @since 3.0.0
  183. */
  184. interface PaginationComponent extends BaseComponent {
  185. items: PaginationItem[];
  186. getAt(index: number): PaginationItem;
  187. update(): void;
  188. }
  189. /**
  190. * The interface for data of the pagination.
  191. *
  192. * @since 3.0.0
  193. */
  194. interface PaginationData {
  195. list: HTMLUListElement;
  196. items: PaginationItem[];
  197. }
  198. /**
  199. * The interface for each pagination item.
  200. *
  201. * @since 3.0.0
  202. */
  203. interface PaginationItem {
  204. li: HTMLLIElement;
  205. button: HTMLButtonElement;
  206. page: number;
  207. }
  208. /**
  209. * The interface for the Sync component.
  210. *
  211. * @since 3.0.0
  212. */
  213. interface SyncComponent extends BaseComponent {
  214. remount(): void;
  215. }
  216. /**
  217. * The interface for the Wheel component.
  218. *
  219. * @since 3.0.0
  220. */
  221. interface WheelComponent extends BaseComponent {
  222. }
  223. /**
  224. * The interface for the Live component.
  225. *
  226. * @since 4.0.0
  227. */
  228. interface LiveComponent extends BaseComponent {
  229. disable(disabled: boolean): void;
  230. }
  231. /**
  232. * The collection of i18n strings.
  233. *
  234. * @since 3.0.0
  235. */
  236. declare const I18N: {
  237. prev: string;
  238. next: string;
  239. first: string;
  240. last: string;
  241. slideX: string;
  242. pageX: string;
  243. play: string;
  244. pause: string;
  245. carousel: string;
  246. slide: string;
  247. select: string;
  248. slideLabel: string;
  249. };
  250. /**
  251. * The interface for options.
  252. *
  253. * @since 3.0.0
  254. */
  255. interface Options extends ResponsiveOptions {
  256. /**
  257. * The type of the slider.
  258. * - 'slide': A slider with the slide transition
  259. * - 'loop' : A carousel slider
  260. * - 'fade' : A slider with the fade transition. This does not support the perPage option.
  261. */
  262. type?: string;
  263. /**
  264. * The `role` attribute for the root element.
  265. * If the tag is `<section>`, this value will not be used. The default value is `'region'`.
  266. */
  267. role?: string;
  268. /**
  269. * Determines whether to disable any actions while the slider is transitioning.
  270. * Even if `false`, the slider forcibly waits for transition on the loop points.
  271. */
  272. waitForTransition?: boolean;
  273. /**
  274. * If `true`, the width of slides are determined by their width.
  275. * The `perPage` and `perMove` options should be `1`.
  276. */
  277. autoWidth?: boolean;
  278. /**
  279. * If `true`, the height of slides are determined by their height.
  280. * The `perPage` and `perMove` options should be `1`.
  281. */
  282. autoHeight?: boolean;
  283. /**
  284. * The start index.
  285. */
  286. start?: number;
  287. /**
  288. * Changes the arrow SVG path, like 'm7.61 0.807-2.12...'.
  289. */
  290. arrowPath?: string;
  291. /**
  292. * Determines whether to activate autoplay or not.
  293. * If `paused`, it will not begin when the slider becomes active.
  294. * You need to provided play/pause buttons or manually start it by `Autoplay#play()`.
  295. */
  296. autoplay?: boolean | 'pause';
  297. /**
  298. * The autoplay interval in milliseconds.
  299. */
  300. interval?: number;
  301. /**
  302. * Determines whether to pause autoplay on mouseover.
  303. */
  304. pauseOnHover?: boolean;
  305. /**
  306. * Determines whether to pause autoplay when the slider contains the active element (focused element).
  307. * This should be `true` for accessibility.
  308. */
  309. pauseOnFocus?: boolean;
  310. /**
  311. * Determines whether to reset the autoplay progress when it is requested to start again.
  312. */
  313. resetProgress?: boolean;
  314. /**
  315. * Enables lazy loading.
  316. * Provide the `src` by the `data-splide-lazy` or the `srcset` by the `data-splide-lazy-srcset`.
  317. * You may also provide `src` for the placeholder, but the value must be different with the data.
  318. *
  319. * - `false`: Disables lazy loading
  320. * - `'nearby'`: Starts loading only images around the active slide (page)
  321. * - `'sequential'`: Loads images sequentially
  322. */
  323. lazyLoad?: boolean | 'nearby' | 'sequential';
  324. /**
  325. * Determine how many pages (not slides) around the active slide should be loaded beforehand.
  326. * This only works when the `lazyLoad` option is `'nearby'`.
  327. */
  328. preloadPages?: number;
  329. /**
  330. * Enables keyboard shortcuts for the slider control.
  331. * - `true` or `'global'`: Listens to the `keydown` event of the document.
  332. * - 'focused': Listens to the `keydown` event of the slider root element with adding `tabindex="0"` to it.
  333. * - `false`: Disables keyboard shortcuts (default).
  334. */
  335. keyboard?: boolean | 'global' | 'focused';
  336. /**
  337. * Enables navigation by the mouse wheel.
  338. * Set `waitForTransition` to `ture` or provide the `wheelSleep` duration.
  339. */
  340. wheel?: boolean;
  341. /**
  342. * The threshold to cut off the small delta produced by inertia scroll.
  343. */
  344. wheelMinThreshold?: number;
  345. /**
  346. * The sleep time in milliseconds until accepting next wheel.
  347. * The timer starts when the transition begins.
  348. */
  349. wheelSleep?: number;
  350. /**
  351. * Determines whether to release the wheel event when the slider reaches the first or last slide.
  352. */
  353. releaseWheel?: boolean;
  354. /**
  355. * The direction of the slider.
  356. * - 'ltr': Left to right
  357. * - 'rtl': Right to left
  358. * - 'ttb': Top to bottom
  359. */
  360. direction?: 'ltr' | 'rtl' | 'ttb';
  361. /**
  362. * Converts the image `src` to the css `background-image` URL of the parent element.
  363. * This requires `fixedHeight` or `heightRatio` option.
  364. */
  365. cover?: boolean;
  366. /**
  367. * Determines whether to add `tabindex="0"` to visible slides or not.
  368. */
  369. slideFocus?: boolean;
  370. /**
  371. * If `true`, the slider makes slides clickable to navigate another slider.
  372. * Use `Splide#sync()` to sync multiple sliders.
  373. */
  374. isNavigation?: boolean;
  375. /**
  376. * Determines whether to trim spaces before/after the slider if the `focus` option is available.
  377. * - `true`: Trims spaces. The slider may stay on the same location even when requested to move.
  378. * - `'move'`: Trims spaces and focuses to move the slider when requested.
  379. */
  380. trimSpace?: boolean | 'move';
  381. /**
  382. * Updates the `is-active` status of slides just before moving the slider.
  383. */
  384. updateOnMove?: boolean;
  385. /**
  386. * If `min`, the media query for breakpoints will be `min-width`, or otherwise, `max-width`.
  387. */
  388. mediaQuery?: 'min' | 'max';
  389. /**
  390. * The selector to find focusable elements
  391. * where `tabindex="-1"` will be assigned when their ascendant slide is hidden.
  392. */
  393. focusableNodes?: string;
  394. /**
  395. * The selector for nodes that cannot be dragged.
  396. */
  397. noDrag?: string;
  398. /**
  399. * Enables the live region by `aria-live`.
  400. * If `true`, screen readers will read a content of each slide whenever slide changes.
  401. */
  402. live?: boolean;
  403. /**
  404. * Determines whether to use the Transition component or not.
  405. */
  406. useScroll?: boolean;
  407. /**
  408. * Options for specific breakpoints.
  409. *
  410. * @example
  411. * ```ts
  412. * {
  413. * 1000: {
  414. * perPage: 3,
  415. * gap : 20
  416. * },
  417. * 600: {
  418. * perPage: 1,
  419. * gap : 5,
  420. * },
  421. * }
  422. * ```
  423. */
  424. breakpoints?: Record<string | number, ResponsiveOptions>;
  425. /**
  426. * Options used when the `(prefers-reduced-motion: reduce)` is detected.
  427. */
  428. reducedMotion?: Options;
  429. /**
  430. * The collection of class names.
  431. */
  432. classes?: Record<string, string>;
  433. /**
  434. * The collection of i18n strings.
  435. */
  436. i18n?: Record<keyof typeof I18N | string, string>;
  437. }
  438. /**
  439. * The interface for options that can correspond with breakpoints.
  440. *
  441. * @since 3.0.0
  442. */
  443. interface ResponsiveOptions {
  444. /**
  445. * Accepts arbitrary properties for extensions, although it's not ideal typing.
  446. */
  447. [key: string]: any;
  448. /**
  449. * The label for the root element.
  450. * Use `labelledby` instead if there is a visible label.
  451. */
  452. label?: string;
  453. /**
  454. * The ID for the element that used as the label of the carousel.
  455. */
  456. labelledby?: string;
  457. /**
  458. * The transition speed in milliseconds.
  459. */
  460. speed?: number;
  461. /**
  462. * Determines whether to rewind the carousel or not.
  463. * This is ignored when the `type` option is `'loop'`.
  464. */
  465. rewind?: boolean;
  466. /**
  467. * The transition speed on rewind in milliseconds.
  468. */
  469. rewindSpeed?: number;
  470. /**
  471. * Allows to rewind a carousel by drag if the `rewind` option is enabled.
  472. */
  473. rewindByDrag?: boolean;
  474. /**
  475. * Defines the slider max width, accepting the CSS format such as 10em, 80vw.
  476. */
  477. width?: number | string;
  478. /**
  479. * Defines the slider height, accepting the CSS format.
  480. */
  481. height?: number | string;
  482. /**
  483. * Fixes width of slides, accepting the CSS format.
  484. * The slider will ignore the `perPage` option if you provide this value.
  485. */
  486. fixedWidth?: number | string;
  487. /**
  488. * Fixes height of slides, accepting the CSS format.
  489. * The slider will ignore the `heightRatio` option if you provide this value.
  490. */
  491. fixedHeight?: number | string;
  492. /**
  493. * Determines height of slides by the ratio to the slider width.
  494. * For example, when the slider width is `1000` and the ratio is `0.5`, the height will be `500`.
  495. */
  496. heightRatio?: number;
  497. /**
  498. * Determines the number of slides to display in a page.
  499. */
  500. perPage?: number;
  501. /**
  502. * Determines the number of slides to move at once.
  503. */
  504. perMove?: number;
  505. /**
  506. * Determine the number of clones on each side of the slider.
  507. * In most cases, you don't need to provide this value.
  508. */
  509. clones?: number;
  510. /**
  511. * Determines whether to clone status classes for clones or not.
  512. */
  513. cloneStatus?: boolean;
  514. /**
  515. * Determines which slide should be active if there are multiple slides in a page.
  516. * Numbers and `'center'` are acceptable.
  517. */
  518. focus?: number | 'center';
  519. /**
  520. * The gap between slides. The CSS format is acceptable, such as `1em`.
  521. */
  522. gap?: number | string;
  523. /**
  524. * Sets padding left/right or top/bottom of the slider.
  525. * The CSS format is acceptable, such as `1em`.
  526. *
  527. * @example
  528. * ```ts
  529. * // By number
  530. * padding: 10,
  531. *
  532. * // By the CSS format
  533. * padding: '1rem',
  534. *
  535. * // Specifies each value for a horizontal slider
  536. * padding: { left: 10, right: 20 },
  537. * padding: { left: '1rem', right: '2rem' },
  538. *
  539. * // Specified each value for a vertical slider
  540. * padding: { top: 10, bottom: 20 },
  541. * ```
  542. */
  543. padding?: number | string | {
  544. left?: number | string;
  545. right?: number | string;
  546. } | {
  547. top?: number | string;
  548. bottom?: number | string;
  549. };
  550. /**
  551. * Determines whether to create/find arrows or not.
  552. */
  553. arrows?: boolean;
  554. /**
  555. * Determines whether to create pagination (indicator dots) or not.
  556. */
  557. pagination?: boolean;
  558. /**
  559. * Determines whether to enable keyboard shortcuts for pagination when it contains focus.
  560. * The default value is `true`.
  561. */
  562. paginationKeyboard?: boolean;
  563. /**
  564. * Explicitly sets the pagination direction that does not only affect appearance but also shortcuts and ARIA attributes.
  565. * The default value is same with the carousel direction.
  566. */
  567. paginationDirection?: Options['direction'];
  568. /**
  569. * The timing function for the CSS transition. For example, `linear`, ease or `cubic-bezier()`.
  570. */
  571. easing?: string;
  572. /**
  573. * The easing function for the drag free mode.
  574. * The default function is the `easeOutQuart` interpolation.
  575. */
  576. easingFunc?: (t: number) => number;
  577. /**
  578. * Allows to drag the slider by a mouse or swipe.
  579. * If `free`, the slider does not snap to a slide after drag.
  580. */
  581. drag?: boolean | 'free';
  582. /**
  583. * Snaps the closest slide in the drag-free mode.
  584. */
  585. snap?: boolean;
  586. /**
  587. * The required distance to start moving the slider by the touch action.
  588. * If you want to define the threshold for the mouse, provide an object.
  589. */
  590. dragMinThreshold?: number | {
  591. mouse: number;
  592. touch: number;
  593. };
  594. /**
  595. * Determine the power of "flick". The larger number this is, the farther the slider runs.
  596. * Around 500 is recommended.
  597. */
  598. flickPower?: number;
  599. /**
  600. * Limits the number of pages to move by "flick".
  601. */
  602. flickMaxPages?: number;
  603. /**
  604. * Destroys the slider.
  605. */
  606. destroy?: boolean | 'completely';
  607. }
  608. /**
  609. * The type for any function.
  610. *
  611. * @since 3.0.0
  612. */
  613. declare type AnyFunction = (...args: any[]) => any;
  614. /**
  615. * The type for a component.
  616. *
  617. * @since 3.0.0
  618. */
  619. declare type ComponentConstructor = (Splide: Splide, Components: Components, options: Options) => BaseComponent;
  620. /**
  621. * The interface for any component.
  622. *
  623. * @since 3.0.0
  624. */
  625. interface BaseComponent {
  626. setup?(): void;
  627. mount?(): void;
  628. destroy?(completely?: boolean): void;
  629. }
  630. /**
  631. * The interface for the Transition component.
  632. *
  633. * @since 3.0.0
  634. */
  635. interface TransitionComponent extends BaseComponent {
  636. start(index: number, done: () => void): void;
  637. cancel(): void;
  638. }
  639. /**
  640. * The interface for info of a splide instance to sync with.
  641. *
  642. * @since 3.2.8
  643. */
  644. interface SyncTarget {
  645. splide: Splide;
  646. isParent?: boolean;
  647. }
  648. /**
  649. * The interface for all components.
  650. *
  651. * @since 3.0.0
  652. */
  653. interface Components {
  654. [key: string]: BaseComponent;
  655. Media: MediaComponent;
  656. Direction: DirectionComponent;
  657. Elements: ElementsComponent;
  658. Slides: SlidesComponent;
  659. Layout: LayoutComponent;
  660. Clones: ClonesComponent;
  661. Move: MoveComponent;
  662. Controller: ControllerComponent;
  663. Arrows: ArrowsComponent;
  664. Autoplay: AutoplayComponent;
  665. Cover: CoverComponent;
  666. Scroll: ScrollComponent;
  667. Drag: DragComponent;
  668. Keyboard: KeyboardComponent;
  669. LazyLoad: LazyLoadComponent;
  670. Pagination: PaginationComponent;
  671. Sync: SyncComponent;
  672. Wheel: WheelComponent;
  673. Live: LiveComponent;
  674. Transition: TransitionComponent;
  675. }
  676. /**
  677. * The interface for all internal events.
  678. *
  679. * @since 3.0.0
  680. */
  681. interface EventMap {
  682. 'mounted': () => void;
  683. 'ready': () => void;
  684. 'click': (Slide: SlideComponent, e: MouseEvent) => void;
  685. 'move': (index: number, prev: number, dest: number) => void;
  686. 'moved': (index: number, prev: number, dest: number) => void;
  687. 'active': (Slide: SlideComponent) => void;
  688. 'inactive': (Slide: SlideComponent) => void;
  689. 'visible': (Slide: SlideComponent) => void;
  690. 'hidden': (Slide: SlideComponent) => void;
  691. 'refresh': () => void;
  692. 'updated': (options: Options) => void;
  693. 'resize': () => void;
  694. 'resized': () => void;
  695. 'drag': () => void;
  696. 'dragging': () => void;
  697. 'dragged': () => void;
  698. 'scroll': () => void;
  699. 'scrolled': () => void;
  700. 'destroy': () => void;
  701. 'arrows:mounted': (prev: HTMLButtonElement, next: HTMLButtonElement) => void;
  702. 'arrows:updated': (prev: HTMLButtonElement, next: HTMLButtonElement, prevIndex: number, nextIndex: number) => void;
  703. 'pagination:mounted': (data: PaginationData, item: PaginationItem) => void;
  704. 'pagination:updated': (data: PaginationData, prev: PaginationItem, curr: PaginationItem) => void;
  705. 'navigation:mounted': (splides: Splide[]) => void;
  706. 'autoplay:play': () => void;
  707. 'autoplay:playing': (rate: number) => void;
  708. 'autoplay:pause': () => void;
  709. 'lazyload:loaded': (img: HTMLImageElement, Slide: SlideComponent) => void;
  710. /** @internal */
  711. 'shifted': () => void;
  712. 'slide:keydown': (Slide: SlideComponent, e: KeyboardEvent) => void;
  713. 'media': (query: MediaQueryList) => void;
  714. }
  715. /**
  716. * Casts T to U.
  717. *
  718. * @internal
  719. */
  720. declare type Cast<T, U> = T extends U ? T : U;
  721. /**
  722. * Makes the T easy to read.
  723. */
  724. declare type Resolve<T> = {
  725. [K in keyof T]: T[K];
  726. } & unknown;
  727. /**
  728. * Pushes U to tuple T.
  729. *
  730. * @internal
  731. */
  732. declare type Push<T extends any[], U = any> = [...T, U];
  733. /**
  734. * Returns the first type of the tuple.
  735. *
  736. * @internal
  737. */
  738. declare type Head<T extends any[]> = ((...args: T) => any) extends (arg: infer A, ...args: any[]) => any ? A : never;
  739. /**
  740. * Removes the first type from the tuple T.
  741. *
  742. * @internal
  743. */
  744. declare type Shift<T extends any[]> = ((...args: T) => any) extends (arg: any, ...args: infer A) => any ? A : never;
  745. /**
  746. * Removes the N types from the tuple T.
  747. *
  748. * @internal
  749. */
  750. declare type ShiftN<T extends any[], N extends number, C extends any[] = []> = {
  751. 0: T;
  752. 1: ShiftN<Shift<T>, N, Push<C>>;
  753. }[C['length'] extends N ? 0 : 1] extends infer A ? Cast<A, any[]> : never;
  754. /**
  755. * The interface for the Slides component.
  756. *
  757. * @since 3.0.0
  758. */
  759. interface SlidesComponent extends BaseComponent {
  760. update(): void;
  761. register(slide: HTMLElement, index: number, slideIndex: number): void;
  762. get(excludeClones?: boolean): SlideComponent[];
  763. getIn(page: number): SlideComponent[];
  764. getAt(index: number): SlideComponent | undefined;
  765. add(slide: string | Element | Array<string | Element>, index?: number): void;
  766. remove(selector: SlideMatcher): void;
  767. forEach(iteratee: SlidesIteratee, excludeClones?: boolean): void;
  768. filter(matcher: SlideMatcher): SlideComponent[];
  769. style(prop: string, value: string | number, useContainer?: boolean): void;
  770. getLength(excludeClones?: boolean): number;
  771. isEnough(): boolean;
  772. }
  773. /**
  774. * The iteratee function for Slides.
  775. *
  776. * @since 3.0.0
  777. */
  778. declare type SlidesIteratee = (Slide: SlideComponent, index: number, Slides: SlideComponent[]) => void;
  779. /**
  780. * The predicate function for Slides.
  781. *
  782. * @since 3.0.0
  783. */
  784. declare type SlidesPredicate = (Slide: SlideComponent, index: number, Slides: SlideComponent[]) => any;
  785. /**
  786. * The type for filtering SlideComponent objects.
  787. *
  788. * @since 3.0.0
  789. */
  790. declare type SlideMatcher = number | number[] | string | SlidesPredicate;
  791. /**
  792. * The type for an EventTarget or an array with EventTarget objects.
  793. *
  794. * @since 4.0.0
  795. */
  796. declare type EventTargets = EventTarget | EventTarget[];
  797. /**
  798. * The interface for the EventBinder object.
  799. *
  800. * @since 3.0.0
  801. */
  802. interface EventBinderObject {
  803. bind(target: EventTargets, events: string | string[], callback: AnyFunction, options?: AddEventListenerOptions): void;
  804. unbind(target: EventTarget | EventTarget[], events: string | string[], callback?: AnyFunction): void;
  805. dispatch<T>(target: EventTarget, event: string, detail?: T): void;
  806. destroy(): void;
  807. }
  808. /**
  809. * The constructor function to provide methods to subscribe native events.
  810. *
  811. * @since 4.0.0
  812. * @constructor
  813. *
  814. * @return An EventBinder object.
  815. */
  816. declare function EventBinder(): EventBinderObject;
  817. /**
  818. * The interface for the EventInterface object.
  819. *
  820. * @since 3.0.0
  821. */
  822. interface EventInterfaceObject extends EventBinderObject {
  823. on<K extends keyof EventMap>(event: K, callback: EventMap[K]): void;
  824. on(events: string | string[], callback: AnyFunction): void;
  825. off<K extends keyof EventMap>(events: K | K[] | string | string[]): void;
  826. emit<K extends keyof EventMap>(event: K, ...args: Parameters<EventMap[K]>): void;
  827. emit(event: string, ...args: any[]): void;
  828. /** @internal */
  829. bus: DocumentFragment;
  830. }
  831. /**
  832. * The constructor function that provides interface for internal and native events.
  833. *
  834. * @since 3.0.0
  835. * @constructor
  836. *
  837. * @param Splide - A Splide instance.
  838. *
  839. * @return A collection of interface functions.
  840. */
  841. declare function EventInterface(Splide?: Splide): EventInterfaceObject;
  842. /**
  843. * The interface for the returning value of the RequestInterval.
  844. *
  845. * @since 3.0.0
  846. */
  847. interface RequestIntervalInterface {
  848. start(resume?: boolean): void;
  849. pause(): void;
  850. rewind(): void;
  851. cancel(): void;
  852. set(interval: number): void;
  853. isPaused(): boolean;
  854. }
  855. /**
  856. * Requests interval like the native `setInterval()` with using `requestAnimationFrame`.
  857. *
  858. * @since 3.0.0
  859. *
  860. * @param interval - The interval duration in milliseconds.
  861. * @param onInterval - The callback fired on every interval.
  862. * @param onUpdate - Optional. Called on every animation frame, taking the progress rate.
  863. * @param limit - Optional. Limits the number of interval.
  864. */
  865. declare function RequestInterval(interval: number, onInterval: () => void, onUpdate?: (rate: number) => void, limit?: number): RequestIntervalInterface;
  866. /**
  867. * The interface for the State object.
  868. *
  869. * @since 3.0.0
  870. */
  871. interface StateObject {
  872. set(state: number): void;
  873. is(states: number | number[]): boolean;
  874. }
  875. /**
  876. * The function providing a super simple state system.
  877. *
  878. * @param initialState - Specifies the initial state.
  879. */
  880. declare function State(initialState: number): StateObject;
  881. /**
  882. * The interface for the returning value of the RequestInterval.
  883. *
  884. * @since 3.0.0
  885. */
  886. interface ThrottleInstance<F extends AnyFunction> extends Function {
  887. (...args: Parameters<F>): void;
  888. }
  889. /**
  890. * Returns the throttled function.
  891. *
  892. * @param func - A function to throttle.
  893. * @param duration - Optional. Throttle duration in milliseconds.
  894. *
  895. * @return A throttled function.
  896. */
  897. declare function Throttle<F extends AnyFunction>(func: F, duration?: number): ThrottleInstance<F>;
  898. /**
  899. * The frontend class for the Splide slider.
  900. *
  901. * @since 3.0.0
  902. */
  903. declare class Splide {
  904. /**
  905. * Changes the default options for all Splide instances.
  906. */
  907. static defaults: Options;
  908. /**
  909. * The collection of state numbers.
  910. */
  911. static readonly STATES: {
  912. CREATED: number;
  913. MOUNTED: number;
  914. IDLE: number;
  915. MOVING: number;
  916. SCROLLING: number;
  917. DRAGGING: number;
  918. DESTROYED: number;
  919. };
  920. /**
  921. * The root element where the Splide is applied.
  922. */
  923. readonly root: HTMLElement;
  924. /**
  925. * The EventBusObject object.
  926. */
  927. readonly event: EventInterfaceObject;
  928. /**
  929. * The collection of all component objects.
  930. */
  931. readonly Components: Components;
  932. /**
  933. * The StateObject object.
  934. */
  935. readonly state: StateObject;
  936. /**
  937. * An array with SyncTarget objects for splide instances to sync with.
  938. */
  939. readonly splides: SyncTarget[];
  940. /**
  941. * The current options.
  942. */
  943. private readonly _o;
  944. /**
  945. * The collection of all components.
  946. */
  947. private _C;
  948. /**
  949. * The collection of extensions.
  950. */
  951. private _E;
  952. /**
  953. * The Transition component.
  954. */
  955. private _T;
  956. /**
  957. * The Splide constructor.
  958. *
  959. * @param target - The selector for the target element, or the element itself.
  960. * @param options - Optional. An object with options.
  961. */
  962. constructor(target: string | HTMLElement, options?: Options);
  963. /**
  964. * Initializes the instance.
  965. *
  966. * @param Extensions - Optional. An object with extensions.
  967. * @param Transition - Optional. A Transition component.
  968. *
  969. * @return `this`
  970. */
  971. mount(Extensions?: Record<string, ComponentConstructor>, Transition?: ComponentConstructor): this;
  972. /**
  973. * Syncs the slider with the provided one.
  974. * This method must be called before the `mount()`.
  975. *
  976. * @example
  977. * ```ts
  978. * var primary = new Splide();
  979. * var secondary = new Splide();
  980. *
  981. * primary.sync( secondary );
  982. * primary.mount();
  983. * secondary.mount();
  984. * ```
  985. *
  986. * @param splide - A Splide instance to sync with.
  987. *
  988. * @return `this`
  989. */
  990. sync(splide: Splide): this;
  991. /**
  992. * Moves the slider with the following control pattern.
  993. *
  994. * | Pattern | Description |
  995. * |---|---|
  996. * | `i` | Goes to the slide `i` |
  997. * | `'+${i}'` | Increments the slide index by `i` |
  998. * | `'-${i}'` | Decrements the slide index by `i` |
  999. * | `'>'` | Goes to the next page |
  1000. * | `'<'` | Goes to the previous page |
  1001. * | `>${i}` | Goes to the page `i` |
  1002. *
  1003. * In most cases, `'>'` and `'<'` notations are enough to control the slider
  1004. * because they respect `perPage` and `perMove` options.
  1005. *
  1006. * @example
  1007. * ```ts
  1008. * var splide = new Splide();
  1009. *
  1010. * // Goes to the slide 1:
  1011. * splide.go( 1 );
  1012. *
  1013. * // Increments the index:
  1014. * splide.go( '+2' );
  1015. *
  1016. * // Goes to the next page:
  1017. * splide.go( '>' );
  1018. *
  1019. * // Goes to the page 2:
  1020. * splide.go( '>2' );
  1021. * ```
  1022. *
  1023. * @param control - A control pattern.
  1024. *
  1025. * @return `this`
  1026. */
  1027. go(control: number | string): this;
  1028. /**
  1029. * Registers an event handler.
  1030. *
  1031. * @example
  1032. * ```ts
  1033. * var splide = new Splide();
  1034. *
  1035. * // Listens to a single event:
  1036. * splide.on( 'move', function() {} );
  1037. *
  1038. * // Listens to multiple events:
  1039. * splide.on( 'move resize', function() {} );
  1040. *
  1041. * // Appends a namespace:
  1042. * splide.on( 'move.myNamespace resize.myNamespace', function() {} );
  1043. * ```
  1044. *
  1045. * @param events - An event name or names separated by spaces. Use a dot(.) to append a namespace.
  1046. * @param callback - A callback function.
  1047. *
  1048. * @return `this`
  1049. */
  1050. on<K extends keyof EventMap>(events: K, callback: EventMap[K]): this;
  1051. on(events: string | string[], callback: AnyFunction): this;
  1052. /**
  1053. * Removes the registered all handlers for the specified event or events.
  1054. * If you want to only remove a particular handler, use namespace to identify it.
  1055. *
  1056. * @example
  1057. * ```ts
  1058. * var splide = new Splide();
  1059. *
  1060. * // Removes all handlers assigned to "move":
  1061. * splide.off( 'move' );
  1062. *
  1063. * // Only removes handlers that belong to the specified namespace:
  1064. * splide.off( 'move.myNamespace' );
  1065. * ```
  1066. *
  1067. * @param events - An event name or names separated by spaces. Use a dot(.) to append a namespace.
  1068. *
  1069. * @return `this`
  1070. */
  1071. off<K extends keyof EventMap>(events: K | K[] | string | string[]): this;
  1072. /**
  1073. * Emits an event and triggers registered handlers.
  1074. *
  1075. * @param event - An event name to emit.
  1076. * @param args - Optional. Any number of arguments to pass to handlers.
  1077. *
  1078. * @return `this`
  1079. */
  1080. emit<K extends keyof EventMap>(event: K, ...args: Parameters<EventMap[K]>): this;
  1081. emit(event: string, ...args: any[]): this;
  1082. /**
  1083. * Inserts a slide at the specified position.
  1084. *
  1085. * @example
  1086. * ```ts
  1087. * var splide = new Splide();
  1088. * splide.mount();
  1089. *
  1090. * // Adds the slide by the HTML:
  1091. * splide.add( '<li></li> );
  1092. *
  1093. * // or adds the element:
  1094. * splide.add( document.createElement( 'li' ) );
  1095. * ```
  1096. *
  1097. * @param slides - A slide element, an HTML string that represents a slide, or an array with them.
  1098. * @param index - Optional. An index to insert a slide at.
  1099. *
  1100. * @return `this`
  1101. */
  1102. add(slides: string | HTMLElement | Array<string | HTMLElement>, index?: number): this;
  1103. /**
  1104. * Removes slides that match the matcher
  1105. * that can be an index, an array with indices, a selector, or an iteratee function.
  1106. *
  1107. * @param matcher - An index, an array with indices, a selector string, or an iteratee function.
  1108. */
  1109. remove(matcher: SlideMatcher): this;
  1110. /**
  1111. * Checks the slider type.
  1112. *
  1113. * @param type - A type to test.
  1114. *
  1115. * @return `true` if the type matches the current one, or otherwise `false`.
  1116. */
  1117. is(type: string): boolean;
  1118. /**
  1119. * Refreshes the slider.
  1120. *
  1121. * @return `this`
  1122. */
  1123. refresh(): this;
  1124. /**
  1125. * Destroys the slider.
  1126. *
  1127. * @param completely - Optional. If `true`, Splide will not remount the slider by breakpoints.
  1128. *
  1129. * @return `this`
  1130. */
  1131. destroy(completely?: boolean): this;
  1132. /**
  1133. * Returns options.
  1134. *
  1135. * @return An object with the latest options.
  1136. */
  1137. get options(): Options;
  1138. /**
  1139. * Merges options to the current options and emits `updated` event.
  1140. *
  1141. * @param options - An object with new options.
  1142. */
  1143. set options(options: Options);
  1144. /**
  1145. * Returns the number of slides without clones.
  1146. *
  1147. * @return The number of slides.
  1148. */
  1149. get length(): number;
  1150. /**
  1151. * Returns the active slide index.
  1152. *
  1153. * @return The active slide index.
  1154. */
  1155. get index(): number;
  1156. }
  1157. /**
  1158. * The interface for the content of each slide.
  1159. *
  1160. * @since 3.0.0
  1161. */
  1162. interface SlideContent {
  1163. /**
  1164. * The HTML or text for each slide.
  1165. */
  1166. html?: string;
  1167. /**
  1168. * The collection of styles. They will remain after Splide is applied.
  1169. */
  1170. styles?: Record<string, string | number>;
  1171. /**
  1172. * The collection of attributes. They will remain after Splide is applied.
  1173. */
  1174. attrs?: Record<string, string | number | boolean>;
  1175. }
  1176. /**
  1177. * The interface for the config of the renderer.
  1178. *
  1179. * @since 3.0.0
  1180. */
  1181. interface RendererConfig {
  1182. /**
  1183. * The slider ID.
  1184. */
  1185. id?: string;
  1186. /**
  1187. * The additional class for the root element.
  1188. */
  1189. rootClass?: string;
  1190. /**
  1191. * The tag used for the list element.
  1192. */
  1193. listTag?: string;
  1194. /**
  1195. * The tag used for each slide.
  1196. */
  1197. slideTag?: string;
  1198. /**
  1199. * Determines whether to render arrows or not.
  1200. */
  1201. arrows?: boolean;
  1202. /**
  1203. * Keeps the slider hidden.
  1204. */
  1205. hidden?: boolean;
  1206. /**
  1207. * Determines whether to wrap the track by the slider element or not.
  1208. */
  1209. slider?: boolean;
  1210. /**
  1211. * The additional HTML rendered before the slider element.
  1212. */
  1213. beforeSlider?: string;
  1214. /**
  1215. * The additional HTML rendered after the slider element.
  1216. */
  1217. afterSlider?: string;
  1218. /**
  1219. * The additional HTML rendered before the track element.
  1220. */
  1221. beforeTrack?: string;
  1222. /**
  1223. * The additional HTML rendered after the track element.
  1224. */
  1225. afterTrack?: string;
  1226. }
  1227. /**
  1228. * The class to generate static HTML of the slider for the first view.
  1229. *
  1230. * @since 3.0.0
  1231. */
  1232. declare class SplideRenderer {
  1233. /**
  1234. * Removes a style element and clones.
  1235. *
  1236. * @param splide - A Splide instance.
  1237. */
  1238. static clean(splide: Splide): void;
  1239. /**
  1240. * Holds slide contents.
  1241. */
  1242. private readonly contents;
  1243. /**
  1244. * Stores data of slides.
  1245. */
  1246. private readonly slides;
  1247. /**
  1248. * The Direction component.
  1249. */
  1250. private readonly Direction;
  1251. /**
  1252. * Holds the Style instance.
  1253. */
  1254. private readonly Style;
  1255. /**
  1256. * Holds options.
  1257. */
  1258. private readonly options;
  1259. /**
  1260. * Holds options for this instance.
  1261. */
  1262. private readonly config;
  1263. /**
  1264. * The slider ID.
  1265. */
  1266. private readonly id;
  1267. /**
  1268. * An array with options for each breakpoint.
  1269. */
  1270. private readonly breakpoints;
  1271. /**
  1272. * The SplideRenderer constructor.
  1273. *
  1274. * @param contents - An array with slide contents. Each item must be an HTML or a plain text.
  1275. * @param options - Optional. Slider options.
  1276. * @param config - Static default options.
  1277. * @param defaults - Default options for the slider. Pass `Splide.defaults` if you are using it.
  1278. */
  1279. constructor(contents: string[] | SlideContent[], options?: Options, config?: RendererConfig, defaults?: Options);
  1280. /**
  1281. * Initializes the instance.
  1282. */
  1283. private init;
  1284. /**
  1285. * Initializes slides.
  1286. */
  1287. private initSlides;
  1288. /**
  1289. * Registers styles for the root element.
  1290. */
  1291. private registerRootStyles;
  1292. /**
  1293. * Registers styles for the track element.
  1294. */
  1295. private registerTrackStyles;
  1296. /**
  1297. * Registers styles for the list element.
  1298. */
  1299. private registerListStyles;
  1300. /**
  1301. * Registers styles for slides and clones.
  1302. */
  1303. private registerSlideStyles;
  1304. /**
  1305. * Builds multiple `translateX` for the list element.
  1306. *
  1307. * @param options - Options for each breakpoint.
  1308. *
  1309. * @return A string with multiple translate functions.
  1310. */
  1311. private buildTranslate;
  1312. /**
  1313. * Returns offset for the list element.
  1314. * This does not include gaps because it can not be converted into percent.
  1315. *
  1316. * @param options - Options for each breakpoint.
  1317. *
  1318. * @return The offset.
  1319. */
  1320. private cssOffsetClones;
  1321. /**
  1322. * Returns offset for centering the active slide.
  1323. *
  1324. * Note:
  1325. * ( 100% + gap ) / perPage - gap
  1326. * 100% / perPage + gap / perPage - gap;
  1327. * 50% / perPage + ( gap / perPage - gap ) / 2;
  1328. *
  1329. * @param options - Options for each breakpoint.
  1330. *
  1331. * @return The offset.
  1332. */
  1333. private cssOffsetCenter;
  1334. /**
  1335. * Returns offset for gaps.
  1336. *
  1337. * @param options - Options for each breakpoint.
  1338. *
  1339. * @return The offset as `calc()`.
  1340. */
  1341. private cssOffsetGaps;
  1342. /**
  1343. * Resolves the prop for the current direction and converts it into the Kebab case.
  1344. *
  1345. * @param prop - A property name to resolve.
  1346. *
  1347. * @return A resolved property name in the Kebab case.
  1348. */
  1349. private resolve;
  1350. /**
  1351. * Returns padding in the CSS format.
  1352. *
  1353. * @param options - Options.
  1354. * @param right - Determines whether to get padding right or left.
  1355. *
  1356. * @return Padding in the CSS format.
  1357. */
  1358. private cssPadding;
  1359. /**
  1360. * Returns height of the track element in the CSS format.
  1361. *
  1362. * @param options - Options.
  1363. *
  1364. * @return Height in the CSS format.
  1365. */
  1366. private cssTrackHeight;
  1367. /**
  1368. * Returns height provided though options in the CSS format.
  1369. *
  1370. * @param options - Options.
  1371. *
  1372. * @return Height in the CSS format.
  1373. */
  1374. private cssHeight;
  1375. /**
  1376. * Returns width of each slide in the CSS format.
  1377. *
  1378. * @param options - Options.
  1379. *
  1380. * @return Width in the CSS format.
  1381. */
  1382. private cssSlideWidth;
  1383. /**
  1384. * Returns height of each slide in the CSS format.
  1385. *
  1386. * @param options - Options.
  1387. *
  1388. * @return Height in the CSS format.
  1389. */
  1390. private cssSlideHeight;
  1391. /**
  1392. * Returns width or height of each slide in the CSS format, considering the current direction.
  1393. *
  1394. * @param options - Options.
  1395. *
  1396. * @return Width or height in the CSS format.
  1397. */
  1398. private cssSlideSize;
  1399. /**
  1400. * Returns the aspectRatio value to simulate the `heightRatio` option.
  1401. *
  1402. * @param options - Options.
  1403. *
  1404. * @return aspectRatio in the CSS format.
  1405. */
  1406. private cssAspectRatio;
  1407. /**
  1408. * Builds the css value by the provided value and unit.
  1409. *
  1410. * @param value - A value.
  1411. * @param unit - A CSS unit.
  1412. *
  1413. * @return A built value for a CSS value.
  1414. */
  1415. private buildCssValue;
  1416. /**
  1417. * Parses the CSS value into number and unit.
  1418. *
  1419. * @param value - A value to parse.
  1420. *
  1421. * @return An object with value and unit.
  1422. */
  1423. private parseCssValue;
  1424. /**
  1425. * Parses breakpoints and generate options for each breakpoint.
  1426. */
  1427. private parseBreakpoints;
  1428. /**
  1429. * Checks if the slide width is fixed or not.
  1430. *
  1431. * @return `true` if the slide width is fixed, or otherwise `false`.
  1432. */
  1433. private isFixedWidth;
  1434. /**
  1435. * Checks if the slider type is loop or not.
  1436. *
  1437. * @return `true` if the slider type is loop, or otherwise `false`.
  1438. */
  1439. private isLoop;
  1440. /**
  1441. * Checks if the active slide should be centered or not.
  1442. *
  1443. * @return `true` if the slide should be centered, or otherwise `false`.
  1444. */
  1445. private isCenter;
  1446. /**
  1447. * Checks if the direction is TTB or not.
  1448. *
  1449. * @return `true` if the direction is TTB, or otherwise `false`.
  1450. */
  1451. private isVertical;
  1452. /**
  1453. * Builds classes of the root element.
  1454. *
  1455. * @return Classes for the root element as a single string.
  1456. */
  1457. private buildClasses;
  1458. /**
  1459. * Converts provided attributes into a single string.
  1460. *
  1461. * @param attrs - An object with attributes.
  1462. *
  1463. * @return A built string.
  1464. */
  1465. private buildAttrs;
  1466. /**
  1467. * Converts provided styles into a single string.
  1468. *
  1469. * @param styles - An object with styles.
  1470. *
  1471. * @return A built string.
  1472. */
  1473. private buildStyles;
  1474. /**
  1475. * Generates HTML of slides with inserting provided contents.
  1476. *
  1477. * @return The HTML for all slides and clones.
  1478. */
  1479. private renderSlides;
  1480. /**
  1481. * Add the `background` style for the cover mode.
  1482. *
  1483. * @param content - A slide content.
  1484. */
  1485. private cover;
  1486. /**
  1487. * Generates clones.
  1488. *
  1489. * @param contents - An array with SlideContent objects.
  1490. */
  1491. private generateClones;
  1492. /**
  1493. * Returns the number of clones to generate.
  1494. *
  1495. * @return A number of clones.
  1496. */
  1497. private getCloneCount;
  1498. /**
  1499. * Generates arrows and the wrapper element.
  1500. *
  1501. * @return The HTML for arrows.
  1502. */
  1503. private renderArrows;
  1504. /**
  1505. * Generates an arrow HTML.
  1506. * Some attributes are temporary, and Splide changes them after mount.
  1507. *
  1508. * @param prev - Options for each breakpoint.
  1509. *
  1510. * @return The HTML for the prev or next arrow.
  1511. */
  1512. private renderArrow;
  1513. /**
  1514. * Returns the HTML of the slider.
  1515. *
  1516. * @return The generated HTML.
  1517. */
  1518. html(): string;
  1519. }
  1520. declare const EVENT_MOUNTED = "mounted";
  1521. declare const EVENT_READY = "ready";
  1522. declare const EVENT_MOVE = "move";
  1523. declare const EVENT_MOVED = "moved";
  1524. declare const EVENT_SHIFTED = "shifted";
  1525. declare const EVENT_CLICK = "click";
  1526. declare const EVENT_ACTIVE = "active";
  1527. declare const EVENT_INACTIVE = "inactive";
  1528. declare const EVENT_VISIBLE = "visible";
  1529. declare const EVENT_HIDDEN = "hidden";
  1530. declare const EVENT_SLIDE_KEYDOWN = "slide:keydown";
  1531. declare const EVENT_REFRESH = "refresh";
  1532. declare const EVENT_UPDATED = "updated";
  1533. declare const EVENT_RESIZE = "resize";
  1534. declare const EVENT_RESIZED = "resized";
  1535. declare const EVENT_DRAG = "drag";
  1536. declare const EVENT_DRAGGING = "dragging";
  1537. declare const EVENT_DRAGGED = "dragged";
  1538. declare const EVENT_SCROLL = "scroll";
  1539. declare const EVENT_SCROLLED = "scrolled";
  1540. declare const EVENT_DESTROY = "destroy";
  1541. declare const EVENT_ARROWS_MOUNTED = "arrows:mounted";
  1542. declare const EVENT_ARROWS_UPDATED = "arrows:updated";
  1543. declare const EVENT_PAGINATION_MOUNTED = "pagination:mounted";
  1544. declare const EVENT_PAGINATION_UPDATED = "pagination:updated";
  1545. declare const EVENT_NAVIGATION_MOUNTED = "navigation:mounted";
  1546. declare const EVENT_AUTOPLAY_PLAY = "autoplay:play";
  1547. declare const EVENT_AUTOPLAY_PLAYING = "autoplay:playing";
  1548. declare const EVENT_AUTOPLAY_PAUSE = "autoplay:pause";
  1549. declare const EVENT_LAZYLOAD_LOADED = "lazyload:loaded";
  1550. declare const CLASS_ROOT = "splide";
  1551. declare const CLASS_TRACK: string;
  1552. declare const CLASS_LIST: string;
  1553. declare const CLASS_SLIDE: string;
  1554. declare const CLASS_CLONE: string;
  1555. declare const CLASS_CONTAINER: string;
  1556. declare const CLASS_ARROWS: string;
  1557. declare const CLASS_ARROW: string;
  1558. declare const CLASS_ARROW_PREV: string;
  1559. declare const CLASS_ARROW_NEXT: string;
  1560. declare const CLASS_PAGINATION: string;
  1561. declare const CLASS_PAGINATION_PAGE: string;
  1562. declare const CLASS_PROGRESS: string;
  1563. declare const CLASS_PROGRESS_BAR: string;
  1564. declare const CLASS_TOGGLE: string;
  1565. declare const CLASS_TOGGLE_PLAY: string;
  1566. declare const CLASS_TOGGLE_PAUSE: string;
  1567. declare const CLASS_SPINNER: string;
  1568. declare const CLASS_SR: string;
  1569. declare const CLASS_INITIALIZED = "is-initialized";
  1570. declare const CLASS_ACTIVE = "is-active";
  1571. declare const CLASS_PREV = "is-prev";
  1572. declare const CLASS_NEXT = "is-next";
  1573. declare const CLASS_VISIBLE = "is-visible";
  1574. declare const CLASS_LOADING = "is-loading";
  1575. declare const CLASS_FOCUS_IN = "is-focus-in";
  1576. /**
  1577. * The array with all status classes.
  1578. *
  1579. * @since 3.0.0
  1580. */
  1581. declare const STATUS_CLASSES: string[];
  1582. /**
  1583. * The collection of classes for elements that Splide dynamically creates.
  1584. *
  1585. * @since 3.0.0
  1586. */
  1587. declare const CLASSES: {
  1588. slide: string;
  1589. clone: string;
  1590. arrows: string;
  1591. arrow: string;
  1592. prev: string;
  1593. next: string;
  1594. pagination: string;
  1595. page: string;
  1596. spinner: string;
  1597. };
  1598. /**
  1599. * The collection of default options.
  1600. * Note that this collection does not contain all options.
  1601. *
  1602. * @since 3.0.0
  1603. */
  1604. declare const DEFAULTS: Options;
  1605. /**
  1606. * Enumerates slides from left to right.
  1607. */
  1608. declare const LTR = "ltr";
  1609. /**
  1610. * Enumerates slides from right to left.
  1611. */
  1612. declare const RTL = "rtl";
  1613. /**
  1614. * Enumerates slides in a col.
  1615. */
  1616. declare const TTB = "ttb";
  1617. /**
  1618. * The type for the regular slider.
  1619. *
  1620. * @since 3.0.0
  1621. */
  1622. declare const SLIDE = "slide";
  1623. /**
  1624. * The type for the carousel slider.
  1625. *
  1626. * @since 3.0.0
  1627. */
  1628. declare const LOOP = "loop";
  1629. /**
  1630. * The type for the fade slider that can not have multiple slides in a page.
  1631. *
  1632. * @since 3.0.0
  1633. */
  1634. declare const FADE = "fade";
  1635. export { AnyFunction, ArrowsComponent, AutoplayComponent, BaseComponent, 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_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, Cast, ClonesComponent, ComponentConstructor, Components, ControllerComponent, CoverComponent, DEFAULTS, DirectionComponent, DragComponent, 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_HIDDEN, EVENT_INACTIVE, EVENT_LAZYLOAD_LOADED, EVENT_MOUNTED, EVENT_MOVE, EVENT_MOVED, EVENT_NAVIGATION_MOUNTED, 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, ElementsComponent, EventBinder, EventBinderObject, EventInterface, EventInterfaceObject, EventMap, FADE, Head, KeyboardComponent, LOOP, LTR, LayoutComponent, LazyLoadComponent, LiveComponent, MediaComponent, MoveComponent, Options, PaginationComponent, PaginationData, PaginationItem, Push, RTL, RequestInterval, RequestIntervalInterface, Resolve, ResponsiveOptions, SLIDE, STATUS_CLASSES, ScrollComponent, Shift, ShiftN, SlideComponent, SlidesComponent, Splide, SplideRenderer, State, StateObject, SyncComponent, SyncTarget, TTB, Throttle, ThrottleInstance, TransitionComponent, WheelComponent, Splide as default };