@bydata/react-supertabs 1.1.1 → 1.1.3

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,6 +13,7 @@ var _reactRouterDom = require("react-router-dom");
13
13
  var _usePrevious = _interopRequireDefault(require("./usePrevious"));
14
14
  var _Utils = require("./Utils");
15
15
  var _Constants = require("./Constants");
16
+ var _jsxRuntime = require("react/jsx-runtime");
16
17
  var _excluded = ["subTabs", "level", "order", "tabId", "unique_identifier", "parent_tab_id", "width", "elementWidth"],
17
18
  _excluded2 = ["tab_info"],
18
19
  _excluded3 = ["subTabs", "level", "order", "tabId", "unique_identifier", "parent_tab_id", "width", "elementWidth"],
@@ -1830,7 +1831,7 @@ function TabProvider(_ref9) {
1830
1831
  clearTimeout(openingUnexpandedSubTabTimeoutRef.current);
1831
1832
  };
1832
1833
  }, []);
1833
- return /*#__PURE__*/React.createElement(TabContext.Provider, {
1834
+ return /*#__PURE__*/(0, _jsxRuntime.jsx)(TabContext.Provider, {
1834
1835
  value: {
1835
1836
  activeTab: activeTab,
1836
1837
  activeTabRef: activeTabRef,
@@ -1887,8 +1888,9 @@ function TabProvider(_ref9) {
1887
1888
  discardSubTabWrapperWidth: discardSubTabWrapperWidth,
1888
1889
  isMobileView: isMobileView,
1889
1890
  isDefaultExpanded: isDefaultExpanded
1890
- }
1891
- }, children);
1891
+ },
1892
+ children: children
1893
+ });
1892
1894
  }
1893
1895
  function useTabContext() {
1894
1896
  return (0, _react.useContext)(TabContext);
package/dist/TabList.js CHANGED
@@ -9,6 +9,7 @@ var _TabContext = require("./TabContext");
9
9
  var _reactRouterDom = require("react-router-dom");
10
10
  var _ClickOutsideListener = _interopRequireDefault(require("./ClickOutsideListener"));
11
11
  require("./TabList.scss");
12
+ var _jsxRuntime = require("react/jsx-runtime");
12
13
  function _interopRequireDefault(e) { return e && e.__esModule ? e : { "default": e }; }
13
14
  function _slicedToArray(r, e) { return _arrayWithHoles(r) || _iterableToArrayLimit(r, e) || _unsupportedIterableToArray(r, e) || _nonIterableRest(); }
14
15
  function _nonIterableRest() { throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); }
@@ -132,103 +133,117 @@ var TabList = function TabList(_ref) {
132
133
  return exactMatches.flat().concat(otherMatches);
133
134
  };
134
135
  var filteredTabs = filterTabs(tabs);
135
- return /*#__PURE__*/React.createElement(_ClickOutsideListener["default"], {
136
- onOutsideClick: handleOutsideClick
137
- }, /*#__PURE__*/React.createElement("div", {
138
- className: "tab-list-wrapper ".concat(showList ? 'show' : ''),
139
- style: position
140
- }, /*#__PURE__*/React.createElement("div", {
141
- className: "tab-list"
142
- }, /*#__PURE__*/React.createElement("div", {
143
- className: "tab-list-header ".concat(hasCustomAddButtons ? 'wrap' : '')
144
- }, customAddButtons.length > 0 ? customAddButtons.map(function (predefinedSubTab, index) {
145
- var title = predefinedSubTab.title || predefinedSubTab.name || (predefinedSubTab !== null && predefinedSubTab !== void 0 && predefinedSubTab.firstName ? "".concat(predefinedSubTab.firstName, " ").concat(predefinedSubTab.lastName || '') : 'Untitled');
146
- return /*#__PURE__*/React.createElement(_react.Fragment, {
147
- key: predefinedSubTab.id || index
148
- }, /*#__PURE__*/React.createElement("button", {
149
- className: "icon-add",
150
- onClick: function onClick() {
151
- onAddButtonClick(predefinedSubTab);
152
- closeList();
153
- setShowList(false);
154
- }
155
- }, title), !(index == customAddButtons.length - 1) && /*#__PURE__*/React.createElement("span", {
156
- className: "pipe"
157
- }));
158
- }) : showAddButton && !hasCustomAddButtons && /*#__PURE__*/React.createElement(React.Fragment, null, /*#__PURE__*/React.createElement("button", {
159
- className: "icon-add",
160
- onClick: handlePlusButtonClick
161
- }, "Tab"), /*#__PURE__*/React.createElement("span", {
162
- className: "pipe"
163
- })), /*#__PURE__*/React.createElement("div", {
164
- className: "tab-list-search-wrapper ".concat(!showAddButton || hasCustomAddButtons ? 'no-add-tab' : '', " ").concat(searchExpanded || !showAddButton || hasCustomAddButtons ? 'expanded' : ''),
165
- onClick: expandSearch
166
- }, /*#__PURE__*/React.createElement("div", {
167
- className: "tab-list-search-wrapper-inner"
168
- }, /*#__PURE__*/React.createElement("input", {
169
- ref: searchWrapperRef,
170
- type: "text",
171
- className: "tab-list-search",
172
- value: tabListSearch,
173
- onChange: handleSearch
174
- }), tabListSearch.trim() && /*#__PURE__*/React.createElement("button", {
175
- className: "tab-list-close tab-close-btn",
176
- onClick: function onClick() {
177
- return setTabListSearch('');
178
- }
179
- })))), /*#__PURE__*/React.createElement("div", {
180
- className: "tab-list-open-tabs"
181
- }, /*#__PURE__*/React.createElement("div", {
182
- className: "tab-list-tabs-wrapper"
183
- }, filteredTabs.length > 0 ? filteredTabs.map(function (tab, index) {
184
- var title = tab.title || tab.name || (tab !== null && tab !== void 0 && tab.firstName ? "".concat(tab.firstName, " ").concat(tab.lastName || '') : 'Untitled');
185
- return /*#__PURE__*/React.createElement(_reactRouterDom.NavLink, {
186
- className: "tab-list-open-tab ".concat(id === activeTab.id && tab.id === activeSubTab.id ? 'active' : ''),
187
- key: tab.id || index,
188
- onClick: function onClick(e) {
189
- // e.preventDefault();
190
- handleTabClick({
191
- tab: tab,
192
- isSubTab: true,
193
- parentId: id,
194
- sort: true
195
- });
196
- // clearTimeout(openingUnexpandedSubTabTimeoutRef.current);
197
- updateSubTabChange({
198
- parentTabId: id,
199
- newTab: tab,
200
- oldTab: tabs.find(function (t) {
201
- return t.open_order === 1;
136
+ return /*#__PURE__*/(0, _jsxRuntime.jsx)(_ClickOutsideListener["default"], {
137
+ onOutsideClick: handleOutsideClick,
138
+ children: /*#__PURE__*/(0, _jsxRuntime.jsx)("div", {
139
+ className: "tab-list-wrapper ".concat(showList ? 'show' : ''),
140
+ style: position,
141
+ children: /*#__PURE__*/(0, _jsxRuntime.jsxs)("div", {
142
+ className: "tab-list",
143
+ children: [/*#__PURE__*/(0, _jsxRuntime.jsxs)("div", {
144
+ className: "tab-list-header ".concat(hasCustomAddButtons ? 'wrap' : ''),
145
+ children: [customAddButtons.length > 0 ? customAddButtons.map(function (predefinedSubTab, index) {
146
+ var title = predefinedSubTab.title || predefinedSubTab.name || (predefinedSubTab !== null && predefinedSubTab !== void 0 && predefinedSubTab.firstName ? "".concat(predefinedSubTab.firstName, " ").concat(predefinedSubTab.lastName || '') : 'Untitled');
147
+ return /*#__PURE__*/(0, _jsxRuntime.jsxs)(_react.Fragment, {
148
+ children: [/*#__PURE__*/(0, _jsxRuntime.jsx)("button", {
149
+ className: "icon-add",
150
+ onClick: function onClick() {
151
+ onAddButtonClick(predefinedSubTab);
152
+ closeList();
153
+ setShowList(false);
154
+ },
155
+ children: title
156
+ }), !(index == customAddButtons.length - 1) && /*#__PURE__*/(0, _jsxRuntime.jsx)("span", {
157
+ className: "pipe"
158
+ })]
159
+ }, predefinedSubTab.id || index);
160
+ }) : showAddButton && !hasCustomAddButtons && /*#__PURE__*/(0, _jsxRuntime.jsxs)(_jsxRuntime.Fragment, {
161
+ children: [/*#__PURE__*/(0, _jsxRuntime.jsx)("button", {
162
+ className: "icon-add",
163
+ onClick: handlePlusButtonClick,
164
+ children: "Tab"
165
+ }), /*#__PURE__*/(0, _jsxRuntime.jsx)("span", {
166
+ className: "pipe"
167
+ })]
168
+ }), /*#__PURE__*/(0, _jsxRuntime.jsx)("div", {
169
+ className: "tab-list-search-wrapper ".concat(!showAddButton || hasCustomAddButtons ? 'no-add-tab' : '', " ").concat(searchExpanded || !showAddButton || hasCustomAddButtons ? 'expanded' : ''),
170
+ onClick: expandSearch,
171
+ children: /*#__PURE__*/(0, _jsxRuntime.jsxs)("div", {
172
+ className: "tab-list-search-wrapper-inner",
173
+ children: [/*#__PURE__*/(0, _jsxRuntime.jsx)("input", {
174
+ ref: searchWrapperRef,
175
+ type: "text",
176
+ className: "tab-list-search",
177
+ value: tabListSearch,
178
+ onChange: handleSearch
179
+ }), tabListSearch.trim() && /*#__PURE__*/(0, _jsxRuntime.jsx)("button", {
180
+ className: "tab-list-close tab-close-btn",
181
+ onClick: function onClick() {
182
+ return setTabListSearch('');
183
+ }
184
+ })]
185
+ })
186
+ })]
187
+ }), /*#__PURE__*/(0, _jsxRuntime.jsx)("div", {
188
+ className: "tab-list-open-tabs",
189
+ children: /*#__PURE__*/(0, _jsxRuntime.jsx)("div", {
190
+ className: "tab-list-tabs-wrapper",
191
+ children: filteredTabs.length > 0 ? filteredTabs.map(function (tab, index) {
192
+ var title = tab.title || tab.name || (tab !== null && tab !== void 0 && tab.firstName ? "".concat(tab.firstName, " ").concat(tab.lastName || '') : 'Untitled');
193
+ return /*#__PURE__*/(0, _jsxRuntime.jsxs)(_reactRouterDom.NavLink, {
194
+ className: "tab-list-open-tab ".concat(id === activeTab.id && tab.id === activeSubTab.id ? 'active' : ''),
195
+ onClick: function onClick(e) {
196
+ // e.preventDefault();
197
+ handleTabClick({
198
+ tab: tab,
199
+ isSubTab: true,
200
+ parentId: id,
201
+ sort: true
202
+ });
203
+ // clearTimeout(openingUnexpandedSubTabTimeoutRef.current);
204
+ updateSubTabChange({
205
+ parentTabId: id,
206
+ newTab: tab,
207
+ oldTab: tabs.find(function (t) {
208
+ return t.open_order === 1;
209
+ })
210
+ });
211
+ // setOpeningUnexpandedSubTab(true);
212
+ // openingUnexpandedSubTabTimeoutRef.current = setTimeout(() => {
213
+ // setOpeningUnexpandedSubTab(false);
214
+ // }, 300);
215
+ closeList();
216
+ setShowList(false);
217
+ },
218
+ to: tab.url,
219
+ children: [tab.icon && /*#__PURE__*/(0, _jsxRuntime.jsx)("span", {
220
+ className: "icon-container ".concat(tab.icon)
221
+ }), /*#__PURE__*/(0, _jsxRuntime.jsxs)("div", {
222
+ className: "title-wrapper",
223
+ children: [title, !tab.isFixed && /*#__PURE__*/(0, _jsxRuntime.jsx)("span", {
224
+ className: "tab-list-close-btn tab-close-btn",
225
+ onClick: function onClick(e) {
226
+ e.preventDefault();
227
+ e.stopPropagation();
228
+ onClose({
229
+ tab: tab,
230
+ isSubTab: true,
231
+ parentIndex: parentIndex
232
+ });
233
+ closeList();
234
+ setShowList(false);
235
+ }
236
+ })]
237
+ })]
238
+ }, tab.id || index);
239
+ }) : /*#__PURE__*/(0, _jsxRuntime.jsx)("div", {
240
+ className: "tab-list-no-data",
241
+ children: "No data found"
242
+ })
202
243
  })
203
- });
204
- // setOpeningUnexpandedSubTab(true);
205
- // openingUnexpandedSubTabTimeoutRef.current = setTimeout(() => {
206
- // setOpeningUnexpandedSubTab(false);
207
- // }, 300);
208
- closeList();
209
- setShowList(false);
210
- },
211
- to: tab.url
212
- }, tab.icon && /*#__PURE__*/React.createElement("span", {
213
- className: "icon-container ".concat(tab.icon)
214
- }), /*#__PURE__*/React.createElement("div", {
215
- className: "title-wrapper"
216
- }, title, !tab.isFixed && /*#__PURE__*/React.createElement("span", {
217
- className: "tab-list-close-btn tab-close-btn",
218
- onClick: function onClick(e) {
219
- e.preventDefault();
220
- e.stopPropagation();
221
- onClose({
222
- tab: tab,
223
- isSubTab: true,
224
- parentIndex: parentIndex
225
- });
226
- closeList();
227
- setShowList(false);
228
- }
229
- })));
230
- }) : /*#__PURE__*/React.createElement("div", {
231
- className: "tab-list-no-data"
232
- }, "No data found"))))));
244
+ })]
245
+ })
246
+ })
247
+ });
233
248
  };
234
249
  var _default = exports["default"] = TabList;
package/dist/TabStack.js CHANGED
@@ -7,6 +7,7 @@ exports["default"] = void 0;
7
7
  var _react = require("react");
8
8
  var _TabContext = require("./TabContext");
9
9
  var _TabList = _interopRequireDefault(require("./TabList"));
10
+ var _jsxRuntime = require("react/jsx-runtime");
10
11
  function _interopRequireDefault(e) { return e && e.__esModule ? e : { "default": e }; }
11
12
  function _typeof(o) { "@babel/helpers - typeof"; return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function (o) { return typeof o; } : function (o) { return o && "function" == typeof Symbol && o.constructor === Symbol && o !== Symbol.prototype ? "symbol" : typeof o; }, _typeof(o); }
12
13
  function _slicedToArray(r, e) { return _arrayWithHoles(r) || _iterableToArrayLimit(r, e) || _unsupportedIterableToArray(r, e) || _nonIterableRest(); }
@@ -48,51 +49,53 @@ var TabStack = function TabStack(_ref) {
48
49
  }, [tab.customAddButtons, hasPrivilege]);
49
50
  var hasAddBtnPrivilege = typeof tab.showAddButton === 'boolean' ? tab.showAddButton : _typeof(tab.showAddButton) === 'object' && Array.isArray(tab.showAddButton) ? hasPrivilege(tab.showAddButton) : false;
50
51
  var hasCustomAddButtons = tab.customAddButtons && Array.isArray(tab.customAddButtons) && tab.customAddButtons.length > 0;
51
- return /*#__PURE__*/React.createElement("div", {
52
+ return /*#__PURE__*/(0, _jsxRuntime.jsxs)("div", {
52
53
  className: "stack-wrapper stack-".concat(tab.id, " ").concat(showSubTabs || isActive ? 'expanded' : '', " ").concat(isTabClosing ? 'stack-closing' : ''),
53
54
  onMouseEnter: function onMouseEnter() {
54
55
  return !showAddButton && subTabsInList.length > 1 && setShowTabStack(tab.id);
55
56
  },
56
57
  onMouseLeave: function onMouseLeave() {
57
58
  return !showAddButton && subTabsInList.length > 1 && !tabListSearch.trim() && setShowTabStack(null);
58
- }
59
- }, /*#__PURE__*/React.createElement("button", {
60
- className: "icon-stack",
61
- onClick: function onClick() {
62
- setShowTabStack('');
63
- if (hasCustomAddButtons && subTabsInList.length <= 1) {
64
- !showTabStack && setShowTabStack(tab.id);
65
- } else if (showAddButton) {
66
- var _addButtonCallBackRef, _addButtonCallBackRef2;
67
- (_addButtonCallBackRef = addButtonCallBackRefs.current) === null || _addButtonCallBackRef === void 0 || (_addButtonCallBackRef2 = _addButtonCallBackRef[tab.id]) === null || _addButtonCallBackRef2 === void 0 || _addButtonCallBackRef2.call(_addButtonCallBackRef);
68
- } else {
69
- toggleSubTabs(tab, tab.subTabs);
70
- }
71
- }
72
- }, showAddButton && !showChevron && /*#__PURE__*/React.createElement("span", {
73
- className: "icon-plus"
74
- }), showChevron && /*#__PURE__*/React.createElement("span", {
75
- className: "icon-chevron ".concat(showSubTabs ? 'open' : '')
76
- })), /*#__PURE__*/React.createElement(_TabList["default"], {
77
- id: tab.id,
78
- isTabExpanded: showSubTabs,
79
- showTabStack: showTabStack,
80
- showAddButton: hasAddBtnPrivilege,
81
- handleTabClick: handleTabClick,
82
- tabs: subTabsInList,
83
- onClose: handleTabClose,
84
- parentIndex: index,
85
- hasCustomAddButtons: hasCustomAddButtons,
86
- customAddButtons: customAddButtons,
87
- onAddButtonClick: function onAddButtonClick(data) {
88
- var _addButtonCallBackRef3, _addButtonCallBackRef4;
89
- return (_addButtonCallBackRef3 = addButtonCallBackRefs.current) === null || _addButtonCallBackRef3 === void 0 || (_addButtonCallBackRef4 = _addButtonCallBackRef3[tab.id]) === null || _addButtonCallBackRef4 === void 0 ? void 0 : _addButtonCallBackRef4.call(_addButtonCallBackRef3, data);
90
59
  },
91
- closeList: function closeList() {
92
- return setShowTabStack(null);
93
- },
94
- tabListSearch: tabListSearch,
95
- setTabListSearch: setTabListSearch
96
- }));
60
+ children: [/*#__PURE__*/(0, _jsxRuntime.jsxs)("button", {
61
+ className: "icon-stack",
62
+ onClick: function onClick() {
63
+ setShowTabStack('');
64
+ if (hasCustomAddButtons && subTabsInList.length <= 1) {
65
+ !showTabStack && setShowTabStack(tab.id);
66
+ } else if (showAddButton) {
67
+ var _addButtonCallBackRef, _addButtonCallBackRef2;
68
+ (_addButtonCallBackRef = addButtonCallBackRefs.current) === null || _addButtonCallBackRef === void 0 || (_addButtonCallBackRef2 = _addButtonCallBackRef[tab.id]) === null || _addButtonCallBackRef2 === void 0 || _addButtonCallBackRef2.call(_addButtonCallBackRef);
69
+ } else {
70
+ toggleSubTabs(tab, tab.subTabs);
71
+ }
72
+ },
73
+ children: [showAddButton && !showChevron && /*#__PURE__*/(0, _jsxRuntime.jsx)("span", {
74
+ className: "icon-plus"
75
+ }), showChevron && /*#__PURE__*/(0, _jsxRuntime.jsx)("span", {
76
+ className: "icon-chevron ".concat(showSubTabs ? 'open' : '')
77
+ })]
78
+ }), /*#__PURE__*/(0, _jsxRuntime.jsx)(_TabList["default"], {
79
+ id: tab.id,
80
+ isTabExpanded: showSubTabs,
81
+ showTabStack: showTabStack,
82
+ showAddButton: hasAddBtnPrivilege,
83
+ handleTabClick: handleTabClick,
84
+ tabs: subTabsInList,
85
+ onClose: handleTabClose,
86
+ parentIndex: index,
87
+ hasCustomAddButtons: hasCustomAddButtons,
88
+ customAddButtons: customAddButtons,
89
+ onAddButtonClick: function onAddButtonClick(data) {
90
+ var _addButtonCallBackRef3, _addButtonCallBackRef4;
91
+ return (_addButtonCallBackRef3 = addButtonCallBackRefs.current) === null || _addButtonCallBackRef3 === void 0 || (_addButtonCallBackRef4 = _addButtonCallBackRef3[tab.id]) === null || _addButtonCallBackRef4 === void 0 ? void 0 : _addButtonCallBackRef4.call(_addButtonCallBackRef3, data);
92
+ },
93
+ closeList: function closeList() {
94
+ return setShowTabStack(null);
95
+ },
96
+ tabListSearch: tabListSearch,
97
+ setTabListSearch: setTabListSearch
98
+ })]
99
+ });
97
100
  };
98
101
  var _default = exports["default"] = TabStack;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@bydata/react-supertabs",
3
- "version": "1.1.1",
3
+ "version": "1.1.3",
4
4
  "description": "A customizable React super tabs component.",
5
5
  "main": "dist/index.js",
6
6
  "module": "dist/index.js",
@@ -9,25 +9,19 @@
9
9
  "README.md"
10
10
  ],
11
11
  "scripts": {
12
- "test": "echo \"Error: no test specified\" && exit 1",
13
12
  "build": "rm -rf dist && NODE_ENV=production babel src --out-dir dist --copy-files"
14
13
  },
15
- "keywords": [],
16
- "author": "",
17
14
  "license": "ISC",
18
- "devDependencies": {
19
- "@babel/cli": "^7.16.8",
20
- "@babel/core": "^7.16.12",
21
- "@babel/plugin-transform-runtime": "^7.16.10",
22
- "@babel/preset-env": "^7.16.11",
23
- "@babel/preset-react": "^7.16.7",
24
- "@rollup/plugin-babel": "^5.3.0",
25
- "autoprefixer": "^10.4.2",
26
- "rollup": "^2.77.1",
27
- "rollup-plugin-styles": "^4.0.0"
15
+ "peerDependencies": {
16
+ "react": ">=16",
17
+ "react-dom": ">=16"
28
18
  },
29
- "dependencies": {
30
- "@babel/runtime": "^7.16.7",
31
- "next-transpile-modules": "^9.0.0"
19
+ "devDependencies": {
20
+ "@babel/cli": "^7.24.0",
21
+ "@babel/core": "^7.24.0",
22
+ "@babel/preset-env": "^7.24.0",
23
+ "@babel/preset-react": "^7.24.0",
24
+ "react": "16.14.0",
25
+ "react-dom": "16.14.0"
32
26
  }
33
- }
27
+ }