@synerise/ds-tabs 0.14.2 → 0.14.4

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/CHANGELOG.md CHANGED
@@ -3,6 +3,25 @@
3
3
  All notable changes to this project will be documented in this file.
4
4
  See [Conventional Commits](https://conventionalcommits.org) for commit guidelines.
5
5
 
6
+ ## [0.14.4](https://github.com/synerise/synerise-design/compare/@synerise/ds-tabs@0.14.3...@synerise/ds-tabs@0.14.4) (2024-06-05)
7
+
8
+
9
+ ### Bug Fixes
10
+
11
+ * **tabs:** fixed displaying configuration ([7ac150a](https://github.com/synerise/synerise-design/commit/7ac150a157cf0fd24ee2fc34c186612c121414a5))
12
+
13
+
14
+
15
+
16
+
17
+ ## [0.14.3](https://github.com/synerise/synerise-design/compare/@synerise/ds-tabs@0.14.2...@synerise/ds-tabs@0.14.3) (2024-05-29)
18
+
19
+ **Note:** Version bump only for package @synerise/ds-tabs
20
+
21
+
22
+
23
+
24
+
6
25
  ## [0.14.2](https://github.com/synerise/synerise-design/compare/@synerise/ds-tabs@0.14.1...@synerise/ds-tabs@0.14.2) (2024-05-23)
7
26
 
8
27
  **Note:** Version bump only for package @synerise/ds-tabs
package/dist/Tab/Tab.d.ts CHANGED
@@ -1,6 +1,7 @@
1
+ import React from 'react';
1
2
  import { TabProps } from './Tab.types';
2
3
  declare const Tab: {
3
- ({ index, label, icon, isActive, disabled, onClick, forwardedRef, underscore, className, block, suffixel, }: TabProps): JSX.Element;
4
+ ({ index, label, icon, isActive, disabled, onClick, forwardedRef, underscore, className, block, suffixel, }: TabProps): React.JSX.Element;
4
5
  defaultProps: {
5
6
  underscore: boolean;
6
7
  };
package/dist/Tabs.d.ts CHANGED
@@ -1,6 +1,7 @@
1
+ import React from 'react';
1
2
  import { TabsProps } from './Tabs.types';
2
3
  declare const Tabs: {
3
- ({ activeTab, tabs, handleTabClick, configuration, underscore, block }: TabsProps): JSX.Element;
4
+ ({ activeTab, tabs, handleTabClick, configuration, underscore, block }: TabsProps): React.JSX.Element;
4
5
  defaultProps: {
5
6
  underscore: boolean;
6
7
  };
package/dist/Tabs.js CHANGED
@@ -6,6 +6,7 @@ function _defineProperty(obj, key, value) { if (key in obj) { Object.definePrope
6
6
 
7
7
  import React, { useCallback, createRef, useMemo, useState, useRef, useEffect } from 'react';
8
8
  import { debounce } from 'lodash';
9
+ import { theme } from '@synerise/ds-core';
9
10
  import Dropdown from '@synerise/ds-dropdown';
10
11
  import Icon, { OptionHorizontalM } from '@synerise/ds-icon';
11
12
  import { useResizeObserver, NOOP } from '@synerise/ds-utils';
@@ -13,6 +14,10 @@ import * as S from './Tabs.styles';
13
14
  import Tab from './Tab/Tab';
14
15
  var MARGIN_BETWEEN_TABS = 24;
15
16
  var DROPDOWN_TRIGGER_SIZE = 32;
17
+ var DROPDOWN_OVERLAY_STYLE = {
18
+ boxShadow: '0 4px 12px 0 rgba(35, 41, 54, 0.07)',
19
+ zIndex: parseInt(theme.variables['zindex-modal'], 10) - 1
20
+ };
16
21
 
17
22
  var Tabs = function Tabs(_ref) {
18
23
  var activeTab = _ref.activeTab,
@@ -47,9 +52,13 @@ var Tabs = function Tabs(_ref) {
47
52
  visibleTabs = _useState4[0],
48
53
  setVisibleTabs = _useState4[1];
49
54
 
50
- var _useState5 = useState([]),
51
- hiddenTabs = _useState5[0],
52
- setHiddenTabs = _useState5[1];
55
+ var _useState5 = useState(false),
56
+ isDropdownVisible = _useState5[0],
57
+ setIsDropdownVisible = _useState5[1];
58
+
59
+ var _useState6 = useState([]),
60
+ hiddenTabs = _useState6[0],
61
+ setHiddenTabs = _useState6[1];
53
62
 
54
63
  var debouncedEventHandler = useMemo(function () {
55
64
  return debounce(function (newWidth) {
@@ -109,7 +118,12 @@ var Tabs = function Tabs(_ref) {
109
118
  }, [block, itemsWidths, containerWidth]);
110
119
  var handleConfigurationAction = useCallback(function () {
111
120
  configuration && configuration.action();
121
+ setIsDropdownVisible(false);
112
122
  }, [configuration]);
123
+ var handleHiddenTabClick = useCallback(function (index) {
124
+ setIsDropdownVisible(false);
125
+ handleTabClick(index);
126
+ }, [handleTabClick]);
113
127
  var renderHiddenTabs = useMemo(function () {
114
128
  return /*#__PURE__*/React.createElement(S.TabsDropdownContainer, {
115
129
  "data-testid": "tabs-dropdown-container"
@@ -118,7 +132,7 @@ var Tabs = function Tabs(_ref) {
118
132
  // eslint-disable-next-line react/no-array-index-key
119
133
  key: item.label + "-dropdown-" + index,
120
134
  onClick: function onClick() {
121
- return handleTabClick(visibleTabs.length + index);
135
+ return handleHiddenTabClick(visibleTabs.length + index);
122
136
  },
123
137
  disabled: item.disabled
124
138
  }, item.label);
@@ -127,21 +141,22 @@ var Tabs = function Tabs(_ref) {
127
141
  onClick: handleConfigurationAction,
128
142
  disabled: !!(configuration != null && configuration.disabled)
129
143
  }, configuration.label)));
130
- }, [hiddenTabs, configuration, handleConfigurationAction, handleTabClick, visibleTabs.length]);
144
+ }, [hiddenTabs, configuration, handleConfigurationAction, handleHiddenTabClick, visibleTabs.length]);
131
145
 
132
146
  var renderDropdown = function renderDropdown() {
133
147
  return /*#__PURE__*/React.createElement(React.Fragment, null, (hiddenTabs.length || configuration) && /*#__PURE__*/React.createElement(Dropdown, {
134
148
  trigger: ['click'],
135
149
  "data-testid": "tabs-dropdown",
150
+ visible: isDropdownVisible,
151
+ onVisibleChange: setIsDropdownVisible,
136
152
  overlay: renderHiddenTabs,
137
- disabled: !!(configuration != null && configuration.disabled),
138
- overlayStyle: {
139
- boxShadow: '0 4px 12px 0 rgba(35, 41, 54, 0.07)'
140
- }
153
+ disabled: !!(configuration != null && configuration.disabled) && !hiddenTabs.length,
154
+ overlayStyle: DROPDOWN_OVERLAY_STYLE
141
155
  }, /*#__PURE__*/React.createElement(S.ShowHiddenTabsTrigger, {
156
+ "data-testid": "tabs-dropdown-trigger",
142
157
  type: "ghost",
143
158
  mode: "single-icon",
144
- disabled: !!(configuration != null && configuration.disabled)
159
+ disabled: !!(configuration != null && configuration.disabled) && !hiddenTabs.length
145
160
  }, /*#__PURE__*/React.createElement(Icon, {
146
161
  component: /*#__PURE__*/React.createElement(OptionHorizontalM, null)
147
162
  }))));
@@ -187,11 +202,12 @@ var Tabs = function Tabs(_ref) {
187
202
  });
188
203
  }));
189
204
  }, [items, underscore, block]);
190
- return /*#__PURE__*/React.createElement(React.Fragment, null, tabs.length > 0 ? /*#__PURE__*/React.createElement(S.TabsContainer, {
205
+ return /*#__PURE__*/React.createElement(React.Fragment, null, tabs.length > 0 || configuration ? /*#__PURE__*/React.createElement(S.TabsContainer, {
191
206
  className: "ds-tabs",
192
207
  ref: containerRef,
193
208
  "data-testid": "tabs-container",
194
- block: block
209
+ block: block,
210
+ "data-popup-container": true
195
211
  }, renderVisibleTabs, renderDropdown()) : null, !block && renderHelpers);
196
212
  };
197
213
 
package/dist/index.d.ts CHANGED
@@ -1,2 +1,2 @@
1
1
  export { default } from './Tabs';
2
- export type { TabItem } from './Tabs.types';
2
+ export type { TabItem, Configuration as TabsConfiguration, TabsProps } from './Tabs.types';
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@synerise/ds-tabs",
3
- "version": "0.14.2",
3
+ "version": "0.14.4",
4
4
  "description": "Tabs UI Component for the Synerise Design System",
5
5
  "license": "ISC",
6
6
  "repository": "synerise/synerise-design",
@@ -33,13 +33,14 @@
33
33
  ],
34
34
  "types": "dist/index.d.ts",
35
35
  "dependencies": {
36
- "@synerise/ds-button": "^0.20.0",
37
- "@synerise/ds-dropdown": "^0.17.111",
38
- "@synerise/ds-icon": "^0.61.0",
39
- "@synerise/ds-menu": "^0.18.23",
36
+ "@synerise/ds-button": "^0.20.1",
37
+ "@synerise/ds-dropdown": "^0.18.0",
38
+ "@synerise/ds-icon": "^0.62.0",
39
+ "@synerise/ds-menu": "^0.19.1",
40
40
  "@synerise/ds-typography": "^0.15.0",
41
- "@synerise/ds-utils": "^0.26.6",
42
- "classnames": "2.3.2"
41
+ "@synerise/ds-utils": "^0.27.0",
42
+ "classnames": "2.3.2",
43
+ "lodash": "4.17.15"
43
44
  },
44
45
  "peerDependencies": {
45
46
  "@synerise/ds-core": "*",
@@ -48,7 +49,8 @@
48
49
  "styled-components": "5.0.1"
49
50
  },
50
51
  "devDependencies": {
51
- "@testing-library/jest-dom": "5.1.1"
52
+ "@testing-library/jest-dom": "5.1.1",
53
+ "@testing-library/react": "10.0.1"
52
54
  },
53
- "gitHead": "357031f4340eb9a2835f7b0cabffb5b1ad231db8"
55
+ "gitHead": "81acd8bf6b5fb04a22647e43d2c9289dcceb61a2"
54
56
  }