@plesk/ui-library 3.35.4 → 3.35.6

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 (40) hide show
  1. package/cjs/components/List/List.js +1 -1
  2. package/cjs/components/Pagination/Pagination.js +3 -3
  3. package/cjs/components/Progress/Progress.js +7 -0
  4. package/cjs/components/ProgressDialog/ProgressDialog.js +10 -2
  5. package/cjs/components/SegmentedControl/SegmentedControl.js +23 -82
  6. package/cjs/components/SegmentedControl/index.js +9 -2
  7. package/cjs/components/index.js +15 -1
  8. package/cjs/index.js +1 -1
  9. package/dist/plesk-ui-library-rtl.css +1 -1
  10. package/dist/plesk-ui-library-rtl.css.map +1 -1
  11. package/dist/plesk-ui-library.css +1 -1
  12. package/dist/plesk-ui-library.css.map +1 -1
  13. package/dist/plesk-ui-library.js +80 -103
  14. package/dist/plesk-ui-library.js.map +1 -1
  15. package/dist/plesk-ui-library.min.js +5 -5
  16. package/dist/plesk-ui-library.min.js.map +1 -1
  17. package/esm/components/List/List.js +1 -1
  18. package/esm/components/Pagination/Pagination.js +3 -3
  19. package/esm/components/Progress/Progress.js +8 -1
  20. package/esm/components/ProgressDialog/ProgressDialog.js +11 -3
  21. package/esm/components/SegmentedControl/SegmentedControl.js +22 -81
  22. package/esm/components/SegmentedControl/index.js +2 -1
  23. package/esm/components/index.js +2 -1
  24. package/esm/index.js +1 -1
  25. package/package.json +5 -6
  26. package/styleguide/build/bundle.8a07b2dd.js +2 -0
  27. package/styleguide/index.html +2 -2
  28. package/types/src/components/Card/PreviewPanel.d.ts +2 -1
  29. package/types/src/components/List/ListAction.d.ts +3 -3
  30. package/types/src/components/List/ListActions.d.ts +1 -1
  31. package/types/src/components/List/ListOperation.d.ts +1 -1
  32. package/types/src/components/List/ListOperationContext.d.ts +2 -2
  33. package/types/src/components/PageHeader/PageHeader.d.ts +2 -1
  34. package/types/src/components/ProgressDialog/ProgressDialog.d.ts +2 -0
  35. package/types/src/components/SegmentedControl/SegmentedControl.d.ts +112 -0
  36. package/types/src/components/SegmentedControl/index.d.ts +3 -0
  37. package/types/src/components/Toolbar/ToolbarMenu.d.ts +1 -1
  38. package/types/src/components/index.d.ts +3 -1
  39. package/styleguide/build/bundle.17ad5082.js +0 -2
  40. /package/styleguide/build/{bundle.17ad5082.js.LICENSE.txt → bundle.8a07b2dd.js.LICENSE.txt} +0 -0
@@ -866,7 +866,7 @@ class List extends Component {
866
866
  allRowsSelected,
867
867
  translators: locale
868
868
  })
869
- }), ` `, /*#__PURE__*/_jsxs("span", {
869
+ }), /*#__PURE__*/_jsxs("span", {
870
870
  className: `${baseClassName}__header-buttons`,
871
871
  children: [this.renderSelectAllButton(), this.renderDeselectAllButton()]
872
872
  })]
@@ -2,13 +2,13 @@
2
2
 
3
3
  import classNames from 'classnames';
4
4
  import { CLS_PREFIX } from '../../constants';
5
+ import ContentLoader from '../ContentLoader';
5
6
  import InputNumber from '../InputNumber';
6
- import Translate from '../Translate';
7
7
  import Link from '../Link';
8
- import Text from '../Text';
9
8
  import Popover from '../Popover';
10
9
  import SegmentedControl from '../SegmentedControl';
11
- import ContentLoader from '../ContentLoader';
10
+ import Text from '../Text';
11
+ import Translate from '../Translate';
12
12
  import { safeInvoke } from '../utils';
13
13
  import { jsx as _jsx } from "react/jsx-runtime";
14
14
  import { jsxs as _jsxs } from "react/jsx-runtime";
@@ -5,7 +5,7 @@ import { Component, Children, isValidElement } from 'react';
5
5
  import classNames from 'classnames';
6
6
  import { CLS_PREFIX } from '../../constants';
7
7
  import { safeInvoke } from '../utils';
8
- import { STATUS_NOT_STARTED, STATUS_RUNNING, STATUS_DONE, STATUS_ERROR } from '../ProgressStep';
8
+ import { STATUS_NOT_STARTED, STATUS_RUNNING, STATUS_DONE, STATUS_ERROR, STATUS_WARNING } from '../ProgressStep';
9
9
  import { jsx as _jsx } from "react/jsx-runtime";
10
10
  /**
11
11
  * `Progress` is used for showing progress of performing long operations.
@@ -24,12 +24,14 @@ class Progress extends Component {
24
24
  } = _ref;
25
25
  let isNotStarted = true;
26
26
  let isFinished = true;
27
+ let isFinishedWithWarnings = true;
27
28
  let isFailed = false;
28
29
  if (children) {
29
30
  Children.forEach(children, child => {
30
31
  if ( /*#__PURE__*/isValidElement(child) && child.props.status) {
31
32
  isNotStarted = isNotStarted && child.props.status === STATUS_NOT_STARTED;
32
33
  isFinished = isFinished && child.props.status === STATUS_DONE;
34
+ isFinishedWithWarnings = isFinishedWithWarnings && [STATUS_DONE, STATUS_WARNING].includes(child.props.status);
33
35
  isFailed = isFailed || child.props.status === STATUS_ERROR;
34
36
  }
35
37
  });
@@ -39,6 +41,11 @@ class Progress extends Component {
39
41
  status: STATUS_DONE
40
42
  };
41
43
  }
44
+ if (isFinishedWithWarnings) {
45
+ return {
46
+ status: STATUS_WARNING
47
+ };
48
+ }
42
49
  if (isNotStarted) {
43
50
  return {
44
51
  status: STATUS_NOT_STARTED
@@ -7,7 +7,7 @@ import Dialog from '../Dialog';
7
7
  import { CLS_PREFIX } from '../../constants';
8
8
  import Translate from '../Translate';
9
9
  import { safeInvoke } from '../utils';
10
- import { STATUS_DONE, STATUS_ERROR } from '../ProgressStep';
10
+ import { STATUS_DONE, STATUS_ERROR, STATUS_WARNING } from '../ProgressStep';
11
11
  import Progress from '../Progress';
12
12
  import { jsx as _jsx } from "react/jsx-runtime";
13
13
  import { jsxs as _jsxs } from "react/jsx-runtime";
@@ -21,12 +21,14 @@ class ProgressDialog extends Component {
21
21
  _defineProperty(this, "state", {
22
22
  isOpen: false,
23
23
  isFinished: false,
24
+ isFinishedWithWarnings: false,
24
25
  isFailed: false
25
26
  });
26
27
  _defineProperty(this, "closeTimeout", null);
27
28
  _defineProperty(this, "handleStatusChange", status => {
28
29
  this.setState({
29
30
  isFinished: status === STATUS_DONE,
31
+ isFinishedWithWarnings: status === STATUS_WARNING,
30
32
  isFailed: status === STATUS_ERROR
31
33
  });
32
34
  });
@@ -41,6 +43,7 @@ class ProgressDialog extends Component {
41
43
  const {
42
44
  isOpen,
43
45
  isFinished,
46
+ isFinishedWithWarnings,
44
47
  isFailed
45
48
  } = this.state;
46
49
  this.clearCloseTimeout();
@@ -49,6 +52,8 @@ class ProgressDialog extends Component {
49
52
  }
50
53
  if (isFinished) {
51
54
  safeInvoke(onFinish);
55
+ } else if (isFinishedWithWarnings) {
56
+ // TODO: Call onFinish on major update or create onFinishWithWarnings
52
57
  } else if (isFailed) {
53
58
  safeInvoke(onFail);
54
59
  } else if (cancelable) {
@@ -74,8 +79,10 @@ class ProgressDialog extends Component {
74
79
  const {
75
80
  autoCloseTimeout
76
81
  } = this.props;
77
- if (prevState.isFinished === false && isFinished === true) {
82
+ if (prevState.isFinished !== isFinished) {
78
83
  this.clearCloseTimeout();
84
+ }
85
+ if (prevState.isFinished === false && isFinished === true) {
79
86
  if (autoCloseTimeout) {
80
87
  this.closeTimeout = setTimeout(this.handleClose, autoCloseTimeout);
81
88
  }
@@ -107,9 +114,10 @@ class ProgressDialog extends Component {
107
114
  const {
108
115
  isOpen,
109
116
  isFinished,
117
+ isFinishedWithWarnings,
110
118
  isFailed
111
119
  } = this.state;
112
- const canClose = isFinished || isFailed;
120
+ const canClose = isFinished || isFinishedWithWarnings || isFailed;
113
121
  const canCancel = cancelable && !canClose;
114
122
  const cancelTitle = canClose ? /*#__PURE__*/_jsx(Translate, {
115
123
  content: "ProgressDialog.closeButton",
@@ -1,19 +1,19 @@
1
1
  import _defineProperty from "@babel/runtime/helpers/defineProperty";
2
2
  // Copyright 1999-2023. Plesk International GmbH. All rights reserved.
3
3
 
4
- import React, { Component, createRef } from 'react';
5
- import PropTypes from 'prop-types';
6
4
  import classNames from 'classnames';
5
+ import { Component, createRef } from 'react';
7
6
  import { CLS_PREFIX } from '../../constants';
8
- import ButtonGroup from '../ButtonGroup';
9
7
  import Button from '../Button';
8
+ import ButtonGroup from '../ButtonGroup';
10
9
  import Dropdown from '../Dropdown';
11
10
  import Menu, { MenuItem } from '../Menu';
12
- import Squeezer from '../Squeezer';
13
11
  import ResponsiveContext from '../ResponsiveContext';
12
+ import Squeezer from '../Squeezer';
14
13
  import { jsx as _jsx } from "react/jsx-runtime";
15
14
  import { jsxs as _jsxs } from "react/jsx-runtime";
16
15
  const alphaSort = (a, b) => a > b ? 1 : -1;
16
+ export const SEGMENTED_CONTROL_BASE_CLASS_NAME = `${CLS_PREFIX}segmented-control`;
17
17
 
18
18
  /**
19
19
  * `Segmented Control` is a group of several [Buttons](#!/Button)
@@ -36,7 +36,7 @@ class SegmentedControl extends Component {
36
36
  } = this.props;
37
37
  if (monospaced) {
38
38
  let monoWidth = 0;
39
- this.rootRef.current.querySelectorAll(`.${baseClassName}__button`).forEach(el => {
39
+ this.rootRef.current?.querySelectorAll(`.${baseClassName}__button`).forEach(el => {
40
40
  monoWidth = Math.max(monoWidth, el.getBoundingClientRect().width);
41
41
  });
42
42
  if (monoWidth !== this.state.monoWidth) {
@@ -56,24 +56,24 @@ class SegmentedControl extends Component {
56
56
  } = this.state;
57
57
  let newSelected;
58
58
  if (multiple) {
59
- newSelected = selected ? selected.slice() : [];
59
+ newSelected = selected && Array.isArray(selected) ? selected.slice() : [];
60
60
  if (!selected || !(selected instanceof Array) || selected.indexOf(value) === -1) {
61
61
  newSelected.push(value);
62
62
  } else {
63
63
  newSelected.splice(selected.indexOf(value), 1);
64
64
  }
65
65
  newSelected.sort(alphaSort);
66
- } else {
67
- newSelected = value;
68
- }
69
- if (selected instanceof Array) {
70
- selected.sort(alphaSort);
71
- }
72
- if (JSON.stringify(newSelected) !== JSON.stringify(selected)) {
73
66
  this.setState({
74
67
  selected: newSelected
75
68
  });
76
- onChange(newSelected);
69
+ if (JSON.stringify(newSelected) !== JSON.stringify(selected)) {
70
+ onChange?.(newSelected);
71
+ }
72
+ } else {
73
+ newSelected = value;
74
+ if (JSON.stringify(newSelected) !== JSON.stringify(selected)) {
75
+ onChange?.(newSelected);
76
+ }
77
77
  }
78
78
  });
79
79
  _defineProperty(this, "compact", () => {
@@ -147,7 +147,7 @@ class SegmentedControl extends Component {
147
147
  selected
148
148
  } = this.state;
149
149
  const {
150
- title
150
+ title = ''
151
151
  } = buttons.find(button => button.value === selected) || {};
152
152
  const menu = /*#__PURE__*/_jsx(Menu, {
153
153
  children: buttons.map(_ref2 => {
@@ -164,7 +164,7 @@ class SegmentedControl extends Component {
164
164
  ...buttonProps,
165
165
  ...menuItemProps,
166
166
  children: title
167
- }, value);
167
+ }, `${value}`);
168
168
  })
169
169
  });
170
170
  return /*#__PURE__*/_jsx(Dropdown, {
@@ -218,7 +218,7 @@ class SegmentedControl extends Component {
218
218
  ...handler,
219
219
  ...buttonProps,
220
220
  children: title
221
- }, value);
221
+ }, `${value}`);
222
222
  })
223
223
  });
224
224
  }
@@ -244,6 +244,7 @@ class SegmentedControl extends Component {
244
244
  compact: this.compact,
245
245
  uncompact: this.uncompact,
246
246
  innerRef: el => {
247
+ // @ts-ignore
247
248
  this.rootRef.current = el;
248
249
  },
249
250
  children: _ref4 => {
@@ -268,67 +269,7 @@ class SegmentedControl extends Component {
268
269
  });
269
270
  }
270
271
  }
271
- SegmentedControl.propTypes = {
272
- /**
273
- * Label
274
- * @since 0.0.68
275
- */
276
- label: PropTypes.node,
277
- /**
278
- * Where to place label
279
- * @since 0.0.68
280
- */
281
- labelPlacement: PropTypes.oneOf(['top', 'left']),
282
- /**
283
- * Array of buttons to display (every array item must contain an unique "value" property)
284
- * @since 0.0.68
285
- */
286
- buttons: PropTypes.arrayOf(PropTypes.shape({
287
- value: PropTypes.any.isRequired,
288
- title: PropTypes.node
289
- })).isRequired,
290
- /**
291
- * Monospaced version of buttons (all button would have the same width).
292
- * Attention: using it with buttons dynamic update may cause to wrong behavior!
293
- * @since 0.0.68
294
- */
295
- monospaced: PropTypes.bool,
296
- /**
297
- * Multiple selected options version (any number of buttons can be selected)
298
- * @since 0.0.68
299
- */
300
- multiple: PropTypes.bool,
301
- /**
302
- * Selected value or an array of values (for multiple version).
303
- * Used in controlled version or as default value in uncontrolled version (with onChange property)
304
- * @since 0.0.68
305
- */
306
- selected: PropTypes.oneOfType([PropTypes.any, PropTypes.arrayOf(PropTypes.any)]).isRequired,
307
- /**
308
- * On change selection callback for uncontrolled mode.
309
- * @since 0.0.68
310
- */
311
- onChange: PropTypes.func,
312
- /**
313
- * Should component displays as inline element?
314
- * @since 0.0.68
315
- */
316
- inline: PropTypes.bool,
317
- /**
318
- * Use buttons with transparent background (ghost buttons)
319
- * @since 2.3.0
320
- */
321
- ghost: PropTypes.bool,
322
- /**
323
- * @ignore
324
- */
325
- className: PropTypes.string,
326
- /**
327
- * @ignore
328
- */
329
- baseClassName: PropTypes.string
330
- };
331
- SegmentedControl.defaultProps = {
272
+ _defineProperty(SegmentedControl, "defaultProps", {
332
273
  label: null,
333
274
  labelPlacement: 'top',
334
275
  monospaced: false,
@@ -337,7 +278,7 @@ SegmentedControl.defaultProps = {
337
278
  inline: false,
338
279
  ghost: false,
339
280
  className: null,
340
- baseClassName: `${CLS_PREFIX}segmented-control`
341
- };
342
- SegmentedControl.contextType = ResponsiveContext;
281
+ baseClassName: SEGMENTED_CONTROL_BASE_CLASS_NAME
282
+ });
283
+ _defineProperty(SegmentedControl, "contextType", ResponsiveContext);
343
284
  export default SegmentedControl;
@@ -1,3 +1,4 @@
1
1
  // Copyright 1999-2023. Plesk International GmbH. All rights reserved.
2
2
 
3
- export { default } from './SegmentedControl';
3
+ export { default } from './SegmentedControl';
4
+ export { SEGMENTED_CONTROL_BASE_CLASS_NAME } from './SegmentedControl';
@@ -59,7 +59,7 @@ export { default as LocaleProvider } from './LocaleProvider';
59
59
  export * from './LocaleProvider';
60
60
  export { default as Markdown } from './Markdown';
61
61
  export { default as Media, MediaSection } from './Media';
62
- export { default as Menu, MenuDivider, MenuHeader, MenuItem, MenuSelectableItem } from './Menu';
62
+ export { default as Menu, MenuDivider, MenuHeader, MenuItem, MenuSelectableItem, MenuBaseItem } from './Menu';
63
63
  export { default as Overlay } from './Overlay';
64
64
  export { default as PageHeader } from './PageHeader';
65
65
  export { default as Pagination } from './Pagination';
@@ -76,6 +76,7 @@ export { default as Rating } from './Rating';
76
76
  export { default as Section } from './Section';
77
77
  export * from './Section';
78
78
  export { default as SegmentedControl } from './SegmentedControl';
79
+ export { SEGMENTED_CONTROL_BASE_CLASS_NAME } from './SegmentedControl';
79
80
  export { default as Spot } from './Spot';
80
81
  export { default as SplitButton } from './SplitButton';
81
82
  export { default as Status } from './Status';
package/esm/index.js CHANGED
@@ -1,6 +1,6 @@
1
1
  // Copyright 1999-2023. Plesk International GmbH. All rights reserved.
2
2
  import svg4everybody from 'svg4everybody';
3
- const version = "3.35.4";
3
+ const version = "3.35.6";
4
4
  export * from './publicPath';
5
5
  export { version };
6
6
  export * from './utils';
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@plesk/ui-library",
3
- "version": "3.35.4",
3
+ "version": "3.35.6",
4
4
  "description": "Plesk UI Library",
5
5
  "main": "index.js",
6
6
  "module": "esm/index.js",
@@ -27,7 +27,6 @@
27
27
  "lint:style": "stylelint \"{src,styleguidist}/**/*.less\"",
28
28
  "styleguide": "styleguidist server --config ./configs/styleguide.config.js",
29
29
  "styleguide:build": "styleguidist build --config ./configs/styleguide.config.js",
30
- "create-component": "node scripts/create-component.js",
31
30
  "prepublishOnly": "yarn install && yarn test && yarn build && yarn styleguide:build",
32
31
  "storybook": "webpack serve --config ./configs/storybook.config.js --allowed-hosts all",
33
32
  "postinstall": "node ./scripts/postinstall.js"
@@ -77,7 +76,7 @@
77
76
  "@types/classnames": "2.3.1",
78
77
  "@types/doctrine": "^0.0.5",
79
78
  "@types/enzyme": "^3.10.14",
80
- "@types/jest": "^27.5.2",
79
+ "@types/jest": "^28.1.8",
81
80
  "@types/jest-image-snapshot": "^6.2.1",
82
81
  "@types/marked": "^4.3.1",
83
82
  "@types/node": "^16.18.54",
@@ -103,9 +102,9 @@
103
102
  "eslint-plugin-markdown": "^3.0.1",
104
103
  "eslint-plugin-prettier": "^4.2.1",
105
104
  "html-webpack-plugin": "^5.5.3",
106
- "inquirer": "^3.3.0",
107
- "jest": "^27.5.1",
108
- "jest-dev-server": "^9.0.0",
105
+ "jest": "^28.1.3",
106
+ "jest-dev-server": "^9.0.1",
107
+ "jest-environment-jsdom": "^28.1.3",
109
108
  "jest-image-snapshot": "^6.2.0",
110
109
  "less": "^4.2.0",
111
110
  "less-loader": "^11.1.3",