@bydata/react-supertabs 1.1.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.
package/dist/Utils.js ADDED
@@ -0,0 +1,336 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ exports.addOrUpdateSubTab = addOrUpdateSubTab;
7
+ exports.calculateWidth = calculateWidth;
8
+ exports.compareDecimals = compareDecimals;
9
+ exports.findBestMatchFromPages = findBestMatchFromPages;
10
+ exports.getCssUnitDifference = getCssUnitDifference;
11
+ exports.getHomeTab = void 0;
12
+ exports.getTextWidth = getTextWidth;
13
+ exports.getUserDetailsFromToken = exports.getUniqueId = exports.getTitle = void 0;
14
+ exports.isChildPath = isChildPath;
15
+ exports.isDev = isDev;
16
+ exports.normalizeUrl = exports.isEmpty = void 0;
17
+ exports.removeSpaces = removeSpaces;
18
+ exports.reorder = reorder;
19
+ exports.reorderSubTabs = reorderSubTabs;
20
+ exports.splitSubTabs = exports.sortByOrder = void 0;
21
+ var _Constants = require("./Constants");
22
+ function ownKeys(e, r) { var t = Object.keys(e); if (Object.getOwnPropertySymbols) { var o = Object.getOwnPropertySymbols(e); r && (o = o.filter(function (r) { return Object.getOwnPropertyDescriptor(e, r).enumerable; })), t.push.apply(t, o); } return t; }
23
+ function _objectSpread(e) { for (var r = 1; r < arguments.length; r++) { var t = null != arguments[r] ? arguments[r] : {}; r % 2 ? ownKeys(Object(t), !0).forEach(function (r) { _defineProperty(e, r, t[r]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys(Object(t)).forEach(function (r) { Object.defineProperty(e, r, Object.getOwnPropertyDescriptor(t, r)); }); } return e; }
24
+ function _defineProperty(e, r, t) { return (r = _toPropertyKey(r)) in e ? Object.defineProperty(e, r, { value: t, enumerable: !0, configurable: !0, writable: !0 }) : e[r] = t, e; }
25
+ function _toPropertyKey(t) { var i = _toPrimitive(t, "string"); return "symbol" == _typeof(i) ? i : i + ""; }
26
+ function _toPrimitive(t, r) { if ("object" != _typeof(t) || !t) return t; var e = t[Symbol.toPrimitive]; if (void 0 !== e) { var i = e.call(t, r || "default"); if ("object" != _typeof(i)) return i; throw new TypeError("@@toPrimitive must return a primitive value."); } return ("string" === r ? String : Number)(t); }
27
+ function _slicedToArray(r, e) { return _arrayWithHoles(r) || _iterableToArrayLimit(r, e) || _unsupportedIterableToArray(r, e) || _nonIterableRest(); }
28
+ 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."); }
29
+ function _unsupportedIterableToArray(r, a) { if (r) { if ("string" == typeof r) return _arrayLikeToArray(r, a); var t = {}.toString.call(r).slice(8, -1); return "Object" === t && r.constructor && (t = r.constructor.name), "Map" === t || "Set" === t ? Array.from(r) : "Arguments" === t || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(t) ? _arrayLikeToArray(r, a) : void 0; } }
30
+ function _arrayLikeToArray(r, a) { (null == a || a > r.length) && (a = r.length); for (var e = 0, n = Array(a); e < a; e++) n[e] = r[e]; return n; }
31
+ function _iterableToArrayLimit(r, l) { var t = null == r ? null : "undefined" != typeof Symbol && r[Symbol.iterator] || r["@@iterator"]; if (null != t) { var e, n, i, u, a = [], f = !0, o = !1; try { if (i = (t = t.call(r)).next, 0 === l) { if (Object(t) !== t) return; f = !1; } else for (; !(f = (e = i.call(t)).done) && (a.push(e.value), a.length !== l); f = !0); } catch (r) { o = !0, n = r; } finally { try { if (!f && null != t["return"] && (u = t["return"](), Object(u) !== u)) return; } finally { if (o) throw n; } } return a; } }
32
+ function _arrayWithHoles(r) { if (Array.isArray(r)) return r; }
33
+ 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); }
34
+ var getHomeTab = exports.getHomeTab = function getHomeTab() {
35
+ var homeUrl = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : '/';
36
+ return {
37
+ title: 'Home',
38
+ id: 0,
39
+ url: homeUrl
40
+ };
41
+ };
42
+ var getUserDetailsFromToken = exports.getUserDetailsFromToken = function getUserDetailsFromToken(token) {
43
+ if (token) {
44
+ try {
45
+ return JSON.parse(window.atob(token.split('.')[1].replace(/-/g, "+").replace(/_/g, "/")));
46
+ } catch (error) {
47
+ // ignore
48
+ }
49
+ }
50
+ return null;
51
+ };
52
+ var isEmpty = exports.isEmpty = function isEmpty(value) {
53
+ if (value === null) return true;
54
+ if (typeof value === 'undefined') return true;
55
+ if (typeof value === 'string' && value.trim().length === 0) return true;
56
+ if (_typeof(value) === 'object') {
57
+ if (Array.isArray(value) && value.length === 0) {
58
+ return true;
59
+ } else {
60
+ return Object.keys(value).length === 0;
61
+ }
62
+ }
63
+ return false;
64
+ };
65
+ function findBestMatchFromPages(pages, pathname) {
66
+ // Check for exact match first
67
+ var match = pages.find(function (page) {
68
+ return page.url === pathname;
69
+ });
70
+ if (match) {
71
+ return match;
72
+ }
73
+
74
+ // Split the pathname into segments
75
+ var pathSegments = pathname.split('/').filter(function (segment) {
76
+ return segment;
77
+ });
78
+
79
+ // Trim the pathname and check for matches
80
+ var _loop = function _loop() {
81
+ var currentPath = '/' + pathSegments.join('/');
82
+ match = pages.find(function (page) {
83
+ return page.url.includes(currentPath);
84
+ });
85
+ if (match) {
86
+ return {
87
+ v: match
88
+ };
89
+ }
90
+ pathSegments.pop();
91
+ },
92
+ _ret;
93
+ while (pathSegments.length > 0) {
94
+ _ret = _loop();
95
+ if (_ret) return _ret.v;
96
+ }
97
+ return null; // No match found
98
+ }
99
+ function isChildPath(parentPathName, childPathName) {
100
+ // Check for exact match first
101
+ if (parentPathName === childPathName) {
102
+ return true;
103
+ }
104
+
105
+ // Split the childPathName into segments
106
+ var pathSegments = childPathName.split('/').filter(function (segment) {
107
+ return segment;
108
+ });
109
+
110
+ // Trim the childPathName and check for matches
111
+ while (pathSegments.length > 0) {
112
+ var currentPath = '/' + pathSegments.join('/');
113
+ if (parentPathName.includes(currentPath)) {
114
+ return true;
115
+ }
116
+ pathSegments.pop();
117
+ }
118
+ return false; // No match found
119
+ }
120
+ var getUniqueId = exports.getUniqueId = function getUniqueId() {
121
+ return Math.random().toString(36).substring(2, 9);
122
+ };
123
+ function reorder(list, startIndex, finishIndex) {
124
+ if (startIndex === -1 || finishIndex === -1) {
125
+ return list;
126
+ }
127
+ var result = Array.from(list);
128
+ var _result$splice = result.splice(startIndex, 1),
129
+ _result$splice2 = _slicedToArray(_result$splice, 1),
130
+ removed = _result$splice2[0];
131
+ result.splice(finishIndex, 0, removed);
132
+ return result;
133
+ }
134
+ var splitSubTabs = exports.splitSubTabs = function splitSubTabs(subTabs) {
135
+ var itemsWithOrderZero = [];
136
+ var itemsWithNonZeroOrder = [];
137
+ subTabs.forEach(function (item) {
138
+ if (item.order === 0) {
139
+ itemsWithOrderZero.push(item);
140
+ } else {
141
+ itemsWithNonZeroOrder.push(item);
142
+ }
143
+ });
144
+ return {
145
+ itemsWithOrderZero: itemsWithOrderZero,
146
+ itemsWithNonZeroOrder: itemsWithNonZeroOrder
147
+ };
148
+ };
149
+ function reorderSubTabs(array, sourceIndex, destinationIndex) {
150
+ var _splitSubTabs = splitSubTabs(array),
151
+ itemsWithOrderZero = _splitSubTabs.itemsWithOrderZero,
152
+ itemsWithNonZeroOrder = _splitSubTabs.itemsWithNonZeroOrder;
153
+ var _itemsWithNonZeroOrde = itemsWithNonZeroOrder.splice(sourceIndex, 1),
154
+ _itemsWithNonZeroOrde2 = _slicedToArray(_itemsWithNonZeroOrde, 1),
155
+ movedItem = _itemsWithNonZeroOrde2[0];
156
+ itemsWithNonZeroOrder.splice(destinationIndex, 0, movedItem);
157
+ return itemsWithOrderZero.concat(itemsWithNonZeroOrder.map(function (item, index) {
158
+ return _objectSpread(_objectSpread({}, item), {}, {
159
+ order: index + 1
160
+ });
161
+ }));
162
+ }
163
+ function isDev() {
164
+ return process.env.REACT_APP_CUSTOM_NODE_ENV === 'development';
165
+ }
166
+ function removeSpaces(str) {
167
+ return str.replace(/\s/g, '');
168
+ }
169
+ var sortByOrder = exports.sortByOrder = function sortByOrder(a, b) {
170
+ if (a.order === b.order) return a.open_order - b.open_order;
171
+ return a.order - b.order;
172
+ };
173
+ function addOrUpdateSubTab() {
174
+ var _ref = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {},
175
+ array = _ref.array,
176
+ newTab = _ref.newTab,
177
+ _ref$maxOrder = _ref.maxOrder,
178
+ maxOrder = _ref$maxOrder === void 0 ? 0 : _ref$maxOrder,
179
+ _ref$sort = _ref.sort,
180
+ sort = _ref$sort === void 0 ? false : _ref$sort;
181
+ var existingObjectIndex = array.findIndex(function (obj) {
182
+ return obj.id === newTab.id;
183
+ });
184
+ if (existingObjectIndex !== -1) {
185
+ var existingTab = _objectSpread(_objectSpread({}, array[existingObjectIndex]), newTab);
186
+ var oldOrder = existingTab.order;
187
+ var oldOpenOrder = existingTab.open_order || array.length;
188
+ var minLegth = Math.min(array.length, maxOrder);
189
+ if (existingTab.order !== 0 && oldOrder === existingTab.order) {
190
+ return array.map(function (tab) {
191
+ return tab.id === existingTab.id ? _objectSpread(_objectSpread({}, existingTab), {}, {
192
+ open_order: 1
193
+ }) : _objectSpread(_objectSpread({}, tab), {}, {
194
+ open_order: tab.open_order < oldOpenOrder ? tab.open_order + 1 : tab.open_order
195
+ });
196
+ });
197
+ }
198
+
199
+ // Update the existing object
200
+ array[existingObjectIndex] = _objectSpread(_objectSpread({}, existingTab), {}, {
201
+ order: oldOrder === 0 ? minLegth : oldOrder,
202
+ open_order: 1
203
+ });
204
+
205
+ // Increment the order of other objects with less than the old order
206
+ for (var i = 0; i < array.length; i++) {
207
+ if (array[i].id !== existingTab.id) {
208
+ // if ((oldOrder !== 0 ? array[i].order <= oldOrder : true)) {
209
+
210
+ if (array[i].open_order === minLegth) {
211
+ // array[i].order = (array[i].order + 1) % (maxOrder + 1);
212
+ array[i].order = 0;
213
+ }
214
+ if (array[i].order === minLegth) {
215
+ array[i].order -= 1;
216
+ }
217
+ // if (array[i].open_order >= maxOrder) {
218
+ // array[i].order = 0;
219
+ // } else {
220
+ // array[i].order += 1;
221
+ // }
222
+ array[i].open_order += 1;
223
+ }
224
+ }
225
+ } else {
226
+ // New object, set its order and insert at the start
227
+ newTab.order = array.length + 1;
228
+ newTab.open_order = 1;
229
+ array.push(newTab);
230
+
231
+ // Update the order of existing objects
232
+ for (var _i = 0; _i < array.length - 1; _i++) {
233
+ // array[i].order = (array[i].order + 1) % (maxOrder + 1);
234
+ if (array[_i].open_order >= maxOrder) {
235
+ array[_i].order = 0;
236
+ }
237
+ // array[i].order = array[i].order === 0 || array[i].order + 1 > maxOrder ? 0 : array[i].order + 1;
238
+ array[_i].open_order += 1;
239
+ }
240
+ }
241
+ array.sort(sortByOrder);
242
+ return array;
243
+ }
244
+ function getTextWidth(text, font) {
245
+ // Create a canvas element
246
+ var canvas = document.createElement('canvas');
247
+ var context = canvas.getContext('2d');
248
+
249
+ // Set the font properties
250
+ context.font = font;
251
+
252
+ // Measure the text width
253
+ var metrics = context.measureText(text);
254
+ return Math.ceil(metrics.width * 100) / 100;
255
+ }
256
+ function calculateWidth() {
257
+ var _ref2 = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {},
258
+ text = _ref2.text,
259
+ _ref2$hasAvatar = _ref2.hasAvatar,
260
+ hasAvatar = _ref2$hasAvatar === void 0 ? false : _ref2$hasAvatar,
261
+ _ref2$addMargin = _ref2.addMargin,
262
+ addMargin = _ref2$addMargin === void 0 ? false : _ref2$addMargin,
263
+ _ref2$hasToolbarButto = _ref2.hasToolbarButton,
264
+ hasToolbarButton = _ref2$hasToolbarButto === void 0 ? false : _ref2$hasToolbarButto,
265
+ _ref2$hasCloseButton = _ref2.hasCloseButton,
266
+ hasCloseButton = _ref2$hasCloseButton === void 0 ? false : _ref2$hasCloseButton;
267
+ var textWidth = getTextWidth(text, _Constants.fontStyle);
268
+ var avatarWidth = hasAvatar ? _Constants.AvatarSize : 0;
269
+ var marginWidth = addMargin ? _Constants.MarginLeft : 0;
270
+ var toolbarButtonWidth = hasToolbarButton ? _Constants.ToolbarButtonWidth : 0;
271
+ var closeButtonWidth = hasCloseButton ? _Constants.CloseButtonWidth : 0;
272
+ return textWidth + _Constants.SubTabPadding + marginWidth + avatarWidth + toolbarButtonWidth + closeButtonWidth;
273
+ }
274
+ function compareDecimals(num1, num2) {
275
+ var decimalPlaces = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : 1;
276
+ // Convert numbers to strings
277
+ var strNum1 = num1.toFixed(decimalPlaces + 1);
278
+ var strNum2 = num2.toFixed(decimalPlaces + 1);
279
+
280
+ // Extract the relevant portion
281
+ strNum1 = strNum1.substring(0, strNum1.indexOf('.') + decimalPlaces + 1);
282
+ strNum2 = strNum2.substring(0, strNum2.indexOf('.') + decimalPlaces + 1);
283
+ if (strNum1 === strNum2) {
284
+ return 0; // numbers are equal
285
+ } else if (+strNum1 < +strNum2) {
286
+ return -1; // num1 is less than num2
287
+ } else {
288
+ return 1; // num1 is greater than num2
289
+ }
290
+ }
291
+ function getCssUnitDifference(value1, value2) {
292
+ var includeUnit = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : true;
293
+ // A regex pattern to match the number and the unit
294
+ var regex = /^(-?\d*\.?\d+)([a-zA-Z%]+)$/;
295
+ var match1 = value1.match(regex);
296
+ var match2 = value2.match(regex);
297
+ if (!match1 || !match2) {
298
+ throw new Error("Invalid CSS value provided.");
299
+ }
300
+ var number1 = parseFloat(match1[1]);
301
+ var unit1 = match1[2];
302
+ var number2 = parseFloat(match2[1]);
303
+ var unit2 = match2[2];
304
+
305
+ // Check if both values have the same unit
306
+ if (unit1 !== unit2) {
307
+ throw new Error("CSS units do not match.");
308
+ }
309
+ var difference = number1 - number2;
310
+ return "".concat(difference).concat(includeUnit ? unit1 : '');
311
+ }
312
+ var getTitle = exports.getTitle = function getTitle(tab) {
313
+ return (tab.title || tab.name || (tab !== null && tab !== void 0 && tab.firstName ? "".concat(tab.firstName, " ").concat(tab.lastName || '') : 'Untitled')).trim();
314
+ };
315
+
316
+ // export function checkPrivilege(privileges, access) {
317
+ // const accessArray = Array.isArray(access) ? access : [access];
318
+
319
+ // return accessArray.some(item =>
320
+ // Object.keys(privileges).includes(item) ||
321
+ // Object.values(privileges).flat().includes(item)
322
+ // );
323
+ // }
324
+
325
+ // Normalize URL function to handle different representations of the same URL
326
+ var normalizeUrl = exports.normalizeUrl = function normalizeUrl(url) {
327
+ if (!url) return null;
328
+ try {
329
+ // Create URL object to standardize format
330
+ var urlObj = new URL(url, window.location.origin);
331
+ return urlObj.pathname;
332
+ } catch (e) {
333
+ console.warn("Error normalizing URL:", e);
334
+ return url; // Fallback to original URL if parsing fails
335
+ }
336
+ };
@@ -0,0 +1,116 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ exports["default"] = void 0;
7
+ 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); }
8
+ function _classCallCheck(a, n) { if (!(a instanceof n)) throw new TypeError("Cannot call a class as a function"); }
9
+ function _defineProperties(e, r) { for (var t = 0; t < r.length; t++) { var o = r[t]; o.enumerable = o.enumerable || !1, o.configurable = !0, "value" in o && (o.writable = !0), Object.defineProperty(e, _toPropertyKey(o.key), o); } }
10
+ function _createClass(e, r, t) { return r && _defineProperties(e.prototype, r), t && _defineProperties(e, t), Object.defineProperty(e, "prototype", { writable: !1 }), e; }
11
+ function _toPropertyKey(t) { var i = _toPrimitive(t, "string"); return "symbol" == _typeof(i) ? i : i + ""; }
12
+ function _toPrimitive(t, r) { if ("object" != _typeof(t) || !t) return t; var e = t[Symbol.toPrimitive]; if (void 0 !== e) { var i = e.call(t, r || "default"); if ("object" != _typeof(i)) return i; throw new TypeError("@@toPrimitive must return a primitive value."); } return ("string" === r ? String : Number)(t); }
13
+ var EventEmitter = exports["default"] = /*#__PURE__*/function () {
14
+ function EventEmitter() {
15
+ _classCallCheck(this, EventEmitter);
16
+ /** @type {Map<string|symbol, Function[]>} */
17
+ this.events = new Map();
18
+ }
19
+
20
+ /**
21
+ * Register an event handler for the given type.
22
+ * @param {string|symbol} type Type of event to listen for, or `'*'` for all events
23
+ * @param {Function} handler Function to call in response to given event
24
+ * @return {Function} A function that will unregister this event handler when called
25
+ */
26
+ return _createClass(EventEmitter, [{
27
+ key: "subscribe",
28
+ value: function subscribe(type, handler) {
29
+ var _this = this;
30
+ var handlers = this.events.get(type);
31
+ if (handlers) {
32
+ handlers.push(handler);
33
+ } else {
34
+ this.events.set(type, [handler]);
35
+ }
36
+ return function () {
37
+ _this.unsubscribe(type, handler);
38
+ };
39
+ }
40
+
41
+ /**
42
+ * Remove an event handler for the given type.
43
+ * If `handler` is omitted, all handlers of the given type are removed.
44
+ * @param {string|symbol} type Type of event to unregister `handler` from (`'*'` to remove a wildcard handler)
45
+ * @param {Function} [handler] Handler function to remove
46
+ */
47
+ }, {
48
+ key: "unsubscribe",
49
+ value: function unsubscribe(type, handler) {
50
+ var handlers = this.events.get(type);
51
+ if (handlers) {
52
+ if (handler) {
53
+ handlers.splice(handlers.indexOf(handler) >>> 0, 1);
54
+ } else {
55
+ this.events.set(type, []);
56
+ }
57
+ }
58
+ }
59
+
60
+ /**
61
+ * Invoke all handlers for the given type.
62
+ * If present, `'*'` handlers are invoked after type-matched handlers.
63
+ *
64
+ * Note: Manually firing '*' handlers is not supported.
65
+ *
66
+ * @param {string|symbol} type The event type to invoke
67
+ * @param {any} [evt] Any value (object is recommended and powerful), passed to each handler
68
+ */
69
+ }, {
70
+ key: "emit",
71
+ value: function emit(type, evt) {
72
+ var handlers = this.events.get(type);
73
+ if (handlers) {
74
+ handlers.slice().map(function (handler) {
75
+ handler(evt);
76
+ return false;
77
+ });
78
+ }
79
+ handlers = this.events.get("*");
80
+ if (handlers) {
81
+ handlers.slice().map(function (handler) {
82
+ handler(type, evt);
83
+ return false;
84
+ });
85
+ }
86
+ }
87
+
88
+ /**
89
+ * Register an event handler for once of the given type.
90
+ * @param {string|symbol} type Type of event to listen for an event
91
+ * @param {Function} handler Function to call in response to given event
92
+ */
93
+ }, {
94
+ key: "once",
95
+ value: function once(type, handler) {
96
+ var unsubscribe = this.subscribe(type, function (evt) {
97
+ unsubscribe();
98
+ handler(evt);
99
+ });
100
+ }
101
+
102
+ /**
103
+ * Remove all event handlers.
104
+ * @param {string|symbol} [type] Type of event to unregister `handler` from (`'*'` to remove a wildcard handler)
105
+ */
106
+ }, {
107
+ key: "clear",
108
+ value: function clear(type) {
109
+ if (type) {
110
+ this.events["delete"](type);
111
+ } else {
112
+ this.events.clear();
113
+ }
114
+ }
115
+ }]);
116
+ }();
@@ -0,0 +1,3 @@
1
+ <svg width="8" height="10" viewBox="0 0 8 10" fill="none" xmlns="http://www.w3.org/2000/svg">
2
+ <path d="M4.048 10L8 5.55556L4.8 5.55556L4.8 0H3.2L3.2 5.55556H0L4.048 10Z" fill="white"/>
3
+ </svg>
@@ -0,0 +1 @@
1
+ <svg id="Layer_1" data-name="Layer 1" xmlns="http://www.w3.org/2000/svg" viewBox="0 0 9 17.01"><path id="fa-angle-right_1_copy" data-name="fa-angle-right1 copy" d="M8.85,8.89l-7.21,8a.47.47,0,0,1-.64.07l-.07-.07L.16,16a.56.56,0,0,1,0-.78L6.24,8.5.16,1.8A.56.56,0,0,1,.16,1L.93.17A.45.45,0,0,1,1.57.1a.23.23,0,0,1,.07.07L8.85,8.11a.58.58,0,0,1,0,.78Z" transform="translate(0 0)" style="fill-rule:evenodd"/></svg>
@@ -0,0 +1,3 @@
1
+ <svg id="icon-close.3197178d" xmlns="http://www.w3.org/2000/svg" width="12" height="12" viewBox="0 0 12 12">
2
+ <path id="Path_14" data-name="Path 14" d="M19.05,8.764,17.336,7.05,13.05,11.336,8.764,7.05,7.05,8.764l4.286,4.286L7.05,17.336,8.764,19.05l4.286-4.286,4.286,4.286,1.714-1.714L14.764,13.05Z" transform="translate(-7.05 -7.05)" fill="#fff"/>
3
+ </svg>
@@ -0,0 +1,10 @@
1
+ <svg xmlns="http://www.w3.org/2000/svg" width="12" height="12" viewBox="0 0 12 12">
2
+ <defs>
3
+ <style>
4
+ .cls-1 {
5
+ fill-rule: evenodd;
6
+ }
7
+ </style>
8
+ </defs>
9
+ <path class="cls-1" d="M8.023,7.543H8.571L12,10.971,10.971,12,7.543,8.571V8.023L7.337,7.817a4.292,4.292,0,0,1-2.88,1.1A4.457,4.457,0,1,1,8.914,4.457a4.292,4.292,0,0,1-1.1,2.88ZM4.457,1.371A3.086,3.086,0,1,0,7.543,4.457,3.073,3.073,0,0,0,4.457,1.371Z"/>
10
+ </svg>
@@ -0,0 +1,6 @@
1
+ <svg width="36" height="30" viewBox="0 0 36 30" fill="none" xmlns="http://www.w3.org/2000/svg">
2
+ <path d="M8 4.00098C8 2.89641 8.89543 2.00098 10 2.00098H32C33.1046 2.00098 34 2.89641 34 4.00098V26.001C34 27.1055 33.1046 28.001 32 28.001H10C8.89543 28.001 8 27.1055 8 26.001V4.00098Z" fill="#1D2024"/>
3
+ <path fill-rule="evenodd" clip-rule="evenodd" d="M10 0.000976562H32C34.2091 0.000976562 36 1.79184 36 4.00098V26.001C36 28.2101 34.2091 30.001 32 30.001H10C7.79086 30.001 6 28.2101 6 26.001V4.00098C6 1.79184 7.79086 0.000976562 10 0.000976562ZM10 2.00098C8.89543 2.00098 8 2.89641 8 4.00098V26.001C8 27.1055 8.89543 28.001 10 28.001H32C33.1046 28.001 34 27.1055 34 26.001V4.00098C34 2.89641 33.1046 2.00098 32 2.00098H10Z" fill="black"/>
4
+ <path d="M2 4.00098C2 2.89641 2.89543 2.00098 4 2.00098H26C27.1046 2.00098 28 2.89641 28 4.00098V26.001C28 27.1055 27.1046 28.001 26 28.001H4C2.89543 28.001 2 27.1055 2 26.001V4.00098Z" fill="#1D2024"/>
5
+ <path fill-rule="evenodd" clip-rule="evenodd" d="M4 0.000976562H26C28.2091 0.000976562 30 1.79184 30 4.00098V26.001C30 28.2101 28.2091 30.001 26 30.001H4C1.79086 30.001 0 28.2101 0 26.001V4.00098C0 1.79184 1.79086 0.000976562 4 0.000976562ZM4 2.00098C2.89543 2.00098 2 2.89641 2 4.00098V26.001C2 27.1055 2.89543 28.001 4 28.001H26C27.1046 28.001 28 27.1055 28 26.001V4.00098C28 2.89641 27.1046 2.00098 26 2.00098H4Z" fill="black"/>
6
+ </svg>
package/dist/index.js ADDED
@@ -0,0 +1,20 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ Object.defineProperty(exports, "SuperTabs", {
7
+ enumerable: true,
8
+ get: function get() {
9
+ return _SuperTabs["default"];
10
+ }
11
+ });
12
+ Object.defineProperty(exports, "TabProvider", {
13
+ enumerable: true,
14
+ get: function get() {
15
+ return _TabContext.TabProvider;
16
+ }
17
+ });
18
+ var _SuperTabs = _interopRequireDefault(require("./SuperTabs"));
19
+ var _TabContext = require("./components/SuperTabs/TabContext");
20
+ function _interopRequireDefault(e) { return e && e.__esModule ? e : { "default": e }; }
@@ -0,0 +1,37 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ exports["default"] = void 0;
7
+ var _react = require("react");
8
+ /**
9
+ * Custom hook to store the previous value of a state or prop.
10
+ *
11
+ * @param {*} value - The current value you want to track.
12
+ * @returns {*} - The previous value before the last render.
13
+ *
14
+ * 👉 Usage:
15
+ * const prevCount = usePrevious(count);
16
+ *
17
+ * Example:
18
+ * - On first render:
19
+ * count = 0, prevCount = undefined
20
+ * - After setCount(1):
21
+ * count = 1, prevCount = 0
22
+ * - After setCount(2):
23
+ * count = 2, prevCount = 1
24
+ */
25
+ function usePrevious(value) {
26
+ // A ref object holds a mutable value across renders
27
+ var ref = (0, _react.useRef)();
28
+ (0, _react.useEffect)(function () {
29
+ // After every render where `value` changes,
30
+ // update the ref to hold the latest value.
31
+ ref.current = value;
32
+ }, [value]); // runs whenever `value` changes
33
+
34
+ // Return whatever was stored before this render
35
+ return ref.current;
36
+ }
37
+ var _default = exports["default"] = usePrevious;
package/package.json ADDED
@@ -0,0 +1,33 @@
1
+ {
2
+ "name": "@bydata/react-supertabs",
3
+ "version": "1.1.0",
4
+ "description": "A customizable React super tabs component.",
5
+ "main": "dist/index.js",
6
+ "module": "dist/index.js",
7
+ "files": [
8
+ "dist",
9
+ "README.md"
10
+ ],
11
+ "scripts": {
12
+ "test": "echo \"Error: no test specified\" && exit 1",
13
+ "build": "rm -rf dist && NODE_ENV=production babel src --out-dir dist --copy-files"
14
+ },
15
+ "keywords": [],
16
+ "author": "",
17
+ "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"
28
+ },
29
+ "dependencies": {
30
+ "@babel/runtime": "^7.16.7",
31
+ "next-transpile-modules": "^9.0.0"
32
+ }
33
+ }