@synerise/ds-tabs 0.17.7 → 0.17.9

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,22 @@
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.17.9](https://github.com/synerise/synerise-design/compare/@synerise/ds-tabs@0.17.8...@synerise/ds-tabs@0.17.9) (2024-11-29)
7
+
8
+ **Note:** Version bump only for package @synerise/ds-tabs
9
+
10
+
11
+
12
+
13
+
14
+ ## [0.17.8](https://github.com/synerise/synerise-design/compare/@synerise/ds-tabs@0.17.7...@synerise/ds-tabs@0.17.8) (2024-11-28)
15
+
16
+ **Note:** Version bump only for package @synerise/ds-tabs
17
+
18
+
19
+
20
+
21
+
6
22
  ## [0.17.7](https://github.com/synerise/synerise-design/compare/@synerise/ds-tabs@0.17.6...@synerise/ds-tabs@0.17.7) (2024-11-21)
7
23
 
8
24
  **Note:** Version bump only for package @synerise/ds-tabs
package/dist/Tab/Tab.js CHANGED
@@ -1,56 +1,46 @@
1
1
  function _extends() { _extends = Object.assign ? Object.assign.bind() : function (target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]; for (var key in source) { if (Object.prototype.hasOwnProperty.call(source, key)) { target[key] = source[key]; } } } return target; }; return _extends.apply(this, arguments); }
2
-
3
2
  import React, { useState } from 'react';
4
3
  import classNames from 'classnames';
5
4
  import Icon from '@synerise/ds-icon';
6
5
  import Tooltip from '@synerise/ds-tooltip';
7
6
  import * as S from './Tab.styles';
8
-
9
7
  var Tab = function Tab(_ref) {
10
8
  var index = _ref.index,
11
- label = _ref.label,
12
- icon = _ref.icon,
13
- isActive = _ref.isActive,
14
- disabled = _ref.disabled,
15
- onClick = _ref.onClick,
16
- forwardedRef = _ref.forwardedRef,
17
- underscore = _ref.underscore,
18
- className = _ref.className,
19
- block = _ref.block,
20
- suffixel = _ref.suffixel,
21
- tooltip = _ref.tooltip,
22
- tooltipProps = _ref.tooltipProps;
23
-
9
+ label = _ref.label,
10
+ icon = _ref.icon,
11
+ isActive = _ref.isActive,
12
+ disabled = _ref.disabled,
13
+ onClick = _ref.onClick,
14
+ forwardedRef = _ref.forwardedRef,
15
+ underscore = _ref.underscore,
16
+ className = _ref.className,
17
+ block = _ref.block,
18
+ suffixel = _ref.suffixel,
19
+ tooltip = _ref.tooltip,
20
+ tooltipProps = _ref.tooltipProps;
24
21
  var _useState = useState(false),
25
- isPressed = _useState[0],
26
- setPressed = _useState[1];
27
-
22
+ isPressed = _useState[0],
23
+ setPressed = _useState[1];
28
24
  var handleClick = function handleClick() {
29
25
  onClick(index);
30
26
  };
31
-
32
27
  var handleMouseDown = function handleMouseDown() {
33
28
  setPressed(true);
34
29
  };
35
-
36
30
  var handleMouseUp = function handleMouseUp() {
37
31
  setPressed(false);
38
32
  };
39
-
40
33
  var containerClasses = classNames(className, {
41
34
  underscore: underscore,
42
35
  active: isActive,
43
36
  pressed: isPressed
44
37
  });
45
-
46
38
  var renderSuffixel = function renderSuffixel() {
47
39
  if (typeof suffixel === 'string' || typeof suffixel === 'number') {
48
40
  return /*#__PURE__*/React.createElement(S.SuffixWrapper, null, suffixel);
49
41
  }
50
-
51
42
  return /*#__PURE__*/React.createElement(S.DefaultSuffixWrapper, null, suffixel);
52
43
  };
53
-
54
44
  var tabContent = /*#__PURE__*/React.createElement(S.BlockContentWrapper, {
55
45
  block: block
56
46
  }, /*#__PURE__*/React.createElement(S.TabContent, {
@@ -79,7 +69,6 @@ var Tab = function Tab(_ref) {
79
69
  title: tooltip
80
70
  }, tooltipProps), tabContent) : tabContent);
81
71
  };
82
-
83
72
  Tab.defaultProps = {
84
73
  underscore: true
85
74
  };
@@ -18,11 +18,9 @@ export var TabContent = styled.div.withConfig({
18
18
  displayName: "Tabstyles__TabContent",
19
19
  componentId: "sc-8a5swe-2"
20
20
  })(["display:flex;flex-direction:row;align-self:center;align-items:center;justify-content:flex-start;height:24px;overflow:hidden;text-overflow:ellipsis;"]);
21
-
22
21
  var applyBlockStyles = function applyBlockStyles(props) {
23
22
  return "\n margin-right: 0;\n flex: 1;\n " + TabContent + " {\n border-left: 5px solid transparent;\n border-right: 5px solid transparent;\n }\n &: after {\n background-color:" + props.theme.palette['grey-200'] + ";\n height:1px;\n }\n &: hover {\n &::after {\n background-color:" + props.theme.palette['grey-300'] + ";\n height: 1px;\n }\n }\n &:focus:active:not(:hover) {\n &::after {\n background-color:" + props.theme.palette['blue-600'] + ";\n background-image:none;\n height: 1px;\n }\n }\n &.pressed {\n && {\n &::after {\n height: 1px;\n }\n }\n }\n";
24
23
  };
25
-
26
24
  export var TabContainer = styled.button.withConfig({
27
25
  displayName: "Tabstyles__TabContainer",
28
26
  componentId: "sc-8a5swe-3"
package/dist/Tabs.js CHANGED
@@ -1,20 +1,12 @@
1
1
  var _excluded = ["ref"],
2
- _excluded2 = ["ref"];
3
-
2
+ _excluded2 = ["ref"];
4
3
  function _extends() { _extends = Object.assign ? Object.assign.bind() : function (target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]; for (var key in source) { if (Object.prototype.hasOwnProperty.call(source, key)) { target[key] = source[key]; } } } return target; }; return _extends.apply(this, arguments); }
5
-
6
4
  function _objectWithoutPropertiesLoose(source, excluded) { if (source == null) return {}; var target = {}; var sourceKeys = Object.keys(source); var key, i; for (i = 0; i < sourceKeys.length; i++) { key = sourceKeys[i]; if (excluded.indexOf(key) >= 0) continue; target[key] = source[key]; } return target; }
7
-
8
5
  function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); enumerableOnly && (symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; })), keys.push.apply(keys, symbols); } return keys; }
9
-
10
6
  function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = null != arguments[i] ? arguments[i] : {}; i % 2 ? ownKeys(Object(source), !0).forEach(function (key) { _defineProperty(target, key, source[key]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)) : ownKeys(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } return target; }
11
-
12
7
  function _defineProperty(obj, key, value) { key = _toPropertyKey(key); if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }
13
-
14
8
  function _toPropertyKey(arg) { var key = _toPrimitive(arg, "string"); return typeof key === "symbol" ? key : String(key); }
15
-
16
9
  function _toPrimitive(input, hint) { if (typeof input !== "object" || input === null) return input; var prim = input[Symbol.toPrimitive]; if (prim !== undefined) { var res = prim.call(input, hint || "default"); if (typeof res !== "object") return res; throw new TypeError("@@toPrimitive must return a primitive value."); } return (hint === "string" ? String : Number)(input); }
17
-
18
10
  import React, { useCallback, createRef, useMemo, useState, useRef, useEffect } from 'react';
19
11
  import { debounce } from 'lodash';
20
12
  import { theme } from '@synerise/ds-core';
@@ -29,48 +21,37 @@ var DROPDOWN_OVERLAY_STYLE = {
29
21
  boxShadow: '0 4px 12px 0 rgba(35, 41, 54, 0.07)',
30
22
  zIndex: parseInt(theme.variables['zindex-modal'], 10) - 1
31
23
  };
32
-
33
24
  var Tabs = function Tabs(_ref) {
34
25
  var activeTab = _ref.activeTab,
35
- tabs = _ref.tabs,
36
- handleTabClick = _ref.handleTabClick,
37
- configuration = _ref.configuration,
38
- underscore = _ref.underscore,
39
- block = _ref.block;
40
-
26
+ tabs = _ref.tabs,
27
+ handleTabClick = _ref.handleTabClick,
28
+ configuration = _ref.configuration,
29
+ underscore = _ref.underscore,
30
+ block = _ref.block;
41
31
  var _useState = useState(0),
42
- containerWidth = _useState[0],
43
- setContainerWidth = _useState[1];
44
-
32
+ containerWidth = _useState[0],
33
+ setContainerWidth = _useState[1];
45
34
  var containerRef = useRef(null);
46
35
  var helperContainerRef = useRef(null);
47
-
48
36
  var _useResizeObserver = useResizeObserver(containerRef),
49
- width = _useResizeObserver.width;
50
-
37
+ width = _useResizeObserver.width;
51
38
  var _useResizeObserver2 = useResizeObserver(helperContainerRef),
52
- helperWidth = _useResizeObserver2.width;
53
-
39
+ helperWidth = _useResizeObserver2.width;
54
40
  var _useState2 = useState([]),
55
- items = _useState2[0],
56
- setItems = _useState2[1];
57
-
41
+ items = _useState2[0],
42
+ setItems = _useState2[1];
58
43
  var _useState3 = useState([]),
59
- itemsWidths = _useState3[0],
60
- setItemsWidths = _useState3[1];
61
-
44
+ itemsWidths = _useState3[0],
45
+ setItemsWidths = _useState3[1];
62
46
  var _useState4 = useState([]),
63
- visibleTabs = _useState4[0],
64
- setVisibleTabs = _useState4[1];
65
-
47
+ visibleTabs = _useState4[0],
48
+ setVisibleTabs = _useState4[1];
66
49
  var _useState5 = useState(false),
67
- isDropdownVisible = _useState5[0],
68
- setIsDropdownVisible = _useState5[1];
69
-
50
+ isDropdownVisible = _useState5[0],
51
+ setIsDropdownVisible = _useState5[1];
70
52
  var _useState6 = useState([]),
71
- hiddenTabs = _useState6[0],
72
- setHiddenTabs = _useState6[1];
73
-
53
+ hiddenTabs = _useState6[0],
54
+ setHiddenTabs = _useState6[1];
74
55
  var debouncedEventHandler = useMemo(function () {
75
56
  return debounce(function (newWidth) {
76
57
  return setContainerWidth(newWidth);
@@ -81,8 +62,8 @@ var Tabs = function Tabs(_ref) {
81
62
  }, [width, debouncedEventHandler]);
82
63
  useEffect(function () {
83
64
  var _containerRef$current;
84
-
85
- containerRef.current && setContainerWidth((_containerRef$current = containerRef.current) == null ? void 0 : _containerRef$current.offsetWidth); // eslint-disable-next-line react-hooks/exhaustive-deps
65
+ containerRef.current && setContainerWidth((_containerRef$current = containerRef.current) == null ? void 0 : _containerRef$current.offsetWidth);
66
+ // eslint-disable-next-line react-hooks/exhaustive-deps
86
67
  }, [containerRef.current]);
87
68
  useEffect(function () {
88
69
  var newTabs = tabs.map(function (tab) {
@@ -119,13 +100,12 @@ var Tabs = function Tabs(_ref) {
119
100
  } else {
120
101
  hiddenItems.push(items[index]);
121
102
  }
122
-
123
103
  tabsWidth += itemWidth;
124
104
  });
125
105
  setVisibleTabs(visibleItems);
126
106
  setHiddenTabs(hiddenItems);
127
- } // eslint-disable-next-line react-hooks/exhaustive-deps
128
-
107
+ }
108
+ // eslint-disable-next-line react-hooks/exhaustive-deps
129
109
  }, [block, itemsWidths, containerWidth]);
130
110
  var handleConfigurationAction = useCallback(function () {
131
111
  configuration && configuration.action();
@@ -135,25 +115,30 @@ var Tabs = function Tabs(_ref) {
135
115
  setIsDropdownVisible(false);
136
116
  handleTabClick(index);
137
117
  }, [handleTabClick]);
118
+ var dropdownMenuItems = hiddenTabs.map(function (item, index) {
119
+ return {
120
+ key: item.label + "-dropdown-" + index,
121
+ onClick: function onClick() {
122
+ return handleHiddenTabClick(visibleTabs.length + index);
123
+ },
124
+ disabled: item.disabled,
125
+ text: item.label
126
+ };
127
+ });
138
128
  var renderHiddenTabs = useMemo(function () {
139
129
  return /*#__PURE__*/React.createElement(S.TabsDropdownContainer, {
140
130
  "data-testid": "tabs-dropdown-container"
141
- }, hiddenTabs.length > 0 && /*#__PURE__*/React.createElement(S.DropdownMenu, null, hiddenTabs.map(function (item, index) {
142
- return /*#__PURE__*/React.createElement(S.DropdownMenuItem, {
143
- // eslint-disable-next-line react/no-array-index-key
144
- key: item.label + "-dropdown-" + index,
145
- onClick: function onClick() {
146
- return handleHiddenTabClick(visibleTabs.length + index);
147
- },
148
- disabled: item.disabled
149
- }, item.label);
150
- })), hiddenTabs.length > 0 && configuration && /*#__PURE__*/React.createElement(S.TabsDropdownDivider, null), configuration && /*#__PURE__*/React.createElement(S.DropdownMenu, null, /*#__PURE__*/React.createElement(S.DropdownMenuItem, {
151
- key: "configuration-btn",
152
- onClick: handleConfigurationAction,
153
- disabled: !!(configuration != null && configuration.disabled)
154
- }, configuration.label)));
155
- }, [hiddenTabs, configuration, handleConfigurationAction, handleHiddenTabClick, visibleTabs.length]);
156
-
131
+ }, hiddenTabs.length > 0 && /*#__PURE__*/React.createElement(S.DropdownMenu, {
132
+ dataSource: dropdownMenuItems
133
+ }), hiddenTabs.length > 0 && configuration && /*#__PURE__*/React.createElement(S.TabsDropdownDivider, null), configuration && /*#__PURE__*/React.createElement(S.DropdownMenu, {
134
+ dataSource: [{
135
+ key: 'configuration-btn',
136
+ onClick: handleConfigurationAction,
137
+ disabled: !!(configuration != null && configuration.disabled),
138
+ text: configuration.label
139
+ }]
140
+ }));
141
+ }, [hiddenTabs.length, dropdownMenuItems, configuration, handleConfigurationAction]);
157
142
  var renderDropdown = function renderDropdown() {
158
143
  return /*#__PURE__*/React.createElement(React.Fragment, null, (hiddenTabs.length || configuration) && /*#__PURE__*/React.createElement(Dropdown, {
159
144
  trigger: ['click'],
@@ -172,16 +157,13 @@ var Tabs = function Tabs(_ref) {
172
157
  component: /*#__PURE__*/React.createElement(OptionHorizontalM, null)
173
158
  }))));
174
159
  };
175
-
176
160
  var renderVisibleTabs = useMemo(function () {
177
161
  return /*#__PURE__*/React.createElement(React.Fragment, null, visibleTabs.filter(function (tab) {
178
162
  return Boolean(tab);
179
163
  }).map(function (tab, index) {
180
164
  var key = "tabs-tab-" + index;
181
-
182
165
  var ref = tab.ref,
183
- tabProps = _objectWithoutPropertiesLoose(tab, _excluded);
184
-
166
+ tabProps = _objectWithoutPropertiesLoose(tab, _excluded);
185
167
  return /*#__PURE__*/React.createElement(Tab, _extends({
186
168
  underscore: underscore,
187
169
  forwardedRef: ref,
@@ -200,10 +182,8 @@ var Tabs = function Tabs(_ref) {
200
182
  className: "ds-hidden-helper"
201
183
  }, items.map(function (tab, index) {
202
184
  var key = "tabs-tab-helper-" + index;
203
-
204
185
  var ref = tab.ref,
205
- tabProps = _objectWithoutPropertiesLoose(tab, _excluded2);
206
-
186
+ tabProps = _objectWithoutPropertiesLoose(tab, _excluded2);
207
187
  return /*#__PURE__*/React.createElement(Tab, _extends({
208
188
  className: "hidden",
209
189
  underscore: underscore,
@@ -223,7 +203,6 @@ var Tabs = function Tabs(_ref) {
223
203
  "data-popup-container": true
224
204
  }, renderVisibleTabs, renderDropdown()) : null, !block && renderHelpers);
225
205
  };
226
-
227
206
  Tabs.defaultProps = {
228
207
  underscore: true
229
208
  };
@@ -1,6 +1,6 @@
1
1
  /// <reference types="react" />
2
2
  import Button from '@synerise/ds-button';
3
- import Menu, { MenuItemProps } from '@synerise/ds-menu';
3
+ import Menu from '@synerise/ds-menu';
4
4
  export declare const TabsContainer: import("styled-components").StyledComponent<"div", any, {
5
5
  block?: boolean | undefined;
6
6
  }, never>;
@@ -30,7 +30,7 @@ export declare const ShowHiddenTabsTrigger: import("styled-components").StyledCo
30
30
  }, never>;
31
31
  export declare const HiddenTabs: import("styled-components").StyledComponent<"div", any, {}, never>;
32
32
  export declare const DropdownMenu: import("styled-components").StyledComponent<typeof Menu, any, Omit<import("antd/lib/menu").MenuProps, "footer" | "dataSource"> & {
33
- dataSource?: MenuItemProps[] | undefined;
33
+ dataSource?: import("@synerise/ds-menu").MenuItemProps[] | undefined;
34
34
  ordered?: boolean | undefined;
35
35
  asDropdownMenu?: boolean | undefined;
36
36
  showTextTooltip?: boolean | undefined;
@@ -38,4 +38,3 @@ export declare const DropdownMenu: import("styled-components").StyledComponent<t
38
38
  maxToShowItems?: number | undefined;
39
39
  texts?: Partial<import("@synerise/ds-menu").MenuTexts> | undefined;
40
40
  }, never>;
41
- export declare const DropdownMenuItem: import("styled-components").StyledComponent<import("react").FC<import("@synerise/ds-menu/dist/Elements/SubMenu/SubMenu.types").SubMenuProps & MenuItemProps>, any, MenuItemProps, never>;
@@ -35,8 +35,4 @@ export var HiddenTabs = styled.div.withConfig({
35
35
  export var DropdownMenu = styled(Menu).withConfig({
36
36
  displayName: "Tabsstyles__DropdownMenu",
37
37
  componentId: "sc-16x3i3b-5"
38
- })([""]);
39
- export var DropdownMenuItem = styled(Menu.Item).withConfig({
40
- displayName: "Tabsstyles__DropdownMenuItem",
41
- componentId: "sc-16x3i3b-6"
42
- })(["&&&{border:none;}"]);
38
+ })([""]);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@synerise/ds-tabs",
3
- "version": "0.17.7",
3
+ "version": "0.17.9",
4
4
  "description": "Tabs UI Component for the Synerise Design System",
5
5
  "license": "ISC",
6
6
  "repository": "synerise/synerise-design",
@@ -34,11 +34,11 @@
34
34
  ],
35
35
  "types": "dist/index.d.ts",
36
36
  "dependencies": {
37
- "@synerise/ds-button": "^0.21.19",
38
- "@synerise/ds-dropdown": "^0.18.24",
39
- "@synerise/ds-icon": "^0.67.0",
40
- "@synerise/ds-menu": "^0.20.6",
41
- "@synerise/ds-typography": "^0.16.6",
37
+ "@synerise/ds-button": "^0.21.21",
38
+ "@synerise/ds-dropdown": "^0.18.26",
39
+ "@synerise/ds-icon": "^0.68.0",
40
+ "@synerise/ds-menu": "^0.20.8",
41
+ "@synerise/ds-typography": "^0.16.8",
42
42
  "@synerise/ds-utils": "^0.31.2",
43
43
  "classnames": "2.3.2",
44
44
  "lodash": "^4.17.21"
@@ -49,5 +49,5 @@
49
49
  "react": ">=16.9.0 <= 17.0.2",
50
50
  "styled-components": "5.0.1"
51
51
  },
52
- "gitHead": "05f083c767e2cec3c2f91c9475aee89852a77d6c"
52
+ "gitHead": "9ebd107163650754a5f55680d62d30812d740084"
53
53
  }