index.d.ts 48 KB

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