@plesk/ui-library 3.38.0 → 3.38.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/cjs/components/Carousel/Carousel.js +24 -31
- package/cjs/index.js +1 -1
- package/dist/plesk-ui-library-rtl.css +1 -1
- package/dist/plesk-ui-library-rtl.css.map +1 -1
- package/dist/plesk-ui-library.css +1 -1
- package/dist/plesk-ui-library.css.map +1 -1
- package/dist/plesk-ui-library.js +25 -32
- package/dist/plesk-ui-library.js.map +1 -1
- package/dist/plesk-ui-library.min.js +2 -2
- package/dist/plesk-ui-library.min.js.map +1 -1
- package/esm/components/Carousel/Carousel.js +24 -31
- package/esm/index.js +1 -1
- package/package.json +1 -1
- package/styleguide/build/bundle.83446a26.js +2 -0
- package/styleguide/index.html +2 -2
- package/types/src/components/Carousel/Carousel.d.ts +2 -1
- package/styleguide/build/bundle.e57858cb.js +0 -2
- /package/styleguide/build/{bundle.e57858cb.js.LICENSE.txt → bundle.83446a26.js.LICENSE.txt} +0 -0
|
@@ -30,7 +30,9 @@ const calcWidths = node => {
|
|
|
30
30
|
*/
|
|
31
31
|
class Carousel extends _react.Component {
|
|
32
32
|
constructor() {
|
|
33
|
+
var _this;
|
|
33
34
|
super(...arguments);
|
|
35
|
+
_this = this;
|
|
34
36
|
(0, _defineProperty2.default)(this, "state", {
|
|
35
37
|
showControls: false,
|
|
36
38
|
current: 0,
|
|
@@ -83,9 +85,14 @@ class Carousel extends _react.Component {
|
|
|
83
85
|
showControls: (bounds?.width || 0) < totalWidth
|
|
84
86
|
});
|
|
85
87
|
});
|
|
88
|
+
(0, _defineProperty2.default)(this, "getChildrenCount", () => {
|
|
89
|
+
const {
|
|
90
|
+
children
|
|
91
|
+
} = this.props;
|
|
92
|
+
return Array.isArray(children) ? children?.reduce((prev, curr) => Array.isArray(curr) ? prev + curr.length : prev + 1, 0) : 0;
|
|
93
|
+
});
|
|
86
94
|
(0, _defineProperty2.default)(this, "renderNavigationDots", () => {
|
|
87
95
|
const {
|
|
88
|
-
children,
|
|
89
96
|
baseClassName,
|
|
90
97
|
dots,
|
|
91
98
|
items
|
|
@@ -96,18 +103,17 @@ class Carousel extends _react.Component {
|
|
|
96
103
|
const {
|
|
97
104
|
current
|
|
98
105
|
} = this.state;
|
|
99
|
-
const childrenCount =
|
|
100
|
-
|
|
101
|
-
if (pages <= 1) {
|
|
106
|
+
const childrenCount = this.getChildrenCount();
|
|
107
|
+
if (childrenCount <= 1) {
|
|
102
108
|
return null;
|
|
103
109
|
}
|
|
104
110
|
return /*#__PURE__*/(0, _jsxRuntime.jsx)("div", {
|
|
105
111
|
className: `${baseClassName}__dots`,
|
|
106
112
|
children: Array.from({
|
|
107
|
-
length:
|
|
113
|
+
length: childrenCount
|
|
108
114
|
}).map((_, idx) => /*#__PURE__*/(0, _jsxRuntime.jsx)("div", {
|
|
109
115
|
role: "button",
|
|
110
|
-
className: (0, _classnames.default)(`${baseClassName}
|
|
116
|
+
className: (0, _classnames.default)(`${baseClassName}__dot`, current === idx ? `${baseClassName}__dot--current` : null),
|
|
111
117
|
"aria-current": current === idx,
|
|
112
118
|
onClick: () => this.setCurrentSlide(idx)
|
|
113
119
|
// eslint-disable-next-line react/no-array-index-key
|
|
@@ -154,19 +160,23 @@ class Carousel extends _react.Component {
|
|
|
154
160
|
})]
|
|
155
161
|
});
|
|
156
162
|
});
|
|
157
|
-
(0, _defineProperty2.default)(this, "renderSliderItems", ()
|
|
163
|
+
(0, _defineProperty2.default)(this, "renderSliderItems", function () {
|
|
164
|
+
let showCurrent = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : false;
|
|
158
165
|
const {
|
|
159
166
|
children,
|
|
160
167
|
baseClassName,
|
|
161
168
|
items
|
|
162
|
-
} =
|
|
163
|
-
const
|
|
169
|
+
} = _this.props;
|
|
170
|
+
const {
|
|
171
|
+
current
|
|
172
|
+
} = _this.state;
|
|
173
|
+
const childrenCount = _this.getChildrenCount();
|
|
164
174
|
let width = '';
|
|
165
175
|
if (items) {
|
|
166
|
-
width =
|
|
176
|
+
width = `${Math.ceil(100 / Math.min(childrenCount, items))}%`;
|
|
167
177
|
}
|
|
168
|
-
return _react.Children.map(children, item => item && /*#__PURE__*/(0, _jsxRuntime.jsx)("div", {
|
|
169
|
-
className: `${baseClassName}__item`,
|
|
178
|
+
return _react.Children.map(children, (item, idx) => item && /*#__PURE__*/(0, _jsxRuntime.jsx)("div", {
|
|
179
|
+
className: (0, _classnames.default)(`${baseClassName}__item`, showCurrent && idx === current ? `${baseClassName}__item--current` : null),
|
|
170
180
|
style: {
|
|
171
181
|
width
|
|
172
182
|
},
|
|
@@ -187,23 +197,6 @@ class Carousel extends _react.Component {
|
|
|
187
197
|
const {
|
|
188
198
|
width
|
|
189
199
|
} = this.rootRef.current.getBoundingClientRect();
|
|
190
|
-
const {
|
|
191
|
-
items,
|
|
192
|
-
children
|
|
193
|
-
} = this.props;
|
|
194
|
-
if (items) {
|
|
195
|
-
const slideItems = items;
|
|
196
|
-
const childrenCount = children?.length ?? 1;
|
|
197
|
-
const totalWidth = childrenCount * (width / slideItems);
|
|
198
|
-
if (this.state.totalWidth !== totalWidth) {
|
|
199
|
-
this.setState({
|
|
200
|
-
slideWidths: new Array(childrenCount).fill(width),
|
|
201
|
-
totalWidth,
|
|
202
|
-
showControls: childrenCount > slideItems
|
|
203
|
-
});
|
|
204
|
-
}
|
|
205
|
-
return;
|
|
206
|
-
}
|
|
207
200
|
const {
|
|
208
201
|
slideWidths,
|
|
209
202
|
totalWidth
|
|
@@ -237,7 +230,7 @@ class Carousel extends _react.Component {
|
|
|
237
230
|
if (current >= slideWidths.length) {
|
|
238
231
|
current = 0;
|
|
239
232
|
}
|
|
240
|
-
this.props.onSlide?.(
|
|
233
|
+
this.props.onSlide?.(current);
|
|
241
234
|
this.setState({
|
|
242
235
|
current,
|
|
243
236
|
next,
|
|
@@ -323,7 +316,7 @@ class Carousel extends _react.Component {
|
|
|
323
316
|
children: [showControls && this.renderSliderItems(), /*#__PURE__*/(0, _jsxRuntime.jsx)("div", {
|
|
324
317
|
className: `${baseClassName}__genuine-slides`,
|
|
325
318
|
ref: this.genuineRef,
|
|
326
|
-
children: this.renderSliderItems()
|
|
319
|
+
children: this.renderSliderItems(true)
|
|
327
320
|
}), showControls && this.renderSliderItems()]
|
|
328
321
|
}), this.renderNavigationArrows()]
|
|
329
322
|
}), this.renderNavigationDots()]
|
package/cjs/index.js
CHANGED