index.d.ts 46 KB

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