@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
|
@@ -24,7 +24,9 @@ const calcWidths = node => {
|
|
|
24
24
|
*/
|
|
25
25
|
class Carousel extends Component {
|
|
26
26
|
constructor() {
|
|
27
|
+
var _this;
|
|
27
28
|
super(...arguments);
|
|
29
|
+
_this = this;
|
|
28
30
|
_defineProperty(this, "state", {
|
|
29
31
|
showControls: false,
|
|
30
32
|
current: 0,
|
|
@@ -77,9 +79,14 @@ class Carousel extends Component {
|
|
|
77
79
|
showControls: (bounds?.width || 0) < totalWidth
|
|
78
80
|
});
|
|
79
81
|
});
|
|
82
|
+
_defineProperty(this, "getChildrenCount", () => {
|
|
83
|
+
const {
|
|
84
|
+
children
|
|
85
|
+
} = this.props;
|
|
86
|
+
return Array.isArray(children) ? children?.reduce((prev, curr) => Array.isArray(curr) ? prev + curr.length : prev + 1, 0) : 0;
|
|
87
|
+
});
|
|
80
88
|
_defineProperty(this, "renderNavigationDots", () => {
|
|
81
89
|
const {
|
|
82
|
-
children,
|
|
83
90
|
baseClassName,
|
|
84
91
|
dots,
|
|
85
92
|
items
|
|
@@ -90,18 +97,17 @@ class Carousel extends Component {
|
|
|
90
97
|
const {
|
|
91
98
|
current
|
|
92
99
|
} = this.state;
|
|
93
|
-
const childrenCount =
|
|
94
|
-
|
|
95
|
-
if (pages <= 1) {
|
|
100
|
+
const childrenCount = this.getChildrenCount();
|
|
101
|
+
if (childrenCount <= 1) {
|
|
96
102
|
return null;
|
|
97
103
|
}
|
|
98
104
|
return /*#__PURE__*/_jsx("div", {
|
|
99
105
|
className: `${baseClassName}__dots`,
|
|
100
106
|
children: Array.from({
|
|
101
|
-
length:
|
|
107
|
+
length: childrenCount
|
|
102
108
|
}).map((_, idx) => /*#__PURE__*/_jsx("div", {
|
|
103
109
|
role: "button",
|
|
104
|
-
className: classNames(`${baseClassName}
|
|
110
|
+
className: classNames(`${baseClassName}__dot`, current === idx ? `${baseClassName}__dot--current` : null),
|
|
105
111
|
"aria-current": current === idx,
|
|
106
112
|
onClick: () => this.setCurrentSlide(idx)
|
|
107
113
|
// eslint-disable-next-line react/no-array-index-key
|
|
@@ -148,19 +154,23 @@ class Carousel extends Component {
|
|
|
148
154
|
})]
|
|
149
155
|
});
|
|
150
156
|
});
|
|
151
|
-
_defineProperty(this, "renderSliderItems", ()
|
|
157
|
+
_defineProperty(this, "renderSliderItems", function () {
|
|
158
|
+
let showCurrent = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : false;
|
|
152
159
|
const {
|
|
153
160
|
children,
|
|
154
161
|
baseClassName,
|
|
155
162
|
items
|
|
156
|
-
} =
|
|
157
|
-
const
|
|
163
|
+
} = _this.props;
|
|
164
|
+
const {
|
|
165
|
+
current
|
|
166
|
+
} = _this.state;
|
|
167
|
+
const childrenCount = _this.getChildrenCount();
|
|
158
168
|
let width = '';
|
|
159
169
|
if (items) {
|
|
160
|
-
width =
|
|
170
|
+
width = `${Math.ceil(100 / Math.min(childrenCount, items))}%`;
|
|
161
171
|
}
|
|
162
|
-
return Children.map(children, item => item && /*#__PURE__*/_jsx("div", {
|
|
163
|
-
className: `${baseClassName}__item`,
|
|
172
|
+
return Children.map(children, (item, idx) => item && /*#__PURE__*/_jsx("div", {
|
|
173
|
+
className: classNames(`${baseClassName}__item`, showCurrent && idx === current ? `${baseClassName}__item--current` : null),
|
|
164
174
|
style: {
|
|
165
175
|
width
|
|
166
176
|
},
|
|
@@ -181,23 +191,6 @@ class Carousel extends Component {
|
|
|
181
191
|
const {
|
|
182
192
|
width
|
|
183
193
|
} = this.rootRef.current.getBoundingClientRect();
|
|
184
|
-
const {
|
|
185
|
-
items,
|
|
186
|
-
children
|
|
187
|
-
} = this.props;
|
|
188
|
-
if (items) {
|
|
189
|
-
const slideItems = items;
|
|
190
|
-
const childrenCount = children?.length ?? 1;
|
|
191
|
-
const totalWidth = childrenCount * (width / slideItems);
|
|
192
|
-
if (this.state.totalWidth !== totalWidth) {
|
|
193
|
-
this.setState({
|
|
194
|
-
slideWidths: new Array(childrenCount).fill(width),
|
|
195
|
-
totalWidth,
|
|
196
|
-
showControls: childrenCount > slideItems
|
|
197
|
-
});
|
|
198
|
-
}
|
|
199
|
-
return;
|
|
200
|
-
}
|
|
201
194
|
const {
|
|
202
195
|
slideWidths,
|
|
203
196
|
totalWidth
|
|
@@ -231,7 +224,7 @@ class Carousel extends Component {
|
|
|
231
224
|
if (current >= slideWidths.length) {
|
|
232
225
|
current = 0;
|
|
233
226
|
}
|
|
234
|
-
this.props.onSlide?.(
|
|
227
|
+
this.props.onSlide?.(current);
|
|
235
228
|
this.setState({
|
|
236
229
|
current,
|
|
237
230
|
next,
|
|
@@ -317,7 +310,7 @@ class Carousel extends Component {
|
|
|
317
310
|
children: [showControls && this.renderSliderItems(), /*#__PURE__*/_jsx("div", {
|
|
318
311
|
className: `${baseClassName}__genuine-slides`,
|
|
319
312
|
ref: this.genuineRef,
|
|
320
|
-
children: this.renderSliderItems()
|
|
313
|
+
children: this.renderSliderItems(true)
|
|
321
314
|
}), showControls && this.renderSliderItems()]
|
|
322
315
|
}), this.renderNavigationArrows()]
|
|
323
316
|
}), this.renderNavigationDots()]
|
package/esm/index.js
CHANGED