@plesk/ui-library 3.42.0 → 3.43.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.
- package/cjs/components/CodeEditor/CodeEditor.js +1 -2
- package/cjs/components/Icon/constants.js +0 -1
- package/cjs/components/List/List.js +6 -3
- package/cjs/components/Tabs/FakeTabs.js +58 -0
- package/cjs/components/Tabs/Tab.js +0 -1
- package/cjs/components/Tabs/TabClose.js +35 -0
- package/cjs/components/Tabs/TabIcon.js +22 -0
- package/cjs/components/Tabs/TabLabel.js +34 -0
- package/cjs/components/Tabs/TabList.js +120 -0
- package/cjs/components/Tabs/TabListItem.js +75 -0
- package/cjs/components/Tabs/Tabs.js +98 -537
- package/cjs/components/Tabs/useActive.js +19 -0
- package/cjs/components/Tabs/useWidths.js +102 -0
- package/cjs/components/Toaster/PanelView.js +15 -13
- package/cjs/components/Toolbar/ToolbarMenu.js +0 -1
- package/cjs/components/Toolbar/index.js +1 -8
- package/cjs/components/index.js +0 -7
- 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 +668 -608
- package/dist/plesk-ui-library.js.map +1 -1
- package/dist/plesk-ui-library.min.js +5 -5
- package/dist/plesk-ui-library.min.js.map +1 -1
- package/esm/components/CodeEditor/CodeEditor.js +1 -2
- package/esm/components/Icon/constants.js +0 -1
- package/esm/components/List/List.js +6 -3
- package/esm/components/Tabs/FakeTabs.js +51 -0
- package/esm/components/Tabs/Tab.js +0 -1
- package/esm/components/Tabs/TabClose.js +28 -0
- package/esm/components/Tabs/TabIcon.js +14 -0
- package/esm/components/Tabs/TabLabel.js +27 -0
- package/esm/components/Tabs/TabList.js +111 -0
- package/esm/components/Tabs/TabListItem.js +68 -0
- package/esm/components/Tabs/Tabs.js +100 -537
- package/esm/components/Tabs/useActive.js +12 -0
- package/esm/components/Tabs/useWidths.js +95 -0
- package/esm/components/Toaster/PanelView.js +15 -13
- package/esm/components/Toolbar/ToolbarMenu.js +0 -1
- package/esm/components/Toolbar/index.js +1 -2
- package/esm/components/index.js +1 -1
- package/esm/index.js +1 -1
- package/package.json +9 -10
- package/styleguide/build/bundle.ef040f7a.js +2 -0
- package/styleguide/index.html +2 -2
- package/types/components/Carousel/Carousel.d.ts +1 -1
- package/types/components/Label/Label.d.ts +1 -1
- package/types/components/List/List.d.ts +8 -2
- package/types/components/Tabs/FakeTabs.d.ts +9 -0
- package/types/components/Tabs/SearchBar.d.ts +3 -3
- package/types/components/Tabs/TabClose.d.ts +9 -0
- package/types/components/Tabs/TabIcon.d.ts +7 -0
- package/types/components/Tabs/TabLabel.d.ts +9 -0
- package/types/components/Tabs/TabList.d.ts +14 -0
- package/types/components/Tabs/TabListItem.d.ts +12 -0
- package/types/components/Tabs/Tabs.d.ts +2 -52
- package/types/components/Tabs/useActive.d.ts +1 -0
- package/types/components/Tabs/useWidths.d.ts +16 -0
- package/types/components/Toolbar/index.d.ts +0 -1
- package/types/components/index.d.ts +1 -1
- package/types/utils/types/ComponentProps.d.ts +1 -1
- package/types/utils/types/PolymorphicComponent.d.ts +2 -2
- package/cjs/components/Toolbar/ToolbarBetaProvider.js +0 -23
- package/esm/components/Toolbar/ToolbarBetaProvider.js +0 -16
- package/styleguide/build/bundle.7ac8a2af.js +0 -2
- package/types/components/Toolbar/ToolbarBetaProvider.d.ts +0 -5
- /package/styleguide/build/{bundle.7ac8a2af.js.LICENSE.txt → bundle.ef040f7a.js.LICENSE.txt} +0 -0
|
@@ -0,0 +1,95 @@
|
|
|
1
|
+
// Copyright 1999-2025. WebPros International GmbH. All rights reserved.
|
|
2
|
+
|
|
3
|
+
import { useState, useRef, useLayoutEffect, useCallback } from 'react';
|
|
4
|
+
import { useResizeObserver } from '../../hooks';
|
|
5
|
+
export const useWidths = _ref => {
|
|
6
|
+
let {
|
|
7
|
+
tabNavRef,
|
|
8
|
+
tabListRef,
|
|
9
|
+
fakeAddonRef,
|
|
10
|
+
baseClassName,
|
|
11
|
+
monospaced = false,
|
|
12
|
+
childrenCount
|
|
13
|
+
} = _ref;
|
|
14
|
+
const [compact, setCompact] = useState(false);
|
|
15
|
+
const [monospacedWidth, setMonospacedWidth] = useState(undefined);
|
|
16
|
+
const [visibleLength, setVisibleLength] = useState(childrenCount);
|
|
17
|
+
const lastCollapsedKey = useRef('');
|
|
18
|
+
const recalculateWidths = useCallback(() => {
|
|
19
|
+
if (!tabNavRef.current || !tabListRef.current) {
|
|
20
|
+
return;
|
|
21
|
+
}
|
|
22
|
+
const fakeTabElements = tabNavRef.current.querySelectorAll(`.${baseClassName}__tab-list--fake .${baseClassName}__tab`);
|
|
23
|
+
const moreElement = fakeTabElements[fakeTabElements.length - 1];
|
|
24
|
+
const tabLength = fakeTabElements.length - 1;
|
|
25
|
+
const fakeTabWidths = Array.from(fakeTabElements).slice(0, -1).map(el => el.getBoundingClientRect().width);
|
|
26
|
+
let tabWidths = fakeTabWidths;
|
|
27
|
+
let monospacedWidth = undefined;
|
|
28
|
+
if (monospaced) {
|
|
29
|
+
const linkElements = tabNavRef.current.querySelectorAll(`.${baseClassName}__tab-list--fake .${baseClassName}__link`);
|
|
30
|
+
const linkWidths = Array.from(linkElements).slice(0, -1).map(el => el.getBoundingClientRect().width);
|
|
31
|
+
monospacedWidth = linkWidths.length ? Math.max(...linkWidths) : undefined;
|
|
32
|
+
tabWidths = fakeTabWidths.map((width, index) => (monospacedWidth ?? 0) + width - linkWidths[index]);
|
|
33
|
+
}
|
|
34
|
+
setMonospacedWidth(monospacedWidth);
|
|
35
|
+
const tabsWidth = tabWidths.reduce((acc, width) => acc + width, 0);
|
|
36
|
+
const tabNavWidth = tabNavRef.current.getBoundingClientRect().width;
|
|
37
|
+
const addon = tabNavRef.current.querySelector(`.${baseClassName}__addon`) ?? tabNavRef.current.querySelector(`.${baseClassName}__search`);
|
|
38
|
+
const addonWidth = addon ? addon.getBoundingClientRect().width : 0;
|
|
39
|
+
let availableSpace = tabNavWidth - addonWidth;
|
|
40
|
+
const allTabsFit = availableSpace >= tabsWidth;
|
|
41
|
+
const getContentKey = () => {
|
|
42
|
+
const fakeAddonWidth = fakeAddonRef.current?.getBoundingClientRect().width ?? 0;
|
|
43
|
+
return `${fakeTabWidths.join('-')}-${tabNavWidth}-${fakeAddonWidth}-${monospacedWidth}`;
|
|
44
|
+
};
|
|
45
|
+
if (allTabsFit) {
|
|
46
|
+
setVisibleLength(tabLength);
|
|
47
|
+
if (!compact) {
|
|
48
|
+
return;
|
|
49
|
+
}
|
|
50
|
+
if (lastCollapsedKey.current !== getContentKey()) {
|
|
51
|
+
setCompact(false);
|
|
52
|
+
}
|
|
53
|
+
return;
|
|
54
|
+
}
|
|
55
|
+
if (!allTabsFit && !compact) {
|
|
56
|
+
setCompact(true);
|
|
57
|
+
lastCollapsedKey.current = getContentKey();
|
|
58
|
+
return;
|
|
59
|
+
}
|
|
60
|
+
const moreWidth = moreElement ? moreElement.getBoundingClientRect().width : 0;
|
|
61
|
+
availableSpace -= moreWidth;
|
|
62
|
+
const calculateVisibleLength = () => {
|
|
63
|
+
let totalWidth = 0;
|
|
64
|
+
for (let i = 0; i < tabWidths.length; i++) {
|
|
65
|
+
totalWidth += tabWidths[i];
|
|
66
|
+
if (totalWidth > availableSpace) {
|
|
67
|
+
return i;
|
|
68
|
+
}
|
|
69
|
+
}
|
|
70
|
+
return 0;
|
|
71
|
+
};
|
|
72
|
+
setVisibleLength(calculateVisibleLength());
|
|
73
|
+
}, [tabNavRef, tabListRef, fakeAddonRef, baseClassName, monospaced, compact]);
|
|
74
|
+
useLayoutEffect(() => {
|
|
75
|
+
recalculateWidths();
|
|
76
|
+
}, [recalculateWidths]);
|
|
77
|
+
useResizeObserver({
|
|
78
|
+
ref: tabNavRef,
|
|
79
|
+
onResize: recalculateWidths
|
|
80
|
+
});
|
|
81
|
+
useResizeObserver({
|
|
82
|
+
ref: tabListRef,
|
|
83
|
+
onResize: recalculateWidths
|
|
84
|
+
});
|
|
85
|
+
useResizeObserver({
|
|
86
|
+
ref: fakeAddonRef,
|
|
87
|
+
onResize: recalculateWidths
|
|
88
|
+
});
|
|
89
|
+
return {
|
|
90
|
+
recalculateWidths,
|
|
91
|
+
monospacedWidth,
|
|
92
|
+
compact,
|
|
93
|
+
visibleLength
|
|
94
|
+
};
|
|
95
|
+
};
|
|
@@ -52,6 +52,20 @@ const PanelView = _ref => {
|
|
|
52
52
|
if (isEmpty && isCollapsed) {
|
|
53
53
|
onCollapseStateChange?.(false);
|
|
54
54
|
}
|
|
55
|
+
const panelHeaderLabels = /*#__PURE__*/_jsx("div", {
|
|
56
|
+
className: `${baseClassName}__header-labels`,
|
|
57
|
+
children: notEmptyGroups.map(group => /*#__PURE__*/_jsx(GroupLabel, {
|
|
58
|
+
group: group,
|
|
59
|
+
onClose: () => onToastGroupClose?.(group.keys)
|
|
60
|
+
}, group.groupKey))
|
|
61
|
+
});
|
|
62
|
+
const panelHeaderCollapseButton = /*#__PURE__*/_jsx(Button, {
|
|
63
|
+
ghost: true,
|
|
64
|
+
icon: isCollapsed ? 'chevron-up' : 'chevron-down',
|
|
65
|
+
onClick: () => onCollapseStateChange?.(!isCollapsed),
|
|
66
|
+
className: `${baseClassName}__header-collapse`,
|
|
67
|
+
"aria-label": "Collapse"
|
|
68
|
+
});
|
|
55
69
|
const panelHeader = /*#__PURE__*/_jsx(CSSTransition, {
|
|
56
70
|
nodeRef: headerRef,
|
|
57
71
|
in: isHeaderVisible,
|
|
@@ -68,19 +82,7 @@ const PanelView = _ref => {
|
|
|
68
82
|
'--_pul-toaster--panel-header-enter-delay': isSingleNonClosableToast ? '300ms' : 0,
|
|
69
83
|
'--_pul-toaster--panel-header-exit-delay': isEmpty ? '300ms' : undefined
|
|
70
84
|
},
|
|
71
|
-
children: [
|
|
72
|
-
className: `${baseClassName}__header-labels`,
|
|
73
|
-
children: notEmptyGroups.map(group => /*#__PURE__*/_jsx(GroupLabel, {
|
|
74
|
-
group: group,
|
|
75
|
-
onClose: () => onToastGroupClose?.(group.keys)
|
|
76
|
-
}, group.groupKey))
|
|
77
|
-
}), /*#__PURE__*/_jsx(Button, {
|
|
78
|
-
ghost: true,
|
|
79
|
-
icon: isCollapsed ? 'chevron-up' : 'chevron-down',
|
|
80
|
-
onClick: () => onCollapseStateChange?.(!isCollapsed),
|
|
81
|
-
className: `${baseClassName}__header-collapse`,
|
|
82
|
-
"aria-label": "Collapse"
|
|
83
|
-
})]
|
|
85
|
+
children: [panelHeaderLabels, panelHeaderCollapseButton]
|
|
84
86
|
})
|
|
85
87
|
});
|
|
86
88
|
const panelContent = /*#__PURE__*/_jsx("div", {
|
|
@@ -2,5 +2,4 @@
|
|
|
2
2
|
|
|
3
3
|
export { default } from './Toolbar';
|
|
4
4
|
export { default as ToolbarGroup } from './ToolbarGroup';
|
|
5
|
-
export { default as ToolbarExpander } from './ToolbarExpander';
|
|
6
|
-
export { default as ToolbarBetaProvider } from './ToolbarBetaProvider';
|
|
5
|
+
export { default as ToolbarExpander } from './ToolbarExpander';
|
package/esm/components/index.js
CHANGED
|
@@ -85,7 +85,7 @@ export { default as SwitchesPanelItem } from './SwitchesPanelItem';
|
|
|
85
85
|
export { default as Tabs, Tab, SearchBar } from './Tabs';
|
|
86
86
|
export { default as Text } from './Text';
|
|
87
87
|
export { default as Toaster } from './Toaster';
|
|
88
|
-
export { default as Toolbar, ToolbarGroup, ToolbarExpander
|
|
88
|
+
export { default as Toolbar, ToolbarGroup, ToolbarExpander } from './Toolbar';
|
|
89
89
|
export { default as Tooltip } from './Tooltip';
|
|
90
90
|
export { default as Tour } from './Tour';
|
|
91
91
|
export { default as Translate } from './Translate';
|
package/esm/index.js
CHANGED
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@plesk/ui-library",
|
|
3
|
-
"version": "3.
|
|
3
|
+
"version": "3.43.0",
|
|
4
4
|
"description": "Plesk UI Library",
|
|
5
5
|
"main": "index.js",
|
|
6
6
|
"module": "esm/index.js",
|
|
@@ -24,7 +24,7 @@
|
|
|
24
24
|
"lint": "yarn lint:es && yarn lint:types && yarn lint:style && yarn format:check",
|
|
25
25
|
"lint:es": "eslint --ext js,md,tsx src configs scripts styleguidist",
|
|
26
26
|
"lint:types": "tsc",
|
|
27
|
-
"lint:style": "stylelint \"{src,styleguidist}/**/*.less\"",
|
|
27
|
+
"lint:style": "stylelint \"{src,styleguidist}/**/*.(less|css)\"",
|
|
28
28
|
"format:check": "prettier --check src styleguidist",
|
|
29
29
|
"format": "prettier --write src styleguidist",
|
|
30
30
|
"styleguide": "styleguidist server --config ./configs/styleguide.config.js",
|
|
@@ -68,8 +68,8 @@
|
|
|
68
68
|
"@babel/preset-typescript": "^7.24.7",
|
|
69
69
|
"@babel/types": "^7.25.6",
|
|
70
70
|
"@csstools/postcss-logical-float-and-clear": "^3.0.0",
|
|
71
|
-
"@plesk/eslint-config": "^
|
|
72
|
-
"@plesk/stylelint-config": "^3.0.
|
|
71
|
+
"@plesk/eslint-config": "^4.0.0",
|
|
72
|
+
"@plesk/stylelint-config": "^3.0.1",
|
|
73
73
|
"@testing-library/dom": "^10.4.0",
|
|
74
74
|
"@testing-library/jest-dom": "^6.5.0",
|
|
75
75
|
"@testing-library/react": "^16.1.0",
|
|
@@ -88,16 +88,14 @@
|
|
|
88
88
|
"@types/react-transition-group": "^4.4.11",
|
|
89
89
|
"@types/svg4everybody": "2.1.5",
|
|
90
90
|
"@types/webpack-env": "^1.18.5",
|
|
91
|
-
"@typescript-eslint/eslint-plugin": "^8.17.0",
|
|
92
|
-
"@typescript-eslint/parser": "^8.17.0",
|
|
93
91
|
"autoprefixer": "^10.4.20",
|
|
94
|
-
"babel-loader": "^
|
|
92
|
+
"babel-loader": "^10.0.0",
|
|
95
93
|
"babel-plugin-transform-require-ignore": "^0.1.1",
|
|
96
94
|
"cross-env": "^7.0.3",
|
|
97
95
|
"css-loader": "^7.1.2",
|
|
98
96
|
"css-minimizer-webpack-plugin": "^7.0.0",
|
|
99
|
-
"eslint": "^
|
|
100
|
-
"eslint-config-prettier": "^10.0.
|
|
97
|
+
"eslint": "^9.21.0",
|
|
98
|
+
"eslint-config-prettier": "^10.0.2",
|
|
101
99
|
"eslint-plugin-markdown": "^5.1.0",
|
|
102
100
|
"html-webpack-plugin": "^5.6.0",
|
|
103
101
|
"jest": "^29.7.0",
|
|
@@ -127,7 +125,8 @@
|
|
|
127
125
|
"stylelint-use-logical-spec": "^5.0.1",
|
|
128
126
|
"svg-mixer": "^2.3.14",
|
|
129
127
|
"terser-webpack-plugin": "^5.3.10",
|
|
130
|
-
"typescript": "5.
|
|
128
|
+
"typescript": "5.8.2",
|
|
129
|
+
"typescript-eslint": "^8.26.0",
|
|
131
130
|
"webpack": "^5.94.0",
|
|
132
131
|
"webpack-cli": "^6.0.1"
|
|
133
132
|
},
|