@plesk/ui-library 3.40.5 → 3.40.7

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 (50) hide show
  1. package/cjs/components/Badge/Badge.js +2 -2
  2. package/cjs/components/Carousel/Carousel.js +0 -14
  3. package/cjs/components/LocaleProvider/LocaleProvider.js +17 -1
  4. package/cjs/components/SegmentedControl/SegmentedControl.js +12 -10
  5. package/cjs/components/StatusMessage/StatusMessage.js +1 -0
  6. package/cjs/components/Subnav/Subnav.js +1 -1
  7. package/cjs/components/Tabs/SearchBar.js +12 -13
  8. package/cjs/components/Toolbar/RegistryContext.js +90 -31
  9. package/cjs/components/Toolbar/Toolbar.js +5 -80
  10. package/cjs/components/Toolbar/ToolbarGroup.js +6 -159
  11. package/cjs/components/Toolbar/ToolbarItem.js +15 -59
  12. package/cjs/components/index.js +21 -11
  13. package/cjs/hooks/useSqueeze.js +3 -1
  14. package/cjs/index.js +1 -1
  15. package/dist/plesk-ui-library-rtl.css +1 -1
  16. package/dist/plesk-ui-library-rtl.css.map +1 -1
  17. package/dist/plesk-ui-library.css +1 -1
  18. package/dist/plesk-ui-library.css.map +1 -1
  19. package/dist/plesk-ui-library.js +103 -420
  20. package/dist/plesk-ui-library.js.map +1 -1
  21. package/dist/plesk-ui-library.min.js +6 -6
  22. package/dist/plesk-ui-library.min.js.map +1 -1
  23. package/esm/components/Badge/Badge.js +2 -2
  24. package/esm/components/Carousel/Carousel.js +0 -14
  25. package/esm/components/LocaleProvider/LocaleProvider.js +16 -1
  26. package/esm/components/SegmentedControl/SegmentedControl.js +12 -10
  27. package/esm/components/StatusMessage/StatusMessage.js +1 -0
  28. package/esm/components/Subnav/Subnav.js +1 -1
  29. package/esm/components/Tabs/SearchBar.js +12 -13
  30. package/esm/components/Toolbar/RegistryContext.js +87 -30
  31. package/esm/components/Toolbar/Toolbar.js +7 -82
  32. package/esm/components/Toolbar/ToolbarGroup.js +7 -160
  33. package/esm/components/Toolbar/ToolbarItem.js +15 -59
  34. package/esm/components/index.js +1 -2
  35. package/esm/hooks/useSqueeze.js +3 -1
  36. package/esm/index.js +1 -1
  37. package/package.json +23 -25
  38. package/styleguide/build/bundle.52d1d9a1.js +2 -0
  39. package/styleguide/index.html +2 -2
  40. package/types/src/components/LocaleProvider/LocaleProvider.d.ts +1 -0
  41. package/types/src/components/Toolbar/RegistryContext.d.ts +22 -13
  42. package/types/src/components/Toolbar/Toolbar.d.ts +8 -8
  43. package/types/src/components/Toolbar/ToolbarGroup.d.ts +6 -16
  44. package/types/src/components/Toolbar/ToolbarItem.d.ts +1 -1
  45. package/types/src/components/index.d.ts +2 -2
  46. package/cjs/components/Toolbar/RegistryContextBeta.js +0 -112
  47. package/esm/components/Toolbar/RegistryContextBeta.js +0 -103
  48. package/styleguide/build/bundle.f0d21187.js +0 -2
  49. package/types/src/components/Toolbar/RegistryContextBeta.d.ts +0 -25
  50. /package/styleguide/build/{bundle.f0d21187.js.LICENSE.txt → bundle.52d1d9a1.js.LICENSE.txt} +0 -0
@@ -20,7 +20,7 @@ const Badge = _ref => {
20
20
  hidden,
21
21
  ...props
22
22
  } = _ref;
23
- const isAmpty = !label;
23
+ const isEmpty = !label && label !== 0;
24
24
  if (Children.toArray(children).length && !hidden) {
25
25
  if (! /*#__PURE__*/isValidElement(label)) {
26
26
  label = /*#__PURE__*/_jsx(Label, {
@@ -31,7 +31,7 @@ const Badge = _ref => {
31
31
  if ( /*#__PURE__*/isValidElement(label)) {
32
32
  const cloneProps = {
33
33
  className: classNames(`${baseClassName}__value`, {
34
- [`${baseClassName}__value--dot`]: isAmpty
34
+ [`${baseClassName}__value--dot`]: isEmpty
35
35
  }, label.props.className)
36
36
  };
37
37
  if (intent && (label.type === Label || label.type === Icon)) {
@@ -190,20 +190,6 @@ class Carousel extends Component {
190
190
  if (prevProps.autoplay !== this.props.autoplay) {
191
191
  this.props.autoplay ? this.play() : this.stop();
192
192
  }
193
- const {
194
- width
195
- } = this.rootRef.current.getBoundingClientRect();
196
- const {
197
- slideWidths,
198
- totalWidth
199
- } = calcWidths(this.genuineRef.current);
200
- if (this.state.totalWidth !== totalWidth) {
201
- this.setState({
202
- slideWidths,
203
- totalWidth,
204
- showControls: width < totalWidth
205
- });
206
- }
207
193
  }
208
194
  componentWillUnmount() {
209
195
  this.stop();
@@ -1,7 +1,7 @@
1
1
  import _defineProperty from "@babel/runtime/helpers/defineProperty";
2
2
  // Copyright 1999-2023. Plesk International GmbH. All rights reserved.
3
3
 
4
- import { PureComponent, isValidElement, cloneElement, createContext, useContext, useCallback } from 'react';
4
+ import { PureComponent, isValidElement, cloneElement, createContext, useContext, useCallback, useMemo } from 'react';
5
5
  import PropTypes from 'prop-types';
6
6
  import { jsx as _jsx } from "react/jsx-runtime";
7
7
  const applyParams = function (message) {
@@ -71,6 +71,21 @@ export const useTranslate = namespace => {
71
71
  return typeof fallback === 'string' ? applyParams(fallback, params) : `[${key}]`;
72
72
  }, [context, namespace]);
73
73
  };
74
+ export const LocaleBetaProvider = _ref => {
75
+ let {
76
+ messages,
77
+ children
78
+ } = _ref;
79
+ const value = useMemo(() => ({
80
+ locale: {
81
+ lmsg: createTranslate(messages)
82
+ }
83
+ }), [messages]);
84
+ return /*#__PURE__*/_jsx(LocaleContext.Provider, {
85
+ value: value,
86
+ children: children
87
+ });
88
+ };
74
89
  /**
75
90
  * LocaleProvider provides a uniform localization support for built-in text of components.
76
91
  * @since 0.0.42
@@ -54,26 +54,28 @@ class SegmentedControl extends Component {
54
54
  const {
55
55
  selected
56
56
  } = this.state;
57
+ let prevSelected = selected;
57
58
  let newSelected;
58
59
  if (multiple) {
59
- newSelected = selected && Array.isArray(selected) ? selected.slice() : [];
60
- if (!selected || !(selected instanceof Array) || selected.indexOf(value) === -1) {
60
+ const isSelectedArray = Array.isArray(selected);
61
+ newSelected = isSelectedArray ? [...selected] : [];
62
+ if (!isSelectedArray || selected.indexOf(value) === -1) {
61
63
  newSelected.push(value);
62
64
  } else {
63
65
  newSelected.splice(selected.indexOf(value), 1);
64
66
  }
65
67
  newSelected.sort(alphaSort);
66
- this.setState({
67
- selected: newSelected
68
- });
69
- if (JSON.stringify(newSelected) !== JSON.stringify(selected)) {
70
- onChange?.(newSelected);
68
+ if (isSelectedArray) {
69
+ prevSelected = [...selected].sort(alphaSort);
71
70
  }
72
71
  } else {
73
72
  newSelected = value;
74
- if (JSON.stringify(newSelected) !== JSON.stringify(selected)) {
75
- onChange?.(newSelected);
76
- }
73
+ }
74
+ if (JSON.stringify(prevSelected) !== JSON.stringify(newSelected)) {
75
+ this.setState({
76
+ selected: newSelected
77
+ });
78
+ onChange?.(newSelected);
77
79
  }
78
80
  });
79
81
  _defineProperty(this, "compact", () => {
@@ -25,6 +25,7 @@ const StatusMessage = _ref => {
25
25
  ...props,
26
26
  children: [/*#__PURE__*/_jsx(Icon, {
27
27
  name: intentIconMap[intent],
28
+ intent: intent,
28
29
  className: `${baseClassName}__icon`
29
30
  }), children]
30
31
  });
@@ -98,7 +98,7 @@ const SubnavItem = _ref2 => {
98
98
  } = _ref2;
99
99
  return /*#__PURE__*/cloneElement(children, {
100
100
  className: classNames(baseClassName, active && `${baseClassName}--active`, className),
101
- tabIndex: -1,
101
+ tabIndex: 0,
102
102
  ...props
103
103
  });
104
104
  };
@@ -7,7 +7,6 @@ import { CLS_PREFIX } from '../../constants';
7
7
  import { isRtl } from '../../utils';
8
8
  import Badge from '../Badge';
9
9
  import Button from '../Button';
10
- import ButtonGroup from '../ButtonGroup';
11
10
  import DistractionFreeModeContext from '../DistractionFreeModeContext';
12
11
  import Input from '../Input';
13
12
  import Menu, { MenuItem, MenuSelectableItem } from '../Menu';
@@ -339,7 +338,7 @@ class SearchBar extends Component {
339
338
  } = this.state;
340
339
  const isCollapsed = this.isResponsive();
341
340
  const distractionFreeModeEnabled = Boolean(distractionFreeMode && distractionFreeMode.enabled);
342
- return /*#__PURE__*/_jsxs("div", {
341
+ return /*#__PURE__*/_jsx("div", {
343
342
  className: classNames(baseClassName, {
344
343
  [`${baseClassName}--focused`]: focused
345
344
  }, className),
@@ -348,16 +347,16 @@ class SearchBar extends Component {
348
347
  minWidth
349
348
  },
350
349
  ...props,
351
- children: [/*#__PURE__*/_jsx(ButtonGroup, {
350
+ children: isCollapsed && (collapsable || !distractionFreeModeEnabled) ? /*#__PURE__*/_jsx(Badge, {
351
+ intent: "info",
352
+ hidden: !value,
353
+ children: /*#__PURE__*/_jsx(Button, {
354
+ icon: "search",
355
+ onClick: this.handleExpand
356
+ })
357
+ }) : /*#__PURE__*/_jsxs("div", {
352
358
  className: `${baseClassName}__group`,
353
- children: isCollapsed && (collapsable || !distractionFreeModeEnabled) ? /*#__PURE__*/_jsx(Badge, {
354
- intent: "info",
355
- hidden: !value,
356
- children: /*#__PURE__*/_jsx(Button, {
357
- icon: "search",
358
- onClick: this.handleExpand
359
- })
360
- }) : /*#__PURE__*/_jsx(Input, {
359
+ children: [/*#__PURE__*/_jsx(Input, {
361
360
  innerRef: ref => this.search = ref,
362
361
  className: `${baseClassName}__input`,
363
362
  size: "fill",
@@ -387,8 +386,8 @@ class SearchBar extends Component {
387
386
  ghost: true
388
387
  })]
389
388
  })
390
- })
391
- }), Array.isArray(results) && this.renderResults(results), results && !Array.isArray(results) && results.type === Menu && this.renderResultsMenu(results)]
389
+ }), Array.isArray(results) && this.renderResults(results), results && !Array.isArray(results) && results.type === Menu && this.renderResultsMenu(results)]
390
+ })
392
391
  });
393
392
  }
394
393
  }
@@ -1,46 +1,103 @@
1
+ import _defineProperty from "@babel/runtime/helpers/defineProperty";
1
2
  // Copyright 1999-2023. Plesk International GmbH. All rights reserved.
2
3
 
3
- import { createContext } from 'react';
4
+ import { createContext, useContext, useState, useLayoutEffect } from 'react';
4
5
  const RegistryContext = /*#__PURE__*/createContext(undefined);
5
6
  RegistryContext.displayName = 'RegistryContext';
7
+ const useRegistryContext = () => useContext(RegistryContext);
6
8
  export default RegistryContext;
7
- export const createRegistry = () => ({
8
- stack: [],
9
+ class Registry {
10
+ constructor() {
11
+ _defineProperty(this, "items", []);
12
+ }
9
13
  register(item) {
10
- this.stack.push(item);
11
- },
14
+ this.items.push(item);
15
+ }
12
16
  unregister(item) {
13
- this.stack = this.stack.filter(i => i !== item);
14
- },
15
- uncompact() {
17
+ this.items = this.items.filter(i => i !== item);
18
+ }
19
+ compact() {
16
20
  let changed = false;
17
- this.stack.every(item => {
18
- if (item.isCompact(true)) {
19
- item.setCompact(false);
21
+ for (const item of [...this.items].reverse()) {
22
+ if (!item.isCompact) {
23
+ item.compact();
20
24
  changed = true;
21
- return false;
25
+ break;
22
26
  }
23
- return true;
24
- });
27
+ }
25
28
  return changed;
26
- },
27
- compact() {
29
+ }
30
+ expand() {
28
31
  let changed = false;
29
- [...this.stack].reverse().every(item => {
30
- if (!item.isCompact(false)) {
31
- item.setCompact(true);
32
+ for (const item of this.items) {
33
+ if (this.checkItemIsCompactOrHasCompactItems(item)) {
34
+ item.expand();
32
35
  changed = true;
33
- return false;
36
+ break;
34
37
  }
35
- return true;
36
- });
37
- return changed;
38
- },
39
- isCompact() {
40
- let one = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : false;
41
- if (one) {
42
- return this.stack.some(item => item.isCompact(one));
43
38
  }
44
- return this.stack.every(item => item.isCompact(one));
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;
45
75
  }
46
- });
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,17 +1,13 @@
1
- import _defineProperty from "@babel/runtime/helpers/defineProperty";
2
1
  // Copyright 1999-2023. Plesk International GmbH. All rights reserved.
3
2
 
4
- import { Component, useRef, useState, useMemo } from 'react';
3
+ import { useRef, useState, useMemo } from 'react';
5
4
  import classNames from 'classnames';
6
5
  import { CLS_PREFIX } from '../../constants';
7
- import RegistryContext, { createRegistry } from './RegistryContext';
8
- import RegistryContextBeta, { useRegistry } from './RegistryContextBeta';
6
+ import RegistryContext, { useRegistry } from './RegistryContext';
9
7
  import DistractionFreeModeContext from '../DistractionFreeModeContext';
10
8
  import { toToolbarItems } from './ToolbarItem';
11
- import Squeezer from '../Squeezer';
12
9
  import { useSqueeze } from '../../hooks';
13
- import { useToolbarBetaContext } from './ToolbarBetaProvider';
14
-
10
+ import { jsx as _jsx } from "react/jsx-runtime";
15
11
  /**
16
12
  * `Toolbar` component is a panel containing various instruments used for managing the contents of a large content block.
17
13
  * Toolbar is located on top of the managed content block.
@@ -19,76 +15,13 @@ import { useToolbarBetaContext } from './ToolbarBetaProvider';
19
15
  * and controls for changing the way the content block looks.
20
16
  * @since 0.0.57
21
17
  */
22
- import { jsx as _jsx } from "react/jsx-runtime";
23
- class ToolbarClassComponent extends Component {
24
- constructor(props) {
25
- super(props);
26
- _defineProperty(this, "state", {
27
- distractionFreeMode: {
28
- enabled: false,
29
- toggle: () => {
30
- this.setState(prevState => ({
31
- distractionFreeMode: {
32
- ...prevState.distractionFreeMode,
33
- enabled: !prevState.distractionFreeMode.enabled
34
- }
35
- }), () => {
36
- this.measure();
37
- });
38
- }
39
- }
40
- });
41
- _defineProperty(this, "registry", void 0);
42
- _defineProperty(this, "measure", void 0);
43
- this.registry = createRegistry();
44
- this.measure = () => {};
45
- }
46
- render() {
47
- const {
48
- baseClassName,
49
- className,
50
- children,
51
- ...props
52
- } = this.props;
53
- const toolbarItems = toToolbarItems(children);
54
- return /*#__PURE__*/_jsx(Squeezer, {
55
- compact: () => this.registry.compact(),
56
- uncompact: () => this.registry.uncompact(),
57
- innerMeasure: measure => {
58
- this.measure = measure;
59
- },
60
- children: _ref => {
61
- let {
62
- ref
63
- } = _ref;
64
- return /*#__PURE__*/_jsx("div", {
65
- ref: ref,
66
- className: classNames(baseClassName, className),
67
- ...props,
68
- children: /*#__PURE__*/_jsx(RegistryContext.Provider, {
69
- value: this.registry,
70
- children: /*#__PURE__*/_jsx(DistractionFreeModeContext.Provider, {
71
- value: this.state.distractionFreeMode,
72
- children: toolbarItems
73
- })
74
- })
75
- });
76
- }
77
- });
78
- }
79
- }
80
- _defineProperty(ToolbarClassComponent, "defaultProps", {
81
- children: null,
82
- className: null,
83
- baseClassName: `${CLS_PREFIX}toolbar`
84
- });
85
- const ToolbarBeta = _ref2 => {
18
+ const Toolbar = _ref => {
86
19
  let {
87
20
  children,
88
21
  className,
89
22
  baseClassName = `${CLS_PREFIX}toolbar`,
90
23
  ...props
91
- } = _ref2;
24
+ } = _ref;
92
25
  const containerRef = useRef(null);
93
26
  const [isDistractionFreeModeEnabled, setIsDistractionFreeModeEnabled] = useState(false);
94
27
  const distractionFreeModeContextValue = useMemo(() => ({
@@ -101,12 +34,12 @@ const ToolbarBeta = _ref2 => {
101
34
  compact: () => registry.compact(),
102
35
  expand: () => registry.expand()
103
36
  });
104
- const toolbarItems = toToolbarItems(children, true);
37
+ const toolbarItems = toToolbarItems(children);
105
38
  return /*#__PURE__*/_jsx("div", {
106
39
  ref: containerRef,
107
40
  className: classNames(baseClassName, className),
108
41
  ...props,
109
- children: /*#__PURE__*/_jsx(RegistryContextBeta.Provider, {
42
+ children: /*#__PURE__*/_jsx(RegistryContext.Provider, {
110
43
  value: registry,
111
44
  children: /*#__PURE__*/_jsx(DistractionFreeModeContext.Provider, {
112
45
  value: distractionFreeModeContextValue,
@@ -115,12 +48,4 @@ const ToolbarBeta = _ref2 => {
115
48
  })
116
49
  });
117
50
  };
118
- const Toolbar = props => {
119
- const isToolbarBeta = useToolbarBetaContext();
120
- return isToolbarBeta ? /*#__PURE__*/_jsx(ToolbarBeta, {
121
- ...props
122
- }) : /*#__PURE__*/_jsx(ToolbarClassComponent, {
123
- ...props
124
- });
125
- };
126
51
  export default Toolbar;
@@ -1,166 +1,21 @@
1
- import _defineProperty from "@babel/runtime/helpers/defineProperty";
2
1
  // Copyright 1999-2023. Plesk International GmbH. All rights reserved.
3
2
 
4
- import { Component, Children, useContext, isValidElement, useState } from 'react';
3
+ import { Children, useContext, isValidElement, useState } from 'react';
5
4
  import classNames from 'classnames';
6
5
  import { CLS_PREFIX } from '../../constants';
7
6
  import Dropdown from '../Dropdown';
8
7
  import ToolbarMenu from './ToolbarMenu';
9
- import RegistryContext, { createRegistry } from './RegistryContext';
10
- import RegistryContextBeta, { useRegistry, useRegistryItem } from './RegistryContextBeta';
8
+ import RegistryContext, { useRegistry, useRegistryItem } from './RegistryContext';
11
9
  import DistractionFreeModeContext from '../DistractionFreeModeContext';
12
10
  import { toToolbarItems } from './ToolbarItem';
13
11
  import ToolbarExpander from './ToolbarExpander';
14
- import { useToolbarBetaContext } from './ToolbarBetaProvider';
15
-
12
+ import { jsx as _jsx } from "react/jsx-runtime";
16
13
  /**
17
14
  * `ToolbarGroup` is a part of [Toolbar](#!/Toolbar) component.
18
15
  * It is used for grouping several toolbar controls together.
19
16
  * @since 0.0.57
20
17
  */
21
- import { jsx as _jsx } from "react/jsx-runtime";
22
- class ToolbarGroupClassComponent extends Component {
23
- constructor(props) {
24
- super(props);
25
- _defineProperty(this, "state", {
26
- compact: false,
27
- availableInDistractionFreeMode: false,
28
- distractionFreeMode: {
29
- enabled: false,
30
- toggle: () => {
31
- if (this.props.distractionFreeMode) {
32
- this.props.distractionFreeMode.toggle();
33
- this.setState({
34
- availableInDistractionFreeMode: !this.props.distractionFreeMode.enabled
35
- });
36
- }
37
- }
38
- }
39
- });
40
- _defineProperty(this, "registry", void 0);
41
- _defineProperty(this, "selfApi", void 0);
42
- _defineProperty(this, "childrenApi", void 0);
43
- this.registry = createRegistry();
44
- this.selfApi = {
45
- isCompact: () => this.state.compact,
46
- setCompact: compact => {
47
- this.setState({
48
- compact
49
- });
50
- }
51
- };
52
- this.childrenApi = {
53
- isCompact: one => this.registry.isCompact(one),
54
- setCompact: compact => {
55
- if (compact) {
56
- this.registry.compact();
57
- } else {
58
- this.registry.uncompact();
59
- }
60
- }
61
- };
62
- }
63
- static getDerivedStateFromProps(props, state) {
64
- if (props.distractionFreeMode) {
65
- return {
66
- distractionFreeMode: {
67
- ...state.distractionFreeMode,
68
- enabled: props.distractionFreeMode.enabled
69
- }
70
- };
71
- }
72
- return null;
73
- }
74
- componentDidMount() {
75
- const {
76
- registry
77
- } = this.props;
78
- if (registry) {
79
- registry.register(this.selfApi);
80
- registry.register(this.childrenApi);
81
- }
82
- }
83
- componentWillUnmount() {
84
- const {
85
- registry
86
- } = this.props;
87
- if (registry) {
88
- registry.unregister(this.selfApi);
89
- registry.unregister(this.childrenApi);
90
- }
91
- }
92
- render() {
93
- const {
94
- baseClassName,
95
- className,
96
- title,
97
- children: childrenProp,
98
- distractionFreeMode: distractionFreeModeProp,
99
- registry,
100
- groupable,
101
- ...props
102
- } = this.props;
103
- let {
104
- children
105
- } = this.props;
106
- const {
107
- compact,
108
- distractionFreeMode,
109
- availableInDistractionFreeMode
110
- } = this.state;
111
- let hasExpander = Children.toArray(children).some(child => /*#__PURE__*/isValidElement(child) && child.type === ToolbarExpander);
112
- if (groupable && compact && Children.count(children) > 1) {
113
- hasExpander = false;
114
- children = /*#__PURE__*/_jsx(Dropdown, {
115
- menu: /*#__PURE__*/_jsx(ToolbarMenu, {
116
- onItemClick: () => {},
117
- children: children
118
- }),
119
- children: title
120
- });
121
- } else {
122
- children = /*#__PURE__*/_jsx(RegistryContext.Provider, {
123
- value: this.registry,
124
- children: /*#__PURE__*/_jsx(DistractionFreeModeContext.Provider, {
125
- value: distractionFreeMode,
126
- children: toToolbarItems(children)
127
- })
128
- });
129
- }
130
- if (distractionFreeMode.enabled && !availableInDistractionFreeMode) {
131
- return null;
132
- }
133
- return /*#__PURE__*/_jsx("div", {
134
- className: classNames(baseClassName, className, {
135
- [`${baseClassName}--grow`]: hasExpander || distractionFreeMode.enabled && availableInDistractionFreeMode
136
- }),
137
- ...props,
138
- children: children
139
- });
140
- }
141
- }
142
- _defineProperty(ToolbarGroupClassComponent, "defaultProps", {
143
- registry: undefined,
144
- distractionFreeMode: undefined
145
- });
146
- const ToolbarGroupWrapper = _ref => {
147
- let {
148
- groupable = true,
149
- baseClassName = `${CLS_PREFIX}toolbar__group`,
150
- ...props
151
- } = _ref;
152
- const registry = useContext(RegistryContext);
153
- const distractionFreeMode = useContext(DistractionFreeModeContext);
154
- return /*#__PURE__*/_jsx(ToolbarGroupClassComponent, {
155
- groupable: groupable,
156
- baseClassName: baseClassName,
157
- ...props,
158
- registry: registry,
159
- distractionFreeMode: distractionFreeMode
160
- });
161
- };
162
- ToolbarGroupWrapper.displayName = 'ToolbarGroup';
163
- const ToolbarGroupBeta = _ref2 => {
18
+ const ToolbarGroup = _ref => {
164
19
  let {
165
20
  baseClassName = `${CLS_PREFIX}toolbar__group`,
166
21
  className,
@@ -168,7 +23,7 @@ const ToolbarGroupBeta = _ref2 => {
168
23
  children,
169
24
  groupable = true,
170
25
  ...props
171
- } = _ref2;
26
+ } = _ref;
172
27
  const [compact] = useRegistryItem();
173
28
  const registry = useRegistry();
174
29
  const [availableInDistractionFreeMode, setAvailableInDistractionFreeMode] = useState(false);
@@ -193,11 +48,11 @@ const ToolbarGroupBeta = _ref2 => {
193
48
  children: title
194
49
  });
195
50
  } else {
196
- children = /*#__PURE__*/_jsx(RegistryContextBeta.Provider, {
51
+ children = /*#__PURE__*/_jsx(RegistryContext.Provider, {
197
52
  value: registry,
198
53
  children: /*#__PURE__*/_jsx(DistractionFreeModeContext.Provider, {
199
54
  value: distractionFreeModeContextValue,
200
- children: toToolbarItems(children, true)
55
+ children: toToolbarItems(children)
201
56
  })
202
57
  });
203
58
  }
@@ -212,12 +67,4 @@ const ToolbarGroupBeta = _ref2 => {
212
67
  children: children
213
68
  });
214
69
  };
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
70
  export default ToolbarGroup;