index.d.ts 48 KB

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