index.d.ts 48 KB

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