@plesk/ui-library 3.43.0 → 3.43.2
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/Tabs/TabList.js +8 -7
- package/cjs/components/Tabs/TabListItem.js +14 -10
- package/cjs/components/Tabs/Tabs.js +3 -8
- 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 +26 -26
- package/dist/plesk-ui-library.js.map +1 -1
- package/dist/plesk-ui-library.min.js +3 -3
- package/dist/plesk-ui-library.min.js.map +1 -1
- package/esm/components/Tabs/TabList.js +8 -7
- package/esm/components/Tabs/TabListItem.js +14 -10
- package/esm/components/Tabs/Tabs.js +3 -8
- package/esm/index.js +1 -1
- package/package.json +1 -1
- package/styleguide/build/{bundle.ef040f7a.js → bundle.2360aa9e.js} +2 -2
- package/styleguide/index.html +2 -2
- package/types/components/Tabs/TabList.d.ts +1 -1
- /package/styleguide/build/{bundle.ef040f7a.js.LICENSE.txt → bundle.2360aa9e.js.LICENSE.txt} +0 -0
|
@@ -21,25 +21,26 @@ const TabList = _ref => {
|
|
|
21
21
|
monospacedWidth,
|
|
22
22
|
baseClassName
|
|
23
23
|
} = _ref;
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
24
|
+
const handleTabClick = (tab, position) => {
|
|
25
|
+
onTabClick(position);
|
|
26
|
+
tab?.props?.onActivate?.();
|
|
27
|
+
};
|
|
27
28
|
let tabs = Children.toArray(children);
|
|
28
29
|
tabs = tabs.filter(child => child?.type === Tab);
|
|
29
30
|
const listChildren = tabs.slice(0, visibleLength);
|
|
30
31
|
const menuChildren = tabs.slice(visibleLength);
|
|
31
|
-
const listItems =
|
|
32
|
+
const listItems = listChildren.map((tab, index) => {
|
|
32
33
|
const position = index + 1;
|
|
33
34
|
return /*#__PURE__*/_jsx(TabListItem, {
|
|
34
35
|
// eslint-disable-line react/no-array-index-key
|
|
35
36
|
tab: tab,
|
|
36
37
|
baseClassName: baseClassName,
|
|
37
38
|
selected: position === active,
|
|
38
|
-
onClick: () =>
|
|
39
|
+
onClick: () => handleTabClick(tab, position),
|
|
39
40
|
monospacedWidth: monospacedWidth
|
|
40
41
|
}, index);
|
|
41
42
|
});
|
|
42
|
-
const menuItems =
|
|
43
|
+
const menuItems = menuChildren.map((tab, index) => {
|
|
43
44
|
const position = listChildren.length + index + 1;
|
|
44
45
|
const {
|
|
45
46
|
title,
|
|
@@ -68,7 +69,7 @@ const TabList = _ref => {
|
|
|
68
69
|
})]
|
|
69
70
|
}),
|
|
70
71
|
active: active === position,
|
|
71
|
-
onClick: () =>
|
|
72
|
+
onClick: () => handleTabClick(tab, position),
|
|
72
73
|
className: `${baseClassName}__menu-item`,
|
|
73
74
|
component: Tag,
|
|
74
75
|
...tabProps,
|
|
@@ -21,32 +21,36 @@ const TabListItem = _ref => {
|
|
|
21
21
|
icon,
|
|
22
22
|
onActivate,
|
|
23
23
|
onClose,
|
|
24
|
-
component
|
|
24
|
+
component = 'a',
|
|
25
25
|
style = {},
|
|
26
26
|
...tabProps
|
|
27
27
|
} = tab.props;
|
|
28
28
|
const closable = typeof onClose === 'function';
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
29
|
+
const linkProps = isFake ? {
|
|
30
|
+
tabIndex: -1
|
|
31
|
+
} : {
|
|
32
|
+
tabIndex: tabProps.tabIndex || 0,
|
|
33
|
+
onClick,
|
|
34
|
+
onKeyDown: wrapFunction(tabProps.onKeyDown, e => {
|
|
32
35
|
if (e.key === 'Enter') {
|
|
33
36
|
e.currentTarget.click();
|
|
34
37
|
}
|
|
35
|
-
})
|
|
36
|
-
|
|
38
|
+
}),
|
|
39
|
+
role: 'tab',
|
|
40
|
+
'aria-selected': selected || undefined,
|
|
41
|
+
...tabProps
|
|
42
|
+
};
|
|
43
|
+
const Tag = isFake ? 'a' : component;
|
|
37
44
|
return /*#__PURE__*/_jsx("li", {
|
|
38
45
|
className: classNames(`${baseClassName}__tab`, selected && `${baseClassName}__tab--selected`, closable && `${baseClassName}__tab--closable`),
|
|
39
46
|
role: isFake ? undefined : 'presentation',
|
|
40
47
|
children: /*#__PURE__*/_jsxs(Tag, {
|
|
41
48
|
className: `${baseClassName}__link`,
|
|
42
|
-
role: isFake ? undefined : 'tab',
|
|
43
|
-
"aria-selected": selected || undefined,
|
|
44
|
-
onClick: onClick,
|
|
45
49
|
style: {
|
|
46
50
|
width: monospacedWidth || undefined,
|
|
47
51
|
...style
|
|
48
52
|
},
|
|
49
|
-
...
|
|
53
|
+
...linkProps,
|
|
50
54
|
children: [/*#__PURE__*/_jsx(TabIcon, {
|
|
51
55
|
icon: icon,
|
|
52
56
|
baseClassName: baseClassName
|
|
@@ -33,7 +33,7 @@ const Tabs = _ref => {
|
|
|
33
33
|
const tabNavRef = useRef(null);
|
|
34
34
|
const tabListRef = useRef(null);
|
|
35
35
|
const fakeAddonRef = useRef(null);
|
|
36
|
-
const childrenCount = Children.
|
|
36
|
+
const childrenCount = Children.toArray(children).length;
|
|
37
37
|
const [active, setActive] = useActive(externalActive);
|
|
38
38
|
const {
|
|
39
39
|
monospacedWidth,
|
|
@@ -48,11 +48,6 @@ const Tabs = _ref => {
|
|
|
48
48
|
baseClassName,
|
|
49
49
|
childrenCount
|
|
50
50
|
});
|
|
51
|
-
const handleTabClick = active => {
|
|
52
|
-
setActive(active);
|
|
53
|
-
const tab = Array.isArray(children) ? children[active - 1] : children;
|
|
54
|
-
tab?.props?.onActivate?.();
|
|
55
|
-
};
|
|
56
51
|
const [searching, setSearching] = useState(false);
|
|
57
52
|
if (!childrenCount) {
|
|
58
53
|
return null;
|
|
@@ -103,7 +98,7 @@ const Tabs = _ref => {
|
|
|
103
98
|
children: [/*#__PURE__*/_jsx(TabList, {
|
|
104
99
|
tabListRef: tabListRef,
|
|
105
100
|
active: active,
|
|
106
|
-
onTabClick:
|
|
101
|
+
onTabClick: setActive,
|
|
107
102
|
visibleLength: visibleLength,
|
|
108
103
|
monospacedWidth: monospacedWidth,
|
|
109
104
|
baseClassName: baseClassName,
|
|
@@ -125,7 +120,7 @@ const Tabs = _ref => {
|
|
|
125
120
|
}), /*#__PURE__*/_jsx("div", {
|
|
126
121
|
className: `${baseClassName}__tab-panel`,
|
|
127
122
|
role: "tabpanel",
|
|
128
|
-
children: Children.
|
|
123
|
+
children: Children.toArray(children).map((tab, index) => index + 1 === active ? tab : null)
|
|
129
124
|
})]
|
|
130
125
|
});
|
|
131
126
|
};
|
package/esm/index.js
CHANGED