@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.
@@ -21,25 +21,26 @@ const TabList = _ref => {
21
21
  monospacedWidth,
22
22
  baseClassName
23
23
  } = _ref;
24
- if (!Children.toArray(children).length) {
25
- return null;
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 = Children.map(listChildren, (tab, index) => {
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: () => onTabClick(position),
39
+ onClick: () => handleTabClick(tab, position),
39
40
  monospacedWidth: monospacedWidth
40
41
  }, index);
41
42
  });
42
- const menuItems = Children.map(menuChildren, (tab, index) => {
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: () => onTabClick(position),
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: Tag = 'a',
24
+ component = 'a',
25
25
  style = {},
26
26
  ...tabProps
27
27
  } = tab.props;
28
28
  const closable = typeof onClose === 'function';
29
- tabProps.tabIndex = isFake ? -1 : tabProps.tabIndex || 0;
30
- if (!isFake) {
31
- tabProps.onKeyDown = wrapFunction(tabProps.onKeyDown, e => {
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
- ...tabProps,
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.count(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: handleTabClick,
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.map(children, (tab, index) => index + 1 === active ? tab : null)
123
+ children: Children.toArray(children).map((tab, index) => index + 1 === active ? tab : null)
129
124
  })]
130
125
  });
131
126
  };
package/esm/index.js CHANGED
@@ -1,6 +1,6 @@
1
1
  // Copyright 1999-2025. WebPros International GmbH. All rights reserved.
2
2
  import svg4everybody from 'svg4everybody';
3
- const version = "3.43.0";
3
+ const version = "3.43.2";
4
4
  export * from './publicPath';
5
5
  export { version };
6
6
  export * from './utils';
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@plesk/ui-library",
3
- "version": "3.43.0",
3
+ "version": "3.43.2",
4
4
  "description": "Plesk UI Library",
5
5
  "main": "index.js",
6
6
  "module": "esm/index.js",