@bydata/react-supertabs 1.1.8 → 1.2.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.
@@ -13,7 +13,7 @@ var NotAvailable = function NotAvailable(_ref) {
13
13
  var title = _ref.title,
14
14
  description = _ref.description,
15
15
  _ref$subTabName = _ref.subTabName,
16
- subTabName = _ref$subTabName === void 0 ? 'Page' : _ref$subTabName;
16
+ subTabName = _ref$subTabName === void 0 ? "Page" : _ref$subTabName;
17
17
  var _useTabContext = (0, _TabContext.useTabContext)(),
18
18
  activeSubTab = _useTabContext.activeSubTab;
19
19
  var heading = title !== null && title !== void 0 ? title : (0, _Utils.getTitle)(activeSubTab);
@@ -24,7 +24,7 @@ var NotAvailable = function NotAvailable(_ref) {
24
24
  className: "not-available-content"
25
25
  }, /*#__PURE__*/_react["default"].createElement("h3", {
26
26
  className: "title"
27
- }, heading.replace('Loading...', 'Untitled')), /*#__PURE__*/_react["default"].createElement("p", {
27
+ }, heading.replace("Loading...", "Untitled")), /*#__PURE__*/_react["default"].createElement("p", {
28
28
  className: "description"
29
29
  }, subHeading)));
30
30
  };
package/dist/Readme.md CHANGED
@@ -1,258 +1,320 @@
1
-
2
1
  # SuperTabs
3
2
 
4
- **SuperTabs** is a powerful and user-friendly tab management component. It enables seamless navigation by opening modules as tabs, with support for sub-tabs, smooth transitions. An experimental _keep-alive_ feature ensures components stay active across tab switches for enhanced usability.
5
-
6
- ### SuperTabs Features
7
- ------
8
- - **Tab-based Navigation**: Open modules as tabs for an intuitive and efficient navigation experience.
9
- - **Sub-Tabs Support**: Create nested sub-tabs within a main tab for hierarchical organization.
10
- - **Smooth Transitions**: Enjoy a polished user experience with fluid tab-switching animations.
11
- - **Keep-Alive (Experimental)**: Maintain the state of components across tab switches for seamless interaction (experimental feature).
12
-
13
- ### Installation and usage
14
- ------
15
-
16
- #### Basic
17
-
18
- >**Import TabProvider and wrap it around the main wrapper**
19
-
20
- - This is needed to access useTabContext.
21
- - Make sure to pass `SITE_PREFIX` and `SITE_PAGES` (From Navigation.js)
22
- - `homeUrl` is optional and defaults to "/"
23
- - `persistTabsAfterLogin` is optional and defaults to "false"
24
- - Used to preserve tab state upon login.
25
- - `entityIdentifierKey` is optional and defaults to 'organization_id',
26
- - Used to identify the organization / client id
27
- - `preventHomeRedirect` is optional and defaults to false,
28
- - This will open a menu on click of home button instead of redirecting
29
- - `handleOpenTab` async function to open the tab in backend
30
- - expects the following keys in return
31
- - { status: 1, tabId, children: undefined }
32
- - `handleCloseTab` async function to open the tab in backend
33
- - expects the following keys in return
34
- - { status: 1, current_tab_id: 123 }
35
- - `handleReorderTabs` async function to open the tab in backend
36
- - { status: 1 }
37
- - `getTabs` async function to open the tab in backend async () => { },
38
- - expects the following keys in return
39
- - { status: 1, tabs: [], current_tab: {} || null, hasNoTabs }
40
- - hasNoTabs = user for whom there are no tabs open
41
- - `getUserDetails` function which return the user details from user token
42
- - `hasPrivilege` function which checks if the user has the privilege passed in function param
43
- - `alertService` An object containing different methods for displaying toast alerts.
44
- - can call success, warning, error, info, alert methods.
45
- - super-notifier - NPM package can be used here
46
- - https://www.npmjs.com/package/super-notifier
3
+ `SuperTabs` is a production-ready React navigation library for managing parent tabs and nested sub-tabs in complex applications.
47
4
 
48
- ```
49
- Eg.
50
- const SITE_PREFIX = 'teamLink_'
51
- const API_BASE_URL = 'https://api.teamlink.com/data_stream'
52
- const SITE_PAGES = [{
53
- title: "Organization",
54
- url: "/app/organization",
55
- privilege: "ORGANIZATION",
56
- id: 1,
57
- },
58
- {
59
- title: "Recruiter",
60
- url: "/app/recruiter/f-home",
61
- privilege: "RECRUITER",
62
- showAddButton: true,
63
- customAddButtons: [
64
- {
65
- name: "Data Grid",
66
- id: 1,
67
- },
68
- {
69
- name: "Trend Master",
70
- id: 2,
71
- }
72
- ],
73
- containsSubTabs: true,
74
- id: 2,
75
- }]
5
+ It provides a robust tab lifecycle with route integration, privilege-aware module access, and extensible UI controls for module-level workflows.
6
+
7
+ ### Highlights
8
+
9
+ - Parent tab and sub-tab navigation with URL synchronization
10
+ - Drag-and-drop tab reordering
11
+ - Configurable module actions (`showAddButton` and `customAddButtons`)
12
+ - Pluggable handlers for open, close, reorder, and fetch operations
13
+
14
+ ---
15
+
16
+ ## 1) Setup
17
+
18
+ Wrap your app with `TabProvider`.
76
19
 
77
- // showAddButton - can be added if the module needs plus button.
78
- // containsSubTabs - can be added if the tab includes sub tabs.
79
- // customAddButtons - These buttons will be added in the sub tab list. Clicking on the button will trigger the binded callback with object as param.
20
+ ```jsx
21
+ import { TabProvider } from "components/SuperTabs/TabContext";
22
+ import { alertService } from "super-notifier";
80
23
 
81
- import { TabProvider } from 'components/SuperTabs/TabContext';
82
24
  <TabProvider
83
- SITE_PREFIX={SITE_PREFIX}
84
- SITE_PAGES={SITE_PAGES}
85
- homeUrl="/app"
86
- getTabs={getTabs}
87
- handleOpenTab={handleOpenTab}
88
- handleCloseTab={handleCloseTab}
89
- handleReorderTabs={handleReorderTabs}
90
- alertService={alertService}
25
+ SITE_PREFIX={SITE_PREFIX}
26
+ SITE_PAGES={SITE_PAGES}
27
+ homeUrl="/app"
28
+ getUserDetails={getUser}
29
+ hasPrivilege={(privilege) => checkPrivilege(getUser().privileges, privilege)}
30
+ getTabs={getTabs}
31
+ handleOpenTab={handleOpenTab}
32
+ handleCloseTab={handleCloseTab}
33
+ handleReorderTabs={handleReorderTabs}
34
+ isDefaultExpanded={true}
35
+ alertService={alertService}
91
36
  >
92
- <Main />
93
- </TabProvider>
37
+ <Main />
38
+ </TabProvider>;
94
39
  ```
95
40
 
96
- >**Render the component within the App's header**
97
- ```
98
- import { useTabContext } from "components/SuperTabs/TabContext";
41
+ Render tabs in header:
42
+
43
+ ```jsx
44
+ import SuperTabs from "components/SuperTabs/SuperTabs";
99
45
 
100
46
  <header>
101
- <SuperTabs />
102
- </header>
47
+ <SuperTabs />
48
+ </header>;
103
49
  ```
104
50
 
105
- >**Wrap the hyperlink as follows:**
51
+ ---
106
52
 
107
- Each tab should contain all the necessary information to be stored.
53
+ ## 2) `TabProvider` props
108
54
 
109
- Mandatory Fields:
110
- - `id`
111
- - `name`
112
- - `url`
55
+ ### Required
113
56
 
114
- For Avatar:
115
- - `showAvatar` must be set to `true`
116
- - The following fields must be provided:
117
- - `firstName`
118
- - `lastName`
119
- - `imgSrc`
57
+ - `SITE_PREFIX: string`
58
+ - `SITE_PAGES: Array<SitePage>`
120
59
 
60
+ `SitePage` is typically:
61
+
62
+ ```js
63
+ {
64
+ id: 2,
65
+ title: "Recruiter",
66
+ url: "/app/recruiter/f-home",
67
+ privilege: "RECRUITER",
68
+ containsSubTabs: true,
69
+ showAddButton: true, // boolean or privilege array
70
+ customAddButtons: [
71
+ { id: 1, name: "Data Grid", privilege: "RECRUITER" },
72
+ { id: 2, name: "Trend Master", privilege: "RECRUITER" }
73
+ ],
74
+ showInMobile: true, // optional
75
+ isExternal: false // optional
76
+ }
121
77
  ```
122
- // Tab object Examples
123
78
 
79
+ ### Optional
80
+
81
+ - `homeUrl` (default: `/`)
82
+ - `entityIdentifierKey` (default: `organization_id`)
83
+ - `persistTabsAfterLogin` (default: `false`)
84
+ - `preventHomeRedirect` (default: `false`)
85
+ - When `true`, clicking home opens module menu instead of redirecting.
86
+ - `retainTabsAfterEntityChange` (default: `false`)
87
+ - `shouldRedirectToSubTab` (default: `true`)
88
+ - `isMobileView` (default: `false`)
89
+ - `isDefaultExpanded` (default: `false`)
90
+ - `getUserDetails` (function)
91
+ - `hasPrivilege` (function)
92
+ - `getTabs` (async function)
93
+ - `handleOpenTab` (async function)
94
+ - `handleCloseTab` (async function)
95
+ - `handleReorderTabs` (async function)
96
+ - `alertService` object with optional methods: `success`, `warning`, `error`, `info`, `alert`
97
+
98
+ ---
99
+
100
+ ## 3) API callback contracts
101
+
102
+ ### `getTabs({ payload, controller })`
103
+
104
+ Expected shape:
105
+
106
+ ```js
124
107
  {
125
- id: 1,
126
- name: 'title',
127
- url: '/recruiter/f-1`
108
+ status: 1,
109
+ tabs: [], // flat backend tabs with tab_info
110
+ current_tab: {} | null, // current tab from backend
111
+ hasNoTabs: false // true when backend has no open tabs
128
112
  }
113
+ ```
114
+
115
+ ### `handleOpenTab(payload[, controller])`
116
+
117
+ Expected shape:
129
118
 
119
+ ```js
130
120
  {
131
- id: 100,
132
- url: '/profile/100`
133
- firstName: 'John',
134
- lastName: 'Doe',
135
- showAvatar: true,
136
- imgSrc: img_url,
137
- department,
138
- designation,
139
- department_id,
121
+ status: 1,
122
+ tabId: 123,
123
+ children: [] // optional child tabs
140
124
  }
141
125
  ```
126
+
127
+ ### `handleCloseTab(tabId)`
128
+
129
+ Expected shape:
130
+
131
+ ```js
132
+ {
133
+ status: 1,
134
+ current_tab_id: 456 // optional
135
+ }
142
136
  ```
137
+
138
+ ### `handleReorderTabs(payload)`
139
+
140
+ Expected shape:
141
+
142
+ ```js
143
+ {
144
+ status: 1;
145
+ }
146
+ ```
147
+
148
+ ---
149
+
150
+ ## 4) Opening tabs
151
+
152
+ ### Option 1: `SuperLink`
153
+
154
+ ```jsx
143
155
  import SuperLink from "components/SuperTabs/SuperLink";
156
+
144
157
  <SuperLink tab={page} isSubTab={false}>
145
- {page.title}
146
- </SuperLink>
158
+ {page.title}
159
+ </SuperLink>;
147
160
  ```
148
161
 
149
- OR
162
+ Open external links:
150
163
 
164
+ ```jsx
165
+ <SuperLink tab={{ ...page, isExternal: true }} isSubTab={false} isExternal>
166
+ {page.title}
167
+ </SuperLink>
151
168
  ```
169
+
170
+ ### Option 2: `openSuperTabOnRowClick`
171
+
172
+ ```jsx
152
173
  import { useTabContext } from "components/SuperTabs/TabContext";
174
+
153
175
  const { openSuperTabOnRowClick } = useTabContext();
154
176
 
155
- function handleRowClick(e) {
156
- const tab = { id: e.id, name: e.name, url: `/recruiter/f-${e.id}` };
157
- // isSubTab defaults to true
158
- openSuperTabOnRowClick({ tab, isSubTab });
177
+ function handleRowClick(row) {
178
+ openSuperTabOnRowClick({
179
+ tab: {
180
+ id: row.id,
181
+ name: row.name,
182
+ url: `/app/recruiter/f-${row.id}`,
183
+ },
184
+ isSubTab: true, // defaults to true
185
+ });
159
186
  }
160
187
  ```
161
188
 
162
- >**Bind the callback for the plus button to each module during the initial render.**
189
+ ---
190
+
191
+ ## 5) Tab object notes
192
+
193
+ Common fields:
194
+
195
+ - `id`
196
+ - `url`
197
+ - one of `name` / `title`
163
198
 
164
- If a module requires a plus button for adding a new tab, you can include the following:
199
+ Optional:
200
+
201
+ - `showAvatar`, `firstName`, `lastName`, `imgSrc` or `img_url`
202
+ - `isExternal`
203
+ - any extra metadata your module uses
204
+
205
+ ```js
206
+ {
207
+ id: 100,
208
+ url: "/app/profile/100",
209
+ firstName: "John",
210
+ lastName: "Doe",
211
+ showAvatar: true,
212
+ imgSrc: "https://cdn.example.com/u100.png"
213
+ }
165
214
  ```
215
+
216
+ ---
217
+
218
+ ## 6) Add button callbacks
219
+
220
+ Bind module add callbacks using emitter:
221
+
222
+ ```jsx
223
+ import { useCallback, useEffect } from "react";
166
224
  import { emitter } from "components/SuperTabs/SuperTabs";
167
225
  import { useTabContext } from "components/SuperTabs/TabContext";
168
226
 
169
227
  const { openSuperTabOnRowClick } = useTabContext();
170
228
 
171
- const handleTabAddBtn = useCallback(() => {
229
+ const handleTabAddBtn = useCallback(
230
+ (customButtonData) => {
231
+ // customButtonData is passed when using customAddButtons
172
232
  openSuperTabOnRowClick({
173
- tab: {
174
- id: 123,
175
- name: `New Funnel`,
176
- url: `/recruiter/f-${123}`,
177
- },
178
- isSubTab: true,
233
+ tab: {
234
+ id: 123,
235
+ name: "New Funnel",
236
+ url: "/app/recruiter/f-123",
237
+ },
238
+ isSubTab: true,
179
239
  });
180
- }, [openSuperTabOnRowClick]);
240
+ },
241
+ [openSuperTabOnRowClick],
242
+ );
181
243
 
182
244
  useEffect(() => {
183
- const unsub = emitter.emit("bindCallback", {
184
- id: 2, // Same id provided for this module in navigation.js
185
- callback: handleTabAddBtn,
186
- });
187
- return unsub;
245
+ const unsub = emitter.emit("bindCallback", {
246
+ id: 2, // same parent module id from SITE_PAGES
247
+ callback: handleTabAddBtn,
248
+ });
249
+ return unsub;
188
250
  }, [handleTabAddBtn]);
189
251
  ```
190
252
 
191
- > Note: The logo of the home tab can be updated by targeting the `brand-logo` class.
192
-
193
- -----
194
-
195
- #### Advanced
253
+ ---
196
254
 
197
- >**Cleanup**
255
+ ## 7) Close cleanup event
198
256
 
199
- When a tab is closed, it may be necessary to clean up some data. The `superTabClose` event can be utilized for this purpose.
200
-
201
- ```
202
- import { emitter } from 'components/SuperTabs/SuperTabs';
257
+ ```jsx
258
+ import { useEffect } from "react";
259
+ import { emitter } from "components/SuperTabs/SuperTabs";
203
260
 
204
261
  useEffect(() => {
205
- const unsub = emitter.subscribe('superTabClose', ({ appId, isSubTab, tab }) => {
206
- // Same id provided for this module in navigation.js
207
- if (appId === 2 && isSubTab) {
208
- // handle clean up here
209
- }
210
- })
211
- return unsub;
262
+ const unsub = emitter.subscribe(
263
+ "superTabClose",
264
+ ({ appId, isSubTab, tab }) => {
265
+ if (appId === 2 && isSubTab) {
266
+ // cleanup here
267
+ }
268
+ },
269
+ );
270
+ return unsub;
212
271
  }, []);
213
272
  ```
214
273
 
215
- >**Not Available page**
216
- - If a profile is deleted, the tab will remain open. To address this, we can display a "Page Not Available" message.
274
+ ---
217
275
 
218
- ```
219
- import NotAvailable from 'components/SuperTabs/NotAvailable';
276
+ ## 8) Not Available page
220
277
 
221
- <NotAvailable subTabName='Profile' />
278
+ ```jsx
279
+ import NotAvailable from "components/SuperTabs/NotAvailable";
280
+
281
+ <NotAvailable subTabName="Profile" />;
222
282
  ```
223
283
 
224
- >**Keep Alive (Experimental)**
284
+ ---
225
285
 
226
- ```
227
- import { withKeepAlive } from "components/SuperTabs/KeepAlive";
286
+ ## 9) Keep-alive (optional)
228
287
 
229
- // Same id provided for this module in navigation.js
230
- export default withKeepAlive(Component, Unique ID);
288
+ Use shared keep-alive utility:
231
289
 
232
- Eg.
233
- const Component = () => {
234
- return <div>Component</div>
235
- }
290
+ ```jsx
291
+ import { withKeepAlive } from "components/KeepAlive";
236
292
 
237
- export default withKeepAlive(Component, 2);
238
- ```
239
- Keep Alive Cleanup
293
+ const Component = () => <div>Component</div>;
294
+ export default withKeepAlive(Component, 2); // module id
240
295
  ```
241
- // This can be incorporated into a component that is always rendered, such as the header.
242
296
 
243
- import { useAliveScope } from "components/SuperTabs/KeepAlive";
244
- import { emitter } from "components/SuperTabs/SuperTabs";
297
+ Cleanup keep-alive cache on parent tab close:
245
298
 
246
- const { drop } = useAliveScope();
299
+ ```jsx
300
+ import { useEffect } from "react";
301
+ import { useAliveScope } from "components/KeepAlive";
302
+ import { emitter } from "components/SuperTabs/SuperTabs";
303
+
304
+ const { drop } = useAliveScope();
247
305
 
248
306
  useEffect(() => {
249
- const unsub = emitter.subscribe('superTabClose', (e) => {
250
- const { appId, isSubTab } = e;
251
- if (appId && !isSubTab) {
252
- // drop the cache of the tab
253
- drop(appId);
254
- }
255
- })
256
- return unsub;
257
- }, []);
258
- ```
307
+ const unsub = emitter.subscribe("superTabClose", ({ appId, isSubTab }) => {
308
+ if (appId && !isSubTab) {
309
+ drop(appId);
310
+ }
311
+ });
312
+ return unsub;
313
+ }, [drop]);
314
+ ```
315
+
316
+ ---
317
+
318
+ ## 10) Styling note
319
+
320
+ Home tab logo can be styled with `.brand-logo`.
package/dist/SuperTabs.js CHANGED
@@ -50,7 +50,11 @@ var tooltipStyles = {
50
50
  zIndex: 100000,
51
51
  boxShadow: "0px 1px 10px 0px rgba(0, 0, 0, 0.10)",
52
52
  marginBottom: "5px",
53
- minWidth: "fit-content"
53
+ minWidth: "fit-content",
54
+ marginTop: "2px",
55
+ borderRadius: "2px",
56
+ backgroundColor: 'var(--tab-background-overlay, #272B32)',
57
+ color: 'var(--tab-text-normal, #BDC3CC)'
54
58
  };
55
59
  var filterSubTabs = function filterSubTabs(subTabs) {
56
60
  // const subTabsInList = [];
@@ -106,6 +110,7 @@ var SuperTabs = function SuperTabs(_ref) {
106
110
  updateExpandedID = _useTabContext.updateExpandedID,
107
111
  expandedTabIDRef = _useTabContext.expandedTabIDRef,
108
112
  updateCurrentTab = _useTabContext.updateCurrentTab,
113
+ openSuperTabOnRowClick = _useTabContext.openSuperTabOnRowClick,
109
114
  hasPrivilege = _useTabContext.hasPrivilege,
110
115
  subTabChange = _useTabContext.subTabChange,
111
116
  updateSubTabChange = _useTabContext.updateSubTabChange,
@@ -324,8 +329,6 @@ var SuperTabs = function SuperTabs(_ref) {
324
329
 
325
330
  // Hover handlers for brand wrapper
326
331
  var handleBrandHoverEnter = function handleBrandHoverEnter() {
327
- console.log('handleBrandHoverEnter', isMobile, preventHomeRedirect);
328
-
329
332
  // Skip hover functionality on mobile devices to avoid conflicts
330
333
  if (isMobile) return;
331
334
 
@@ -849,7 +852,14 @@ var SuperTabs = function SuperTabs(_ref) {
849
852
  ref: provided.innerRef
850
853
  // (snapshot.isDragging ? " dragging" : "") +
851
854
  ,
852
- className: 'tab-with-child-wrapper parent-super-tab' + " tab-".concat(tab.id) + (isActive ? ' active' : '') + (closingTabID === tab.id ? ' stack-closing' : '') + (shrinkedTab ? ' shrinked-parent-tab' : '') + (snapshot.isDragging ? ' dragging' : '')
855
+ className: 'tab-with-child-wrapper parent-super-tab' + " tab-".concat(tab.id) + (isActive ? ' active' : '') + (closingTabID === tab.id ? ' stack-closing' : '') + (shrinkedTab ? ' shrinked-parent-tab' : '') + (snapshot.isDragging ? ' dragging' : ''),
856
+ onClick: function onClick() {
857
+ if (isActive) return;
858
+ openSuperTabOnRowClick({
859
+ tab: tab,
860
+ isSubTab: false
861
+ });
862
+ }
853
863
  }), /*#__PURE__*/_react["default"].createElement("div", {
854
864
  className: 'child-tabs-wrapper tab-' + tab.id + (showSubTabs ? ' expanded' : '')
855
865
  // (isActive ? ' active' : '')
@@ -870,6 +880,7 @@ var SuperTabs = function SuperTabs(_ref) {
870
880
  // title={tab.title}
871
881
  ,
872
882
  onClick: function onClick(e) {
883
+ e.stopPropagation();
873
884
  var ignoreActiveTabUpdate = false;
874
885
  if (containsSubTabs && !isActive) {
875
886
  var _lastOpenedUrl$curren;
@@ -197,6 +197,7 @@ body[data-theme="light"] {
197
197
 
198
198
  display: flex;
199
199
  align-items: center;
200
+ cursor: pointer !important;
200
201
  transition-duration: var(--transition-duration-extended);
201
202
  transition-property: padding, opacity, border-color, max-width;
202
203
 
@@ -536,6 +537,7 @@ body[data-theme="light"] {
536
537
  align-items: center;
537
538
  position: relative;
538
539
  z-index: 10;
540
+ cursor: pointer !important;
539
541
 
540
542
  &:not(.active) {
541
543
  position: relative;
@@ -252,8 +252,8 @@ function TabProvider(_ref9) {
252
252
  subTabWrapperWidth = _useState12[0],
253
253
  setSubTabWrapperWidth = _useState12[1];
254
254
  var _useState13 = (0, _react.useState)(function () {
255
- var _getUserDetails;
256
- return ((_getUserDetails = getUserDetails()) === null || _getUserDetails === void 0 ? void 0 : _getUserDetails[entityIdentifierKey]) || null;
255
+ var _getUserDetails$entit, _getUserDetails;
256
+ return (_getUserDetails$entit = (_getUserDetails = getUserDetails()) === null || _getUserDetails === void 0 ? void 0 : _getUserDetails[entityIdentifierKey]) !== null && _getUserDetails$entit !== void 0 ? _getUserDetails$entit : null;
257
257
  }),
258
258
  _useState14 = _slicedToArray(_useState13, 2),
259
259
  currentEntityId = _useState14[0],
@@ -1496,7 +1496,7 @@ function TabProvider(_ref9) {
1496
1496
  break;
1497
1497
  }
1498
1498
  pathName = window.location.pathname;
1499
- isHomeTab = pathName === homeUrl;
1499
+ isHomeTab = pathName === homeUrl || pathName === '/';
1500
1500
  _context10.n = 3;
1501
1501
  return findDuplicateEntriesAndCloseTab(response.tabs);
1502
1502
  case 3:
package/dist/TabList.js CHANGED
@@ -6,6 +6,7 @@ Object.defineProperty(exports, "__esModule", {
6
6
  });
7
7
  exports["default"] = void 0;
8
8
  var _react = _interopRequireWildcard(require("react"));
9
+ var _reactDom = require("react-dom");
9
10
  var _TabContext = require("./TabContext");
10
11
  var _reactRouterDom = require("react-router-dom");
11
12
  var _ClickOutsideListener = _interopRequireDefault(require("./ClickOutsideListener"));
@@ -74,13 +75,16 @@ var TabList = function TabList(_ref) {
74
75
  if (popupElem) {
75
76
  var popupRect = popupElem.getBoundingClientRect();
76
77
  var windowWidth = window.innerWidth;
78
+ var top = "".concat(popupRect.bottom - 2, "px");
77
79
  if (popupRect.right + 300 > windowWidth) {
78
80
  position = {
79
- right: "".concat(window.innerWidth - (popupRect === null || popupRect === void 0 ? void 0 : popupRect.right), "px")
81
+ right: "".concat(window.innerWidth - (popupRect === null || popupRect === void 0 ? void 0 : popupRect.right), "px"),
82
+ top: top
80
83
  };
81
84
  } else {
82
85
  position = {
83
- left: "".concat((popupRect === null || popupRect === void 0 ? void 0 : popupRect.left) + 5, "px")
86
+ left: "".concat((popupRect === null || popupRect === void 0 ? void 0 : popupRect.left) + 5, "px"),
87
+ top: top
84
88
  };
85
89
  }
86
90
  }
@@ -134,7 +138,7 @@ var TabList = function TabList(_ref) {
134
138
  return exactMatches.flat().concat(otherMatches);
135
139
  };
136
140
  var filteredTabs = filterTabs(tabs);
137
- return /*#__PURE__*/_react["default"].createElement(_ClickOutsideListener["default"], {
141
+ var tabListContent = /*#__PURE__*/_react["default"].createElement(_ClickOutsideListener["default"], {
138
142
  onOutsideClick: handleOutsideClick
139
143
  }, /*#__PURE__*/_react["default"].createElement("div", {
140
144
  className: "tab-list-wrapper ".concat(showList ? 'show' : ''),
@@ -154,7 +158,7 @@ var TabList = function TabList(_ref) {
154
158
  closeList();
155
159
  setShowList(false);
156
160
  }
157
- }, title), !(index == customAddButtons.length - 1) && /*#__PURE__*/_react["default"].createElement("span", {
161
+ }, title), !(index === customAddButtons.length - 1) && /*#__PURE__*/_react["default"].createElement("span", {
158
162
  className: "pipe"
159
163
  }));
160
164
  }) : showAddButton && !hasCustomAddButtons && /*#__PURE__*/_react["default"].createElement(_react["default"].Fragment, null, /*#__PURE__*/_react["default"].createElement("button", {
@@ -232,5 +236,9 @@ var TabList = function TabList(_ref) {
232
236
  }) : /*#__PURE__*/_react["default"].createElement("div", {
233
237
  className: "tab-list-no-data"
234
238
  }, "No data found"))))));
239
+ if (!showList) {
240
+ return null;
241
+ }
242
+ return /*#__PURE__*/(0, _reactDom.createPortal)(tabListContent, document.body);
235
243
  };
236
244
  var _default = exports["default"] = TabList;
package/dist/TabList.scss CHANGED
@@ -1,11 +1,11 @@
1
1
  .tab-list-wrapper {
2
2
  padding-top: 12px;
3
3
  position: fixed;
4
- top: calc(var(--header-height-other-tab) - 8px);
5
4
  opacity: 0;
6
5
  visibility: hidden;
7
6
  transition: opacity 0.3s;
8
7
  pointer-events: none;
8
+ z-index: 10000;
9
9
 
10
10
  &.show {
11
11
  opacity: 1;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@bydata/react-supertabs",
3
- "version": "1.1.8",
3
+ "version": "1.2.0",
4
4
  "description": "A customizable React super tabs component.",
5
5
  "main": "dist/index.js",
6
6
  "module": "dist/index.js",