@plesk/ui-library 3.38.2 → 3.40.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 (93) hide show
  1. package/cjs/components/Button/Button.js +4 -22
  2. package/cjs/components/Card/CardButton.js +2 -3
  3. package/cjs/components/CardList/CardListToolbar.js +3 -8
  4. package/cjs/components/Dialog/Dialog.js +5 -27
  5. package/cjs/components/Drawer/Drawer.js +7 -20
  6. package/cjs/components/Dropdown/Dropdown.js +3 -11
  7. package/cjs/components/FormField/FormField.js +13 -26
  8. package/cjs/components/Icon/constants.js +2 -2
  9. package/cjs/components/Icon/images/symbols.svg +9 -1
  10. package/cjs/components/List/List.js +1 -14
  11. package/cjs/components/Progress/Progress.js +6 -5
  12. package/cjs/components/ProgressStep/ProgressStep.js +5 -14
  13. package/cjs/components/ProgressStep/index.js +6 -0
  14. package/cjs/components/Section/Section.js +11 -19
  15. package/cjs/components/SplitButton/SplitButton.js +2 -3
  16. package/cjs/components/TextArea/TextArea.js +49 -97
  17. package/cjs/components/TextArea/calculateNodeHeight.js +8 -8
  18. package/cjs/components/Toolbar/RegistryContextBeta.js +112 -0
  19. package/cjs/components/Toolbar/Toolbar.js +46 -2
  20. package/cjs/components/Toolbar/ToolbarBetaProvider.js +23 -0
  21. package/cjs/components/Toolbar/ToolbarGroup.js +66 -4
  22. package/cjs/components/Toolbar/ToolbarItem.js +27 -12
  23. package/cjs/components/Toolbar/ToolbarMenu.js +2 -1
  24. package/cjs/components/Toolbar/index.js +8 -1
  25. package/cjs/components/index.js +15 -1
  26. package/cjs/hooks/index.js +12 -0
  27. package/cjs/hooks/useResizeObserver.js +29 -0
  28. package/cjs/hooks/useSqueeze.js +48 -0
  29. package/cjs/index.js +1 -1
  30. package/dist/images/symbols.svg +9 -1
  31. package/dist/plesk-ui-library-rtl.css +1 -1
  32. package/dist/plesk-ui-library-rtl.css.map +1 -1
  33. package/dist/plesk-ui-library.css +1 -1
  34. package/dist/plesk-ui-library.css.map +1 -1
  35. package/dist/plesk-ui-library.js +591 -309
  36. package/dist/plesk-ui-library.js.map +1 -1
  37. package/dist/plesk-ui-library.min.js +5 -5
  38. package/dist/plesk-ui-library.min.js.map +1 -1
  39. package/esm/components/Button/Button.js +3 -21
  40. package/esm/components/Card/CardButton.js +2 -3
  41. package/esm/components/CardList/CardListToolbar.js +3 -8
  42. package/esm/components/Dialog/Dialog.js +5 -27
  43. package/esm/components/Drawer/Drawer.js +7 -20
  44. package/esm/components/Dropdown/Dropdown.js +3 -11
  45. package/esm/components/FormField/FormField.js +13 -26
  46. package/esm/components/Icon/constants.js +2 -2
  47. package/esm/components/Icon/images/symbols.svg +9 -1
  48. package/esm/components/List/List.js +1 -14
  49. package/esm/components/Progress/Progress.js +7 -6
  50. package/esm/components/ProgressStep/ProgressStep.js +4 -13
  51. package/esm/components/ProgressStep/index.js +1 -1
  52. package/esm/components/Section/Section.js +11 -19
  53. package/esm/components/SplitButton/SplitButton.js +2 -3
  54. package/esm/components/TextArea/TextArea.js +50 -98
  55. package/esm/components/TextArea/calculateNodeHeight.js +8 -8
  56. package/esm/components/Toolbar/RegistryContextBeta.js +103 -0
  57. package/esm/components/Toolbar/Toolbar.js +47 -3
  58. package/esm/components/Toolbar/ToolbarBetaProvider.js +16 -0
  59. package/esm/components/Toolbar/ToolbarGroup.js +67 -5
  60. package/esm/components/Toolbar/ToolbarItem.js +27 -12
  61. package/esm/components/Toolbar/ToolbarMenu.js +2 -1
  62. package/esm/components/Toolbar/index.js +2 -1
  63. package/esm/components/index.js +2 -2
  64. package/esm/hooks/index.js +3 -0
  65. package/esm/hooks/useResizeObserver.js +22 -0
  66. package/esm/hooks/useSqueeze.js +41 -0
  67. package/esm/index.js +1 -1
  68. package/package.json +13 -13
  69. package/styleguide/build/bundle.8f00c54c.js +2 -0
  70. package/styleguide/images/symbols.svg +9 -1
  71. package/styleguide/index.html +2 -2
  72. package/types/src/components/Button/Button.d.ts +1 -0
  73. package/types/src/components/Dialog/Dialog.d.ts +1 -25
  74. package/types/src/components/Drawer/Drawer.d.ts +1 -4
  75. package/types/src/components/FormField/FormField.d.ts +1 -23
  76. package/types/src/components/Icon/constants.d.ts +1 -1
  77. package/types/src/components/ProgressStep/ProgressStep.d.ts +2 -13
  78. package/types/src/components/ProgressStep/index.d.ts +1 -1
  79. package/types/src/components/Section/Section.d.ts +2 -32
  80. package/types/src/components/TextArea/TextArea.d.ts +5 -32
  81. package/types/src/components/TextArea/calculateNodeHeight.d.ts +2 -6
  82. package/types/src/components/Toolbar/RegistryContextBeta.d.ts +25 -0
  83. package/types/src/components/Toolbar/Toolbar.d.ts +2 -22
  84. package/types/src/components/Toolbar/ToolbarBetaProvider.d.ts +5 -0
  85. package/types/src/components/Toolbar/ToolbarGroup.d.ts +2 -5
  86. package/types/src/components/Toolbar/ToolbarItem.d.ts +1 -1
  87. package/types/src/components/Toolbar/index.d.ts +1 -0
  88. package/types/src/components/index.d.ts +2 -2
  89. package/types/src/hooks/index.d.ts +1 -0
  90. package/types/src/hooks/useResizeObserver.d.ts +7 -0
  91. package/types/src/hooks/useSqueeze.d.ts +10 -0
  92. package/styleguide/build/bundle.42040fbd.js +0 -2
  93. /package/styleguide/build/{bundle.42040fbd.js.LICENSE.txt → bundle.8f00c54c.js.LICENSE.txt} +0 -0
@@ -1,8 +1,7 @@
1
- import _defineProperty from "@babel/runtime/helpers/defineProperty";
2
1
  // Copyright 1999-2023. Plesk International GmbH. All rights reserved.
3
2
 
4
3
  import classNames from 'classnames';
5
- import { Component, createRef } from 'react';
4
+ import { useCallback, useLayoutEffect, useRef, useState } from 'react';
6
5
  import { CLS_PREFIX } from '../../constants';
7
6
  import calculateNodeHeight from './calculateNodeHeight';
8
7
  import { jsx as _jsx } from "react/jsx-runtime";
@@ -17,109 +16,62 @@ const getMinMax = rows => {
17
16
  maxRows: rows.max
18
17
  };
19
18
  }
20
- return null;
19
+ return {};
21
20
  };
22
- const AVAILABLE_SIZES = ['sm', 'md', 'lg', 'xl', 'fill'];
21
+ const AVAILABLE_SIZES = new Set(['sm', 'md', 'lg', 'xl', 'fill']);
23
22
 
24
23
  /**
25
24
  * `TextArea` is used for entering long text (like email body, descriptions, comments).
26
25
  * @since 1.9.0
27
26
  */
28
-
29
- class TextArea extends Component {
30
- constructor() {
31
- super(...arguments);
32
- _defineProperty(this, "state", {
33
- textareaStyles: null
34
- });
35
- _defineProperty(this, "rootRef", /*#__PURE__*/createRef());
36
- _defineProperty(this, "handleChange", e => {
37
- const {
38
- autoheight,
39
- onChange
40
- } = this.props;
41
- if (autoheight) {
42
- this.adjustHeight();
43
- }
44
- if (typeof onChange === 'function') {
45
- onChange(e);
46
- }
47
- });
48
- }
49
- static getDerivedStateFromProps(_ref) {
50
- let {
51
- rows
52
- } = _ref;
53
- if (rows) {
54
- return getMinMax(rows);
55
- }
56
- return null;
57
- }
58
- componentDidMount() {
59
- this.adjustHeight();
60
- }
61
- componentDidUpdate(prevProps) {
62
- const {
63
- autoheight
64
- } = this.props;
65
- if (autoheight !== prevProps.autoheight) {
66
- this.adjustHeight();
67
- }
68
- }
69
- adjustHeight() {
70
- const {
71
- autoheight
72
- } = this.props;
73
- if (!autoheight) {
74
- this.setState({
75
- textareaStyles: null
76
- });
27
+ const TextArea = _ref => {
28
+ let {
29
+ baseClassName = `${CLS_PREFIX}textarea`,
30
+ className,
31
+ rows = 4,
32
+ size = 'md',
33
+ autoheight = false,
34
+ onChange,
35
+ style,
36
+ ...props
37
+ } = _ref;
38
+ const rootRef = useRef(null);
39
+ const useSizeModifier = size && AVAILABLE_SIZES.has(size);
40
+ const {
41
+ minRows,
42
+ maxRows
43
+ } = getMinMax(rows);
44
+ const [heightStyle, setHeightStyle] = useState();
45
+ const adjustHeight = useCallback(() => {
46
+ if (!autoheight || !rootRef.current) {
47
+ setHeightStyle(undefined);
77
48
  return;
78
49
  }
79
- const {
80
- minRows,
81
- maxRows
82
- } = this.state;
83
- if (this.rootRef.current) {
84
- const textareaStyles = calculateNodeHeight(this.rootRef.current, false, minRows, maxRows);
85
- this.setState({
86
- textareaStyles
87
- });
50
+ setHeightStyle(calculateNodeHeight(rootRef.current, false, minRows, maxRows));
51
+ }, [autoheight, maxRows, minRows]);
52
+ useLayoutEffect(() => {
53
+ adjustHeight();
54
+ }, [adjustHeight]);
55
+ const handleChange = e => {
56
+ if (autoheight) {
57
+ adjustHeight();
88
58
  }
89
- }
90
- render() {
91
- const {
92
- baseClassName,
93
- className,
94
- rows,
95
- size,
96
- autoheight,
97
- onChange,
98
- ...other
99
- } = this.props;
100
- const {
101
- textareaStyles,
102
- minRows
103
- } = this.state;
104
- const useSizeModifier = size && AVAILABLE_SIZES.indexOf(size) !== -1;
105
- return /*#__PURE__*/_jsx("textarea", {
106
- className: classNames(baseClassName, {
107
- [`${baseClassName}--size-${size}`]: useSizeModifier
108
- }, className),
109
- ref: this.rootRef,
110
- style: textareaStyles,
111
- onChange: this.handleChange,
112
- rows: minRows,
113
- ...other
114
- });
115
- }
116
- }
117
- _defineProperty(TextArea, "defaultProps", {
118
- baseClassName: `${CLS_PREFIX}textarea`,
119
- className: null,
120
- rows: 4,
121
- size: 'md',
122
- autoheight: false,
123
- onChange: null
124
- });
59
+ if (typeof onChange === 'function') {
60
+ onChange(e);
61
+ }
62
+ };
63
+ return /*#__PURE__*/_jsx("textarea", {
64
+ ref: rootRef,
65
+ className: classNames(baseClassName, {
66
+ [`${baseClassName}--size-${size}`]: useSizeModifier
67
+ }, className),
68
+ style: {
69
+ ...style,
70
+ ...heightStyle
71
+ },
72
+ onChange: handleChange,
73
+ rows: minRows,
74
+ ...props
75
+ });
76
+ };
125
77
  export default TextArea;
@@ -41,8 +41,8 @@ const calculateNodeStyling = function (node) {
41
41
  // eslint-disable-next-line max-params
42
42
  export default function calculateNodeHeight(uiTextNode) {
43
43
  let useCache = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : false;
44
- let minRows = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : null;
45
- let maxRows = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : null;
44
+ let minRows = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : undefined;
45
+ let maxRows = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : undefined;
46
46
  if (!hiddenTextarea) {
47
47
  hiddenTextarea = document.createElement('textarea');
48
48
  document.body.appendChild(hiddenTextarea);
@@ -64,8 +64,8 @@ export default function calculateNodeHeight(uiTextNode) {
64
64
  // Need to have the overflow attribute to hide the scrollbar otherwise text-lines will not calculated properly as the shadow will technically be narrower for content
65
65
  hiddenTextarea.setAttribute('style', `${sizingStyle};${HIDDEN_TEXTAREA_STYLE}`);
66
66
  hiddenTextarea.value = uiTextNode.value || uiTextNode.placeholder || '';
67
- let minHeight = null;
68
- let maxHeight = null;
67
+ let minHeight = undefined;
68
+ let maxHeight = undefined;
69
69
  let height = hiddenTextarea.scrollHeight;
70
70
  let overflowY;
71
71
  if (boxSizing === 'border-box') {
@@ -75,23 +75,23 @@ export default function calculateNodeHeight(uiTextNode) {
75
75
  // remove padding, since height = content
76
76
  height = height - paddingSize;
77
77
  }
78
- if (minRows !== null || maxRows !== null) {
78
+ if (minRows !== undefined || maxRows !== undefined) {
79
79
  // measure height of a textarea with a single row
80
80
  hiddenTextarea.value = ' ';
81
81
  const singleRowHeight = hiddenTextarea.scrollHeight - paddingSize;
82
- if (minRows !== null) {
82
+ if (minRows !== undefined) {
83
83
  minHeight = singleRowHeight * minRows;
84
84
  if (boxSizing === 'border-box') {
85
85
  minHeight = minHeight + paddingSize + borderSize;
86
86
  }
87
87
  height = Math.max(minHeight, height);
88
88
  }
89
- if (maxRows !== null) {
89
+ if (maxRows !== undefined) {
90
90
  maxHeight = singleRowHeight * maxRows;
91
91
  if (boxSizing === 'border-box') {
92
92
  maxHeight = maxHeight + paddingSize + borderSize;
93
93
  }
94
- overflowY = height > maxHeight ? '' : 'hidden';
94
+ overflowY = height > maxHeight ? undefined : 'hidden';
95
95
  height = Math.min(maxHeight, height);
96
96
  }
97
97
  }
@@ -0,0 +1,103 @@
1
+ import _defineProperty from "@babel/runtime/helpers/defineProperty";
2
+ // Copyright 1999-2023. Plesk International GmbH. All rights reserved.
3
+
4
+ import { createContext, useContext, useState, useLayoutEffect } from 'react';
5
+ const RegistryContext = /*#__PURE__*/createContext(undefined);
6
+ RegistryContext.displayName = 'RegistryContext';
7
+ const useRegistryContext = () => useContext(RegistryContext);
8
+ export default RegistryContext;
9
+ class Registry {
10
+ constructor() {
11
+ _defineProperty(this, "items", []);
12
+ }
13
+ register(item) {
14
+ this.items.push(item);
15
+ }
16
+ unregister(item) {
17
+ this.items = this.items.filter(i => i !== item);
18
+ }
19
+ compact() {
20
+ let changed = false;
21
+ for (const item of [...this.items].reverse()) {
22
+ if (!item.isCompact) {
23
+ item.compact();
24
+ changed = true;
25
+ break;
26
+ }
27
+ }
28
+ return changed;
29
+ }
30
+ expand() {
31
+ let changed = false;
32
+ for (const item of this.items) {
33
+ if (this.checkItemIsCompactOrHasCompactItems(item)) {
34
+ item.expand();
35
+ changed = true;
36
+ break;
37
+ }
38
+ }
39
+ return changed;
40
+ }
41
+ get isCompact() {
42
+ return this.items.every(_ref => {
43
+ let {
44
+ isCompact
45
+ } = _ref;
46
+ return isCompact;
47
+ });
48
+ }
49
+ get hasCompactItems() {
50
+ return this.items.some(this.checkItemIsCompactOrHasCompactItems);
51
+ }
52
+ checkItemIsCompactOrHasCompactItems(item) {
53
+ return item.isCompact || 'hasCompactItems' in item && item.hasCompactItems;
54
+ }
55
+ }
56
+ class RegistryItem {
57
+ constructor(_ref2) {
58
+ let {
59
+ onCompactStateChange
60
+ } = _ref2;
61
+ _defineProperty(this, "_isCompact", false);
62
+ _defineProperty(this, "onCompactStateChange", void 0);
63
+ this.onCompactStateChange = onCompactStateChange;
64
+ }
65
+ compact() {
66
+ this._isCompact = true;
67
+ this.onCompactStateChange(true);
68
+ }
69
+ expand() {
70
+ this._isCompact = false;
71
+ this.onCompactStateChange(false);
72
+ }
73
+ get isCompact() {
74
+ return this._isCompact;
75
+ }
76
+ }
77
+ export const useRegistry = () => {
78
+ const parentRegistry = useRegistryContext();
79
+ const [registry] = useState(() => new Registry());
80
+ useLayoutEffect(() => {
81
+ if (!parentRegistry) return undefined;
82
+ parentRegistry.register(registry);
83
+ return () => {
84
+ parentRegistry.unregister(registry);
85
+ };
86
+ }, [parentRegistry, registry]);
87
+ return registry;
88
+ };
89
+ export const useRegistryItem = () => {
90
+ const registry = useRegistryContext();
91
+ const [isCompact, setIsCompact] = useState(false);
92
+ const [registryItem] = useState(() => new RegistryItem({
93
+ onCompactStateChange: setIsCompact
94
+ }));
95
+ useLayoutEffect(() => {
96
+ if (!registry) return undefined;
97
+ registry.register(registryItem);
98
+ return () => {
99
+ registry.unregister(registryItem);
100
+ };
101
+ }, [registry, registryItem]);
102
+ return [isCompact];
103
+ };
@@ -1,13 +1,16 @@
1
1
  import _defineProperty from "@babel/runtime/helpers/defineProperty";
2
2
  // Copyright 1999-2023. Plesk International GmbH. All rights reserved.
3
3
 
4
- import { Component } from 'react';
4
+ import { Component, useRef, useState, useMemo } from 'react';
5
5
  import classNames from 'classnames';
6
6
  import { CLS_PREFIX } from '../../constants';
7
7
  import RegistryContext, { createRegistry } from './RegistryContext';
8
+ import RegistryContextBeta, { useRegistry } from './RegistryContextBeta';
8
9
  import DistractionFreeModeContext from '../DistractionFreeModeContext';
9
10
  import { toToolbarItems } from './ToolbarItem';
10
11
  import Squeezer from '../Squeezer';
12
+ import { useSqueeze } from '../../hooks';
13
+ import { useToolbarBetaContext } from './ToolbarBetaProvider';
11
14
 
12
15
  /**
13
16
  * `Toolbar` component is a panel containing various instruments used for managing the contents of a large content block.
@@ -17,7 +20,7 @@ import Squeezer from '../Squeezer';
17
20
  * @since 0.0.57
18
21
  */
19
22
  import { jsx as _jsx } from "react/jsx-runtime";
20
- class Toolbar extends Component {
23
+ class ToolbarClassComponent extends Component {
21
24
  constructor(props) {
22
25
  super(props);
23
26
  _defineProperty(this, "state", {
@@ -74,9 +77,50 @@ class Toolbar extends Component {
74
77
  });
75
78
  }
76
79
  }
77
- _defineProperty(Toolbar, "defaultProps", {
80
+ _defineProperty(ToolbarClassComponent, "defaultProps", {
78
81
  children: null,
79
82
  className: null,
80
83
  baseClassName: `${CLS_PREFIX}toolbar`
81
84
  });
85
+ const ToolbarBeta = _ref2 => {
86
+ let {
87
+ children,
88
+ className,
89
+ baseClassName = `${CLS_PREFIX}toolbar`,
90
+ ...props
91
+ } = _ref2;
92
+ const containerRef = useRef(null);
93
+ const [isDistractionFreeModeEnabled, setIsDistractionFreeModeEnabled] = useState(false);
94
+ const distractionFreeModeContextValue = useMemo(() => ({
95
+ enabled: isDistractionFreeModeEnabled,
96
+ toggle: () => setIsDistractionFreeModeEnabled(current => !current)
97
+ }), [isDistractionFreeModeEnabled]);
98
+ const registry = useRegistry();
99
+ useSqueeze({
100
+ ref: containerRef,
101
+ compact: () => registry.compact(),
102
+ expand: () => registry.expand()
103
+ });
104
+ const toolbarItems = toToolbarItems(children, true);
105
+ return /*#__PURE__*/_jsx("div", {
106
+ ref: containerRef,
107
+ className: classNames(baseClassName, className),
108
+ ...props,
109
+ children: /*#__PURE__*/_jsx(RegistryContextBeta.Provider, {
110
+ value: registry,
111
+ children: /*#__PURE__*/_jsx(DistractionFreeModeContext.Provider, {
112
+ value: distractionFreeModeContextValue,
113
+ children: toolbarItems
114
+ })
115
+ })
116
+ });
117
+ };
118
+ const Toolbar = props => {
119
+ const isToolbarBeta = useToolbarBetaContext();
120
+ return isToolbarBeta ? /*#__PURE__*/_jsx(ToolbarBeta, {
121
+ ...props
122
+ }) : /*#__PURE__*/_jsx(ToolbarClassComponent, {
123
+ ...props
124
+ });
125
+ };
82
126
  export default Toolbar;
@@ -0,0 +1,16 @@
1
+ // Copyright 1999-2024. Plesk International GmbH. All rights reserved.
2
+
3
+ import { createContext, useContext } from 'react';
4
+ import { jsx as _jsx } from "react/jsx-runtime";
5
+ const ToolbarBetaContext = /*#__PURE__*/createContext(false);
6
+ export const useToolbarBetaContext = () => useContext(ToolbarBetaContext);
7
+ const ToolbarBetaProvider = _ref => {
8
+ let {
9
+ children
10
+ } = _ref;
11
+ return /*#__PURE__*/_jsx(ToolbarBetaContext.Provider, {
12
+ value: true,
13
+ children: children
14
+ });
15
+ };
16
+ export default ToolbarBetaProvider;
@@ -1,15 +1,17 @@
1
1
  import _defineProperty from "@babel/runtime/helpers/defineProperty";
2
2
  // Copyright 1999-2023. Plesk International GmbH. All rights reserved.
3
3
 
4
- import { Component, Children, useContext, isValidElement } from 'react';
4
+ import { Component, Children, useContext, isValidElement, useState } from 'react';
5
5
  import classNames from 'classnames';
6
6
  import { CLS_PREFIX } from '../../constants';
7
7
  import Dropdown from '../Dropdown';
8
8
  import ToolbarMenu from './ToolbarMenu';
9
9
  import RegistryContext, { createRegistry } from './RegistryContext';
10
+ import RegistryContextBeta, { useRegistry, useRegistryItem } from './RegistryContextBeta';
10
11
  import DistractionFreeModeContext from '../DistractionFreeModeContext';
11
12
  import { toToolbarItems } from './ToolbarItem';
12
13
  import ToolbarExpander from './ToolbarExpander';
14
+ import { useToolbarBetaContext } from './ToolbarBetaProvider';
13
15
 
14
16
  /**
15
17
  * `ToolbarGroup` is a part of [Toolbar](#!/Toolbar) component.
@@ -17,7 +19,7 @@ import ToolbarExpander from './ToolbarExpander';
17
19
  * @since 0.0.57
18
20
  */
19
21
  import { jsx as _jsx } from "react/jsx-runtime";
20
- class ToolbarGroup extends Component {
22
+ class ToolbarGroupClassComponent extends Component {
21
23
  constructor(props) {
22
24
  super(props);
23
25
  _defineProperty(this, "state", {
@@ -137,7 +139,7 @@ class ToolbarGroup extends Component {
137
139
  });
138
140
  }
139
141
  }
140
- _defineProperty(ToolbarGroup, "defaultProps", {
142
+ _defineProperty(ToolbarGroupClassComponent, "defaultProps", {
141
143
  registry: undefined,
142
144
  distractionFreeMode: undefined
143
145
  });
@@ -149,7 +151,7 @@ const ToolbarGroupWrapper = _ref => {
149
151
  } = _ref;
150
152
  const registry = useContext(RegistryContext);
151
153
  const distractionFreeMode = useContext(DistractionFreeModeContext);
152
- return /*#__PURE__*/_jsx(ToolbarGroup, {
154
+ return /*#__PURE__*/_jsx(ToolbarGroupClassComponent, {
153
155
  groupable: groupable,
154
156
  baseClassName: baseClassName,
155
157
  ...props,
@@ -158,4 +160,64 @@ const ToolbarGroupWrapper = _ref => {
158
160
  });
159
161
  };
160
162
  ToolbarGroupWrapper.displayName = 'ToolbarGroup';
161
- export default ToolbarGroupWrapper;
163
+ const ToolbarGroupBeta = _ref2 => {
164
+ let {
165
+ baseClassName = `${CLS_PREFIX}toolbar__group`,
166
+ className,
167
+ title,
168
+ children,
169
+ groupable = true,
170
+ ...props
171
+ } = _ref2;
172
+ const [compact] = useRegistryItem();
173
+ const registry = useRegistry();
174
+ const [availableInDistractionFreeMode, setAvailableInDistractionFreeMode] = useState(false);
175
+ const distractionFreeMode = useContext(DistractionFreeModeContext);
176
+ const distractionFreeModeContextValue = {
177
+ enabled: distractionFreeMode?.enabled ?? false,
178
+ toggle: () => {
179
+ if (distractionFreeMode) {
180
+ distractionFreeMode.toggle();
181
+ setAvailableInDistractionFreeMode(current => !current);
182
+ }
183
+ }
184
+ };
185
+ let hasExpander = Children.toArray(children).some(child => /*#__PURE__*/isValidElement(child) && child.type === ToolbarExpander);
186
+ if (groupable && compact && Children.count(children) > 1) {
187
+ hasExpander = false;
188
+ children = /*#__PURE__*/_jsx(Dropdown, {
189
+ menu: /*#__PURE__*/_jsx(ToolbarMenu, {
190
+ onItemClick: () => {},
191
+ children: children
192
+ }),
193
+ children: title
194
+ });
195
+ } else {
196
+ children = /*#__PURE__*/_jsx(RegistryContextBeta.Provider, {
197
+ value: registry,
198
+ children: /*#__PURE__*/_jsx(DistractionFreeModeContext.Provider, {
199
+ value: distractionFreeModeContextValue,
200
+ children: toToolbarItems(children, true)
201
+ })
202
+ });
203
+ }
204
+ if (distractionFreeModeContextValue.enabled && !availableInDistractionFreeMode) {
205
+ return null;
206
+ }
207
+ return /*#__PURE__*/_jsx("div", {
208
+ className: classNames(baseClassName, className, {
209
+ [`${baseClassName}--grow`]: hasExpander || distractionFreeModeContextValue.enabled && availableInDistractionFreeMode
210
+ }),
211
+ ...props,
212
+ children: children
213
+ });
214
+ };
215
+ const ToolbarGroup = props => {
216
+ const isToolbarBeta = useToolbarBetaContext();
217
+ return isToolbarBeta ? /*#__PURE__*/_jsx(ToolbarGroupBeta, {
218
+ ...props
219
+ }) : /*#__PURE__*/_jsx(ToolbarGroupWrapper, {
220
+ ...props
221
+ });
222
+ };
223
+ export default ToolbarGroup;
@@ -8,6 +8,7 @@ import ResponsiveContext from '../ResponsiveContext';
8
8
  import RegistryContext from './RegistryContext';
9
9
  import ToolbarGroup from './ToolbarGroup';
10
10
  import ToolbarExpander from './ToolbarExpander';
11
+ import { useRegistryItem } from './RegistryContextBeta';
11
12
  import { jsx as _jsx } from "react/jsx-runtime";
12
13
  class ToolbarItem extends Component {
13
14
  constructor() {
@@ -47,16 +48,30 @@ class ToolbarItem extends Component {
47
48
  }
48
49
  }
49
50
  ToolbarItem.contextType = RegistryContext;
50
- export const toToolbarItems = children => Children.map(children, child => {
51
- if (! /*#__PURE__*/isValidElement(child)) {
52
- return child;
53
- }
54
- if (child.type === ToolbarGroup || child.type === ToolbarExpander) {
55
- return child;
56
- }
57
- return /*#__PURE__*/_jsx(ToolbarItem, {
58
- children: /*#__PURE__*/cloneElement(child, {
59
- className: classNames(child.props.className, `${CLS_PREFIX}toolbar__group-item`)
60
- })
51
+ const ToolbarItemBeta = _ref => {
52
+ let {
53
+ children
54
+ } = _ref;
55
+ const [isCompact] = useRegistryItem();
56
+ return /*#__PURE__*/_jsx(ResponsiveContext.Provider, {
57
+ value: isCompact,
58
+ children: children
59
+ });
60
+ };
61
+ export const toToolbarItems = function (children) {
62
+ let isBeta = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : false;
63
+ return Children.map(children, child => {
64
+ if (! /*#__PURE__*/isValidElement(child)) {
65
+ return child;
66
+ }
67
+ if (child.type === ToolbarGroup || child.type === ToolbarExpander) {
68
+ return child;
69
+ }
70
+ const Component = isBeta ? ToolbarItemBeta : ToolbarItem;
71
+ return /*#__PURE__*/_jsx(Component, {
72
+ children: /*#__PURE__*/cloneElement(child, {
73
+ className: classNames(child.props.className, `${CLS_PREFIX}toolbar__group-item`)
74
+ })
75
+ });
61
76
  });
62
- });
77
+ };
@@ -8,6 +8,7 @@ import Button from '../Button';
8
8
  import Dropdown from '../Dropdown';
9
9
  import { ListOperation } from '../List';
10
10
  import { wrapFunction } from '../utils';
11
+ import { BUTTON_PROP_NAMES } from '../Button/Button';
11
12
  import { jsx as _jsx } from "react/jsx-runtime";
12
13
  const toMenuItem = (child, isLast, onItemClick) => {
13
14
  switch (child.type) {
@@ -24,7 +25,7 @@ const toMenuItem = (child, isLast, onItemClick) => {
24
25
  } = child.props);
25
26
  props.onClick = wrapFunction(props.onClick, onItemClick);
26
27
  Object.keys(other).forEach(k => {
27
- if (!(Button.defaultProps && k in Button.defaultProps)) {
28
+ if (!BUTTON_PROP_NAMES.includes(k)) {
28
29
  props[k] = other[k];
29
30
  }
30
31
  });
@@ -2,4 +2,5 @@
2
2
 
3
3
  export { default } from './Toolbar';
4
4
  export { default as ToolbarGroup } from './ToolbarGroup';
5
- export { default as ToolbarExpander } from './ToolbarExpander';
5
+ export { default as ToolbarExpander } from './ToolbarExpander';
6
+ export { default as ToolbarBetaProvider } from './ToolbarBetaProvider';
@@ -69,7 +69,7 @@ export { default as Progress } from './Progress';
69
69
  export { default as ProgressBar } from './ProgressBar';
70
70
  export { default as ProgressDialog } from './ProgressDialog';
71
71
  export { default as ProgressDialogStep } from './ProgressDialogStep';
72
- export { default as ProgressStep } from './ProgressStep';
72
+ export { default as ProgressStep, PROGRESS_STEP_DEFAULT_STATUS } from './ProgressStep';
73
73
  export { default as Rating } from './Rating';
74
74
  export { default as Section } from './Section';
75
75
  export * from './Section';
@@ -86,7 +86,7 @@ export { default as SwitchesPanelItem } from './SwitchesPanelItem';
86
86
  export { default as Tabs, Tab, SearchBar } from './Tabs';
87
87
  export { default as Text } from './Text';
88
88
  export { default as Toaster } from './Toaster';
89
- export { default as Toolbar, ToolbarGroup, ToolbarExpander } from './Toolbar';
89
+ export { default as Toolbar, ToolbarGroup, ToolbarExpander, ToolbarBetaProvider } from './Toolbar';
90
90
  export { default as Tooltip } from './Tooltip';
91
91
  export { default as Tour } from './Tour';
92
92
  export { default as Translate } from './Translate';
@@ -0,0 +1,3 @@
1
+ // Copyright 1999-2024. Plesk International GmbH. All rights reserved.
2
+
3
+ export { useSqueeze } from './useSqueeze';
@@ -0,0 +1,22 @@
1
+ // Copyright 1999-2024. Plesk International GmbH. All rights reserved.
2
+
3
+ import { useEffect, useRef } from 'react';
4
+ export const useResizeObserver = _ref => {
5
+ let {
6
+ ref,
7
+ onResize
8
+ } = _ref;
9
+ const onResizeRef = useRef(undefined);
10
+ onResizeRef.current = onResize;
11
+ useEffect(() => {
12
+ if (!ref.current) return undefined;
13
+ if (typeof window === 'undefined' || !('ResizeObserver' in window)) return undefined;
14
+ const observer = new ResizeObserver(() => {
15
+ onResizeRef.current?.();
16
+ });
17
+ observer.observe(ref.current);
18
+ return () => {
19
+ observer.disconnect();
20
+ };
21
+ }, [ref]);
22
+ };