index.d.ts 47 KB

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