@plesk/ui-library 3.40.6 → 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.
- package/cjs/components/Badge/Badge.js +2 -2
- package/cjs/components/SegmentedControl/SegmentedControl.js +12 -10
- package/cjs/components/Subnav/Subnav.js +1 -1
- package/cjs/components/Toolbar/RegistryContext.js +90 -31
- package/cjs/components/Toolbar/Toolbar.js +5 -80
- package/cjs/components/Toolbar/ToolbarGroup.js +6 -159
- package/cjs/components/Toolbar/ToolbarItem.js +15 -59
- 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 +48 -379
- package/dist/plesk-ui-library.js.map +1 -1
- package/dist/plesk-ui-library.min.js +6 -6
- package/dist/plesk-ui-library.min.js.map +1 -1
- package/esm/components/Badge/Badge.js +2 -2
- package/esm/components/SegmentedControl/SegmentedControl.js +12 -10
- package/esm/components/Subnav/Subnav.js +1 -1
- package/esm/components/Toolbar/RegistryContext.js +87 -30
- package/esm/components/Toolbar/Toolbar.js +7 -82
- package/esm/components/Toolbar/ToolbarGroup.js +7 -160
- package/esm/components/Toolbar/ToolbarItem.js +15 -59
- package/esm/index.js +1 -1
- package/package.json +20 -22
- package/styleguide/build/bundle.52d1d9a1.js +2 -0
- package/styleguide/index.html +2 -2
- package/types/src/components/Toolbar/RegistryContext.d.ts +22 -13
- package/types/src/components/Toolbar/Toolbar.d.ts +8 -8
- package/types/src/components/Toolbar/ToolbarGroup.d.ts +6 -16
- package/types/src/components/Toolbar/ToolbarItem.d.ts +1 -1
- package/cjs/components/Toolbar/RegistryContextBeta.js +0 -112
- package/esm/components/Toolbar/RegistryContextBeta.js +0 -103
- package/styleguide/build/bundle.9eeb2c9d.js +0 -2
- package/types/src/components/Toolbar/RegistryContextBeta.d.ts +0 -25
- /package/styleguide/build/{bundle.9eeb2c9d.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
|
|
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`]:
|
|
34
|
+
[`${baseClassName}__value--dot`]: isEmpty
|
|
35
35
|
}, label.props.className)
|
|
36
36
|
};
|
|
37
37
|
if (intent && (label.type === Label || label.type === Icon)) {
|
|
@@ -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
|
-
|
|
60
|
-
|
|
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
|
-
|
|
67
|
-
selected
|
|
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
|
-
|
|
75
|
-
|
|
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", () => {
|
|
@@ -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
|
-
|
|
8
|
-
|
|
9
|
+
class Registry {
|
|
10
|
+
constructor() {
|
|
11
|
+
_defineProperty(this, "items", []);
|
|
12
|
+
}
|
|
9
13
|
register(item) {
|
|
10
|
-
this.
|
|
11
|
-
}
|
|
14
|
+
this.items.push(item);
|
|
15
|
+
}
|
|
12
16
|
unregister(item) {
|
|
13
|
-
this.
|
|
14
|
-
}
|
|
15
|
-
|
|
17
|
+
this.items = this.items.filter(i => i !== item);
|
|
18
|
+
}
|
|
19
|
+
compact() {
|
|
16
20
|
let changed = false;
|
|
17
|
-
this.
|
|
18
|
-
if (item.isCompact
|
|
19
|
-
item.
|
|
21
|
+
for (const item of [...this.items].reverse()) {
|
|
22
|
+
if (!item.isCompact) {
|
|
23
|
+
item.compact();
|
|
20
24
|
changed = true;
|
|
21
|
-
|
|
25
|
+
break;
|
|
22
26
|
}
|
|
23
|
-
|
|
24
|
-
});
|
|
27
|
+
}
|
|
25
28
|
return changed;
|
|
26
|
-
}
|
|
27
|
-
|
|
29
|
+
}
|
|
30
|
+
expand() {
|
|
28
31
|
let changed = false;
|
|
29
|
-
|
|
30
|
-
if (
|
|
31
|
-
item.
|
|
32
|
+
for (const item of this.items) {
|
|
33
|
+
if (this.checkItemIsCompactOrHasCompactItems(item)) {
|
|
34
|
+
item.expand();
|
|
32
35
|
changed = true;
|
|
33
|
-
|
|
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
|
|
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 {
|
|
3
|
+
import { useRef, useState, useMemo } from 'react';
|
|
5
4
|
import classNames from 'classnames';
|
|
6
5
|
import { CLS_PREFIX } from '../../constants';
|
|
7
|
-
import 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 {
|
|
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
|
-
|
|
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
|
-
} =
|
|
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
|
|
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(
|
|
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 {
|
|
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, {
|
|
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 {
|
|
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
|
-
|
|
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
|
-
} =
|
|
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(
|
|
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
|
|
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;
|
|
@@ -1,54 +1,14 @@
|
|
|
1
|
-
import _defineProperty from "@babel/runtime/helpers/defineProperty";
|
|
2
1
|
// Copyright 1999-2023. Plesk International GmbH. All rights reserved.
|
|
3
2
|
|
|
4
|
-
import {
|
|
3
|
+
import { isValidElement, Children, cloneElement } from 'react';
|
|
5
4
|
import classNames from 'classnames';
|
|
6
5
|
import { CLS_PREFIX } from '../../constants';
|
|
7
6
|
import ResponsiveContext from '../ResponsiveContext';
|
|
8
|
-
import RegistryContext from './RegistryContext';
|
|
9
7
|
import ToolbarGroup from './ToolbarGroup';
|
|
10
8
|
import ToolbarExpander from './ToolbarExpander';
|
|
11
|
-
import { useRegistryItem } from './
|
|
9
|
+
import { useRegistryItem } from './RegistryContext';
|
|
12
10
|
import { jsx as _jsx } from "react/jsx-runtime";
|
|
13
|
-
|
|
14
|
-
constructor() {
|
|
15
|
-
super(...arguments);
|
|
16
|
-
_defineProperty(this, "state", {
|
|
17
|
-
compact: false
|
|
18
|
-
});
|
|
19
|
-
_defineProperty(this, "context", void 0);
|
|
20
|
-
}
|
|
21
|
-
componentDidMount() {
|
|
22
|
-
const registry = this.context;
|
|
23
|
-
registry.register(this);
|
|
24
|
-
}
|
|
25
|
-
componentWillUnmount() {
|
|
26
|
-
const registry = this.context;
|
|
27
|
-
registry.unregister(this);
|
|
28
|
-
}
|
|
29
|
-
isCompact() {
|
|
30
|
-
return this.state.compact;
|
|
31
|
-
}
|
|
32
|
-
setCompact(compact) {
|
|
33
|
-
this.setState({
|
|
34
|
-
compact
|
|
35
|
-
});
|
|
36
|
-
}
|
|
37
|
-
render() {
|
|
38
|
-
const {
|
|
39
|
-
children
|
|
40
|
-
} = this.props;
|
|
41
|
-
const {
|
|
42
|
-
compact
|
|
43
|
-
} = this.state;
|
|
44
|
-
return /*#__PURE__*/_jsx(ResponsiveContext.Provider, {
|
|
45
|
-
value: compact,
|
|
46
|
-
children: children
|
|
47
|
-
});
|
|
48
|
-
}
|
|
49
|
-
}
|
|
50
|
-
ToolbarItem.contextType = RegistryContext;
|
|
51
|
-
const ToolbarItemBeta = _ref => {
|
|
11
|
+
const ToolbarItem = _ref => {
|
|
52
12
|
let {
|
|
53
13
|
children
|
|
54
14
|
} = _ref;
|
|
@@ -58,20 +18,16 @@ const ToolbarItemBeta = _ref => {
|
|
|
58
18
|
children: children
|
|
59
19
|
});
|
|
60
20
|
};
|
|
61
|
-
export const toToolbarItems =
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
children: /*#__PURE__*/cloneElement(child, {
|
|
73
|
-
className: classNames(child.props.className, `${CLS_PREFIX}toolbar__group-item`)
|
|
74
|
-
})
|
|
75
|
-
});
|
|
21
|
+
export const toToolbarItems = children => Children.map(children, child => {
|
|
22
|
+
if (! /*#__PURE__*/isValidElement(child)) {
|
|
23
|
+
return child;
|
|
24
|
+
}
|
|
25
|
+
if (child.type === ToolbarGroup || child.type === ToolbarExpander) {
|
|
26
|
+
return child;
|
|
27
|
+
}
|
|
28
|
+
return /*#__PURE__*/_jsx(ToolbarItem, {
|
|
29
|
+
children: /*#__PURE__*/cloneElement(child, {
|
|
30
|
+
className: classNames(child.props.className, `${CLS_PREFIX}toolbar__group-item`)
|
|
31
|
+
})
|
|
76
32
|
});
|
|
77
|
-
};
|
|
33
|
+
});
|
package/esm/index.js
CHANGED