@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.
@@ -30,25 +30,26 @@ const TabList = _ref => {
30
30
  monospacedWidth,
31
31
  baseClassName
32
32
  } = _ref;
33
- if (!_react.Children.toArray(children).length) {
34
- return null;
35
- }
33
+ const handleTabClick = (tab, position) => {
34
+ onTabClick(position);
35
+ tab?.props?.onActivate?.();
36
+ };
36
37
  let tabs = _react.Children.toArray(children);
37
38
  tabs = tabs.filter(child => child?.type === _Tab.default);
38
39
  const listChildren = tabs.slice(0, visibleLength);
39
40
  const menuChildren = tabs.slice(visibleLength);
40
- const listItems = _react.Children.map(listChildren, (tab, index) => {
41
+ const listItems = listChildren.map((tab, index) => {
41
42
  const position = index + 1;
42
43
  return /*#__PURE__*/(0, _jsxRuntime.jsx)(_TabListItem.default, {
43
44
  // eslint-disable-line react/no-array-index-key
44
45
  tab: tab,
45
46
  baseClassName: baseClassName,
46
47
  selected: position === active,
47
- onClick: () => onTabClick(position),
48
+ onClick: () => handleTabClick(tab, position),
48
49
  monospacedWidth: monospacedWidth
49
50
  }, index);
50
51
  });
51
- const menuItems = _react.Children.map(menuChildren, (tab, index) => {
52
+ const menuItems = menuChildren.map((tab, index) => {
52
53
  const position = listChildren.length + index + 1;
53
54
  const {
54
55
  title,
@@ -77,7 +78,7 @@ const TabList = _ref => {
77
78
  })]
78
79
  }),
79
80
  active: active === position,
80
- onClick: () => onTabClick(position),
81
+ onClick: () => handleTabClick(tab, position),
81
82
  className: `${baseClassName}__menu-item`,
82
83
  component: Tag,
83
84
  ...tabProps,
@@ -28,32 +28,36 @@ const TabListItem = _ref => {
28
28
  icon,
29
29
  onActivate,
30
30
  onClose,
31
- component: Tag = 'a',
31
+ component = 'a',
32
32
  style = {},
33
33
  ...tabProps
34
34
  } = tab.props;
35
35
  const closable = typeof onClose === 'function';
36
- tabProps.tabIndex = isFake ? -1 : tabProps.tabIndex || 0;
37
- if (!isFake) {
38
- tabProps.onKeyDown = (0, _utils.wrapFunction)(tabProps.onKeyDown, e => {
36
+ const linkProps = isFake ? {
37
+ tabIndex: -1
38
+ } : {
39
+ tabIndex: tabProps.tabIndex || 0,
40
+ onClick,
41
+ onKeyDown: (0, _utils.wrapFunction)(tabProps.onKeyDown, e => {
39
42
  if (e.key === 'Enter') {
40
43
  e.currentTarget.click();
41
44
  }
42
- });
43
- }
45
+ }),
46
+ role: 'tab',
47
+ 'aria-selected': selected || undefined,
48
+ ...tabProps
49
+ };
50
+ const Tag = isFake ? 'a' : component;
44
51
  return /*#__PURE__*/(0, _jsxRuntime.jsx)("li", {
45
52
  className: (0, _classnames.default)(`${baseClassName}__tab`, selected && `${baseClassName}__tab--selected`, closable && `${baseClassName}__tab--closable`),
46
53
  role: isFake ? undefined : 'presentation',
47
54
  children: /*#__PURE__*/(0, _jsxRuntime.jsxs)(Tag, {
48
55
  className: `${baseClassName}__link`,
49
- role: isFake ? undefined : 'tab',
50
- "aria-selected": selected || undefined,
51
- onClick: onClick,
52
56
  style: {
53
57
  width: monospacedWidth || undefined,
54
58
  ...style
55
59
  },
56
- ...tabProps,
60
+ ...linkProps,
57
61
  children: [/*#__PURE__*/(0, _jsxRuntime.jsx)(_TabIcon.default, {
58
62
  icon: icon,
59
63
  baseClassName: baseClassName
@@ -40,7 +40,7 @@ const Tabs = _ref => {
40
40
  const tabNavRef = (0, _react.useRef)(null);
41
41
  const tabListRef = (0, _react.useRef)(null);
42
42
  const fakeAddonRef = (0, _react.useRef)(null);
43
- const childrenCount = _react.Children.count(children);
43
+ const childrenCount = _react.Children.toArray(children).length;
44
44
  const [active, setActive] = (0, _useActive.useActive)(externalActive);
45
45
  const {
46
46
  monospacedWidth,
@@ -55,11 +55,6 @@ const Tabs = _ref => {
55
55
  baseClassName,
56
56
  childrenCount
57
57
  });
58
- const handleTabClick = active => {
59
- setActive(active);
60
- const tab = Array.isArray(children) ? children[active - 1] : children;
61
- tab?.props?.onActivate?.();
62
- };
63
58
  const [searching, setSearching] = (0, _react.useState)(false);
64
59
  if (!childrenCount) {
65
60
  return null;
@@ -110,7 +105,7 @@ const Tabs = _ref => {
110
105
  children: [/*#__PURE__*/(0, _jsxRuntime.jsx)(_TabList.default, {
111
106
  tabListRef: tabListRef,
112
107
  active: active,
113
- onTabClick: handleTabClick,
108
+ onTabClick: setActive,
114
109
  visibleLength: visibleLength,
115
110
  monospacedWidth: monospacedWidth,
116
111
  baseClassName: baseClassName,
@@ -132,7 +127,7 @@ const Tabs = _ref => {
132
127
  }), /*#__PURE__*/(0, _jsxRuntime.jsx)("div", {
133
128
  className: `${baseClassName}__tab-panel`,
134
129
  role: "tabpanel",
135
- children: _react.Children.map(children, (tab, index) => index + 1 === active ? tab : null)
130
+ children: _react.Children.toArray(children).map((tab, index) => index + 1 === active ? tab : null)
136
131
  })]
137
132
  });
138
133
  };
package/cjs/index.js CHANGED
@@ -46,5 +46,5 @@ Object.keys(_components).forEach(function (key) {
46
46
  });
47
47
  });
48
48
  // Copyright 1999-2025. WebPros International GmbH. All rights reserved.
49
- const version = exports.version = "3.43.0";
49
+ const version = exports.version = "3.43.2";
50
50
  (0, _svg4everybody.default)();