imageslider-next 1.2.1 → 1.3.2

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
@@ -1,79 +1,116 @@
1
- # Simple Image Slider - Next
2
-
3
- imageslider-next is a simple image slider using tailwind css.
1
+ # imageslider-next
4
2
 
5
- ## Installation
3
+ A small, framework-agnostic image slider component built with Tailwind CSS and TypeScript. This package now supports passing a custom image component (for example, Next.js `Image`) so you can enable optimized images inside Next.js projects.
4
+
5
+ ## Install
6
6
 
7
7
  ```zsh
8
8
  npm i imageslider-next
9
+ # or
10
+ pnpm add imageslider-next
9
11
  ```
10
12
 
11
- ### Configure Tailwind
13
+ ## Features
14
+
15
+ - Lightweight, accessible image slider.
16
+ - Accepts a custom `ImageComponent` (e.g. `next/image`) for optimized images.
17
+ - `imageProps` forwarding for responsive behavior (e.g. `sizes`, `priority`, `objectFit`).
18
+ - Responsive native `<img>` fallback when no `ImageComponent` is provided.
19
+ - Fixed: each slider instance is independent; controls no longer collide across multiple instances.
20
+
21
+ ## Basic usage
22
+
23
+ ```tsx
24
+ import ImageSliderNext from 'imageslider-next';
25
+
26
+ const data = [
27
+ { id: 1, imageUrl: '/images/1.jpg', title: 'One', alt: 'One', width: 1200, height: 800 },
28
+ { id: 2, imageUrl: '/images/2.jpg', title: 'Two', alt: 'Two', width: 1200, height: 800 },
29
+ { id: 3, imageUrl: '/images/3.jpg', title: 'Three', alt: 'Three', width: 1200, height: 800 },
30
+ ];
31
+
32
+ <ImageSliderNext
33
+ data={data}
34
+ sliderClassName="w-full shadow-md h-64 sm:h-80 rounded-lg"
35
+ slideClassName=""
36
+ buttonClassName="w-3 h-3 rounded-full bg-black/50"
37
+ imageWidth={1200}
38
+ imageHeight={800}
39
+ />
40
+ ```
12
41
 
13
- For help with Tailwind CSS installation:
14
- [Tailwind CSS Installation](https://tailwindcss.com/docs/installation)
42
+ ## Using Next.js `Image` for optimization
15
43
 
16
- Add imageslider-next component to the template path in `tailwind.config.js` file:
44
+ If you use Next.js, pass `Image` as the `ImageComponent` prop and optionally forward `imageProps` to enable responsive loading. Example:
17
45
 
18
- ```ts
19
- import type { Config } from "tailwindcss";
20
-
21
- const config: Config = {
22
- content: [
23
- "./node_modules/imageslider-next/**/*.js"
24
- ],
25
- theme: {
26
- extend: {},
27
- },
28
- plugins: [],
29
- }
46
+ ```tsx
47
+ import Image from 'next/image';
48
+ import ImageSliderNext from 'imageslider-next';
49
+ import img1 from '@/public/1.jpg';
50
+
51
+ const slides = [
52
+ { id: 1, imageSrc: img1, title: 'First', alt: 'first', width: 1200, height: 800 },
53
+ // ...
54
+ ];
55
+
56
+ <ImageSliderNext
57
+ data={slides}
58
+ sliderClassName="w-full shadow-md h-[50vh] rounded-lg"
59
+ ImageComponent={Image}
60
+ imageProps={{ sizes: '100vw', priority: true }}
61
+ imageWidth={1200}
62
+ imageHeight={800}
63
+ />
30
64
  ```
31
65
 
32
- ## Example
66
+ Notes:
67
+ - We intentionally strip `fill: true` when forwarded to avoid layout issues inside the slider (the slider manages layout). If you need `fill` behavior, you can implement a wrapper with an explicit aspect ratio on your slide.
68
+ - Provide `width`/`height` per item or use `imageWidth`/`imageHeight` defaults to help the component calculate correct sizes.
33
69
 
34
- ```ts
70
+ ## Storybook
35
71
 
36
- <div className="relative flex items-center justify-center">
37
- <ImageSliderNext data={imageData} sliderClassName={"w-full shadow-md h-48 sm:h-64 xl:h-80 2xl:h-96 rounded-lg"} slideClassName={""} buttonClassName={"w-3 h-3 rounded-full bg-black/50"} buttonLabelClassName={"hidden"} imageHeight={300} imageWidth={500} />
38
- </div>
72
+ To run the component locally with Storybook:
39
73
 
74
+ ```bash
75
+ npm run storybook
76
+ # or
77
+ pnpm storybook
40
78
  ```
41
79
 
42
- ### data structure
43
- ```ts
80
+ There are example stories that show a native `<img>` fallback and usage with a mock `Image` component. Use the `With Image Component` story to test integration.
44
81
 
45
- // json data structure
46
- [
47
- {
48
- id: 1,
49
- imageUrl: 'https://www.w3schools.com/w3images/workbench.jpg',
50
- title: 'Image 1',
51
- },
52
- {
53
- id: 2,
54
- imageUrl: 'https://www.w3schools.com/w3images/coffee.jpg',
55
- title: 'Image 2',
56
- },
57
- {
58
- id: 3,
59
- imageUrl: 'https://www.w3schools.com/w3images/sound.jpg',
60
- title: 'Image 3',
61
- },
62
- // Add more images as needed
63
- ]
82
+ Hosted Storybook: https://imageslider-next.vercel.app/
64
83
 
65
- ```
84
+ ## TypeScript / image imports
85
+
86
+ If your TypeScript setup complains about importing image files, add a simple declaration file `src/types/images.d.ts`:
66
87
 
67
- ### import in NextJS via external json file
68
88
  ```ts
89
+ declare module '*.jpg';
90
+ declare module '*.png';
91
+ declare module '*.svg';
92
+ declare module '*.webp';
93
+ declare module '*.avif';
94
+ ```
69
95
 
70
- // Using NextJS and external json.
71
- import imageData from '@/public/your-data.json';
96
+ Also, for local development you may want to add React type declarations if you see missing types:
72
97
 
98
+ ```bash
99
+ npm install -D @types/react @types/react-dom
73
100
  ```
74
101
 
75
- ## Documentation
102
+ ## API
103
+
104
+ `ImageSliderNext` props (high level):
105
+
106
+ - `data: ItemData[]` — items to render. Each item supports `imageUrl`, `imageSrc` (imported images), `title`, `alt`, `width`, `height`.
107
+ - `sliderClassName: string` — classes applied to slider root.
108
+ - `slideClassName: string` — classes applied to each slide.
109
+ - `buttonClassName: string` — classes applied to pagination buttons.
110
+ - `imageWidth?: number`, `imageHeight?: number` — defaults used when per-item sizes missing.
111
+ - `ImageComponent?: React.ComponentType<any>` — optional image component (pass Next's `Image`).
112
+ - `imageProps?: Record<string, any>` — forwarded props for the image component (we strip `fill`).
76
113
 
77
- **Storybook Url:** [https://imageslider-next.vercel.app/](https://imageslider-next.vercel.app/)
114
+ ## Contributing
78
115
 
79
- ## Contributing
116
+ PRs welcome — please run `npm run build` and `npm run storybook` to test changes locally.
@@ -9,6 +9,12 @@ exports["default"] = void 0;
9
9
  var _react = _interopRequireWildcard(require("react"));
10
10
  function _getRequireWildcardCache(e) { if ("function" != typeof WeakMap) return null; var r = new WeakMap(), t = new WeakMap(); return (_getRequireWildcardCache = function _getRequireWildcardCache(e) { return e ? t : r; })(e); }
11
11
  function _interopRequireWildcard(e, r) { if (!r && e && e.__esModule) return e; if (null === e || "object" != _typeof(e) && "function" != typeof e) return { "default": e }; var t = _getRequireWildcardCache(r); if (t && t.has(e)) return t.get(e); var n = { __proto__: null }, a = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var u in e) if ("default" !== u && {}.hasOwnProperty.call(e, u)) { var i = a ? Object.getOwnPropertyDescriptor(e, u) : null; i && (i.get || i.set) ? Object.defineProperty(n, u, i) : n[u] = e[u]; } return n["default"] = e, t && t.set(e, n), n; }
12
+ function _extends() { _extends = Object.assign ? Object.assign.bind() : function (target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]; for (var key in source) { if (Object.prototype.hasOwnProperty.call(source, key)) { target[key] = source[key]; } } } return target; }; return _extends.apply(this, arguments); }
13
+ function ownKeys(e, r) { var t = Object.keys(e); if (Object.getOwnPropertySymbols) { var o = Object.getOwnPropertySymbols(e); r && (o = o.filter(function (r) { return Object.getOwnPropertyDescriptor(e, r).enumerable; })), t.push.apply(t, o); } return t; }
14
+ function _objectSpread(e) { for (var r = 1; r < arguments.length; r++) { var t = null != arguments[r] ? arguments[r] : {}; r % 2 ? ownKeys(Object(t), !0).forEach(function (r) { _defineProperty(e, r, t[r]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys(Object(t)).forEach(function (r) { Object.defineProperty(e, r, Object.getOwnPropertyDescriptor(t, r)); }); } return e; }
15
+ function _defineProperty(obj, key, value) { key = _toPropertyKey(key); if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }
16
+ function _toPropertyKey(t) { var i = _toPrimitive(t, "string"); return "symbol" == _typeof(i) ? i : i + ""; }
17
+ function _toPrimitive(t, r) { if ("object" != _typeof(t) || !t) return t; var e = t[Symbol.toPrimitive]; if (void 0 !== e) { var i = e.call(t, r || "default"); if ("object" != _typeof(i)) return i; throw new TypeError("@@toPrimitive must return a primitive value."); } return ("string" === r ? String : Number)(t); }
12
18
  function _slicedToArray(arr, i) { return _arrayWithHoles(arr) || _iterableToArrayLimit(arr, i) || _unsupportedIterableToArray(arr, i) || _nonIterableRest(); }
13
19
  function _nonIterableRest() { throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); }
14
20
  function _unsupportedIterableToArray(o, minLen) { if (!o) return; if (typeof o === "string") return _arrayLikeToArray(o, minLen); var n = Object.prototype.toString.call(o).slice(8, -1); if (n === "Object" && o.constructor) n = o.constructor.name; if (n === "Map" || n === "Set") return Array.from(o); if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _arrayLikeToArray(o, minLen); }
@@ -22,56 +28,79 @@ var ImageSliderNext = function ImageSliderNext(_ref) {
22
28
  buttonClassName = _ref.buttonClassName,
23
29
  imageWidth = _ref.imageWidth,
24
30
  imageHeight = _ref.imageHeight,
25
- buttonLabelClassName = _ref.buttonLabelClassName;
31
+ buttonLabelClassName = _ref.buttonLabelClassName,
32
+ ImageComponent = _ref.ImageComponent,
33
+ imageProps = _ref.imageProps;
26
34
  var _useState = (0, _react.useState)(0),
27
35
  _useState2 = _slicedToArray(_useState, 2),
28
36
  current = _useState2[0],
29
37
  setCurrent = _useState2[1];
30
- var _useState3 = (0, _react.useState)(null),
31
- _useState4 = _slicedToArray(_useState3, 2),
32
- slides = _useState4[0],
33
- setSlides = _useState4[1];
38
+ var slidesRef = (0, _react.useRef)(null);
39
+ var rootRef = (0, _react.useRef)(null);
34
40
  (0, _react.useEffect)(function () {
35
- var slider = document.getElementById('slider');
36
- if (slider) {
37
- setSlides(slider.querySelector('.slides'));
41
+ if (rootRef.current) {
42
+ slidesRef.current = rootRef.current.querySelector('.slides');
38
43
  }
39
44
  }, []);
40
45
  var handlePrev = function handlePrev() {
41
- if (slides) {
42
- setCurrent((current - 1 + slides.children.length) % slides.children.length);
46
+ if (slidesRef.current) {
47
+ setCurrent((current - 1 + slidesRef.current.children.length) % slidesRef.current.children.length);
43
48
  }
44
49
  };
45
50
  var handleNext = function handleNext() {
46
- if (slides) {
47
- setCurrent((current + 1) % slides.children.length);
51
+ if (slidesRef.current) {
52
+ setCurrent((current + 1) % slidesRef.current.children.length);
48
53
  }
49
54
  };
50
55
  var goToNext = function goToNext(index) {
51
56
  setCurrent(index);
52
57
  };
53
58
  (0, _react.useEffect)(function () {
54
- if (slides) {
55
- slides.style.transform = 'translateX(' + -current * 100 + '%)';
59
+ if (slidesRef.current) {
60
+ slidesRef.current.style.transform = 'translateX(' + -current * 100 + '%)';
56
61
  }
57
- }, [current, slides]);
62
+ }, [current, slidesRef]);
58
63
  var baseSliderCssClass = "overflow-hidden relative flex items-center justify-center";
59
64
  var baseSlideCssClass = "slide flex-none w-full h-full items-center justify-center overflow-hidden";
60
65
  var baseButtonCssClass = buttonClassName === "" ? "w-3 h-3 rounded-full bg-black/50" : buttonClassName;
61
66
  var baseButtonLabelCssClass = buttonLabelClassName === null ? "" : buttonLabelClassName;
62
67
  return /*#__PURE__*/_react["default"].createElement("div", {
63
- className: "".concat(baseSliderCssClass, " ").concat(sliderClassName),
64
- id: "slider"
68
+ ref: rootRef,
69
+ className: "".concat(baseSliderCssClass, " ").concat(sliderClassName)
65
70
  }, /*#__PURE__*/_react["default"].createElement("div", {
66
71
  className: "slides flex transition-transform duration-700 ease-in-out"
67
72
  }, data.map(function (itemData, index) {
73
+ var _ref2, _itemData$width, _ref3, _itemData$height, _ref4, _itemData$imageSrc, _itemData$alt, _itemData$width2, _itemData$height2, _ref5, _itemData$imageUrl, _itemData$alt2;
74
+ var itemWidth = (_ref2 = (_itemData$width = itemData.width) !== null && _itemData$width !== void 0 ? _itemData$width : imageWidth) !== null && _ref2 !== void 0 ? _ref2 : 1;
75
+ var itemHeight = (_ref3 = (_itemData$height = itemData.height) !== null && _itemData$height !== void 0 ? _itemData$height : imageHeight) !== null && _ref3 !== void 0 ? _ref3 : 1;
76
+ // keep paddingTop calculation available if needed elsewhere
77
+ var paddingTop = "".concat(itemHeight / itemWidth * 100, "%");
78
+ var forwardedImageProps = _objectSpread({}, imageProps !== null && imageProps !== void 0 ? imageProps : {});
79
+ // Always ignore fill to avoid absolute/fill behavior which can cause layout issues in the slider
80
+ if ('fill' in forwardedImageProps) delete forwardedImageProps.fill;
68
81
  return /*#__PURE__*/_react["default"].createElement("div", {
69
82
  key: itemData.id,
70
83
  className: "".concat(baseSlideCssClass, " ").concat(slideClassName)
71
- }, /*#__PURE__*/_react["default"].createElement("img", {
72
- src: itemData.imageUrl,
73
- alt: itemData.title,
74
- className: "w-full"
84
+ }, ImageComponent ?
85
+ /*#__PURE__*/
86
+ // Always render the provided Image component in non-fill mode (width/height or responsive)
87
+ _react["default"].createElement(ImageComponent, _extends({
88
+ src: (_ref4 = (_itemData$imageSrc = itemData.imageSrc) !== null && _itemData$imageSrc !== void 0 ? _itemData$imageSrc : itemData.imageUrl) !== null && _ref4 !== void 0 ? _ref4 : '',
89
+ alt: (_itemData$alt = itemData.alt) !== null && _itemData$alt !== void 0 ? _itemData$alt : itemData.title,
90
+ width: (_itemData$width2 = itemData.width) !== null && _itemData$width2 !== void 0 ? _itemData$width2 : imageWidth,
91
+ height: (_itemData$height2 = itemData.height) !== null && _itemData$height2 !== void 0 ? _itemData$height2 : imageHeight,
92
+ className: "w-full h-auto"
93
+ }, forwardedImageProps)) :
94
+ /*#__PURE__*/
95
+ // native img fallback: make responsive via width 100% and height auto
96
+ _react["default"].createElement("img", {
97
+ src: (_ref5 = (_itemData$imageUrl = itemData.imageUrl) !== null && _itemData$imageUrl !== void 0 ? _itemData$imageUrl : itemData.imageSrc) !== null && _ref5 !== void 0 ? _ref5 : '',
98
+ alt: (_itemData$alt2 = itemData.alt) !== null && _itemData$alt2 !== void 0 ? _itemData$alt2 : itemData.title,
99
+ style: {
100
+ width: '100%',
101
+ height: 'auto',
102
+ display: 'block'
103
+ }
75
104
  }));
76
105
  })), /*#__PURE__*/_react["default"].createElement("div", {
77
106
  className: "flex flex-wrap absolute bottom-2 z-50 space-x-3"
@@ -1,13 +1,25 @@
1
1
  "use strict";
2
2
 
3
+ function _typeof(o) { "@babel/helpers - typeof"; return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function (o) { return typeof o; } : function (o) { return o && "function" == typeof Symbol && o.constructor === Symbol && o !== Symbol.prototype ? "symbol" : typeof o; }, _typeof(o); }
3
4
  Object.defineProperty(exports, "__esModule", {
4
5
  value: true
5
6
  });
6
- exports["default"] = exports.Default = void 0;
7
+ exports["default"] = exports.WithImageComponent = exports.Default = void 0;
7
8
  var _react = _interopRequireDefault(require("react"));
8
9
  var _imagesliderNext = _interopRequireDefault(require("./imageslider-next"));
9
10
  require("tailwindcss/tailwind.css");
11
+ var _excluded = ["src", "alt", "width", "height", "fill", "style"];
10
12
  function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { "default": obj }; }
13
+ function ownKeys(e, r) { var t = Object.keys(e); if (Object.getOwnPropertySymbols) { var o = Object.getOwnPropertySymbols(e); r && (o = o.filter(function (r) { return Object.getOwnPropertyDescriptor(e, r).enumerable; })), t.push.apply(t, o); } return t; }
14
+ function _objectSpread(e) { for (var r = 1; r < arguments.length; r++) { var t = null != arguments[r] ? arguments[r] : {}; r % 2 ? ownKeys(Object(t), !0).forEach(function (r) { _defineProperty(e, r, t[r]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys(Object(t)).forEach(function (r) { Object.defineProperty(e, r, Object.getOwnPropertyDescriptor(t, r)); }); } return e; }
15
+ function _defineProperty(obj, key, value) { key = _toPropertyKey(key); if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }
16
+ function _toPropertyKey(t) { var i = _toPrimitive(t, "string"); return "symbol" == _typeof(i) ? i : i + ""; }
17
+ function _toPrimitive(t, r) { if ("object" != _typeof(t) || !t) return t; var e = t[Symbol.toPrimitive]; if (void 0 !== e) { var i = e.call(t, r || "default"); if ("object" != _typeof(i)) return i; throw new TypeError("@@toPrimitive must return a primitive value."); } return ("string" === r ? String : Number)(t); }
18
+ function _objectWithoutProperties(source, excluded) { if (source == null) return {}; var target = _objectWithoutPropertiesLoose(source, excluded); var key, i; if (Object.getOwnPropertySymbols) { var sourceSymbolKeys = Object.getOwnPropertySymbols(source); for (i = 0; i < sourceSymbolKeys.length; i++) { key = sourceSymbolKeys[i]; if (excluded.indexOf(key) >= 0) continue; if (!Object.prototype.propertyIsEnumerable.call(source, key)) continue; target[key] = source[key]; } } return target; }
19
+ function _objectWithoutPropertiesLoose(source, excluded) { if (source == null) return {}; var target = {}; for (var key in source) { if (Object.prototype.hasOwnProperty.call(source, key)) { if (excluded.indexOf(key) >= 0) continue; target[key] = source[key]; } } return target; }
20
+ var img1 = require('./stories/assets/images/1.jpg');
21
+ var img2 = require('./stories/assets/images/2.jpg');
22
+ var img3 = require('./stories/assets/images/3.jpg');
11
23
  var _default = exports["default"] = {
12
24
  title: 'ImageSliderNext',
13
25
  component: _imagesliderNext["default"],
@@ -20,16 +32,19 @@ var Default = exports.Default = Template.bind({});
20
32
  Default.args = {
21
33
  data: [{
22
34
  id: 1,
23
- imageUrl: 'https://www.w3schools.com/w3images/workbench.jpg',
24
- title: 'Image 1'
35
+ imageSrc: img1,
36
+ title: 'Image 1',
37
+ alt: 'Image 1'
25
38
  }, {
26
39
  id: 2,
27
- imageUrl: 'https://www.w3schools.com/w3images/coffee.jpg',
28
- title: 'Image 2'
40
+ imageSrc: img2,
41
+ title: 'Image 2',
42
+ alt: 'Image 2'
29
43
  }, {
30
44
  id: 3,
31
- imageUrl: 'https://www.w3schools.com/w3images/sound.jpg',
32
- title: 'Image 3'
45
+ imageSrc: img3,
46
+ title: 'Image 3',
47
+ alt: 'Image 3'
33
48
  }
34
49
  // Add more images as needed
35
50
  ],
@@ -39,4 +54,49 @@ Default.args = {
39
54
  buttonLabelClassName: 'hidden',
40
55
  imageWidth: 500,
41
56
  imageHeight: 300
42
- };
57
+ };
58
+
59
+ // A tiny Mock Image component that mimics next/image API just for Storybook preview.
60
+ var MockImage = function MockImage(_ref) {
61
+ var src = _ref.src,
62
+ alt = _ref.alt,
63
+ width = _ref.width,
64
+ height = _ref.height,
65
+ fill = _ref.fill,
66
+ style = _ref.style,
67
+ rest = _objectWithoutProperties(_ref, _excluded);
68
+ if (fill) {
69
+ var _rest$objectFit;
70
+ return /*#__PURE__*/_react["default"].createElement("img", {
71
+ src: src,
72
+ alt: alt,
73
+ style: {
74
+ position: 'absolute',
75
+ inset: 0,
76
+ width: '100%',
77
+ height: '100%',
78
+ objectFit: (_rest$objectFit = rest.objectFit) !== null && _rest$objectFit !== void 0 ? _rest$objectFit : 'cover'
79
+ }
80
+ });
81
+ }
82
+ return /*#__PURE__*/_react["default"].createElement("img", {
83
+ src: src,
84
+ alt: alt,
85
+ width: width,
86
+ height: height,
87
+ style: _objectSpread({
88
+ width: '100%',
89
+ height: 'auto',
90
+ display: 'block'
91
+ }, style)
92
+ });
93
+ };
94
+ var WithImageComponent = exports.WithImageComponent = Template.bind({});
95
+ WithImageComponent.args = _objectSpread(_objectSpread({}, Default.args), {}, {
96
+ ImageComponent: MockImage,
97
+ imageProps: {
98
+ fill: false,
99
+ sizes: '100vw'
100
+ },
101
+ sliderClassName: 'm-5 shadow-md h-[50vh] rounded-lg'
102
+ });
@@ -1 +1 @@
1
- {"version":3,"file":"imageslider-next.d.ts","sourceRoot":"","sources":["../../../src/imageslider-next.tsx"],"names":[],"mappings":"AAGA,OAAO,KAA8B,MAAM,OAAO,CAAC;AACnD,OAAO,EAAE,gBAAgB,EAAE,MAAM,oBAAoB,CAAC;AAGtD,QAAA,MAAM,eAAe,EAAE,KAAK,CAAC,EAAE,CAAC,gBAAgB,CA8E/C,CAAA;AAED,eAAe,eAAe,CAAC"}
1
+ {"version":3,"file":"imageslider-next.d.ts","sourceRoot":"","sources":["../../../src/imageslider-next.tsx"],"names":[],"mappings":"AAGA,OAAO,KAAsC,MAAM,OAAO,CAAC;AAC3D,OAAO,EAAE,gBAAgB,EAAE,MAAM,oBAAoB,CAAC;AAGtD,QAAA,MAAM,eAAe,EAAE,KAAK,CAAC,EAAE,CAAC,gBAAgB,CAsG/C,CAAA;AAED,eAAe,eAAe,CAAC"}
@@ -1,6 +1,7 @@
1
1
  import { ImageSliderProps } from './imagesliderprops';
2
2
  import 'tailwindcss/tailwind.css';
3
- declare const _default: import("@storybook/types").ComponentAnnotations<import("@storybook/react").ReactRenderer, import("@storybook/types").Args>;
3
+ declare const _default: import("storybook/internal/csf").ComponentAnnotations<import("@storybook/react-webpack5").ReactRenderer, import("@storybook/react-webpack5").Args>;
4
4
  export default _default;
5
- export declare const Default: import("@storybook/types").AnnotatedStoryFn<import("@storybook/react").ReactRenderer, ImageSliderProps>;
5
+ export declare const Default: import("storybook/internal/csf").AnnotatedStoryFn<import("@storybook/react-webpack5").ReactRenderer, ImageSliderProps>;
6
+ export declare const WithImageComponent: import("storybook/internal/csf").AnnotatedStoryFn<import("@storybook/react-webpack5").ReactRenderer, ImageSliderProps>;
6
7
  //# sourceMappingURL=imageslider-next.stories.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"imageslider-next.stories.d.ts","sourceRoot":"","sources":["../../../src/imageslider-next.stories.tsx"],"names":[],"mappings":"AAGA,OAAO,EAAE,gBAAgB,EAAE,MAAM,oBAAoB,CAAC;AACtD,OAAO,0BAA0B,CAAC;;AAElC,wBAIU;AAIV,eAAO,MAAM,OAAO,yGAAoB,CAAC"}
1
+ {"version":3,"file":"imageslider-next.stories.d.ts","sourceRoot":"","sources":["../../../src/imageslider-next.stories.tsx"],"names":[],"mappings":"AAGA,OAAO,EAAE,gBAAgB,EAAE,MAAM,oBAAoB,CAAC;AAItD,OAAO,0BAA0B,CAAC;;AAElC,wBAIU;AAIV,eAAO,MAAM,OAAO,wHAAoB,CAAC;AA0BzC,eAAO,MAAM,kBAAkB,wHAAoB,CAAC"}
@@ -1,15 +1,27 @@
1
+ import React from 'react';
1
2
  export interface ItemData {
2
3
  id: number;
3
- imageUrl: string;
4
+ /** string URL or imported image (StaticImageData) */
5
+ imageUrl?: string;
6
+ imageSrc?: string | any;
4
7
  title: string;
8
+ alt?: string;
9
+ width?: number;
10
+ height?: number;
5
11
  }
6
12
  export interface ImageSliderProps {
7
13
  data: ItemData[];
8
14
  sliderClassName: string;
9
15
  slideClassName: string;
10
16
  buttonClassName: string;
11
- imageWidth: number;
12
- imageHeight: number;
17
+ /** default width applied when individual item width is not provided */
18
+ imageWidth?: number;
19
+ /** default height applied when individual item height is not provided */
20
+ imageHeight?: number;
13
21
  buttonLabelClassName?: string | null;
22
+ /** Optional image component to render images. Pass Next.js `Image` here for optimized images. */
23
+ ImageComponent?: React.ComponentType<any>;
24
+ /** Optional props forwarded to the image component or native img element (e.g. { fill: true, sizes: '100vw' }) */
25
+ imageProps?: Record<string, any>;
14
26
  }
15
27
  //# sourceMappingURL=imagesliderprops.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"imagesliderprops.d.ts","sourceRoot":"","sources":["../../../src/imagesliderprops.ts"],"names":[],"mappings":"AACA,MAAM,WAAW,QAAQ;IACrB,EAAE,EAAE,MAAM,CAAC;IACX,QAAQ,EAAE,MAAM,CAAC;IACjB,KAAK,EAAE,MAAM,CAAC;CACf;AAEH,MAAM,WAAW,gBAAgB;IAC7B,IAAI,EAAE,QAAQ,EAAE,CAAC;IACjB,eAAe,EAAE,MAAM,CAAC;IACxB,cAAc,EAAE,MAAM,CAAC;IACvB,eAAe,EAAE,MAAM,CAAC;IACxB,UAAU,EAAE,MAAM,CAAC;IACnB,WAAW,EAAE,MAAM,CAAC;IACpB,oBAAoB,CAAC,EAAE,MAAM,GAAG,IAAI,CAAC;CACxC"}
1
+ {"version":3,"file":"imagesliderprops.d.ts","sourceRoot":"","sources":["../../../src/imagesliderprops.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,MAAM,OAAO,CAAC;AAE1B,MAAM,WAAW,QAAQ;IACvB,EAAE,EAAE,MAAM,CAAC;IACX,qDAAqD;IACrD,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB,QAAQ,CAAC,EAAE,MAAM,GAAG,GAAG,CAAC;IACxB,KAAK,EAAE,MAAM,CAAC;IACd,GAAG,CAAC,EAAE,MAAM,CAAC;IACb,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,MAAM,CAAC,EAAE,MAAM,CAAC;CACjB;AAED,MAAM,WAAW,gBAAgB;IAC/B,IAAI,EAAE,QAAQ,EAAE,CAAC;IACjB,eAAe,EAAE,MAAM,CAAC;IACxB,cAAc,EAAE,MAAM,CAAC;IACvB,eAAe,EAAE,MAAM,CAAC;IACxB,uEAAuE;IACvE,UAAU,CAAC,EAAE,MAAM,CAAC;IACpB,yEAAyE;IACzE,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB,oBAAoB,CAAC,EAAE,MAAM,GAAG,IAAI,CAAC;IACrC,iGAAiG;IACjG,cAAc,CAAC,EAAE,KAAK,CAAC,aAAa,CAAC,GAAG,CAAC,CAAC;IAC1C,kHAAkH;IAClH,UAAU,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC,CAAC;CAClC"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "imageslider-next",
3
- "version": "1.2.1",
3
+ "version": "1.3.2",
4
4
  "main": "dist/imageslider-next.js",
5
5
  "types": "dist/types/src/imageslider-next.d.ts",
6
6
  "files": [
@@ -30,29 +30,26 @@
30
30
  "@babel/preset-env": "^7.24.5",
31
31
  "@babel/preset-react": "^7.24.1",
32
32
  "@babel/preset-typescript": "^7.24.6",
33
- "@storybook/addon-docs": "^8.1.3",
33
+ "@storybook/addon-docs": "^9.1.3",
34
+ "@types/react": "^18.3.24",
34
35
  "react": "^18.3.1",
35
36
  "react-dom": "^18.3.1",
36
37
  "typescript": "^5.4.5"
37
38
  },
38
39
  "devDependencies": {
39
40
  "@babel/cli": "^7.24.5",
40
- "@chromatic-com/storybook": "^1.4.0",
41
- "@storybook/addon-essentials": "^8.1.3",
42
- "@storybook/addon-interactions": "^8.1.3",
43
- "@storybook/addon-links": "^8.1.3",
44
- "@storybook/addon-onboarding": "^8.1.3",
41
+ "@chromatic-com/storybook": "^4.1.1",
42
+ "@storybook/addon-links": "^9.1.3",
43
+ "@storybook/addon-onboarding": "^9.1.3",
45
44
  "@storybook/addon-styling-webpack": "^1.0.0",
46
- "@storybook/addon-webpack5-compiler-swc": "^1.0.2",
47
- "@storybook/blocks": "^8.1.3",
48
- "@storybook/react": "^8.1.3",
49
- "@storybook/react-webpack5": "^8.1.3",
50
- "@storybook/test": "^8.1.3",
45
+ "@storybook/addon-webpack5-compiler-swc": "^3.0.0",
46
+ "@storybook/react-webpack5": "^9.1.3",
51
47
  "autoprefixer": "^10.4.19",
52
48
  "cross-env": "^7.0.3",
53
49
  "postcss-loader": "^8.1.1",
54
50
  "rimraf": "^5.0.7",
55
- "storybook": "^8.1.3",
56
- "tailwindcss": "^3.4.3"
51
+ "storybook": "^9.1.3",
52
+ "tailwindcss": "^3.4.3",
53
+ "@storybook/addon-docs": "^9.1.3"
57
54
  }
58
55
  }