mirror of
https://github.com/gosticks/DefinitelyTyped.git
synced 2025-10-16 12:05:41 +00:00
swiper: Fix exports. (#29500)
The `swiper` module provides only a default export of the Swiper class, while the `swiper/dist/js/swiper.esm` provides named exports of this class as well as the Swiper "modules". Also comply with no-declare-current-package dtslint rule. See https://stackoverflow.com/q/52673117 .
This commit is contained in:
parent
96f165b6d0
commit
09e71d3f4f
312
types/swiper/dist/js/swiper.esm.d.ts
vendored
Normal file
312
types/swiper/dist/js/swiper.esm.d.ts
vendored
Normal file
@ -0,0 +1,312 @@
|
||||
import Swiper, { DOM7Element } from '../..';
|
||||
|
||||
// Reexport everything from `swiper` except the default export of the
|
||||
// `Swiper` class, which is instead provided as a named export by
|
||||
// `swiper.esm`.
|
||||
export * from '../..';
|
||||
export { Swiper };
|
||||
|
||||
/*
|
||||
* Swiper exports the following as ES5 module (in swiper.esm.js).
|
||||
*/
|
||||
|
||||
/**
|
||||
* Virtual Slides module.
|
||||
*/
|
||||
export class Virtual {
|
||||
/**
|
||||
* Object with cached slides HTML elements
|
||||
*/
|
||||
cache: object;
|
||||
|
||||
/**
|
||||
* Index of first rendered slide
|
||||
*/
|
||||
from: number;
|
||||
|
||||
/**
|
||||
* Index of last rendered slide
|
||||
*/
|
||||
to: number;
|
||||
|
||||
/**
|
||||
* Array with slide items passed by virtual.slides parameter
|
||||
*/
|
||||
slides: any[];
|
||||
|
||||
/*
|
||||
* Methods
|
||||
*/
|
||||
|
||||
/**
|
||||
* Add new slides to the end. slides could be HTMLElement or HTML string with new slide or array
|
||||
* with such slides, for example:
|
||||
*
|
||||
* @example
|
||||
* mySwiper.appendSlide('<div class="swiper-slide">Slide 10"</div>')
|
||||
* mySwiper.appendSlide([
|
||||
* '<div class="swiper-slide">Slide 10"</div>',
|
||||
* '<div class="swiper-slide">Slide 11"</div>'
|
||||
* ]);
|
||||
*/
|
||||
appendSlide(slide: HTMLElement | string): void;
|
||||
|
||||
/**
|
||||
* Add new slides to the beginning. slides could be HTMLElement or HTML string with new slide or
|
||||
* array with such slides, for example:
|
||||
*
|
||||
* @example
|
||||
* mySwiper.prependSlide('<div class="swiper-slide">Slide 0"</div>')
|
||||
* mySwiper.prependSlide([
|
||||
* '<div class="swiper-slide">Slide 1"</div>',
|
||||
* '<div class="swiper-slide">Slide 2"</div>'
|
||||
* ]);
|
||||
*/
|
||||
prependSlide(slide: HTMLElement | string): void;
|
||||
|
||||
/**
|
||||
* Update virutal slides state
|
||||
*/
|
||||
update(): void;
|
||||
}
|
||||
|
||||
/**
|
||||
* Keyboard Control module.
|
||||
*/
|
||||
export class Keyboard {
|
||||
/**
|
||||
* Whether the keyboard control is enabled
|
||||
*/
|
||||
enabled: boolean;
|
||||
|
||||
// Methods
|
||||
/**
|
||||
* Enable keyboard control
|
||||
*/
|
||||
enable(): void;
|
||||
|
||||
/**
|
||||
* Disable keyboard control
|
||||
*/
|
||||
disable(): void;
|
||||
}
|
||||
|
||||
/**
|
||||
* Mousewheel Control module.
|
||||
*/
|
||||
export class Mousewheel {
|
||||
/**
|
||||
* Whether the mousewheel control is enabled
|
||||
*/
|
||||
enabled: boolean;
|
||||
|
||||
// Methods
|
||||
/**
|
||||
* Enable mousewheel control
|
||||
*/
|
||||
enable(): void;
|
||||
|
||||
/**
|
||||
* Disable mousewheel control
|
||||
*/
|
||||
disable(): void;
|
||||
}
|
||||
|
||||
/**
|
||||
* Navigation module.
|
||||
*/
|
||||
export class Navigation {
|
||||
/**
|
||||
* HTMLElement of "next" navigation button
|
||||
*/
|
||||
nextEl: HTMLElement;
|
||||
|
||||
/**
|
||||
* HTMLElement of "previous" navigation button
|
||||
*/
|
||||
prevEl: HTMLElement;
|
||||
|
||||
/**
|
||||
* Update navigation buttons state (enabled/disabled)
|
||||
*/
|
||||
update(): void;
|
||||
}
|
||||
|
||||
/**
|
||||
* Pagination module.
|
||||
*/
|
||||
export class Pagination {
|
||||
/**
|
||||
* HTMLElement of pagination container element
|
||||
*/
|
||||
el: HTMLElement;
|
||||
|
||||
/**
|
||||
* Dom7 array-like collection of pagination bullets
|
||||
* HTML elements. To get specific slide HTMLElement
|
||||
* use `mySwiper.pagination.bullets[1]`.
|
||||
*/
|
||||
bullets: DOM7Element[];
|
||||
|
||||
/**
|
||||
* Render pagination layout
|
||||
*/
|
||||
render(): void;
|
||||
|
||||
/**
|
||||
* Update pagination state (enabled/disabled/active)
|
||||
*/
|
||||
update(): void;
|
||||
}
|
||||
|
||||
/**
|
||||
* Scrollbar module.
|
||||
*/
|
||||
export class Scrollbar {
|
||||
// Properties
|
||||
/**
|
||||
* HTMLElement of Scrollbar container element
|
||||
*/
|
||||
el: HTMLElement;
|
||||
|
||||
/**
|
||||
* HTMLElement of Scrollbar draggable handler element
|
||||
*/
|
||||
dragEl: HTMLElement;
|
||||
|
||||
// Methods
|
||||
/**
|
||||
* Updates scrollbar track and handler sizes
|
||||
*/
|
||||
updateSize(): void;
|
||||
}
|
||||
|
||||
/**
|
||||
* Parallax module.
|
||||
*/
|
||||
export class Parallax { }
|
||||
|
||||
/**
|
||||
* Zoom module.
|
||||
*/
|
||||
export class Zoom {
|
||||
/**
|
||||
* Whether the zoom module is enabled
|
||||
*/
|
||||
enabled: boolean;
|
||||
|
||||
/**
|
||||
* Current image scale ratio
|
||||
*/
|
||||
scale: number;
|
||||
|
||||
/**
|
||||
* Enable zoom module
|
||||
*/
|
||||
enable(): void;
|
||||
|
||||
/**
|
||||
* Disable zoom module
|
||||
*/
|
||||
disable(): void;
|
||||
|
||||
/**
|
||||
* Zoom in image of the currently active slide
|
||||
*/
|
||||
in(): void;
|
||||
|
||||
/**
|
||||
* Zoom out image of the currently active slide
|
||||
*/
|
||||
out(): void;
|
||||
|
||||
/**
|
||||
* Toggle image zoom of the currently active slide
|
||||
*/
|
||||
toggle(): void;
|
||||
}
|
||||
|
||||
/**
|
||||
* Lazy module.
|
||||
*/
|
||||
export class Lazy {
|
||||
/**
|
||||
* Load/update lazy images based on current slider state (position)
|
||||
*/
|
||||
load(): void;
|
||||
|
||||
/**
|
||||
* Force to load lazy images in slide by specified index
|
||||
* @param number index number of slide to load lazy images in
|
||||
*/
|
||||
loadInSlide(index: number): void;
|
||||
}
|
||||
|
||||
/**
|
||||
* Controller module.
|
||||
*/
|
||||
export class Controller {
|
||||
/**
|
||||
* Pass here another Swiper instance or array with Swiper instances that should be controlled
|
||||
* by this Swiper
|
||||
*/
|
||||
control?: Swiper;
|
||||
}
|
||||
|
||||
/**
|
||||
* Accessibility module (a11y$)
|
||||
*/
|
||||
export class A11y { }
|
||||
|
||||
/**
|
||||
* History Navigation module.
|
||||
*/
|
||||
export class History { }
|
||||
|
||||
/**
|
||||
* Hash Navigation module.
|
||||
*/
|
||||
export class HashNavigation {
|
||||
}
|
||||
|
||||
/**
|
||||
* Autoplay module.
|
||||
*/
|
||||
export class Autoplay {
|
||||
// Properties
|
||||
/**
|
||||
* Whether autoplay enabled and running
|
||||
*/
|
||||
running: boolean;
|
||||
|
||||
// Methods
|
||||
/**
|
||||
* Start autoplay
|
||||
*/
|
||||
start(): boolean;
|
||||
|
||||
/**
|
||||
* Stop autoplay
|
||||
*/
|
||||
stop(): boolean;
|
||||
}
|
||||
|
||||
/**
|
||||
* Fade Effect module.
|
||||
*/
|
||||
export class EffectFade { }
|
||||
|
||||
/**
|
||||
* Cube Effect module.
|
||||
*/
|
||||
export class EffectCube { }
|
||||
|
||||
/**
|
||||
* Flip Effect module.
|
||||
*/
|
||||
export class EffectFlip { }
|
||||
|
||||
/**
|
||||
* Coverflow Effect module.
|
||||
*/
|
||||
export class EffectCoverflow { }
|
||||
2820
types/swiper/index.d.ts
vendored
2820
types/swiper/index.d.ts
vendored
File diff suppressed because it is too large
Load Diff
@ -3,7 +3,8 @@
|
||||
* for more details, please see http://idangero.us/swiper/demos/
|
||||
* @author Eugene Matseruk
|
||||
*/
|
||||
import { Swiper, Navigation, History } from 'swiper';
|
||||
import Swiper from 'swiper';
|
||||
import { Swiper as SwiperESM, Navigation, History } from 'swiper/dist/js/swiper.esm';
|
||||
|
||||
const containerSelector = '.swiper-container';
|
||||
|
||||
@ -12,6 +13,7 @@ const containerSelector = '.swiper-container';
|
||||
*/
|
||||
function defaultDemo() {
|
||||
const swiper = new Swiper(containerSelector);
|
||||
const swiper2 = new SwiperESM(containerSelector);
|
||||
}
|
||||
/**
|
||||
* 020-navigation
|
||||
@ -771,7 +773,7 @@ function slideableNavigation() {
|
||||
* Swiper module instalation.
|
||||
*/
|
||||
function staticUseModules() {
|
||||
Swiper.use([Navigation, History]);
|
||||
SwiperESM.use([Navigation, History]);
|
||||
|
||||
const swiper = new Swiper(containerSelector);
|
||||
}
|
||||
|
||||
@ -19,6 +19,7 @@
|
||||
},
|
||||
"files": [
|
||||
"index.d.ts",
|
||||
"dist/js/swiper.esm.d.ts",
|
||||
"swiper-tests.ts"
|
||||
]
|
||||
}
|
||||
|
||||
@ -1,9 +1,3 @@
|
||||
{
|
||||
"extends": "dtslint/dt.json",
|
||||
"rules": {
|
||||
"no-self-import": false,
|
||||
// TODOs
|
||||
"no-declare-current-package": false,
|
||||
"no-single-declare-module": false
|
||||
}
|
||||
"extends": "dtslint/dt.json"
|
||||
}
|
||||
|
||||
Loading…
Reference in New Issue
Block a user