@plesk/ui-library 3.36.0 → 3.37.0
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/Card/helpers.js +0 -1
- package/cjs/components/Carousel/Carousel.js +182 -77
- package/cjs/components/ComboBox/ComboBoxOption.js +2 -1
- package/cjs/components/Drawer/DrawerProgress.js +1 -1
- package/cjs/components/List/List.js +102 -314
- package/cjs/components/List/ListAction.js +0 -1
- package/cjs/components/Panel/Panel.js +61 -98
- package/cjs/components/Select/SelectControl.js +4 -0
- package/cjs/components/Select/SelectOption.js +2 -1
- package/cjs/components/Toaster/Toaster.js +3 -3
- package/cjs/components/Toolbar/ToolbarMenu.js +0 -1
- package/cjs/components/index.js +42 -22
- 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 +574 -678
- package/dist/plesk-ui-library.js.map +1 -1
- package/dist/plesk-ui-library.min.js +10 -10
- package/dist/plesk-ui-library.min.js.map +1 -1
- package/esm/components/Card/helpers.js +0 -1
- package/esm/components/Carousel/Carousel.js +183 -78
- package/esm/components/ComboBox/ComboBoxOption.js +2 -1
- package/esm/components/Drawer/DrawerProgress.js +1 -1
- package/esm/components/List/List.js +102 -314
- package/esm/components/List/ListAction.js +0 -1
- package/esm/components/Panel/Panel.js +62 -99
- package/esm/components/Select/SelectControl.js +4 -0
- package/esm/components/Select/SelectOption.js +2 -1
- package/esm/components/Toaster/Toaster.js +3 -3
- package/esm/components/Toolbar/ToolbarMenu.js +0 -1
- package/esm/components/index.js +2 -4
- package/esm/index.js +1 -1
- package/package.json +41 -41
- package/styleguide/build/bundle.c3d05006.js +2 -0
- package/styleguide/index.html +2 -2
- package/types/src/components/Action/Action.d.ts +1 -1
- package/types/src/components/Action/index.d.ts +1 -0
- package/types/src/components/Alert/Alert.d.ts +1 -1
- package/types/src/components/Alert/index.d.ts +1 -0
- package/types/src/components/AutoClosable/AutoClosable.d.ts +1 -1
- package/types/src/components/AutoClosable/index.d.ts +1 -0
- package/types/src/components/AuxiliaryActions/AuxiliaryActions.d.ts +1 -1
- package/types/src/components/AuxiliaryActions/index.d.ts +1 -0
- package/types/src/components/Badge/Badge.d.ts +1 -1
- package/types/src/components/Badge/index.d.ts +1 -0
- package/types/src/components/Breadcrumbs/Breadcrumbs.d.ts +1 -1
- package/types/src/components/Breadcrumbs/index.d.ts +1 -0
- package/types/src/components/Button/ButtonContext.d.ts +1 -0
- package/types/src/components/ButtonGroup/ButtonGroup.d.ts +1 -1
- package/types/src/components/ButtonGroup/index.d.ts +1 -0
- package/types/src/components/Carousel/Carousel.d.ts +43 -8
- package/types/src/components/Checkbox/Checkbox.d.ts +1 -1
- package/types/src/components/Checkbox/index.d.ts +1 -0
- package/types/src/components/ComboBox/ComboBox.d.ts +1 -1
- package/types/src/components/ComboBox/ComboBoxOption.d.ts +1 -1
- package/types/src/components/ComboBox/index.d.ts +2 -0
- package/types/src/components/ConsoleOutput/ConsoleOutput.d.ts +1 -1
- package/types/src/components/ConsoleOutput/index.d.ts +1 -0
- package/types/src/components/ContentLoader/ContentLoader.d.ts +1 -1
- package/types/src/components/ContentLoader/index.d.ts +1 -0
- package/types/src/components/Cuttable/Cuttable.d.ts +1 -1
- package/types/src/components/Cuttable/index.d.ts +1 -0
- package/types/src/components/DistractionFreeModeContext/DistractionFreeModeContext.d.ts +1 -0
- package/types/src/components/Drawer/DrawerProgress.d.ts +1 -1
- package/types/src/components/Form/DisabledContext.d.ts +1 -0
- package/types/src/components/Form/FormContext.d.ts +1 -0
- package/types/src/components/Form/ScrollableElementFormContext.d.ts +1 -0
- package/types/src/components/List/List.d.ts +637 -0
- package/types/src/components/List/ListAction.d.ts +21 -18
- package/types/src/components/List/ListActionsDivider.d.ts +1 -1
- package/types/src/components/List/ListEmptyView.d.ts +1 -1
- package/types/src/components/List/index.d.ts +12 -0
- package/types/src/components/OnDarkContext/OnDarkContext.d.ts +1 -0
- package/types/src/components/Pagination/Pagination.d.ts +1 -1
- package/types/src/components/Pagination/index.d.ts +1 -0
- package/types/src/components/Panel/Panel.d.ts +4 -21
- package/types/src/components/Panel/index.d.ts +1 -0
- package/types/src/components/Radio/Radio.d.ts +4 -6
- package/types/src/components/Radio/index.d.ts +1 -0
- package/types/src/components/ResponsiveContext/ResponsiveContext.d.ts +1 -0
- package/types/src/components/Section/Section.d.ts +1 -1
- package/types/src/components/Toolbar/RegistryContext.d.ts +1 -0
- package/types/src/components/Translate/Translate.d.ts +4 -3
- package/types/src/components/Translate/index.d.ts +1 -1
- package/types/src/components/VerticalContext/VerticalContext.d.ts +1 -0
- package/types/src/components/index.d.ts +17 -4
- package/styleguide/build/bundle.2c956ff2.js +0 -2
- /package/styleguide/build/{bundle.2c956ff2.js.LICENSE.txt → bundle.c3d05006.js.LICENSE.txt} +0 -0
|
@@ -2,7 +2,7 @@ import _defineProperty from "@babel/runtime/helpers/defineProperty";
|
|
|
2
2
|
// Copyright 1999-2023. Plesk International GmbH. All rights reserved.
|
|
3
3
|
|
|
4
4
|
import { isRtl } from '../../utils';
|
|
5
|
-
import { Component, createRef } from 'react';
|
|
5
|
+
import { Children, Component, createRef } from 'react';
|
|
6
6
|
import classNames from 'classnames';
|
|
7
7
|
import Measure from 'react-measure';
|
|
8
8
|
import { CLS_PREFIX } from '../../constants';
|
|
@@ -23,8 +23,8 @@ const calcWidths = node => {
|
|
|
23
23
|
* @since 0.0.42
|
|
24
24
|
*/
|
|
25
25
|
class Carousel extends Component {
|
|
26
|
-
constructor(
|
|
27
|
-
super(
|
|
26
|
+
constructor() {
|
|
27
|
+
super(...arguments);
|
|
28
28
|
_defineProperty(this, "state", {
|
|
29
29
|
showControls: false,
|
|
30
30
|
current: 0,
|
|
@@ -34,21 +34,145 @@ class Carousel extends Component {
|
|
|
34
34
|
totalWidth: 0
|
|
35
35
|
});
|
|
36
36
|
_defineProperty(this, "speed", 500);
|
|
37
|
-
_defineProperty(this, "playSpeed", 5000);
|
|
38
37
|
_defineProperty(this, "isRtl", void 0);
|
|
39
38
|
_defineProperty(this, "playTimer", null);
|
|
40
39
|
_defineProperty(this, "movingCallback", null);
|
|
41
40
|
_defineProperty(this, "rootRef", /*#__PURE__*/createRef());
|
|
42
41
|
_defineProperty(this, "genuineRef", /*#__PURE__*/createRef());
|
|
43
|
-
this
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
this
|
|
42
|
+
_defineProperty(this, "handlePrevClick", () => {
|
|
43
|
+
this.stop();
|
|
44
|
+
this.setCurrentSlide(this.state.current - 1);
|
|
45
|
+
});
|
|
46
|
+
_defineProperty(this, "handleNextClick", () => {
|
|
47
|
+
this.stop();
|
|
48
|
+
this.setCurrentSlide(this.state.current + 1);
|
|
49
|
+
});
|
|
50
|
+
_defineProperty(this, "play", () => {
|
|
51
|
+
this.playTimer = setTimeout(() => {
|
|
52
|
+
this.setCurrentSlide(this.state.current + 1);
|
|
53
|
+
this.play();
|
|
54
|
+
}, this.props.autoplayInterval);
|
|
55
|
+
});
|
|
56
|
+
_defineProperty(this, "stop", () => {
|
|
57
|
+
if (this.playTimer) {
|
|
58
|
+
clearTimeout(this.playTimer);
|
|
59
|
+
this.playTimer = null;
|
|
60
|
+
}
|
|
61
|
+
});
|
|
62
|
+
_defineProperty(this, "handleResize", _ref => {
|
|
63
|
+
let {
|
|
64
|
+
bounds
|
|
65
|
+
} = _ref;
|
|
66
|
+
const node = this.genuineRef.current;
|
|
67
|
+
if (!node) {
|
|
68
|
+
return;
|
|
69
|
+
}
|
|
70
|
+
const {
|
|
71
|
+
slideWidths,
|
|
72
|
+
totalWidth
|
|
73
|
+
} = calcWidths(node);
|
|
74
|
+
this.setState({
|
|
75
|
+
slideWidths,
|
|
76
|
+
totalWidth,
|
|
77
|
+
showControls: (bounds?.width || 0) < totalWidth
|
|
78
|
+
});
|
|
79
|
+
});
|
|
80
|
+
_defineProperty(this, "renderNavigationDots", () => {
|
|
81
|
+
const {
|
|
82
|
+
children,
|
|
83
|
+
baseClassName,
|
|
84
|
+
dots,
|
|
85
|
+
items
|
|
86
|
+
} = this.props;
|
|
87
|
+
if (!dots || !items) {
|
|
88
|
+
return null;
|
|
89
|
+
}
|
|
90
|
+
const {
|
|
91
|
+
current
|
|
92
|
+
} = this.state;
|
|
93
|
+
const childrenCount = children?.length ?? 1;
|
|
94
|
+
const pages = Math.ceil(childrenCount / items);
|
|
95
|
+
if (pages <= 1) {
|
|
96
|
+
return null;
|
|
97
|
+
}
|
|
98
|
+
return /*#__PURE__*/_jsx("div", {
|
|
99
|
+
className: `${baseClassName}__dots`,
|
|
100
|
+
children: Array.from({
|
|
101
|
+
length: pages
|
|
102
|
+
}).map((_, idx) => /*#__PURE__*/_jsx("div", {
|
|
103
|
+
role: "button",
|
|
104
|
+
className: classNames(`${baseClassName}__dots--dot`, current === idx ? `${baseClassName}__dots--dot-current` : null),
|
|
105
|
+
"aria-current": current === idx,
|
|
106
|
+
onClick: () => this.setCurrentSlide(idx)
|
|
107
|
+
// eslint-disable-next-line react/no-array-index-key
|
|
108
|
+
,
|
|
109
|
+
children: /*#__PURE__*/_jsx(Icon, {
|
|
110
|
+
name: "dot-big"
|
|
111
|
+
})
|
|
112
|
+
}, idx))
|
|
113
|
+
});
|
|
114
|
+
});
|
|
115
|
+
_defineProperty(this, "renderNavigationArrows", () => {
|
|
116
|
+
const {
|
|
117
|
+
baseClassName,
|
|
118
|
+
arrows
|
|
119
|
+
} = this.props;
|
|
120
|
+
const {
|
|
121
|
+
showControls
|
|
122
|
+
} = this.state;
|
|
123
|
+
if (!arrows || !showControls) {
|
|
124
|
+
return null;
|
|
125
|
+
}
|
|
126
|
+
return /*#__PURE__*/_jsxs("div", {
|
|
127
|
+
className: `${baseClassName}__controls`,
|
|
128
|
+
children: [/*#__PURE__*/_jsx("button", {
|
|
129
|
+
type: "button",
|
|
130
|
+
"aria-label": "previous slide",
|
|
131
|
+
className: classNames(`${baseClassName}__control`, `${baseClassName}__control--previous`),
|
|
132
|
+
onClick: this.handlePrevClick,
|
|
133
|
+
children: /*#__PURE__*/_jsx(Icon, {
|
|
134
|
+
name: "chevron-left",
|
|
135
|
+
flipHorizontal: this.isRtl,
|
|
136
|
+
className: `${baseClassName}__control-icon`
|
|
137
|
+
})
|
|
138
|
+
}), /*#__PURE__*/_jsx("button", {
|
|
139
|
+
type: "button",
|
|
140
|
+
"aria-label": "next slide",
|
|
141
|
+
className: classNames(`${baseClassName}__control`, `${baseClassName}__control--next`),
|
|
142
|
+
onClick: this.handleNextClick,
|
|
143
|
+
children: /*#__PURE__*/_jsx(Icon, {
|
|
144
|
+
name: "chevron-right",
|
|
145
|
+
flipHorizontal: this.isRtl,
|
|
146
|
+
className: `${baseClassName}__control-icon`
|
|
147
|
+
})
|
|
148
|
+
})]
|
|
149
|
+
});
|
|
150
|
+
});
|
|
151
|
+
_defineProperty(this, "renderSliderItems", () => {
|
|
152
|
+
const {
|
|
153
|
+
children,
|
|
154
|
+
baseClassName,
|
|
155
|
+
items
|
|
156
|
+
} = this.props;
|
|
157
|
+
const childrenCount = children?.length ?? 1;
|
|
158
|
+
let width = '';
|
|
159
|
+
if (items) {
|
|
160
|
+
width = `calc(100% / ${Math.min(childrenCount, items)})`;
|
|
161
|
+
}
|
|
162
|
+
return Children.map(children, item => item && /*#__PURE__*/_jsx("div", {
|
|
163
|
+
className: `${baseClassName}__item`,
|
|
164
|
+
style: {
|
|
165
|
+
width
|
|
166
|
+
},
|
|
167
|
+
children: item
|
|
168
|
+
}));
|
|
169
|
+
});
|
|
48
170
|
}
|
|
49
171
|
componentDidMount() {
|
|
50
172
|
this.isRtl = isRtl();
|
|
51
|
-
this.
|
|
173
|
+
if (this.props.autoplay) {
|
|
174
|
+
this.play();
|
|
175
|
+
}
|
|
52
176
|
}
|
|
53
177
|
componentDidUpdate() {
|
|
54
178
|
if (!this.rootRef.current || !this.genuineRef.current) {
|
|
@@ -57,6 +181,23 @@ class Carousel extends Component {
|
|
|
57
181
|
const {
|
|
58
182
|
width
|
|
59
183
|
} = 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
|
+
}
|
|
60
201
|
const {
|
|
61
202
|
slideWidths,
|
|
62
203
|
totalWidth
|
|
@@ -75,26 +216,6 @@ class Carousel extends Component {
|
|
|
75
216
|
clearTimeout(this.movingCallback);
|
|
76
217
|
}
|
|
77
218
|
}
|
|
78
|
-
handlePrevClick() {
|
|
79
|
-
this.stop();
|
|
80
|
-
this.setCurrentSlide(this.state.current - 1);
|
|
81
|
-
}
|
|
82
|
-
handleNextClick() {
|
|
83
|
-
this.stop();
|
|
84
|
-
this.setCurrentSlide(this.state.current + 1);
|
|
85
|
-
}
|
|
86
|
-
play() {
|
|
87
|
-
this.playTimer = setTimeout(() => {
|
|
88
|
-
this.setCurrentSlide(this.state.current + 1);
|
|
89
|
-
this.play();
|
|
90
|
-
}, this.playSpeed);
|
|
91
|
-
}
|
|
92
|
-
stop() {
|
|
93
|
-
if (this.playTimer) {
|
|
94
|
-
clearTimeout(this.playTimer);
|
|
95
|
-
this.playTimer = null;
|
|
96
|
-
}
|
|
97
|
-
}
|
|
98
219
|
setCurrentSlide(next) {
|
|
99
220
|
const {
|
|
100
221
|
slideWidths,
|
|
@@ -110,6 +231,7 @@ class Carousel extends Component {
|
|
|
110
231
|
if (current >= slideWidths.length) {
|
|
111
232
|
current = 0;
|
|
112
233
|
}
|
|
234
|
+
this.props.onSlide?.(next);
|
|
113
235
|
this.setState({
|
|
114
236
|
current,
|
|
115
237
|
next,
|
|
@@ -122,25 +244,10 @@ class Carousel extends Component {
|
|
|
122
244
|
});
|
|
123
245
|
}, this.speed);
|
|
124
246
|
}
|
|
125
|
-
handleResize(_ref) {
|
|
126
|
-
let {
|
|
127
|
-
bounds
|
|
128
|
-
} = _ref;
|
|
129
|
-
const node = this.genuineRef.current;
|
|
130
|
-
if (!node) {
|
|
131
|
-
return;
|
|
132
|
-
}
|
|
133
|
-
const {
|
|
134
|
-
slideWidths,
|
|
135
|
-
totalWidth
|
|
136
|
-
} = calcWidths(node);
|
|
137
|
-
this.setState({
|
|
138
|
-
slideWidths,
|
|
139
|
-
totalWidth,
|
|
140
|
-
showControls: (bounds?.width || 0) < totalWidth
|
|
141
|
-
});
|
|
142
|
-
}
|
|
143
247
|
listStyle() {
|
|
248
|
+
const {
|
|
249
|
+
arrows
|
|
250
|
+
} = this.props;
|
|
144
251
|
const {
|
|
145
252
|
current,
|
|
146
253
|
next,
|
|
@@ -149,7 +256,12 @@ class Carousel extends Component {
|
|
|
149
256
|
totalWidth
|
|
150
257
|
} = this.state;
|
|
151
258
|
const moveTo = moving ? next : current;
|
|
152
|
-
let x = -totalWidth
|
|
259
|
+
let x = -totalWidth;
|
|
260
|
+
|
|
261
|
+
// navigation arrows width
|
|
262
|
+
if (arrows) {
|
|
263
|
+
x += 26;
|
|
264
|
+
}
|
|
153
265
|
if (moveTo < 0) {
|
|
154
266
|
for (let i = moveTo; i < 0; i++) {
|
|
155
267
|
x += slideWidths[i + slideWidths.length];
|
|
@@ -177,6 +289,12 @@ class Carousel extends Component {
|
|
|
177
289
|
baseClassName,
|
|
178
290
|
className,
|
|
179
291
|
children,
|
|
292
|
+
autoplay,
|
|
293
|
+
autoplayInterval,
|
|
294
|
+
items,
|
|
295
|
+
onSlide,
|
|
296
|
+
dots,
|
|
297
|
+
arrows,
|
|
180
298
|
...props
|
|
181
299
|
} = this.props;
|
|
182
300
|
return /*#__PURE__*/_jsx(Measure, {
|
|
@@ -192,35 +310,17 @@ class Carousel extends Component {
|
|
|
192
310
|
className: classNames(baseClassName, className),
|
|
193
311
|
...props,
|
|
194
312
|
children: [/*#__PURE__*/_jsxs("div", {
|
|
195
|
-
className: `${baseClassName}
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
className: classNames(`${baseClassName}__control`, `${baseClassName}__control--previous`),
|
|
207
|
-
onClick: this.handlePrevClick,
|
|
208
|
-
children: /*#__PURE__*/_jsx(Icon, {
|
|
209
|
-
name: "chevron-left",
|
|
210
|
-
flipHorizontal: this.isRtl,
|
|
211
|
-
className: `${baseClassName}__control-icon`
|
|
212
|
-
})
|
|
213
|
-
}), /*#__PURE__*/_jsx("button", {
|
|
214
|
-
type: "button",
|
|
215
|
-
className: classNames(`${baseClassName}__control`, `${baseClassName}__control--next`),
|
|
216
|
-
onClick: this.handleNextClick,
|
|
217
|
-
children: /*#__PURE__*/_jsx(Icon, {
|
|
218
|
-
name: "chevron-right",
|
|
219
|
-
flipHorizontal: this.isRtl,
|
|
220
|
-
className: `${baseClassName}__control-icon`
|
|
221
|
-
})
|
|
222
|
-
})]
|
|
223
|
-
})]
|
|
313
|
+
className: `${baseClassName}__wrap`,
|
|
314
|
+
children: [/*#__PURE__*/_jsxs("div", {
|
|
315
|
+
className: `${baseClassName}__slides`,
|
|
316
|
+
style: showControls ? this.listStyle() : undefined,
|
|
317
|
+
children: [showControls && this.renderSliderItems(), /*#__PURE__*/_jsx("div", {
|
|
318
|
+
className: `${baseClassName}__genuine-slides`,
|
|
319
|
+
ref: this.genuineRef,
|
|
320
|
+
children: this.renderSliderItems()
|
|
321
|
+
}), showControls && this.renderSliderItems()]
|
|
322
|
+
}), this.renderNavigationArrows()]
|
|
323
|
+
}), this.renderNavigationDots()]
|
|
224
324
|
});
|
|
225
325
|
}
|
|
226
326
|
});
|
|
@@ -228,6 +328,11 @@ class Carousel extends Component {
|
|
|
228
328
|
}
|
|
229
329
|
_defineProperty(Carousel, "defaultProps", {
|
|
230
330
|
children: null,
|
|
331
|
+
arrows: true,
|
|
332
|
+
dots: false,
|
|
333
|
+
autoplay: true,
|
|
334
|
+
autoplayInterval: 5000,
|
|
335
|
+
onSlide: null,
|
|
231
336
|
className: null,
|
|
232
337
|
baseClassName: `${CLS_PREFIX}carousel`
|
|
233
338
|
});
|
|
@@ -4,7 +4,8 @@ import { jsx as _jsx } from "react/jsx-runtime";
|
|
|
4
4
|
/**
|
|
5
5
|
* `ComboBoxOption` is a part of [ComboBox](#!/ComboBox) component.
|
|
6
6
|
* @since 2.6.0
|
|
7
|
-
*/
|
|
7
|
+
*/
|
|
8
|
+
// eslint-disable-next-line @typescript-eslint/no-unused-vars
|
|
8
9
|
const ComboBoxOption = _props => {
|
|
9
10
|
// styleguidist doesn't show Props & Methods if component renders nothing
|
|
10
11
|
// eslint-disable-next-line no-constant-condition
|
|
@@ -79,7 +79,7 @@ class DrawerProgress extends Component {
|
|
|
79
79
|
} = this.state;
|
|
80
80
|
if (prevState.status !== STATUS_DONE && status === STATUS_DONE) {
|
|
81
81
|
window.clearTimeout(this.closeTimeout);
|
|
82
|
-
if (autoCloseTimeout !==
|
|
82
|
+
if (autoCloseTimeout !== null) {
|
|
83
83
|
this.closeTimeout = window.setTimeout(this.handleClose, autoCloseTimeout);
|
|
84
84
|
}
|
|
85
85
|
}
|