solid-slider 1.3.18 → 1.3.20

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
@@ -71,7 +71,7 @@ const MyComponent = () => {
71
71
  </Slider>
72
72
  <SliderButton prev>Previous</SliderButton>
73
73
  <SliderButton next>Next</SliderButton>
74
- <SliderProvider>
74
+ </SliderProvider>
75
75
  );
76
76
  };
77
77
  ```
@@ -212,6 +212,145 @@ const [slider] = createSlider(
212
212
  );
213
213
  ```
214
214
 
215
+ ## Helper Components
216
+
217
+ ### Navigation Dots
218
+
219
+ You can add navigation dots to your slider using the `SliderDots` component. The component automatically generates clickable dots for each slide and highlights the active slide.
220
+
221
+ ```tsx
222
+ import { SliderProvider, Slider, SliderDots } from "solid-slider";
223
+
224
+ const MyComponent = () => {
225
+ return (
226
+ <SliderProvider>
227
+ <Slider options={{ loop: true }}>
228
+ <div>Slide 1</div>
229
+ <div>Slide 2</div>
230
+ <div>Slide 3</div>
231
+ </Slider>
232
+ <SliderDots />
233
+ </SliderProvider>
234
+ );
235
+ };
236
+ ```
237
+
238
+ **Customization:**
239
+
240
+ You can customize the dots styling using `class`, `classList`, `dotClass`, and `dotClassList` props:
241
+
242
+ ```tsx
243
+ <SliderDots
244
+ class="my-dots-container"
245
+ dotClass="my-dot"
246
+ dotClassList={{ "my-active-dot": true }}
247
+ />
248
+ ```
249
+
250
+ **Props:**
251
+ - `class` - CSS class for the dots container
252
+ - `classList` - Conditional classes for the dots container
253
+ - `dotClass` - CSS class for individual dot buttons
254
+ - `dotClassList` - Conditional classes for individual dot buttons
255
+
256
+ **Default Classes:**
257
+ - Container: `.slider-dots`
258
+ - Individual dots: `.slider-dot`
259
+ - Active dot: `.slider-dot.active`
260
+
261
+ **Styling Example:**
262
+
263
+ ```css
264
+ .slider-dots {
265
+ display: flex;
266
+ justify-content: center;
267
+ gap: 8px;
268
+ margin-top: 20px;
269
+ }
270
+
271
+ .slider-dot {
272
+ width: 12px;
273
+ height: 12px;
274
+ border-radius: 50%;
275
+ background: #ddd;
276
+ border: none;
277
+ cursor: pointer;
278
+ transition: background 0.3s;
279
+ }
280
+
281
+ .slider-dot:hover {
282
+ background: #aaa;
283
+ }
284
+
285
+ .slider-dot.active {
286
+ background: #333;
287
+ }
288
+ ```
289
+
290
+ ### Thumbnail Navigation
291
+
292
+ Create a synchronized thumbnail navigation using the `SliderThumbnails` component. This creates a second slider that stays in sync with the main slider, allowing users to click thumbnails to navigate.
293
+
294
+ ```tsx
295
+ import { SliderProvider, Slider, SliderThumbnails } from "solid-slider";
296
+ import { For } from "solid-js";
297
+
298
+ const MyComponent = () => {
299
+ const images = [
300
+ { full: "/slide1.jpg", thumb: "/thumb1.jpg" },
301
+ { full: "/slide2.jpg", thumb: "/thumb2.jpg" },
302
+ { full: "/slide3.jpg", thumb: "/thumb3.jpg" },
303
+ ];
304
+
305
+ return (
306
+ <SliderProvider>
307
+ <Slider options={{ loop: true }}>
308
+ <For each={images}>
309
+ {(img) => (
310
+ <div>
311
+ <img src={img.full} alt="Slide" />
312
+ </div>
313
+ )}
314
+ </For>
315
+ </Slider>
316
+ <SliderThumbnails options={{ slides: { perView: 4, spacing: 10 } }}>
317
+ <For each={images}>
318
+ {(img) => (
319
+ <div class="thumbnail-slide">
320
+ <img src={img.thumb} alt="Thumbnail" />
321
+ </div>
322
+ )}
323
+ </For>
324
+ </SliderThumbnails>
325
+ </SliderProvider>
326
+ );
327
+ };
328
+ ```
329
+
330
+ **Important:** When using dynamic content with `SliderThumbnails`, use SolidJS's `<For>` component instead of `.map()` to ensure proper reactivity.
331
+
332
+ **Props:**
333
+ - `options` - KeenSlider options for the thumbnail slider (e.g., slides per view, spacing)
334
+ - `plugins` - Array of KeenSlider plugins to apply to the thumbnail slider
335
+ - `activeClass` - Custom CSS class name for the active thumbnail (default: `"active"`)
336
+
337
+ **Features:**
338
+ - Automatically syncs with the main slider
339
+ - Adds `active` class to the current thumbnail
340
+ - Click any thumbnail to navigate to that slide
341
+ - Supports all KeenSlider options for customization
342
+
343
+ **Styling Example:**
344
+
345
+ ```css
346
+ .thumbnail-slide:hover {
347
+ opacity: 0.8;
348
+ }
349
+ .thumbnail-slide.active {
350
+ opacity: 1;
351
+ }
352
+ ```
353
+
215
354
  ## SolidStart & Server-Side Rendering
216
355
 
217
356
  So you want to use Solid Slider with [SolidStart](https://start.solidjs.com/). No problem but be mindful of how you use it and how server-side rendering impacts the experience. Remember that by default SolidStart enables SSR meaning that your pages are initially rendered on the server. The server has no context of the dimensions of your browser so it cannot calculate how the slider will appear once it's rendered in the browser.
@@ -232,8 +371,8 @@ Thie library exports it's own CSS which is the basic Keen-Slider implementation
232
371
 
233
372
  - [x] Create [adaptiveHeight](https://codesandbox.io/s/github/rcbyr/keen-slider-sandboxes/tree/v6/misc/adaptive-height/react?file=/src/App.js:191-403) plugin
234
373
  - [x] Create [adaptiveWidth](https://github.com/joeygrable94/solid-slider) plugin
235
- - [ ] Add Dots components (to display a row of dots below the slider)
236
- - [ ] Add slider thumbnail navigation
374
+ - [x] Add Dots components (to display a row of dots below the slider)
375
+ - [x] Add slider thumbnail navigation
237
376
  - [ ] Add slider loader
238
377
  - [ ] Build [timepicker](https://keen-slider.io/examples#timepicker) component
239
378
  - [ ] Create [Scroll Wheel](https://keen-slider.io/examples#scroll-wheel-controls) component
@@ -248,7 +387,7 @@ Thie library exports it's own CSS which is the basic Keen-Slider implementation
248
387
  - 1.2.9 - Updated timer primitive and patched issue with current slide setting from initial options.
249
388
  - 1.3.1 - Introduced Slider, SliderProvider and SliderButton for ease.
250
389
  - 1.3.2 - Patched issue with initial slide not setting current signal.
251
- - 1.3.5 - Updated to latest SolidJS version.
390
+ - 1.3.5 - Updated to latest Solid version.
252
391
  - 1.3.7 - Fixed TS issues updated to latest KeenSlider.
253
392
  - 1.3.8 - Updated to Solid 1.5
254
393
  - 1.3.9 - Fixed Keen URLs, type issues and truthy error with autoplay (thanks [ishanAhuja](https://www.github.com/ishanAhuja) and [ahhshm](https://www.github.com/ahhshm))
@@ -260,6 +399,8 @@ Thie library exports it's own CSS which is the basic Keen-Slider implementation
260
399
  - 1.3.16 - Updated dependencies and move Solid from dependency to peer
261
400
  - 1.3.17 - Added typs definition to exports (thanks [ChristophP](https://github.com/ChristophP))
262
401
  - 1.3.18 - Adjusted documentation and minor source cleanup
402
+ - 1.3.19 - Attempt to fix export paths
403
+ - 1.3.20 - Package maintenance (bumping versions) and added new dot and thumbnail navigation components
263
404
 
264
405
  ## Keen Options API
265
406
 
@@ -8,8 +8,8 @@
8
8
  * const [create] = createSlider({}, [adaptiveHeight]);
9
9
  * ```
10
10
  */
11
- var adaptiveHeight = function adaptiveHeight() {
12
- return function (slider) {
11
+ const adaptiveHeight = () => {
12
+ return slider => {
13
13
  function updateHeight() {
14
14
  slider.container.style.height = slider.slides[slider.track.details.rel].offsetHeight + "px";
15
15
  }
@@ -1 +1 @@
1
- {"version":3,"file":"index.common.js","sources":["../../src/plugins/adaptiveHeight.tsx"],"sourcesContent":["import { KeenSliderInstance } from \"keen-slider\";\n\n/**\n * Adaptive height is a plugin that adjusts the height of the slider to the content on change.\n *\n * @example\n * ```ts\n * const [create] = createSlider({}, [adaptiveHeight]);\n * ```\n */\nexport const adaptiveHeight = () => {\n return (slider: KeenSliderInstance) => {\n function updateHeight() {\n slider.container.style.height =\n slider.slides[slider.track.details.rel].offsetHeight + \"px\";\n }\n slider.on(\"created\", updateHeight);\n slider.on(\"slideChanged\", updateHeight);\n };\n};\n"],"names":["adaptiveHeight","slider","updateHeight","container","style","height","slides","track","details","rel","offsetHeight","on"],"mappings":";;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACaA,IAAAA,cAAc,GAAG,SAAjBA,cAAc,GAAS;EAClC,OAAO,UAACC,MAA0B,EAAK;AACrC,IAAA,SAASC,YAAY,GAAG;MACtBD,MAAM,CAACE,SAAS,CAACC,KAAK,CAACC,MAAM,GAC3BJ,MAAM,CAACK,MAAM,CAACL,MAAM,CAACM,KAAK,CAACC,OAAO,CAACC,GAAG,CAAC,CAACC,YAAY,GAAG,IAAI,CAAA;AAC/D,KAAA;AACAT,IAAAA,MAAM,CAACU,EAAE,CAAC,SAAS,EAAET,YAAY,CAAC,CAAA;AAClCD,IAAAA,MAAM,CAACU,EAAE,CAAC,cAAc,EAAET,YAAY,CAAC,CAAA;GACxC,CAAA;AACH;;;;"}
1
+ {"version":3,"file":"index.common.js","sources":["../../src/plugins/adaptiveHeight.tsx"],"sourcesContent":["import { KeenSliderInstance } from \"keen-slider\";\n\n/**\n * Adaptive height is a plugin that adjusts the height of the slider to the content on change.\n *\n * @example\n * ```ts\n * const [create] = createSlider({}, [adaptiveHeight]);\n * ```\n */\nexport const adaptiveHeight = () => {\n return (slider: KeenSliderInstance) => {\n function updateHeight() {\n slider.container.style.height =\n slider.slides[slider.track.details.rel].offsetHeight + \"px\";\n }\n slider.on(\"created\", updateHeight);\n slider.on(\"slideChanged\", updateHeight);\n };\n};\n"],"names":["adaptiveHeight","slider","updateHeight","container","style","height","slides","track","details","rel","offsetHeight","on"],"mappings":";;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACO,MAAMA,cAAc,GAAGA,MAAM;AAClC,EAAA,OAAQC,MAA0B,IAAK;IACrC,SAASC,YAAYA,GAAG;MACtBD,MAAM,CAACE,SAAS,CAACC,KAAK,CAACC,MAAM,GAC3BJ,MAAM,CAACK,MAAM,CAACL,MAAM,CAACM,KAAK,CAACC,OAAO,CAACC,GAAG,CAAC,CAACC,YAAY,GAAG,IAAI;AAC/D,IAAA;AACAT,IAAAA,MAAM,CAACU,EAAE,CAAC,SAAS,EAAET,YAAY,CAAC;AAClCD,IAAAA,MAAM,CAACU,EAAE,CAAC,cAAc,EAAET,YAAY,CAAC;EACzC,CAAC;AACH;;;;"}
@@ -6,8 +6,8 @@
6
6
  * const [create] = createSlider({}, [adaptiveHeight]);
7
7
  * ```
8
8
  */
9
- var adaptiveHeight = function adaptiveHeight() {
10
- return function (slider) {
9
+ const adaptiveHeight = () => {
10
+ return slider => {
11
11
  function updateHeight() {
12
12
  slider.container.style.height = slider.slides[slider.track.details.rel].offsetHeight + "px";
13
13
  }
@@ -1 +1 @@
1
- {"version":3,"file":"index.module.js","sources":["../../src/plugins/adaptiveHeight.tsx"],"sourcesContent":["import { KeenSliderInstance } from \"keen-slider\";\n\n/**\n * Adaptive height is a plugin that adjusts the height of the slider to the content on change.\n *\n * @example\n * ```ts\n * const [create] = createSlider({}, [adaptiveHeight]);\n * ```\n */\nexport const adaptiveHeight = () => {\n return (slider: KeenSliderInstance) => {\n function updateHeight() {\n slider.container.style.height =\n slider.slides[slider.track.details.rel].offsetHeight + \"px\";\n }\n slider.on(\"created\", updateHeight);\n slider.on(\"slideChanged\", updateHeight);\n };\n};\n"],"names":["adaptiveHeight","slider","updateHeight","container","style","height","slides","track","details","rel","offsetHeight","on"],"mappings":"AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACaA,IAAAA,cAAc,GAAG,SAAjBA,cAAc,GAAS;EAClC,OAAO,UAACC,MAA0B,EAAK;AACrC,IAAA,SAASC,YAAY,GAAG;MACtBD,MAAM,CAACE,SAAS,CAACC,KAAK,CAACC,MAAM,GAC3BJ,MAAM,CAACK,MAAM,CAACL,MAAM,CAACM,KAAK,CAACC,OAAO,CAACC,GAAG,CAAC,CAACC,YAAY,GAAG,IAAI,CAAA;AAC/D,KAAA;AACAT,IAAAA,MAAM,CAACU,EAAE,CAAC,SAAS,EAAET,YAAY,CAAC,CAAA;AAClCD,IAAAA,MAAM,CAACU,EAAE,CAAC,cAAc,EAAET,YAAY,CAAC,CAAA;GACxC,CAAA;AACH;;;;"}
1
+ {"version":3,"file":"index.module.js","sources":["../../src/plugins/adaptiveHeight.tsx"],"sourcesContent":["import { KeenSliderInstance } from \"keen-slider\";\n\n/**\n * Adaptive height is a plugin that adjusts the height of the slider to the content on change.\n *\n * @example\n * ```ts\n * const [create] = createSlider({}, [adaptiveHeight]);\n * ```\n */\nexport const adaptiveHeight = () => {\n return (slider: KeenSliderInstance) => {\n function updateHeight() {\n slider.container.style.height =\n slider.slides[slider.track.details.rel].offsetHeight + \"px\";\n }\n slider.on(\"created\", updateHeight);\n slider.on(\"slideChanged\", updateHeight);\n };\n};\n"],"names":["adaptiveHeight","slider","updateHeight","container","style","height","slides","track","details","rel","offsetHeight","on"],"mappings":"AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACO,MAAMA,cAAc,GAAGA,MAAM;AAClC,EAAA,OAAQC,MAA0B,IAAK;IACrC,SAASC,YAAYA,GAAG;MACtBD,MAAM,CAACE,SAAS,CAACC,KAAK,CAACC,MAAM,GAC3BJ,MAAM,CAACK,MAAM,CAACL,MAAM,CAACM,KAAK,CAACC,OAAO,CAACC,GAAG,CAAC,CAACC,YAAY,GAAG,IAAI;AAC/D,IAAA;AACAT,IAAAA,MAAM,CAACU,EAAE,CAAC,SAAS,EAAET,YAAY,CAAC;AAClCD,IAAAA,MAAM,CAACU,EAAE,CAAC,cAAc,EAAET,YAAY,CAAC;EACzC,CAAC;AACH;;;;"}
@@ -8,8 +8,8 @@
8
8
  * const [create] = createSlider({}, [adaptiveWidth]);
9
9
  * ```
10
10
  */
11
- var adaptiveWidth = function adaptiveWidth() {
12
- return function (slider) {
11
+ const adaptiveWidth = () => {
12
+ return slider => {
13
13
  function updateWidth() {
14
14
  slider.container.style.width = slider.slides[slider.track.details.rel].offsetWidth + "px";
15
15
  }
@@ -1 +1 @@
1
- {"version":3,"file":"index.common.js","sources":["../../src/plugins/adaptiveWidth.tsx"],"sourcesContent":["import { KeenSliderInstance } from \"keen-slider\";\n\n/**\n * Adaptive width is a plugin that adjusts the width of the slider to the content on change.\n *\n * @example\n * ```ts\n * const [create] = createSlider({}, [adaptiveWidth]);\n * ```\n */\nexport const adaptiveWidth = () => {\n return (slider: KeenSliderInstance) => {\n function updateWidth() {\n slider.container.style.width =\n slider.slides[slider.track.details.rel].offsetWidth + \"px\";\n }\n slider.on(\"created\", updateWidth);\n slider.on(\"slideChanged\", updateWidth);\n };\n};\n"],"names":["adaptiveWidth","slider","updateWidth","container","style","width","slides","track","details","rel","offsetWidth","on"],"mappings":";;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACaA,IAAAA,aAAa,GAAG,SAAhBA,aAAa,GAAS;EACjC,OAAO,UAACC,MAA0B,EAAK;AACrC,IAAA,SAASC,WAAW,GAAG;MACrBD,MAAM,CAACE,SAAS,CAACC,KAAK,CAACC,KAAK,GAC1BJ,MAAM,CAACK,MAAM,CAACL,MAAM,CAACM,KAAK,CAACC,OAAO,CAACC,GAAG,CAAC,CAACC,WAAW,GAAG,IAAI,CAAA;AAC9D,KAAA;AACAT,IAAAA,MAAM,CAACU,EAAE,CAAC,SAAS,EAAET,WAAW,CAAC,CAAA;AACjCD,IAAAA,MAAM,CAACU,EAAE,CAAC,cAAc,EAAET,WAAW,CAAC,CAAA;GACvC,CAAA;AACH;;;;"}
1
+ {"version":3,"file":"index.common.js","sources":["../../src/plugins/adaptiveWidth.tsx"],"sourcesContent":["import { KeenSliderInstance } from \"keen-slider\";\n\n/**\n * Adaptive width is a plugin that adjusts the width of the slider to the content on change.\n *\n * @example\n * ```ts\n * const [create] = createSlider({}, [adaptiveWidth]);\n * ```\n */\nexport const adaptiveWidth = () => {\n return (slider: KeenSliderInstance) => {\n function updateWidth() {\n slider.container.style.width =\n slider.slides[slider.track.details.rel].offsetWidth + \"px\";\n }\n slider.on(\"created\", updateWidth);\n slider.on(\"slideChanged\", updateWidth);\n };\n};\n"],"names":["adaptiveWidth","slider","updateWidth","container","style","width","slides","track","details","rel","offsetWidth","on"],"mappings":";;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACO,MAAMA,aAAa,GAAGA,MAAM;AACjC,EAAA,OAAQC,MAA0B,IAAK;IACrC,SAASC,WAAWA,GAAG;MACrBD,MAAM,CAACE,SAAS,CAACC,KAAK,CAACC,KAAK,GAC1BJ,MAAM,CAACK,MAAM,CAACL,MAAM,CAACM,KAAK,CAACC,OAAO,CAACC,GAAG,CAAC,CAACC,WAAW,GAAG,IAAI;AAC9D,IAAA;AACAT,IAAAA,MAAM,CAACU,EAAE,CAAC,SAAS,EAAET,WAAW,CAAC;AACjCD,IAAAA,MAAM,CAACU,EAAE,CAAC,cAAc,EAAET,WAAW,CAAC;EACxC,CAAC;AACH;;;;"}
@@ -6,8 +6,8 @@
6
6
  * const [create] = createSlider({}, [adaptiveWidth]);
7
7
  * ```
8
8
  */
9
- var adaptiveWidth = function adaptiveWidth() {
10
- return function (slider) {
9
+ const adaptiveWidth = () => {
10
+ return slider => {
11
11
  function updateWidth() {
12
12
  slider.container.style.width = slider.slides[slider.track.details.rel].offsetWidth + "px";
13
13
  }
@@ -1 +1 @@
1
- {"version":3,"file":"index.module.js","sources":["../../src/plugins/adaptiveWidth.tsx"],"sourcesContent":["import { KeenSliderInstance } from \"keen-slider\";\n\n/**\n * Adaptive width is a plugin that adjusts the width of the slider to the content on change.\n *\n * @example\n * ```ts\n * const [create] = createSlider({}, [adaptiveWidth]);\n * ```\n */\nexport const adaptiveWidth = () => {\n return (slider: KeenSliderInstance) => {\n function updateWidth() {\n slider.container.style.width =\n slider.slides[slider.track.details.rel].offsetWidth + \"px\";\n }\n slider.on(\"created\", updateWidth);\n slider.on(\"slideChanged\", updateWidth);\n };\n};\n"],"names":["adaptiveWidth","slider","updateWidth","container","style","width","slides","track","details","rel","offsetWidth","on"],"mappings":"AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACaA,IAAAA,aAAa,GAAG,SAAhBA,aAAa,GAAS;EACjC,OAAO,UAACC,MAA0B,EAAK;AACrC,IAAA,SAASC,WAAW,GAAG;MACrBD,MAAM,CAACE,SAAS,CAACC,KAAK,CAACC,KAAK,GAC1BJ,MAAM,CAACK,MAAM,CAACL,MAAM,CAACM,KAAK,CAACC,OAAO,CAACC,GAAG,CAAC,CAACC,WAAW,GAAG,IAAI,CAAA;AAC9D,KAAA;AACAT,IAAAA,MAAM,CAACU,EAAE,CAAC,SAAS,EAAET,WAAW,CAAC,CAAA;AACjCD,IAAAA,MAAM,CAACU,EAAE,CAAC,cAAc,EAAET,WAAW,CAAC,CAAA;GACvC,CAAA;AACH;;;;"}
1
+ {"version":3,"file":"index.module.js","sources":["../../src/plugins/adaptiveWidth.tsx"],"sourcesContent":["import { KeenSliderInstance } from \"keen-slider\";\n\n/**\n * Adaptive width is a plugin that adjusts the width of the slider to the content on change.\n *\n * @example\n * ```ts\n * const [create] = createSlider({}, [adaptiveWidth]);\n * ```\n */\nexport const adaptiveWidth = () => {\n return (slider: KeenSliderInstance) => {\n function updateWidth() {\n slider.container.style.width =\n slider.slides[slider.track.details.rel].offsetWidth + \"px\";\n }\n slider.on(\"created\", updateWidth);\n slider.on(\"slideChanged\", updateWidth);\n };\n};\n"],"names":["adaptiveWidth","slider","updateWidth","container","style","width","slides","track","details","rel","offsetWidth","on"],"mappings":"AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACO,MAAMA,aAAa,GAAGA,MAAM;AACjC,EAAA,OAAQC,MAA0B,IAAK;IACrC,SAASC,WAAWA,GAAG;MACrBD,MAAM,CAACE,SAAS,CAACC,KAAK,CAACC,KAAK,GAC1BJ,MAAM,CAACK,MAAM,CAACL,MAAM,CAACM,KAAK,CAACC,OAAO,CAACC,GAAG,CAAC,CAACC,WAAW,GAAG,IAAI;AAC9D,IAAA;AACAT,IAAAA,MAAM,CAACU,EAAE,CAAC,SAAS,EAAET,WAAW,CAAC;AACjCD,IAAAA,MAAM,CAACU,EAAE,CAAC,cAAc,EAAET,WAAW,CAAC;EACxC,CAAC;AACH;;;;"}
@@ -19,27 +19,17 @@ var solidJs = require('solid-js');
19
19
  * const [create] = createSlider({}, [autoplay]);
20
20
  * ```
21
21
  */
22
- var autoplay = function autoplay() {
23
- var interval = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : 1000;
24
- var options = arguments.length > 1 ? arguments[1] : undefined;
25
- return function (slider) {
26
- var dispose;
27
- var start = function start() {
28
- dispose = timer.makeTimer(function () {
29
- return slider.moveToIdx(slider.track.details.position + 1, true, options.animation);
30
- }, interval, setInterval);
22
+ const autoplay = (interval = 1000, options) => {
23
+ return slider => {
24
+ let dispose;
25
+ const start = () => {
26
+ dispose = timer.makeTimer(() => slider.moveToIdx(slider.track.details.position + 1, true, options.animation), interval, setInterval);
31
27
  };
32
28
  // Pause the slider on drag
33
29
  if (options.pauseOnDrag !== false) {
34
- slider.on("dragStarted", function () {
35
- var _dispose;
36
- return (_dispose = dispose) === null || _dispose === void 0 ? void 0 : _dispose();
37
- });
30
+ slider.on("dragStarted", () => dispose?.());
38
31
  }
39
- solidJs.createEffect(function () {
40
- var _dispose2;
41
- return !options.pause || options.pause() === false ? start() : (_dispose2 = dispose) === null || _dispose2 === void 0 ? void 0 : _dispose2();
42
- });
32
+ solidJs.createEffect(() => !options.pause || options.pause() === false ? start() : dispose?.());
43
33
  };
44
34
  };
45
35
 
@@ -1 +1 @@
1
- {"version":3,"file":"index.common.js","sources":["../../src/plugins/autoplay.tsx"],"sourcesContent":["import { makeTimer } from \"@solid-primitives/timer\";\nimport { KeenSliderInstance } from \"keen-slider\";\nimport { Accessor, createEffect } from \"solid-js\";\n\n/**\n * Provides an autoplay plugin.\n *\n * @param {number} interval Interval in milliseconds for switching slides\n * @param {object} options Options to customize the autoplay\n * @param {Function} options.pause A pause signal to control the autoplay\n * @param {boolean} options.pauseOnDrag Denotes of the autoplay should pause on drag.\n * @param {object} options.animation Allows for control of duration and easing.\n * @param {number} options.duration Duration for transitioning the slide.\n * @param {number} options.easing Easing function for the transition animation.\n *\n * @example\n * ```ts\n * const [create] = createSlider({}, [autoplay]);\n * ```\n */\nexport const autoplay = (\n interval: number = 1000,\n options: {\n pause?: Accessor<boolean>;\n pauseOnDrag?: boolean;\n animation?: {\n duration?: number;\n easing?: (t: number) => number;\n };\n },\n) => {\n return (slider: KeenSliderInstance) => {\n let dispose: Function;\n const start = () => {\n dispose = makeTimer(\n () =>\n slider.moveToIdx(\n slider.track.details.position + 1,\n true,\n options.animation,\n ),\n interval,\n setInterval,\n );\n };\n // Pause the slider on drag\n if (options.pauseOnDrag !== false) {\n slider.on(\"dragStarted\", () => dispose?.());\n }\n createEffect(() =>\n !options.pause || options.pause() === false ? start() : dispose?.(),\n );\n };\n};\n"],"names":["autoplay","interval","options","slider","dispose","start","makeTimer","moveToIdx","track","details","position","animation","setInterval","pauseOnDrag","on","createEffect","pause"],"mappings":";;;;;AAIA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACaA,IAAAA,QAAQ,GAAG,SAAXA,QAAQ,GAUhB;EAAA,IATHC,QAAgB,uEAAG,IAAI,CAAA;AAAA,EAAA,IACvBC,OAOC,GAAA,SAAA,CAAA,MAAA,GAAA,CAAA,GAAA,SAAA,CAAA,CAAA,CAAA,GAAA,SAAA,CAAA;EAED,OAAO,UAACC,MAA0B,EAAK;AACrC,IAAA,IAAIC,OAAiB,CAAA;AACrB,IAAA,IAAMC,KAAK,GAAG,SAARA,KAAK,GAAS;MAClBD,OAAO,GAAGE,eAAS,CACjB,YAAA;AAAA,QAAA,OACEH,MAAM,CAACI,SAAS,CACdJ,MAAM,CAACK,KAAK,CAACC,OAAO,CAACC,QAAQ,GAAG,CAAC,EACjC,IAAI,EACJR,OAAO,CAACS,SAAS,CAClB,CAAA;OACHV,EAAAA,QAAQ,EACRW,WAAW,CACZ,CAAA;KACF,CAAA;AACD;AACA,IAAA,IAAIV,OAAO,CAACW,WAAW,KAAK,KAAK,EAAE;AACjCV,MAAAA,MAAM,CAACW,EAAE,CAAC,aAAa,EAAE,YAAA;AAAA,QAAA,IAAA,QAAA,CAAA;QAAA,OAAMV,CAAAA,QAAAA,GAAAA,OAAO,6CAAP,QAAW,EAAA,CAAA;OAAC,CAAA,CAAA;AAC7C,KAAA;AACAW,IAAAA,oBAAY,CAAC,YAAA;AAAA,MAAA,IAAA,SAAA,CAAA;AAAA,MAAA,OACX,CAACb,OAAO,CAACc,KAAK,IAAId,OAAO,CAACc,KAAK,EAAE,KAAK,KAAK,GAAGX,KAAK,EAAE,GAAGD,CAAAA,SAAAA,GAAAA,OAAO,8CAAP,SAAW,EAAA,CAAA;KACpE,CAAA,CAAA;GACF,CAAA;AACH;;;;"}
1
+ {"version":3,"file":"index.common.js","sources":["../../src/plugins/autoplay.tsx"],"sourcesContent":["import { makeTimer } from \"@solid-primitives/timer\";\nimport { KeenSliderInstance } from \"keen-slider\";\nimport { Accessor, createEffect } from \"solid-js\";\n\n/**\n * Provides an autoplay plugin.\n *\n * @param {number} interval Interval in milliseconds for switching slides\n * @param {object} options Options to customize the autoplay\n * @param {Function} options.pause A pause signal to control the autoplay\n * @param {boolean} options.pauseOnDrag Denotes of the autoplay should pause on drag.\n * @param {object} options.animation Allows for control of duration and easing.\n * @param {number} options.duration Duration for transitioning the slide.\n * @param {number} options.easing Easing function for the transition animation.\n *\n * @example\n * ```ts\n * const [create] = createSlider({}, [autoplay]);\n * ```\n */\nexport const autoplay = (\n interval: number = 1000,\n options: {\n pause?: Accessor<boolean>;\n pauseOnDrag?: boolean;\n animation?: {\n duration?: number;\n easing?: (t: number) => number;\n };\n },\n) => {\n return (slider: KeenSliderInstance) => {\n let dispose: Function;\n const start = () => {\n dispose = makeTimer(\n () =>\n slider.moveToIdx(\n slider.track.details.position + 1,\n true,\n options.animation,\n ),\n interval,\n setInterval,\n );\n };\n // Pause the slider on drag\n if (options.pauseOnDrag !== false) {\n slider.on(\"dragStarted\", () => dispose?.());\n }\n createEffect(() =>\n !options.pause || options.pause() === false ? start() : dispose?.(),\n );\n };\n};\n"],"names":["autoplay","interval","options","slider","dispose","start","makeTimer","moveToIdx","track","details","position","animation","setInterval","pauseOnDrag","on","createEffect","pause"],"mappings":";;;;;AAIA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACO,MAAMA,QAAQ,GAAGA,CACtBC,QAAgB,GAAG,IAAI,EACvBC,OAOC,KACE;AACH,EAAA,OAAQC,MAA0B,IAAK;AACrC,IAAA,IAAIC,OAAiB;IACrB,MAAMC,KAAK,GAAGA,MAAM;AAClBD,MAAAA,OAAO,GAAGE,eAAS,CACjB,MACEH,MAAM,CAACI,SAAS,CACdJ,MAAM,CAACK,KAAK,CAACC,OAAO,CAACC,QAAQ,GAAG,CAAC,EACjC,IAAI,EACJR,OAAO,CAACS,SACV,CAAC,EACHV,QAAQ,EACRW,WACF,CAAC;IACH,CAAC;AACD;AACA,IAAA,IAAIV,OAAO,CAACW,WAAW,KAAK,KAAK,EAAE;MACjCV,MAAM,CAACW,EAAE,CAAC,aAAa,EAAE,MAAMV,OAAO,IAAI,CAAC;AAC7C,IAAA;IACAW,oBAAY,CAAC,MACX,CAACb,OAAO,CAACc,KAAK,IAAId,OAAO,CAACc,KAAK,EAAE,KAAK,KAAK,GAAGX,KAAK,EAAE,GAAGD,OAAO,IACjE,CAAC;EACH,CAAC;AACH;;;;"}
@@ -17,27 +17,17 @@ import { createEffect } from 'solid-js';
17
17
  * const [create] = createSlider({}, [autoplay]);
18
18
  * ```
19
19
  */
20
- var autoplay = function autoplay() {
21
- var interval = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : 1000;
22
- var options = arguments.length > 1 ? arguments[1] : undefined;
23
- return function (slider) {
24
- var dispose;
25
- var start = function start() {
26
- dispose = makeTimer(function () {
27
- return slider.moveToIdx(slider.track.details.position + 1, true, options.animation);
28
- }, interval, setInterval);
20
+ const autoplay = (interval = 1000, options) => {
21
+ return slider => {
22
+ let dispose;
23
+ const start = () => {
24
+ dispose = makeTimer(() => slider.moveToIdx(slider.track.details.position + 1, true, options.animation), interval, setInterval);
29
25
  };
30
26
  // Pause the slider on drag
31
27
  if (options.pauseOnDrag !== false) {
32
- slider.on("dragStarted", function () {
33
- var _dispose;
34
- return (_dispose = dispose) === null || _dispose === void 0 ? void 0 : _dispose();
35
- });
28
+ slider.on("dragStarted", () => dispose?.());
36
29
  }
37
- createEffect(function () {
38
- var _dispose2;
39
- return !options.pause || options.pause() === false ? start() : (_dispose2 = dispose) === null || _dispose2 === void 0 ? void 0 : _dispose2();
40
- });
30
+ createEffect(() => !options.pause || options.pause() === false ? start() : dispose?.());
41
31
  };
42
32
  };
43
33
 
@@ -1 +1 @@
1
- {"version":3,"file":"index.module.js","sources":["../../src/plugins/autoplay.tsx"],"sourcesContent":["import { makeTimer } from \"@solid-primitives/timer\";\nimport { KeenSliderInstance } from \"keen-slider\";\nimport { Accessor, createEffect } from \"solid-js\";\n\n/**\n * Provides an autoplay plugin.\n *\n * @param {number} interval Interval in milliseconds for switching slides\n * @param {object} options Options to customize the autoplay\n * @param {Function} options.pause A pause signal to control the autoplay\n * @param {boolean} options.pauseOnDrag Denotes of the autoplay should pause on drag.\n * @param {object} options.animation Allows for control of duration and easing.\n * @param {number} options.duration Duration for transitioning the slide.\n * @param {number} options.easing Easing function for the transition animation.\n *\n * @example\n * ```ts\n * const [create] = createSlider({}, [autoplay]);\n * ```\n */\nexport const autoplay = (\n interval: number = 1000,\n options: {\n pause?: Accessor<boolean>;\n pauseOnDrag?: boolean;\n animation?: {\n duration?: number;\n easing?: (t: number) => number;\n };\n },\n) => {\n return (slider: KeenSliderInstance) => {\n let dispose: Function;\n const start = () => {\n dispose = makeTimer(\n () =>\n slider.moveToIdx(\n slider.track.details.position + 1,\n true,\n options.animation,\n ),\n interval,\n setInterval,\n );\n };\n // Pause the slider on drag\n if (options.pauseOnDrag !== false) {\n slider.on(\"dragStarted\", () => dispose?.());\n }\n createEffect(() =>\n !options.pause || options.pause() === false ? start() : dispose?.(),\n );\n };\n};\n"],"names":["autoplay","interval","options","slider","dispose","start","makeTimer","moveToIdx","track","details","position","animation","setInterval","pauseOnDrag","on","createEffect","pause"],"mappings":";;;AAIA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACaA,IAAAA,QAAQ,GAAG,SAAXA,QAAQ,GAUhB;EAAA,IATHC,QAAgB,uEAAG,IAAI,CAAA;AAAA,EAAA,IACvBC,OAOC,GAAA,SAAA,CAAA,MAAA,GAAA,CAAA,GAAA,SAAA,CAAA,CAAA,CAAA,GAAA,SAAA,CAAA;EAED,OAAO,UAACC,MAA0B,EAAK;AACrC,IAAA,IAAIC,OAAiB,CAAA;AACrB,IAAA,IAAMC,KAAK,GAAG,SAARA,KAAK,GAAS;MAClBD,OAAO,GAAGE,SAAS,CACjB,YAAA;AAAA,QAAA,OACEH,MAAM,CAACI,SAAS,CACdJ,MAAM,CAACK,KAAK,CAACC,OAAO,CAACC,QAAQ,GAAG,CAAC,EACjC,IAAI,EACJR,OAAO,CAACS,SAAS,CAClB,CAAA;OACHV,EAAAA,QAAQ,EACRW,WAAW,CACZ,CAAA;KACF,CAAA;AACD;AACA,IAAA,IAAIV,OAAO,CAACW,WAAW,KAAK,KAAK,EAAE;AACjCV,MAAAA,MAAM,CAACW,EAAE,CAAC,aAAa,EAAE,YAAA;AAAA,QAAA,IAAA,QAAA,CAAA;QAAA,OAAMV,CAAAA,QAAAA,GAAAA,OAAO,6CAAP,QAAW,EAAA,CAAA;OAAC,CAAA,CAAA;AAC7C,KAAA;AACAW,IAAAA,YAAY,CAAC,YAAA;AAAA,MAAA,IAAA,SAAA,CAAA;AAAA,MAAA,OACX,CAACb,OAAO,CAACc,KAAK,IAAId,OAAO,CAACc,KAAK,EAAE,KAAK,KAAK,GAAGX,KAAK,EAAE,GAAGD,CAAAA,SAAAA,GAAAA,OAAO,8CAAP,SAAW,EAAA,CAAA;KACpE,CAAA,CAAA;GACF,CAAA;AACH;;;;"}
1
+ {"version":3,"file":"index.module.js","sources":["../../src/plugins/autoplay.tsx"],"sourcesContent":["import { makeTimer } from \"@solid-primitives/timer\";\nimport { KeenSliderInstance } from \"keen-slider\";\nimport { Accessor, createEffect } from \"solid-js\";\n\n/**\n * Provides an autoplay plugin.\n *\n * @param {number} interval Interval in milliseconds for switching slides\n * @param {object} options Options to customize the autoplay\n * @param {Function} options.pause A pause signal to control the autoplay\n * @param {boolean} options.pauseOnDrag Denotes of the autoplay should pause on drag.\n * @param {object} options.animation Allows for control of duration and easing.\n * @param {number} options.duration Duration for transitioning the slide.\n * @param {number} options.easing Easing function for the transition animation.\n *\n * @example\n * ```ts\n * const [create] = createSlider({}, [autoplay]);\n * ```\n */\nexport const autoplay = (\n interval: number = 1000,\n options: {\n pause?: Accessor<boolean>;\n pauseOnDrag?: boolean;\n animation?: {\n duration?: number;\n easing?: (t: number) => number;\n };\n },\n) => {\n return (slider: KeenSliderInstance) => {\n let dispose: Function;\n const start = () => {\n dispose = makeTimer(\n () =>\n slider.moveToIdx(\n slider.track.details.position + 1,\n true,\n options.animation,\n ),\n interval,\n setInterval,\n );\n };\n // Pause the slider on drag\n if (options.pauseOnDrag !== false) {\n slider.on(\"dragStarted\", () => dispose?.());\n }\n createEffect(() =>\n !options.pause || options.pause() === false ? start() : dispose?.(),\n );\n };\n};\n"],"names":["autoplay","interval","options","slider","dispose","start","makeTimer","moveToIdx","track","details","position","animation","setInterval","pauseOnDrag","on","createEffect","pause"],"mappings":";;;AAIA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACO,MAAMA,QAAQ,GAAGA,CACtBC,QAAgB,GAAG,IAAI,EACvBC,OAOC,KACE;AACH,EAAA,OAAQC,MAA0B,IAAK;AACrC,IAAA,IAAIC,OAAiB;IACrB,MAAMC,KAAK,GAAGA,MAAM;AAClBD,MAAAA,OAAO,GAAGE,SAAS,CACjB,MACEH,MAAM,CAACI,SAAS,CACdJ,MAAM,CAACK,KAAK,CAACC,OAAO,CAACC,QAAQ,GAAG,CAAC,EACjC,IAAI,EACJR,OAAO,CAACS,SACV,CAAC,EACHV,QAAQ,EACRW,WACF,CAAC;IACH,CAAC;AACD;AACA,IAAA,IAAIV,OAAO,CAACW,WAAW,KAAK,KAAK,EAAE;MACjCV,MAAM,CAACW,EAAE,CAAC,aAAa,EAAE,MAAMV,OAAO,IAAI,CAAC;AAC7C,IAAA;IACAW,YAAY,CAAC,MACX,CAACb,OAAO,CAACc,KAAK,IAAId,OAAO,CAACc,KAAK,EAAE,KAAK,KAAK,GAAGX,KAAK,EAAE,GAAGD,OAAO,IACjE,CAAC;EACH,CAAC;AACH;;;;"}
@@ -48,4 +48,69 @@ export declare const SliderButton: FlowComponent<{
48
48
  [k: string]: boolean | undefined;
49
49
  };
50
50
  }>;
51
+ /**
52
+ * Navigation dots component for the slider.
53
+ * Displays a dot for each slide and highlights the current slide.
54
+ *
55
+ * @param props {string} class - Class to override the dots container.
56
+ * @param props {object} classList - List of classes to override the dots container.
57
+ * @param props {string} dotClass - Class to override individual dots.
58
+ * @param props {object} dotClassList - List of classes to override individual dots.
59
+ *
60
+ * @example
61
+ * ```tsx
62
+ * <SliderProvider>
63
+ * <Slider>
64
+ * <div class="keen-slider__slide">Slide 1</div>
65
+ * <div class="keen-slider__slide">Slide 2</div>
66
+ * </Slider>
67
+ * <SliderDots />
68
+ * </SliderProvider>
69
+ * ```
70
+ */
71
+ export declare const SliderDots: FlowComponent<{
72
+ class?: string;
73
+ classList?: {
74
+ [k: string]: boolean | undefined;
75
+ };
76
+ dotClass?: string;
77
+ dotClassList?: {
78
+ [k: string]: boolean | undefined;
79
+ };
80
+ }>;
81
+ /**
82
+ * Thumbnail navigation component for the slider.
83
+ * A second Slider that synchronizes with the main slider.
84
+ * User provides thumbnail slides as children.
85
+ *
86
+ * @param props {KeenSliderOptions} options - Options for the thumbnail slider.
87
+ * @param props {KeenSliderPlugin[]} plugins - Plugins for the thumbnail slider.
88
+ *
89
+ * @example
90
+ * ```tsx
91
+ * <SliderProvider>
92
+ * <Slider options={{ loop: true }}>
93
+ * <div class="keen-slider__slide">
94
+ * <img src="slide1.jpg" alt="Slide 1" />
95
+ * </div>
96
+ * <div class="keen-slider__slide">
97
+ * <img src="slide2.jpg" alt="Slide 2" />
98
+ * </div>
99
+ * </Slider>
100
+ * <SliderThumbnails options={{ slides: { perView: 4, spacing: 10 } }}>
101
+ * <div class="keen-slider__slide">
102
+ * <img src="thumb1.jpg" alt="Thumbnail 1" />
103
+ * </div>
104
+ * <div class="keen-slider__slide">
105
+ * <img src="thumb2.jpg" alt="Thumbnail 2" />
106
+ * </div>
107
+ * </SliderThumbnails>
108
+ * </SliderProvider>
109
+ * ```
110
+ */
111
+ export declare const SliderThumbnails: FlowComponent<{
112
+ options?: KeenSliderOptions;
113
+ plugins?: KeenSliderPlugin[];
114
+ activeClass?: string;
115
+ }>;
51
116
  export {};
@@ -1,4 +1,4 @@
1
- import { on, createContext, useContext, createSignal, createEffect, } from "solid-js";
1
+ import { on, createContext, useContext, createSignal, createEffect, Show, createMemo, Index, onMount, } from "solid-js";
2
2
  import { access } from "@solid-primitives/utils";
3
3
  import { isServer } from "solid-js/web";
4
4
  import { createSlider } from "./primitive";
@@ -55,3 +55,150 @@ export const SliderButton = (props) => {
55
55
  {props.children}
56
56
  </button>);
57
57
  };
58
+ /**
59
+ * Navigation dots component for the slider.
60
+ * Displays a dot for each slide and highlights the current slide.
61
+ *
62
+ * @param props {string} class - Class to override the dots container.
63
+ * @param props {object} classList - List of classes to override the dots container.
64
+ * @param props {string} dotClass - Class to override individual dots.
65
+ * @param props {object} dotClassList - List of classes to override individual dots.
66
+ *
67
+ * @example
68
+ * ```tsx
69
+ * <SliderProvider>
70
+ * <Slider>
71
+ * <div class="keen-slider__slide">Slide 1</div>
72
+ * <div class="keen-slider__slide">Slide 2</div>
73
+ * </Slider>
74
+ * <SliderDots />
75
+ * </SliderProvider>
76
+ * ```
77
+ */
78
+ export const SliderDots = (props) => {
79
+ const context = useContext(SliderContext);
80
+ const [slideCount, setSlideCount] = createSignal(0);
81
+ const handleDotClick = (idx) => {
82
+ if (context == null)
83
+ return;
84
+ const [helpers] = context;
85
+ helpers()?.moveTo(idx);
86
+ };
87
+ // Update slide count when slider is created/updated
88
+ createEffect(() => {
89
+ if (!context)
90
+ return;
91
+ const [helpers] = context;
92
+ const sliderInstance = helpers()?.slider();
93
+ if (sliderInstance) {
94
+ const updateCount = () => {
95
+ const details = helpers()?.details();
96
+ setSlideCount(details?.slides?.length || 0);
97
+ };
98
+ // Set initial count
99
+ updateCount();
100
+ // Listen for slider changes
101
+ sliderInstance.on("created", updateCount);
102
+ sliderInstance.on("updated", updateCount);
103
+ }
104
+ });
105
+ const slides = createMemo(() => Array.from({ length: slideCount() }, (_, i) => i));
106
+ return (<Show when={context != null}>
107
+ <div class={props.class || "keen-slider-dots"} classList={props.classList}>
108
+ <Index each={slides()}>
109
+ {(idx) => {
110
+ const [helpers] = context;
111
+ const isActive = () => helpers()?.current() === idx();
112
+ return (<button class={props.dotClass || "keen-slider-dot"} classList={{
113
+ ...props.dotClassList,
114
+ active: isActive(),
115
+ }} onClick={() => handleDotClick(idx())} aria-label={`Go to slide ${idx() + 1}`}/>);
116
+ }}
117
+ </Index>
118
+ </div>
119
+ </Show>);
120
+ };
121
+ /**
122
+ * Thumbnail navigation component for the slider.
123
+ * A second Slider that synchronizes with the main slider.
124
+ * User provides thumbnail slides as children.
125
+ *
126
+ * @param props {KeenSliderOptions} options - Options for the thumbnail slider.
127
+ * @param props {KeenSliderPlugin[]} plugins - Plugins for the thumbnail slider.
128
+ *
129
+ * @example
130
+ * ```tsx
131
+ * <SliderProvider>
132
+ * <Slider options={{ loop: true }}>
133
+ * <div class="keen-slider__slide">
134
+ * <img src="slide1.jpg" alt="Slide 1" />
135
+ * </div>
136
+ * <div class="keen-slider__slide">
137
+ * <img src="slide2.jpg" alt="Slide 2" />
138
+ * </div>
139
+ * </Slider>
140
+ * <SliderThumbnails options={{ slides: { perView: 4, spacing: 10 } }}>
141
+ * <div class="keen-slider__slide">
142
+ * <img src="thumb1.jpg" alt="Thumbnail 1" />
143
+ * </div>
144
+ * <div class="keen-slider__slide">
145
+ * <img src="thumb2.jpg" alt="Thumbnail 2" />
146
+ * </div>
147
+ * </SliderThumbnails>
148
+ * </SliderProvider>
149
+ * ```
150
+ */
151
+ export const SliderThumbnails = (props) => {
152
+ if (isServer)
153
+ return <div>{props.children}</div>;
154
+ const mainContext = useContext(SliderContext);
155
+ if (!mainContext) {
156
+ console.warn("SliderThumbnails must be used within a SliderProvider");
157
+ return <div>{props.children}</div>;
158
+ }
159
+ const [mainHelpers] = mainContext;
160
+ // Create thumbnail slider with user options
161
+ const [thumbSlider, thumbHelpers] = createSlider(props.options || {}, ...(props.plugins || []));
162
+ // Update on children change (same as main Slider)
163
+ createEffect(on(() => access(props.children), () => queueMicrotask(() => thumbHelpers.update()), { defer: true }));
164
+ // Sync thumbnail slider with main slider
165
+ onMount(() => {
166
+ // Wait for next tick to ensure both sliders are mounted
167
+ queueMicrotask(() => {
168
+ const mainSliderInstance = mainHelpers()?.slider();
169
+ const thumbSliderInstance = thumbHelpers.slider();
170
+ if (mainSliderInstance && thumbSliderInstance) {
171
+ // Function to update active thumbnail
172
+ const activeClassName = props.activeClass || "active";
173
+ const updateActiveThumbnail = () => {
174
+ const mainCurrent = mainHelpers()?.current();
175
+ if (mainCurrent !== undefined) {
176
+ // Remove active class from all thumbnails
177
+ thumbSliderInstance.slides.forEach((slide) => {
178
+ slide.classList.remove(activeClassName);
179
+ });
180
+ // Add active class to current thumbnail
181
+ if (thumbSliderInstance.slides[mainCurrent]) {
182
+ thumbSliderInstance.slides[mainCurrent].classList.add(activeClassName);
183
+ }
184
+ // Move thumbnail slider to show active thumbnail
185
+ thumbHelpers.moveTo(mainCurrent);
186
+ }
187
+ };
188
+ // Listen to main slider changes
189
+ mainSliderInstance.on("slideChanged", updateActiveThumbnail);
190
+ // Set initial active state
191
+ updateActiveThumbnail();
192
+ // Add click handlers to thumbnails
193
+ thumbSliderInstance.slides.forEach((slide, idx) => {
194
+ slide.addEventListener("click", () => {
195
+ mainHelpers()?.moveTo(idx);
196
+ });
197
+ });
198
+ }
199
+ });
200
+ });
201
+ // Prevent tree-shaking
202
+ thumbSlider;
203
+ return <div use:thumbSlider>{props.children}</div>;
204
+ };