index.d.ts 50 KB

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