index.d.ts 49 KB

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