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