index.d.ts 47 KB

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