linear-react-components-ui 1.1.0-beta.4 → 1.1.0-beta.5

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.
@@ -36,6 +36,10 @@ $dropdown-width: 38px;
36
36
  display: flex;
37
37
  flex: 1;
38
38
  overflow: hidden;
39
+
40
+ &.-firsttabident>.menuitem:first-child {
41
+ margin-left: 15px;
42
+ }
39
43
  }
40
44
  .menu>.menuitem {
41
45
  border-bottom: 0;
@@ -7,6 +7,6 @@ import '../@types/Icon.js';
7
7
  import '../icons/helper.js';
8
8
 
9
9
  declare const TabsContext: React__default.Context<TabsContextType>;
10
- declare function TabsProvider({ children, tabs: tabsProp, container, selectedTab, onTabChange, onTabClose, tabsWidth: tabsWidthProp, }: TabsProviderProps): JSX.Element;
10
+ declare function TabsProvider({ children, tabs: tabsProp, container, selectedTab, onTabChange, onTabClose, tabsWidth: tabsWidthProp, firstTabIdent, }: TabsProviderProps): JSX.Element;
11
11
 
12
12
  export { TabsContext, TabsProvider };
@@ -24,6 +24,7 @@ function _iterableToArrayLimit(r, l) { var t = null == r ? null : "undefined" !=
24
24
  function _arrayWithHoles(arr) { if (Array.isArray(arr)) return arr; }
25
25
  var TabsContext = exports.TabsContext = /*#__PURE__*/(0, _react.createContext)({});
26
26
  function TabsProvider(_ref) {
27
+ var _menuRef$current$clie, _menuRef$current;
27
28
  var children = _ref.children,
28
29
  tabsProp = _ref.tabs,
29
30
  container = _ref.container,
@@ -31,7 +32,9 @@ function TabsProvider(_ref) {
31
32
  selectedTab = _ref$selectedTab === void 0 ? null : _ref$selectedTab,
32
33
  onTabChange = _ref.onTabChange,
33
34
  onTabClose = _ref.onTabClose,
34
- tabsWidthProp = _ref.tabsWidth;
35
+ tabsWidthProp = _ref.tabsWidth,
36
+ _ref$firstTabIdent = _ref.firstTabIdent,
37
+ firstTabIdent = _ref$firstTabIdent === void 0 ? false : _ref$firstTabIdent;
35
38
  var _React$useState = _react["default"].useState(selectedTab),
36
39
  _React$useState2 = _slicedToArray(_React$useState, 2),
37
40
  selectedTabId = _React$useState2[0],
@@ -48,10 +51,12 @@ function TabsProvider(_ref) {
48
51
  tabs = _useState4[0],
49
52
  setTabs = _useState4[1];
50
53
  var menuRef = (0, _react.useRef)(null);
54
+ var menuSize = ((_menuRef$current$clie = (_menuRef$current = menuRef.current) === null || _menuRef$current === void 0 ? void 0 : _menuRef$current.clientWidth) !== null && _menuRef$current$clie !== void 0 ? _menuRef$current$clie : 0) - 38 - (firstTabIdent ? 15 : 0);
51
55
  var tabsWidth = (0, _react.useMemo)(function () {
52
56
  if (typeof tabsWidthProp === 'string') return tabsWidthProp === 'auto' ? 100 : parseInt(tabsWidthProp) || 100;
53
57
  return tabsWidthProp;
54
58
  }, [tabsWidthProp]);
59
+ var maxTabs = Math.round(menuSize / tabsWidth);
55
60
  if (selectedTab && selectedTab !== selectedTabId) {
56
61
  setSelectedTabId(selectedTab);
57
62
  }
@@ -60,18 +65,12 @@ function TabsProvider(_ref) {
60
65
  setSelectedTabId((_tabs$ = tabs[0]) === null || _tabs$ === void 0 ? void 0 : _tabs$.id);
61
66
  }
62
67
  var dropdownTabs = (0, _react.useMemo)(function () {
63
- var _menuRef$current$clie, _menuRef$current;
64
- var menuSize = ((_menuRef$current$clie = (_menuRef$current = menuRef.current) === null || _menuRef$current === void 0 ? void 0 : _menuRef$current.clientWidth) !== null && _menuRef$current$clie !== void 0 ? _menuRef$current$clie : 0) - 38;
65
68
  if (menuSize === 0) return [];
66
- var maxTabs = Math.floor(menuSize / tabsWidth);
67
69
  return tabs.slice(maxTabs);
68
- }, [tabs, tabsWidth, containerWidth]);
70
+ }, [tabs, maxTabs, containerWidth]);
69
71
  var menuTabs = (0, _react.useMemo)(function () {
70
- var _menuRef$current$clie2, _menuRef$current2;
71
- var menuSize = ((_menuRef$current$clie2 = (_menuRef$current2 = menuRef.current) === null || _menuRef$current2 === void 0 ? void 0 : _menuRef$current2.clientWidth) !== null && _menuRef$current$clie2 !== void 0 ? _menuRef$current$clie2 : 0) - 38;
72
- var maxTabs = Math.floor(menuSize / tabsWidth);
73
72
  return tabs.slice(0, maxTabs);
74
- }, [tabs, tabsWidth, containerWidth]);
73
+ }, [tabs, maxTabs, containerWidth]);
75
74
  var tabsCount = tabs.length;
76
75
  var updateTabs = (0, _react.useCallback)(function (tabId) {
77
76
  var tabInDropdownIndex = dropdownTabs.findIndex(function (tab) {
package/lib/tabs/index.js CHANGED
@@ -64,7 +64,8 @@ var Tabs = function Tabs(_ref) {
64
64
  container: containerRef,
65
65
  onTabChange: handlerTabClick,
66
66
  onTabClose: handlerCloseTab,
67
- tabsWidth: tabsWidth
67
+ tabsWidth: tabsWidth,
68
+ firstTabIdent: firstTabIdent
68
69
  }, props), /*#__PURE__*/_react["default"].createElement("div", {
69
70
  ref: containerRef,
70
71
  className: (0, _tabHelpers.tabsClass)(tabMenuPosition),
@@ -25,6 +25,7 @@ interface TabsProviderProps {
25
25
  selectedTab?: string | number | null;
26
26
  onTabChange?: (tabId: string) => void;
27
27
  onTabClose?: (tabId: string) => void;
28
+ firstTabIdent?: boolean;
28
29
  }
29
30
  interface ITabsPros {
30
31
  style?: CSSProperties;
@@ -40,7 +41,6 @@ interface ITabsPros {
40
41
  handlerCloseTab?: (id?: string, idx?: string) => void;
41
42
  customClassForToolBar?: string;
42
43
  tabsWidth?: string | number;
43
- tabsWidthOnExceedCount?: number;
44
44
  }
45
45
  interface TabProps {
46
46
  id: string | number;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "linear-react-components-ui",
3
- "version": "1.1.0-beta.4",
3
+ "version": "1.1.0-beta.5",
4
4
  "description": "Linear Sistemas ReactJs Components",
5
5
  "main": "lib/index.js",
6
6
  "module": "lib/index.cjs",