astro-swiper 2.5.3 → 2.6.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/README.md CHANGED
@@ -180,7 +180,7 @@ Here is a snipset of the
180
180
  </Swiper>
181
181
 
182
182
  <script>
183
- import type { PaginationOptions } from 'swiper/types';
183
+ import type { PaginationOptions } from 'astro-swiper/swiper';
184
184
  import { getSwiperFromUniqueSelector } from 'astro-swiper'
185
185
  window.addEventListener('load', () => {
186
186
  const swiper = getSwiperFromUniqueSelector('.swiper-demo-pagination-custom');
@@ -192,6 +192,13 @@ Here is a snipset of the
192
192
  </script>
193
193
  ```
194
194
 
195
+ ### Swiper types
196
+
197
+ Swiper types are available importing types from `astro-swiper/swiper`, such as
198
+
199
+ ```js
200
+ import type { PaginationOptions } from 'astro-swiper/swiper';
201
+ ```
195
202
 
196
203
  ## Help needed?
197
204
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "astro-swiper",
3
- "version": "2.5.3",
3
+ "version": "2.6.1",
4
4
  "description": "Astro component for swiper, dedicated to slider / carousel / photo swiper / slide, including thumbnails",
5
5
  "type": "module",
6
6
  "main": "index.js",
@@ -23,10 +23,12 @@
23
23
  ".": {
24
24
  "types": "./index.ts",
25
25
  "default": "./index.ts"
26
- }
26
+ },
27
+ "./swiper": "./swiper.ts"
27
28
  },
28
29
  "files": [
29
30
  "index.ts",
31
+ "swiper.ts",
30
32
  "src/**"
31
33
  ],
32
34
  "engines": {
@@ -59,6 +61,6 @@
59
61
  "thumbnail"
60
62
  ],
61
63
  "dependencies": {
62
- "swiper": "^12.1.3"
64
+ "swiper": "^12.1.4"
63
65
  }
64
66
  }
@@ -81,10 +81,10 @@ if (options?.astro?.thumbSwiperUniqueSelector === undefined && Astro.props.linkT
81
81
  // Init swipers that have delayed initialization because the thumbnail swiper is not created yet
82
82
  // If this is now the case, then it is intialized, as well as its observer if needed
83
83
  function _initDelayedSwipers() {
84
- Object.keys(_useDelaySwiper).forEach((delayedSelector) => {
84
+ Object.keys(_useDelaySwiper).forEach((delayedSelector: string) => {
85
85
  // swiper of uniqueSelector "delayedSelector" is delayed because it needs the swiper of uniqueSelector
86
86
  // "delayedThumbSelector" to be created first
87
- const delayedThumbSelector = _useDelaySwiper[delayedSelector];
87
+ const delayedThumbSelector: selectorStringType = _useDelaySwiper[delayedSelector] as selectorStringType;
88
88
  const swiper = getSwiperFromUniqueSelector(
89
89
  delayedThumbSelector,
90
90
  getSwiperFromUniqueSelectorOptions,
@@ -99,7 +99,7 @@ if (options?.astro?.thumbSwiperUniqueSelector === undefined && Astro.props.linkT
99
99
  };
100
100
 
101
101
  _createSwiperAndObserver(
102
- delayedSelector,
102
+ delayedSelector as selectorStringType,
103
103
  delayedOptions,
104
104
  document.querySelector(delayedSelector) as AstroSwiper,
105
105
  );
@@ -192,7 +192,7 @@ if (options?.astro?.thumbSwiperUniqueSelector === undefined && Astro.props.linkT
192
192
  const options: AstroSwiperOptions = JSON.parse(this.dataset.options || '{}');
193
193
  // to have more than 1 swiper in a single page
194
194
  const uniqueSelector: selectorStringType = `.${this.dataset.uniqueclass}`;
195
- const thumbSwiperUniqueSelector = options.astro?.thumbSwiperUniqueSelector;
195
+ const thumbSwiperUniqueSelector: selectorStringType = options.astro?.thumbSwiperUniqueSelector as selectorStringType;
196
196
 
197
197
  // no thumbnail link, or link to thumbnail swiper already created,
198
198
  // the swiper can be created or not immediatly depending on the observer option
@@ -220,5 +220,5 @@ if (options?.astro?.thumbSwiperUniqueSelector === undefined && Astro.props.linkT
220
220
  }
221
221
  }
222
222
 
223
- customElements.define('astro-swiper', AstroSwiper);
223
+ customElements.get('astro-swiper') || customElements.define('astro-swiper', AstroSwiper);
224
224
  </script>
package/swiper.ts ADDED
@@ -0,0 +1,8 @@
1
+ // Copyright (c) Pascal Brand
2
+ // MIT License
3
+ //
4
+ // export swiper API
5
+ // to be used with
6
+ // import type { Swiper } from 'astro-swiper/swiper'
7
+
8
+ export type * from 'swiper/types';