index.d.ts 48 KB

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