datastake-daf 0.6.208 → 0.6.210

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.
@@ -21250,83 +21250,13 @@ const CarouselWidget = /*#__PURE__*/React.forwardRef((_ref, ref) => {
21250
21250
  });
21251
21251
  CarouselWidget.displayName = 'CarouselWidget';
21252
21252
 
21253
- function CustomArrowButton({
21254
- icon,
21255
- onClick = () => {},
21256
- isLeft = false,
21257
- iconColor = "#666",
21258
- hoverIconColor = "#1890ff"
21259
- }) {
21260
- const [isHovered, setIsHovered] = React.useState(false);
21261
-
21262
- // Clone the icon and add color styling
21263
- const styledIcon = icon && typeof icon === 'object' ? {
21264
- ...icon,
21265
- props: {
21266
- ...icon.props,
21267
- style: {
21268
- color: isHovered ? hoverIconColor : iconColor
21269
- }
21270
- }
21271
- } : icon;
21272
- return /*#__PURE__*/jsxRuntime.jsx(antd.Button, {
21273
- type: "default",
21274
- shape: "circle",
21275
- icon: styledIcon,
21276
- onClick: onClick,
21277
- style: {
21278
- position: "absolute",
21279
- right: !isLeft ? "40px" : "auto",
21280
- left: !isLeft ? "auto" : "40px",
21281
- top: "58%",
21282
- transform: "translateY(-50%)",
21283
- zIndex: 10,
21284
- backgroundColor: "rgba(255, 255, 255, 0.4)",
21285
- border: "1px solid rgba(0, 0, 0, 0.1)",
21286
- boxShadow: "0 2px 8px rgba(0, 0, 0, 0.2)",
21287
- width: "40px",
21288
- height: "40px",
21289
- display: "flex",
21290
- alignItems: "center",
21291
- justifyContent: "center"
21292
- },
21293
- onMouseEnter: e => {
21294
- e.currentTarget.style.backgroundColor = "rgba(255, 255, 255, 1)";
21295
- setIsHovered(true);
21296
- },
21297
- onMouseLeave: e => {
21298
- e.currentTarget.style.backgroundColor = "rgba(255, 255, 255, 0.4)";
21299
- setIsHovered(false);
21300
- }
21301
- });
21302
- }
21303
-
21304
- const StyledCarouselWrapper = dt.div`
21305
- position: relative;
21306
-
21307
- .ant-carousel .slick-dots li button {
21308
- background: ${props => props.inactiveDotColor} !important;
21309
- opacity: 1 !important;
21310
- }
21311
-
21312
- .ant-carousel .slick-dots li.slick-active button {
21313
- background: ${props => props.activeDotColor} !important;
21314
- opacity: 1 !important;
21315
- }
21316
- `;
21317
-
21318
- const _excluded$d = ["title", "images", "height", "fallback", "activeDotColor", "inactiveDotColor", "arrowIconColor", "arrowHoverIconColor", "customArrows"];
21253
+ const _excluded$d = ["title", "images", "height", "fallback"];
21319
21254
  function ImageCarousel(_ref) {
21320
21255
  let {
21321
21256
  title,
21322
21257
  images,
21323
21258
  height = 400,
21324
- fallback = "/assets/images/empty-box.svg",
21325
- activeDotColor = "#1890ff",
21326
- inactiveDotColor = "rgba(255, 255, 255, 0.3)",
21327
- arrowIconColor = "#666",
21328
- arrowHoverIconColor = "#1890ff",
21329
- customArrows = false
21259
+ fallback = "/assets/images/empty-box.svg"
21330
21260
  } = _ref,
21331
21261
  rest = _objectWithoutProperties(_ref, _excluded$d);
21332
21262
  const [previewVisible, setPreviewVisible] = React.useState(false);
@@ -21335,30 +21265,16 @@ function ImageCarousel(_ref) {
21335
21265
  const handleCarouselChange = index => {
21336
21266
  setCurrent(index);
21337
21267
  };
21338
- const goToPrevious = () => {
21339
- var _carouselRef$current;
21340
- (_carouselRef$current = carouselRef.current) === null || _carouselRef$current === void 0 || _carouselRef$current.prev();
21341
- };
21342
- const goToNext = () => {
21343
- var _carouselRef$current2;
21344
- (_carouselRef$current2 = carouselRef.current) === null || _carouselRef$current2 === void 0 || _carouselRef$current2.next();
21345
- };
21346
-
21347
- // Check if images array is empty or invalid
21348
- const hasImages = images && images.length > 0;
21349
21268
  return /*#__PURE__*/jsxRuntime.jsxs(jsxRuntime.Fragment, {
21350
- children: [/*#__PURE__*/jsxRuntime.jsxs(StyledCarouselWrapper, {
21351
- activeDotColor: activeDotColor,
21352
- inactiveDotColor: inactiveDotColor,
21353
- children: [/*#__PURE__*/jsxRuntime.jsx(CarouselWidget, _objectSpread2(_objectSpread2({
21354
- title: title
21355
- }, rest), {}, {
21356
- arrows: false,
21269
+ children: [/*#__PURE__*/jsxRuntime.jsx(CarouselWidget, _objectSpread2(_objectSpread2({
21270
+ title: title
21271
+ }, rest), {}, {
21272
+ dots: false,
21273
+ children: /*#__PURE__*/jsxRuntime.jsx(antd.Carousel, {
21357
21274
  ref: carouselRef,
21358
21275
  afterChange: handleCarouselChange,
21359
- infinite: hasImages,
21360
- dots: hasImages,
21361
- children: hasImages ? images.map((image, index) => {
21276
+ infinite: true,
21277
+ children: images.map((image, index) => {
21362
21278
  const imageSrc = typeof image === "string" ? image : image.src;
21363
21279
  const imageAlt = typeof image === "string" ? "".concat(title, " - Image ").concat(index + 1) : image.alt;
21364
21280
  return /*#__PURE__*/jsxRuntime.jsx("div", {
@@ -21378,37 +21294,9 @@ function ImageCarousel(_ref) {
21378
21294
  }
21379
21295
  })
21380
21296
  }, imageSrc);
21381
- }) :
21382
- /*#__PURE__*/
21383
- // No images - show placeholder
21384
- jsxRuntime.jsx("div", {
21385
- children: /*#__PURE__*/jsxRuntime.jsx(antd.Image, {
21386
- src: "/assets/images/no-image.svg",
21387
- alt: "No images available",
21388
- height: height,
21389
- width: "100%",
21390
- fallback: fallback,
21391
- preview: false,
21392
- style: {
21393
- objectFit: "contain"
21394
- }
21395
- })
21396
21297
  })
21397
- })), hasImages && customArrows && images.length > 1 && /*#__PURE__*/jsxRuntime.jsxs(jsxRuntime.Fragment, {
21398
- children: [/*#__PURE__*/jsxRuntime.jsx(CustomArrowButton, {
21399
- icon: /*#__PURE__*/jsxRuntime.jsx(Icons.LeftOutlined, {}),
21400
- onClick: goToPrevious,
21401
- isLeft: true,
21402
- iconColor: arrowIconColor,
21403
- hoverIconColor: arrowHoverIconColor
21404
- }), /*#__PURE__*/jsxRuntime.jsx(CustomArrowButton, {
21405
- icon: /*#__PURE__*/jsxRuntime.jsx(Icons.RightOutlined, {}),
21406
- onClick: goToNext,
21407
- iconColor: arrowIconColor,
21408
- hoverIconColor: arrowHoverIconColor
21409
- })]
21410
- })]
21411
- }), hasImages && /*#__PURE__*/jsxRuntime.jsx("div", {
21298
+ })
21299
+ })), /*#__PURE__*/jsxRuntime.jsx("div", {
21412
21300
  style: {
21413
21301
  display: "none"
21414
21302
  },
@@ -21418,9 +21306,9 @@ function ImageCarousel(_ref) {
21418
21306
  current,
21419
21307
  onVisibleChange: vis => setPreviewVisible(vis),
21420
21308
  onChange: idx => {
21421
- var _carouselRef$current3;
21309
+ var _carouselRef$current;
21422
21310
  setCurrent(idx);
21423
- (_carouselRef$current3 = carouselRef.current) === null || _carouselRef$current3 === void 0 || _carouselRef$current3.goTo(idx);
21311
+ (_carouselRef$current = carouselRef.current) === null || _carouselRef$current === void 0 || _carouselRef$current.goTo(idx);
21424
21312
  }
21425
21313
  },
21426
21314
  children: images.map((image, index) => {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "datastake-daf",
3
- "version": "0.6.208",
3
+ "version": "0.6.210",
4
4
  "dependencies": {
5
5
  "@ant-design/icons": "^5.2.5",
6
6
  "@antv/g2": "^5.1.1",
@@ -0,0 +1,185 @@
1
+ import React, { useState, useRef } from "react";
2
+ import styled from "styled-components";
3
+ import CarouselWidget from "../CarouselWidget/index.jsx";
4
+ import { Image, Carousel, Button } from "antd";
5
+ import { LeftOutlined, RightOutlined } from "@ant-design/icons";
6
+ import CustomArrowButton from "./components/CustomArrowButton/index.js";
7
+ import { StyledCarouselWrapper } from "./style.js";
8
+
9
+ /**
10
+ * @typedef {Object} ImageObject
11
+ * @property {string} src - The source URL of the image
12
+ * @property {string} alt - Alternative text for the image
13
+ */
14
+
15
+ /**
16
+ * ImageCarousel Component - A responsive image carousel with preview functionality and keyboard navigation
17
+ *
18
+ * @component
19
+ * @example
20
+ * // Basic usage with string URLs
21
+ * <ImageCarousel
22
+ * title="My Gallery"
23
+ * images={["image1.jpg", "image2.jpg"]}
24
+ * />
25
+ *
26
+ * @example
27
+ * // Advanced usage with image objects and custom height
28
+ * <ImageCarousel
29
+ * title="Nature Gallery"
30
+ * images={[
31
+ * { src: "landscape.jpg", alt: "Beautiful mountain landscape" },
32
+ * { src: "forest.jpg", alt: "Dense forest path" }
33
+ * ]}
34
+ * height={300}
35
+ * fallback="/custom-fallback.svg"
36
+ * />
37
+ *
38
+ * @param {Object} props - Component props
39
+ * @param {string} props.title - The title displayed in the widget header
40
+ * @param {(string|ImageObject)[]} props.images - Array of image URLs (strings) or image objects with src and alt properties
41
+ * @param {number} [props.height=400] - Height of the carousel images in pixels
42
+ * @param {string} [props.fallback="/assets/images/empty-box.svg"] - Fallback image URL when original image fails to load
43
+ * @param {string} [props.activeDotColor="#1890ff"] - Color of the active dot
44
+ * @param {string} [props.inactiveDotColor="rgba(255, 255, 255, 0.3)"] - Color of inactive dots
45
+ * @param {string} [props.arrowIconColor="#666"] - Default color of arrow icons
46
+ * @param {string} [props.arrowHoverIconColor="#1890ff"] - Color of arrow icons on hover
47
+ * @param {boolean} [props.customArrows=false] - Whether to show custom navigation arrows
48
+ * @param {Object} [props.rest] - Additional props passed to the underlying CarouselWidget component
49
+ *
50
+ * @features
51
+ * - ✅ Responsive image display with lazy loading
52
+ * - ✅ Click-to-preview with full-screen image viewer
53
+ * - ✅ Keyboard navigation in preview mode (← → arrow keys)
54
+ * - ✅ Automatic fallback for broken images
55
+ * - ✅ Support for both string URLs and image objects with alt text
56
+ * - ✅ Synchronized carousel and preview navigation
57
+ * - ✅ Infinite scrolling in both carousel and preview modes
58
+ * - ✅ Placeholder image for empty image arrays (/assets/images/no-image.svg)
59
+ * - ✅ Customizable dot colors via props
60
+ *
61
+ * @accessibility
62
+ * - Proper alt text support for screen readers
63
+ * - Keyboard navigation support
64
+ * - Focus management in preview mode
65
+ *
66
+ */
67
+ function ImageCarousel({
68
+ title,
69
+ images,
70
+ height = 400,
71
+ fallback = "/assets/images/empty-box.svg",
72
+ activeDotColor = "#1890ff",
73
+ inactiveDotColor = "rgba(255, 255, 255, 0.3)",
74
+ arrowIconColor = "#666",
75
+ arrowHoverIconColor = "#1890ff",
76
+ customArrows = false,
77
+ ...rest
78
+ }) {
79
+ const [previewVisible, setPreviewVisible] = useState(false);
80
+ const [current, setCurrent] = useState(0);
81
+ const carouselRef = useRef(null);
82
+
83
+ const handleCarouselChange = (index) => {
84
+ setCurrent(index);
85
+ };
86
+
87
+ const goToPrevious = () => {
88
+ carouselRef.current?.prev();
89
+ };
90
+
91
+ const goToNext = () => {
92
+ carouselRef.current?.next();
93
+ };
94
+
95
+
96
+ return (
97
+ <>
98
+ {/* <StyledCarouselWrapper
99
+ activeDotColor={activeDotColor}
100
+ inactiveDotColor={inactiveDotColor}
101
+ > */}
102
+ <CarouselWidget
103
+ title={title}
104
+ {...rest}
105
+ arrows={false}
106
+ ref={carouselRef}
107
+ afterChange={handleCarouselChange}
108
+ infinite
109
+ >
110
+ {images.map((image, index) => {
111
+ const imageSrc = typeof image === "string" ? image : image.src;
112
+ const imageAlt =
113
+ typeof image === "string"
114
+ ? `${title} - Image ${index + 1}`
115
+ : image.alt;
116
+
117
+ return (
118
+ <div key={imageSrc}>
119
+ <Image
120
+ src={imageSrc}
121
+ alt={imageAlt}
122
+ height={height}
123
+ width="100%"
124
+ fallback={fallback}
125
+ loading="lazy"
126
+ preview={{
127
+ visible: false,
128
+ }}
129
+ onClick={() => {
130
+ setCurrent(index);
131
+ setPreviewVisible(true);
132
+ }}
133
+ />
134
+ </div>
135
+ );
136
+ })}
137
+ </CarouselWidget>
138
+
139
+ {customArrows && images && images.length > 1 && (
140
+ <>
141
+ <CustomArrowButton
142
+ icon={<LeftOutlined />}
143
+ onClick={goToPrevious}
144
+ isLeft={true}
145
+ iconColor={arrowIconColor}
146
+ hoverIconColor={arrowHoverIconColor}
147
+ />
148
+ <CustomArrowButton
149
+ icon={<RightOutlined />}
150
+ onClick={goToNext}
151
+ iconColor={arrowIconColor}
152
+ hoverIconColor={arrowHoverIconColor}
153
+ />
154
+ </>
155
+ )}
156
+ {/* </StyledCarouselWrapper> */}
157
+
158
+ <div style={{ display: "none" }}>
159
+ <Image.PreviewGroup
160
+ preview={{
161
+ visible: previewVisible,
162
+ current,
163
+ onVisibleChange: (vis) => setPreviewVisible(vis),
164
+ onChange: (idx) => {
165
+ setCurrent(idx);
166
+ carouselRef.current?.goTo(idx);
167
+ },
168
+ }}
169
+ >
170
+ {images.map((image, index) => {
171
+ const imageSrc = typeof image === "string" ? image : image.src;
172
+ const imageAlt =
173
+ typeof image === "string"
174
+ ? `${title} - Image ${index + 1}`
175
+ : image.alt;
176
+
177
+ return <Image key={imageSrc} src={imageSrc} alt={imageAlt} />;
178
+ })}
179
+ </Image.PreviewGroup>
180
+ </div>
181
+ </>
182
+ );
183
+ }
184
+
185
+ export default ImageCarousel;
@@ -1,10 +1,6 @@
1
1
  import React, { useState, useRef } from "react";
2
- import styled from "styled-components";
3
2
  import CarouselWidget from "../CarouselWidget/index.jsx";
4
- import { Image, Carousel, Button } from "antd";
5
- import { LeftOutlined, RightOutlined } from "@ant-design/icons";
6
- import CustomArrowButton from "./components/CustomArrowButton/index.js";
7
- import { StyledCarouselWrapper } from "./style.js";
3
+ import { Image, Carousel } from "antd";
8
4
 
9
5
  /**
10
6
  * @typedef {Object} ImageObject
@@ -40,10 +36,6 @@ import { StyledCarouselWrapper } from "./style.js";
40
36
  * @param {(string|ImageObject)[]} props.images - Array of image URLs (strings) or image objects with src and alt properties
41
37
  * @param {number} [props.height=400] - Height of the carousel images in pixels
42
38
  * @param {string} [props.fallback="/assets/images/empty-box.svg"] - Fallback image URL when original image fails to load
43
- * @param {string} [props.activeDotColor="#1890ff"] - Color of the active dot
44
- * @param {string} [props.inactiveDotColor="rgba(255, 255, 255, 0.3)"] - Color of inactive dots
45
- * @param {string} [props.arrowIconColor="#666"] - Default color of arrow icons
46
- * @param {string} [props.arrowHoverIconColor="#1890ff"] - Color of arrow icons on hover
47
39
  * @param {Object} [props.rest] - Additional props passed to the underlying CarouselWidget component
48
40
  *
49
41
  * @features
@@ -54,8 +46,6 @@ import { StyledCarouselWrapper } from "./style.js";
54
46
  * - ✅ Support for both string URLs and image objects with alt text
55
47
  * - ✅ Synchronized carousel and preview navigation
56
48
  * - ✅ Infinite scrolling in both carousel and preview modes
57
- * - ✅ Placeholder image for empty image arrays (/assets/images/no-image.svg)
58
- * - ✅ Customizable dot colors via props
59
49
  *
60
50
  * @accessibility
61
51
  * - Proper alt text support for screen readers
@@ -68,11 +58,6 @@ function ImageCarousel({
68
58
  images,
69
59
  height = 400,
70
60
  fallback = "/assets/images/empty-box.svg",
71
- activeDotColor = "#1890ff",
72
- inactiveDotColor = "rgba(255, 255, 255, 0.3)",
73
- arrowIconColor = "#666",
74
- arrowHoverIconColor = "#1890ff",
75
- customArrows = false,
76
61
  ...rest
77
62
  }) {
78
63
  const [previewVisible, setPreviewVisible] = useState(false);
@@ -83,33 +68,11 @@ function ImageCarousel({
83
68
  setCurrent(index);
84
69
  };
85
70
 
86
- const goToPrevious = () => {
87
- carouselRef.current?.prev();
88
- };
89
-
90
- const goToNext = () => {
91
- carouselRef.current?.next();
92
- };
93
-
94
- // Check if images array is empty or invalid
95
- const hasImages = images && images.length > 0;
96
-
97
71
  return (
98
72
  <>
99
- <StyledCarouselWrapper
100
- activeDotColor={activeDotColor}
101
- inactiveDotColor={inactiveDotColor}
102
- >
103
- <CarouselWidget
104
- title={title}
105
- {...rest}
106
- arrows={false}
107
- ref={carouselRef}
108
- afterChange={handleCarouselChange}
109
- infinite={hasImages}
110
- dots={hasImages}
111
- >
112
- {hasImages ? images.map((image, index) => {
73
+ <CarouselWidget title={title} {...rest} dots={false}>
74
+ <Carousel ref={carouselRef} afterChange={handleCarouselChange} infinite>
75
+ {images.map((image, index) => {
113
76
  const imageSrc = typeof image === "string" ? image : image.src;
114
77
  const imageAlt =
115
78
  typeof image === "string"
@@ -135,58 +98,23 @@ function ImageCarousel({
135
98
  />
136
99
  </div>
137
100
  );
138
- }) : (
139
- // No images - show placeholder
140
- <div>
141
- <Image
142
- src="/assets/images/no-image.svg"
143
- alt="No images available"
144
- height={height}
145
- width="100%"
146
- fallback={fallback}
147
- preview={false}
148
- style={{
149
- objectFit: "contain",
150
- }}
151
- />
152
- </div>
153
- )}
154
- </CarouselWidget>
155
-
156
- {(hasImages && customArrows && images.length > 1) && (
157
- <>
158
- <CustomArrowButton
159
- icon={<LeftOutlined />}
160
- onClick={goToPrevious}
161
- isLeft={true}
162
- iconColor={arrowIconColor}
163
- hoverIconColor={arrowHoverIconColor}
164
- />
165
- <CustomArrowButton
166
- icon={<RightOutlined />}
167
- onClick={goToNext}
168
- iconColor={arrowIconColor}
169
- hoverIconColor={arrowHoverIconColor}
170
- />
171
- </>
172
- )}
173
- </StyledCarouselWrapper>
101
+ })}
102
+ </Carousel>
103
+ </CarouselWidget>
174
104
 
175
- {/* Preview functionality - only show if there are images */}
176
- {hasImages && (
177
- <div style={{ display: "none" }}>
178
- <Image.PreviewGroup
179
- preview={{
180
- visible: previewVisible,
181
- current,
182
- onVisibleChange: (vis) => setPreviewVisible(vis),
183
- onChange: (idx) => {
184
- setCurrent(idx);
185
- carouselRef.current?.goTo(idx);
186
- },
187
- }}
188
- >
189
- {images.map((image, index) => {
105
+ <div style={{ display: "none" }}>
106
+ <Image.PreviewGroup
107
+ preview={{
108
+ visible: previewVisible,
109
+ current,
110
+ onVisibleChange: (vis) => setPreviewVisible(vis),
111
+ onChange: (idx) => {
112
+ setCurrent(idx);
113
+ carouselRef.current?.goTo(idx);
114
+ },
115
+ }}
116
+ >
117
+ {images.map((image, index) => {
190
118
  const imageSrc = typeof image === "string" ? image : image.src;
191
119
  const imageAlt =
192
120
  typeof image === "string"
@@ -194,12 +122,11 @@ function ImageCarousel({
194
122
  : image.alt;
195
123
 
196
124
  return <Image key={imageSrc} src={imageSrc} alt={imageAlt} />;
197
- })}
198
- </Image.PreviewGroup>
199
- </div>
200
- )}
125
+ })}
126
+ </Image.PreviewGroup>
127
+ </div>
201
128
  </>
202
129
  );
203
130
  }
204
131
 
205
- export default ImageCarousel;
132
+ export default ImageCarousel;