glints-aries 4.0.154 → 4.0.155

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.
@@ -41,6 +41,14 @@ var Gallery = function Gallery(_ref) {
41
41
  return setCurrentIndex(index - 1);
42
42
  };
43
43
 
44
+ var hasImage = React.Children.toArray(children).some(function (child) {
45
+ return /*#__PURE__*/React.isValidElement(child) && child.type === 'img';
46
+ });
47
+
48
+ if (!hasImage) {
49
+ console.error('Only img components allowed as children.');
50
+ }
51
+
44
52
  React.useEffect(function componentDidMount() {
45
53
  if (React.Children.count(children) > imagesDisplayed) setImageLeft(React.Children.count(children) - imagesDisplayed); // Disabling this warning because we want to preserver some legacy
46
54
  // behaviour here.
@@ -61,8 +69,7 @@ var Gallery = function Gallery(_ref) {
61
69
  onClick: function onClick() {
62
70
  return handleClick(index);
63
71
  }
64
- }, /*#__PURE__*/React.createElement("img", {
65
- src: data.props.src,
72
+ }, /*#__PURE__*/React.cloneElement(data, {
66
73
  alt: index.toString(10)
67
74
  }));
68
75
  })), /*#__PURE__*/React.createElement(Modal, {
@@ -82,9 +89,7 @@ var Gallery = function Gallery(_ref) {
82
89
  }, /*#__PURE__*/React.createElement(GalleryImageWrapper, {
83
90
  role: "banner",
84
91
  tabIndex: 0
85
- }, /*#__PURE__*/React.createElement("img", {
86
- src: data.props.src,
87
- key: data.props.src + "_" + index,
92
+ }, /*#__PURE__*/React.cloneElement(data, {
88
93
  alt: index.toString(10)
89
94
  })));
90
95
  })), /*#__PURE__*/React.createElement(GalleryThumbnailWrapper, null, React.Children.map(children, function (data, index) {
@@ -93,11 +98,10 @@ var Gallery = function Gallery(_ref) {
93
98
  onClick: function onClick() {
94
99
  return handleClickThumbs(index);
95
100
  }
96
- }, /*#__PURE__*/React.createElement("img", {
97
- "data-testid": "gallery_thumbnail",
98
- src: data.props.src,
99
- alt: index.toString(10),
100
- className: index === currentIndex ? 'active' : null
101
+ }, /*#__PURE__*/React.cloneElement(data, {
102
+ className: index === currentIndex ? 'active' : null,
103
+ 'data-testid': 'gallery_thumbnail',
104
+ alt: index.toString(10)
101
105
  }));
102
106
  }))));
103
107
  };
@@ -55,6 +55,14 @@ var Gallery = function Gallery(_ref) {
55
55
  return setCurrentIndex(index - 1);
56
56
  };
57
57
 
58
+ var hasImage = React.Children.toArray(children).some(function (child) {
59
+ return /*#__PURE__*/React.isValidElement(child) && child.type === 'img';
60
+ });
61
+
62
+ if (!hasImage) {
63
+ console.error('Only img components allowed as children.');
64
+ }
65
+
58
66
  React.useEffect(function componentDidMount() {
59
67
  if (React.Children.count(children) > imagesDisplayed) setImageLeft(React.Children.count(children) - imagesDisplayed); // Disabling this warning because we want to preserver some legacy
60
68
  // behaviour here.
@@ -75,8 +83,7 @@ var Gallery = function Gallery(_ref) {
75
83
  onClick: function onClick() {
76
84
  return handleClick(index);
77
85
  }
78
- }, /*#__PURE__*/React.createElement("img", {
79
- src: data.props.src,
86
+ }, /*#__PURE__*/React.cloneElement(data, {
80
87
  alt: index.toString(10)
81
88
  }));
82
89
  })), /*#__PURE__*/React.createElement(_Modal["default"], {
@@ -96,9 +103,7 @@ var Gallery = function Gallery(_ref) {
96
103
  }, /*#__PURE__*/React.createElement(_GalleryStyle.GalleryImageWrapper, {
97
104
  role: "banner",
98
105
  tabIndex: 0
99
- }, /*#__PURE__*/React.createElement("img", {
100
- src: data.props.src,
101
- key: data.props.src + "_" + index,
106
+ }, /*#__PURE__*/React.cloneElement(data, {
102
107
  alt: index.toString(10)
103
108
  })));
104
109
  })), /*#__PURE__*/React.createElement(_GalleryStyle.GalleryThumbnailWrapper, null, React.Children.map(children, function (data, index) {
@@ -107,11 +112,10 @@ var Gallery = function Gallery(_ref) {
107
112
  onClick: function onClick() {
108
113
  return handleClickThumbs(index);
109
114
  }
110
- }, /*#__PURE__*/React.createElement("img", {
111
- "data-testid": "gallery_thumbnail",
112
- src: data.props.src,
113
- alt: index.toString(10),
114
- className: index === currentIndex ? 'active' : null
115
+ }, /*#__PURE__*/React.cloneElement(data, {
116
+ className: index === currentIndex ? 'active' : null,
117
+ 'data-testid': 'gallery_thumbnail',
118
+ alt: index.toString(10)
115
119
  }));
116
120
  }))));
117
121
  };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "glints-aries",
3
- "version": "4.0.154",
3
+ "version": "4.0.155",
4
4
  "description": "Glints ui-kit for frontend",
5
5
  "main": "./lib/index.js",
6
6
  "module": "./es/index.js",