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

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.
Files changed (54) hide show
  1. package/lib/assets/styles/dialog.scss +16 -16
  2. package/lib/assets/styles/drawers.scss +9 -6
  3. package/lib/assets/styles/tabs.scss +22 -21
  4. package/lib/dialog/base/Header.js +11 -8
  5. package/lib/dialog/base/index.d.ts +8 -2
  6. package/lib/dialog/base/index.js +67 -57
  7. package/lib/dialog/form/index.js +7 -5
  8. package/lib/dialog/types.d.ts +8 -13
  9. package/lib/drawer/Header.js +3 -2
  10. package/lib/form/types.d.ts +1 -0
  11. package/lib/form/withFormSecurity.js +4 -2
  12. package/lib/index.d.ts +1 -1
  13. package/lib/inputs/date/Dialog.js +2 -4
  14. package/lib/inputs/date/index.js +1 -3
  15. package/lib/inputs/date/types.d.ts +1 -1
  16. package/lib/inputs/period/Dialog.d.ts +1 -1
  17. package/lib/inputs/period/Dialog.js +2 -4
  18. package/lib/inputs/period/index.js +3 -9
  19. package/lib/inputs/period/types.d.ts +1 -1
  20. package/lib/panel/Content.d.ts +1 -1
  21. package/lib/panel/DangerPanel.d.ts +1 -1
  22. package/lib/panel/Default.d.ts +1 -1
  23. package/lib/panel/Header.d.ts +1 -1
  24. package/lib/panel/InfoPanel.d.ts +1 -1
  25. package/lib/panel/PrimaryPanel.d.ts +1 -1
  26. package/lib/panel/SuccessPanel.d.ts +1 -1
  27. package/lib/panel/ToolBar.d.ts +1 -1
  28. package/lib/panel/WarningPanel.d.ts +1 -1
  29. package/lib/panel/helpers.d.ts +7 -2
  30. package/lib/panel/helpers.js +0 -13
  31. package/lib/panel/index.d.ts +1 -1
  32. package/lib/panel/types.d.ts +46 -5
  33. package/lib/tabs/DropdownTabs.d.ts +11 -0
  34. package/lib/tabs/DropdownTabs.js +75 -0
  35. package/lib/tabs/Menu.d.ts +1 -1
  36. package/lib/tabs/Menu.js +27 -15
  37. package/lib/tabs/{DropdownItems.d.ts → MenuTabs.d.ts} +3 -3
  38. package/lib/tabs/MenuTabs.js +90 -0
  39. package/lib/tabs/Panel.js +62 -39
  40. package/lib/tabs/context.d.ts +12 -0
  41. package/lib/tabs/context.js +162 -0
  42. package/lib/tabs/index.d.ts +1 -1
  43. package/lib/tabs/index.js +23 -198
  44. package/lib/tabs/tabHelpers.d.ts +4 -14
  45. package/lib/tabs/tabHelpers.js +30 -48
  46. package/lib/tabs/types.d.ts +44 -13
  47. package/lib/tabs/useTabs.d.ts +11 -0
  48. package/lib/tabs/useTabs.js +11 -0
  49. package/package.json +2 -1
  50. package/tsconfig.json +1 -0
  51. package/lib/tabs/DropdownItems.js +0 -64
  52. package/lib/tabs/MenuItems.d.ts +0 -11
  53. package/lib/tabs/MenuItems.js +0 -75
  54. package/lib/types-exUmt06D.d.ts +0 -50
@@ -310,9 +310,7 @@ var PeriodPicker = function PeriodPicker(props) {
310
310
  if (showCalendarInDialog) {
311
311
  return /*#__PURE__*/_react["default"].createElement(_Dialog["default"], {
312
312
  dialogSize: dialogSize,
313
- handlerClose: function handlerClose() {
314
- return setShowCalendarValueInitial(false);
315
- }
313
+ onOpenChange: setShowCalendarValueInitial
316
314
  }, getCalendar(valueInitial, calendarColorStyle, 'valueInitial'));
317
315
  }
318
316
  return /*#__PURE__*/_react["default"].createElement(_Dropdown["default"], {
@@ -330,9 +328,7 @@ var PeriodPicker = function PeriodPicker(props) {
330
328
  if (showCalendarInDialog) {
331
329
  return /*#__PURE__*/_react["default"].createElement(_Dialog["default"], {
332
330
  dialogSize: dialogSize,
333
- handlerClose: function handlerClose() {
334
- return setShowCalendarValueFinal(false);
335
- }
331
+ onOpenChange: setShowCalendarValueFinal
336
332
  }, getCalendar(valueFinal, calendarColorStyle, 'valueFinal'));
337
333
  }
338
334
  return /*#__PURE__*/_react["default"].createElement(_Dropdown["default"], {
@@ -349,9 +345,7 @@ var PeriodPicker = function PeriodPicker(props) {
349
345
  if (showCalendarInDialog) {
350
346
  return /*#__PURE__*/_react["default"].createElement(_Dialog["default"], {
351
347
  dialogSize: dialogSize,
352
- handlerClose: function handlerClose() {
353
- return setShowPeriodSelection(false);
354
- }
348
+ onOpenChange: setShowPeriodSelection
355
349
  }, getPeriodSelection(valuePeriodSelection, setPeriodDates));
356
350
  }
357
351
  return /*#__PURE__*/_react["default"].createElement(_Dropdown["default"], {
@@ -19,7 +19,7 @@ interface IPeriodOptions {
19
19
  }
20
20
  interface IDialogProps {
21
21
  children: ReactNode | ReactNode[];
22
- handlerClose: () => void;
22
+ onOpenChange: (open: boolean) => void;
23
23
  dialogSize: {
24
24
  width: string;
25
25
  height: string;
@@ -1,4 +1,4 @@
1
- import { a as IPanelContentProps } from '../types-exUmt06D.js';
1
+ import { IPanelContentProps } from './types.js';
2
2
  import 'react';
3
3
  import '../@types/PermissionAttr.js';
4
4
  import '../internals/colorStyles.js';
@@ -1,4 +1,4 @@
1
- import { I as IPanelProps } from '../types-exUmt06D.js';
1
+ import { IPanelProps } from './types.js';
2
2
  import 'react';
3
3
  import '../@types/PermissionAttr.js';
4
4
  import '../internals/colorStyles.js';
@@ -1,4 +1,4 @@
1
- import { I as IPanelProps } from '../types-exUmt06D.js';
1
+ import { IPanelProps } from './types.js';
2
2
  import 'react';
3
3
  import '../@types/PermissionAttr.js';
4
4
  import '../internals/colorStyles.js';
@@ -1,4 +1,4 @@
1
- import { b as IPanelHeaderProps } from '../types-exUmt06D.js';
1
+ import { IPanelHeaderProps } from './types.js';
2
2
  import 'react';
3
3
  import '../@types/PermissionAttr.js';
4
4
  import '../internals/colorStyles.js';
@@ -1,4 +1,4 @@
1
- import { I as IPanelProps } from '../types-exUmt06D.js';
1
+ import { IPanelProps } from './types.js';
2
2
  import 'react';
3
3
  import '../@types/PermissionAttr.js';
4
4
  import '../internals/colorStyles.js';
@@ -1,4 +1,4 @@
1
- import { I as IPanelProps } from '../types-exUmt06D.js';
1
+ import { IPanelProps } from './types.js';
2
2
  import 'react';
3
3
  import '../@types/PermissionAttr.js';
4
4
  import '../internals/colorStyles.js';
@@ -1,4 +1,4 @@
1
- import { I as IPanelProps } from '../types-exUmt06D.js';
1
+ import { IPanelProps } from './types.js';
2
2
  import 'react';
3
3
  import '../@types/PermissionAttr.js';
4
4
  import '../internals/colorStyles.js';
@@ -1,4 +1,4 @@
1
- import { I as IPanelProps } from '../types-exUmt06D.js';
1
+ import { IPanelProps } from './types.js';
2
2
  import 'react';
3
3
  import '../@types/PermissionAttr.js';
4
4
  import '../internals/colorStyles.js';
@@ -1,4 +1,4 @@
1
- import { I as IPanelProps } from '../types-exUmt06D.js';
1
+ import { IPanelProps } from './types.js';
2
2
  import 'react';
3
3
  import '../@types/PermissionAttr.js';
4
4
  import '../internals/colorStyles.js';
@@ -1,6 +1,11 @@
1
- import 'react';
2
- export { P as default, g as getCurrentThreshold, n as numberAroundZeroAndOne } from '../types-exUmt06D.js';
1
+ import React__default from 'react';
2
+ import { ContextProps } from './types.js';
3
3
  import '../@types/PermissionAttr.js';
4
4
  import '../internals/colorStyles.js';
5
5
  import '../@types/Icon.js';
6
6
  import '../icons/helper.js';
7
+
8
+ declare function getCurrentThreshold(scrollableElement: HTMLDivElement, scrollThreshold: number): number;
9
+ declare const PanelContext: React__default.Context<ContextProps>;
10
+
11
+ export { PanelContext as default, getCurrentThreshold };
@@ -5,21 +5,8 @@ Object.defineProperty(exports, "__esModule", {
5
5
  });
6
6
  exports["default"] = void 0;
7
7
  exports.getCurrentThreshold = getCurrentThreshold;
8
- exports.numberAroundZeroAndOne = numberAroundZeroAndOne;
9
8
  var _react = _interopRequireDefault(require("react"));
10
9
  function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { "default": obj }; }
11
- function numberAroundZeroAndOne(_ref) {
12
- var props = _ref.props,
13
- propName = _ref.propName,
14
- componentName = _ref.componentName;
15
- if (props[propName]) {
16
- var value = props[propName];
17
- if (typeof value === 'number') {
18
- return value >= 0 && value <= 1 ? value : new Error("invalid value of ".concat(propName, " in ").concat(componentName, " component, is not between 0 and 1"));
19
- }
20
- }
21
- return null;
22
- }
23
10
  function getCurrentThreshold(scrollableElement, scrollThreshold) {
24
11
  var MIN_THRESHOLD = 0;
25
12
  var MAX_THRESHOLD = 1;
@@ -6,7 +6,7 @@ export { default as SuccessPanel } from './SuccessPanel.js';
6
6
  export { default as InfoPanel } from './InfoPanel.js';
7
7
  export { default as PanelHeader } from './Header.js';
8
8
  export { default as PanelContent } from './Content.js';
9
- import '../types-exUmt06D.js';
9
+ import './types.js';
10
10
  import 'react';
11
11
  import '../@types/PermissionAttr.js';
12
12
  import '../internals/colorStyles.js';
@@ -1,6 +1,47 @@
1
- import 'react';
2
- export { A as AsyncFunc, C as ContextProps, F as Func, a as IPanelContentProps, b as IPanelHeaderProps, I as IPanelProps, c as IParameterFunction } from '../types-exUmt06D.js';
3
- import '../@types/PermissionAttr.js';
4
- import '../internals/colorStyles.js';
5
- import '../@types/Icon.js';
1
+ import { ComponentPropsWithoutRef, ReactNode, ReactElement } from 'react';
2
+ import { PermissionAttr } from '../@types/PermissionAttr.js';
3
+ import ColorStyles from '../internals/colorStyles.js';
4
+ import { IconNames } from '../@types/Icon.js';
6
5
  import '../icons/helper.js';
6
+
7
+ type Func = () => void;
8
+ type AsyncFunc = () => Promise<void>;
9
+ interface IPanelProps extends Omit<ComponentPropsWithoutRef<'div'>, 'className'> {
10
+ customClass?: string;
11
+ startOpened?: boolean;
12
+ toggleable?: boolean;
13
+ children?: ReactNode;
14
+ colorStyle?: typeof ColorStyles | string;
15
+ gridCols?: string;
16
+ title?: string;
17
+ onEndReached?: Func | AsyncFunc;
18
+ onEndReachedThreshold?: number;
19
+ permissionAttr?: PermissionAttr | PermissionAttr[];
20
+ }
21
+ interface IPanelContentProps extends Omit<ComponentPropsWithoutRef<'div'>, 'className'> {
22
+ customClass?: string;
23
+ }
24
+ interface IPanelHeaderProps extends Omit<ComponentPropsWithoutRef<'div'>, 'className'> {
25
+ title?: string;
26
+ icon?: ReactElement;
27
+ titleIcon?: IconNames;
28
+ customClass?: string;
29
+ styleForTitle?: object;
30
+ customClassForTitle?: string;
31
+ headerColored?: boolean;
32
+ }
33
+ type ContextProps = {
34
+ toggleable: boolean;
35
+ handlerToggleable: () => void;
36
+ opened: boolean;
37
+ hideContent: boolean;
38
+ onEndReached?: Func | AsyncFunc;
39
+ onEndReachedThreshold: number;
40
+ };
41
+ interface IParameterFunction {
42
+ props: any;
43
+ propName: string | number;
44
+ componentName: string;
45
+ }
46
+
47
+ export type { AsyncFunc, ContextProps, Func, IPanelContentProps, IPanelHeaderProps, IPanelProps, IParameterFunction };
@@ -0,0 +1,11 @@
1
+ import { DropdownProps } from './types.js';
2
+ import 'react';
3
+ import '../@types/Size.js';
4
+ import '../@types/Position.js';
5
+ import '../@types/PermissionAttr.js';
6
+ import '../@types/Icon.js';
7
+ import '../icons/helper.js';
8
+
9
+ declare const DropdownTabs: ({ tabs, tabMenuSize, }: DropdownProps) => JSX.Element | null;
10
+
11
+ export { DropdownTabs as default };
@@ -0,0 +1,75 @@
1
+ "use strict";
2
+
3
+ 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); }
4
+ Object.defineProperty(exports, "__esModule", {
5
+ value: true
6
+ });
7
+ exports["default"] = void 0;
8
+ var _react = _interopRequireDefault(require("react"));
9
+ var _buttons = _interopRequireDefault(require("../buttons"));
10
+ var _list = _interopRequireWildcard(require("../list"));
11
+ var _useTabs2 = require("./useTabs");
12
+ function _getRequireWildcardCache(e) { if ("function" != typeof WeakMap) return null; var r = new WeakMap(), t = new WeakMap(); return (_getRequireWildcardCache = function _getRequireWildcardCache(e) { return e ? t : r; })(e); }
13
+ function _interopRequireWildcard(e, r) { if (!r && e && e.__esModule) return e; if (null === e || "object" != _typeof(e) && "function" != typeof e) return { "default": e }; var t = _getRequireWildcardCache(r); if (t && t.has(e)) return t.get(e); var n = { __proto__: null }, a = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var u in e) if ("default" !== u && Object.prototype.hasOwnProperty.call(e, u)) { var i = a ? Object.getOwnPropertyDescriptor(e, u) : null; i && (i.get || i.set) ? Object.defineProperty(n, u, i) : n[u] = e[u]; } return n["default"] = e, t && t.set(e, n), n; }
14
+ function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { "default": obj }; }
15
+ 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); }
16
+ var DropdownTab = function DropdownTab(_ref) {
17
+ var id = _ref.id,
18
+ title = _ref.title,
19
+ closeable = _ref.closeable,
20
+ iconAlign = _ref.iconAlign,
21
+ icon = _ref.icon,
22
+ iconName = _ref.iconName,
23
+ disabled = _ref.disabled,
24
+ tabMenuSize = _ref.tabMenuSize;
25
+ var _useTabs = (0, _useTabs2.useTabs)(),
26
+ selectTab = _useTabs.selectTab,
27
+ removeTab = _useTabs.removeTab;
28
+ return /*#__PURE__*/_react["default"].createElement(_list.ListItem, {
29
+ key: id
30
+ }, /*#__PURE__*/_react["default"].createElement("div", {
31
+ className: "menuitem"
32
+ }, /*#__PURE__*/_react["default"].createElement(_buttons["default"], {
33
+ className: "btn menubutton",
34
+ boxShadow: false,
35
+ onClick: function onClick() {
36
+ return selectTab(id);
37
+ },
38
+ iconAlign: iconAlign,
39
+ iconName: iconName,
40
+ icon: icon,
41
+ disabled: disabled,
42
+ label: title,
43
+ size: tabMenuSize,
44
+ transparent: true
45
+ }), closeable && /*#__PURE__*/_react["default"].createElement("button", {
46
+ className: "closepanel",
47
+ onClick: function onClick() {
48
+ return removeTab(id);
49
+ }
50
+ })));
51
+ };
52
+ var DropdownTabs = function DropdownTabs(_ref2) {
53
+ var _ref2$tabs = _ref2.tabs,
54
+ tabs = _ref2$tabs === void 0 ? [] : _ref2$tabs,
55
+ _ref2$tabMenuSize = _ref2.tabMenuSize,
56
+ tabMenuSize = _ref2$tabMenuSize === void 0 ? 'medium' : _ref2$tabMenuSize;
57
+ var hasTabs = tabs.length > 0;
58
+ if (tabs.length === 0) return null;
59
+ return /*#__PURE__*/_react["default"].createElement(_buttons["default"], {
60
+ dropdown: true,
61
+ dropdownAlign: "right",
62
+ transparent: true,
63
+ boxShadow: false,
64
+ size: "large",
65
+ customClass: "dropdownbutton ".concat(hasTabs ? 'show' : '')
66
+ }, /*#__PURE__*/_react["default"].createElement(_list["default"], {
67
+ customClass: "dropdown-hide-tabs"
68
+ }, tabs.map(function (tab) {
69
+ return /*#__PURE__*/_react["default"].createElement(DropdownTab, _extends({
70
+ key: tab.id,
71
+ tabMenuSize: tabMenuSize
72
+ }, tab));
73
+ })));
74
+ };
75
+ var _default = exports["default"] = DropdownTabs;
@@ -6,6 +6,6 @@ import '../@types/PermissionAttr.js';
6
6
  import '../@types/Icon.js';
7
7
  import '../icons/helper.js';
8
8
 
9
- declare const Menu: ({ menuRef, toolbar, toolBarRef, customClassForToolBar, ...props }: MenuProps) => JSX.Element;
9
+ declare const Menu: ({ toolbar, customClassForToolBar, tabWidth, ...props }: MenuProps) => JSX.Element;
10
10
 
11
11
  export { Menu as default };
package/lib/tabs/Menu.js CHANGED
@@ -5,29 +5,41 @@ Object.defineProperty(exports, "__esModule", {
5
5
  });
6
6
  exports["default"] = void 0;
7
7
  var _react = _interopRequireDefault(require("react"));
8
- var _MenuItems = _interopRequireDefault(require("./MenuItems"));
9
- var _DropdownItems = _interopRequireDefault(require("./DropdownItems"));
10
- var _excluded = ["menuRef", "toolbar", "toolBarRef", "customClassForToolBar"];
8
+ var _MenuTabs = _interopRequireDefault(require("./MenuTabs"));
9
+ var _DropdownTabs = _interopRequireDefault(require("./DropdownTabs"));
10
+ var _useTabs2 = require("./useTabs");
11
+ var _excluded = ["toolbar", "customClassForToolBar", "tabWidth"];
11
12
  function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { "default": obj }; }
12
13
  function _objectWithoutProperties(source, excluded) { if (source == null) return {}; var target = _objectWithoutPropertiesLoose(source, excluded); var key, i; if (Object.getOwnPropertySymbols) { var sourceSymbolKeys = Object.getOwnPropertySymbols(source); for (i = 0; i < sourceSymbolKeys.length; i++) { key = sourceSymbolKeys[i]; if (excluded.indexOf(key) >= 0) continue; if (!Object.prototype.propertyIsEnumerable.call(source, key)) continue; target[key] = source[key]; } } return target; }
13
14
  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; }
14
15
  var Menu = function Menu(_ref) {
15
- var menuRef = _ref.menuRef,
16
- toolbar = _ref.toolbar,
17
- toolBarRef = _ref.toolBarRef,
16
+ var toolbar = _ref.toolbar,
18
17
  _ref$customClassForTo = _ref.customClassForToolBar,
19
18
  customClassForToolBar = _ref$customClassForTo === void 0 ? '' : _ref$customClassForTo,
19
+ _ref$tabWidth = _ref.tabWidth,
20
+ tabWidth = _ref$tabWidth === void 0 ? 'auto' : _ref$tabWidth,
20
21
  props = _objectWithoutProperties(_ref, _excluded);
22
+ var _useTabs = (0, _useTabs2.useTabs)(),
23
+ menuTabs = _useTabs.menuTabs,
24
+ menuRef = _useTabs.menuRef,
25
+ dropdownTabs = _useTabs.dropdownTabs;
21
26
  return /*#__PURE__*/_react["default"].createElement("div", {
22
- className: "menucontainer",
23
- ref: function ref(_ref2) {
24
- menuRef === null || menuRef === void 0 ? void 0 : menuRef(_ref2);
25
- }
26
- }, /*#__PURE__*/_react["default"].createElement(_MenuItems["default"], props), /*#__PURE__*/_react["default"].createElement(_DropdownItems["default"], props), toolbar && /*#__PURE__*/_react["default"].cloneElement(toolbar, {
27
- customClass: "menubar ".concat(customClassForToolBar),
28
- innerRef: toolBarRef ? function (r) {
29
- toolBarRef(r);
30
- } : undefined
27
+ className: "menucontainer"
28
+ }, /*#__PURE__*/_react["default"].createElement(_MenuTabs["default"], {
29
+ tabs: menuTabs,
30
+ tabWidth: tabWidth,
31
+ tabMenuSize: props.tabMenuSize,
32
+ tabMenuAlign: props.tabMenuAlign,
33
+ firstTabIdent: props.firstTabIdent,
34
+ ref: menuRef
35
+ }), /*#__PURE__*/_react["default"].createElement(_DropdownTabs["default"], {
36
+ tabs: dropdownTabs,
37
+ tabWidth: tabWidth,
38
+ tabMenuSize: props.tabMenuSize,
39
+ tabMenuAlign: props.tabMenuAlign,
40
+ firstTabIdent: props.firstTabIdent
41
+ }), toolbar && /*#__PURE__*/_react["default"].cloneElement(toolbar, {
42
+ customClass: "menubar ".concat(customClassForToolBar)
31
43
  }));
32
44
  };
33
45
  var _default = exports["default"] = Menu;
@@ -1,11 +1,11 @@
1
+ import React__default from 'react';
1
2
  import { MenuProps } from './types.js';
2
- import 'react';
3
3
  import '../@types/Size.js';
4
4
  import '../@types/Position.js';
5
5
  import '../@types/PermissionAttr.js';
6
6
  import '../@types/Icon.js';
7
7
  import '../icons/helper.js';
8
8
 
9
- declare const DropdownItems: ({ handlerClick, handlerRemovePanel, dropdownPanels, tabMenuSize, }: MenuProps) => JSX.Element | null;
9
+ declare const MenuTabs: React__default.ForwardRefExoticComponent<MenuProps & React__default.RefAttributes<HTMLUListElement>>;
10
10
 
11
- export { DropdownItems as default };
11
+ export { MenuTabs as default };
@@ -0,0 +1,90 @@
1
+ "use strict";
2
+
3
+ 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); }
4
+ Object.defineProperty(exports, "__esModule", {
5
+ value: true
6
+ });
7
+ exports["default"] = void 0;
8
+ var _react = _interopRequireDefault(require("react"));
9
+ var _buttons = _interopRequireDefault(require("../buttons"));
10
+ var helpers = _interopRequireWildcard(require("./tabHelpers"));
11
+ var _permissionValidations = require("../permissionValidations");
12
+ var _useTabs2 = require("./useTabs");
13
+ function _getRequireWildcardCache(e) { if ("function" != typeof WeakMap) return null; var r = new WeakMap(), t = new WeakMap(); return (_getRequireWildcardCache = function _getRequireWildcardCache(e) { return e ? t : r; })(e); }
14
+ function _interopRequireWildcard(e, r) { if (!r && e && e.__esModule) return e; if (null === e || "object" != _typeof(e) && "function" != typeof e) return { "default": e }; var t = _getRequireWildcardCache(r); if (t && t.has(e)) return t.get(e); var n = { __proto__: null }, a = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var u in e) if ("default" !== u && Object.prototype.hasOwnProperty.call(e, u)) { var i = a ? Object.getOwnPropertyDescriptor(e, u) : null; i && (i.get || i.set) ? Object.defineProperty(n, u, i) : n[u] = e[u]; } return n["default"] = e, t && t.set(e, n), n; }
15
+ function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { "default": obj }; }
16
+ 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); }
17
+ var MenuTab = function MenuTab(_ref) {
18
+ var id = _ref.id,
19
+ title = _ref.title,
20
+ tabWidth = _ref.tabWidth,
21
+ iconAlign = _ref.iconAlign,
22
+ iconName = _ref.iconName,
23
+ icon = _ref.icon,
24
+ disabled = _ref.disabled,
25
+ permissionAttr = _ref.permissionAttr,
26
+ tabMenuSize = _ref.tabMenuSize,
27
+ tooltip = _ref.tooltip,
28
+ tooltipPosition = _ref.tooltipPosition,
29
+ tooltipWidth = _ref.tooltipWidth,
30
+ closeable = _ref.closeable;
31
+ var _useTabs = (0, _useTabs2.useTabs)(),
32
+ selectedTabId = _useTabs.selectedTabId,
33
+ selectTab = _useTabs.selectTab,
34
+ removeTab = _useTabs.removeTab,
35
+ tabsCount = _useTabs.tabsCount;
36
+ var onDenied = (0, _permissionValidations.actionsOnPermissionDenied)(helpers.onDeniedOptions, permissionAttr);
37
+ return onDenied.unvisible ? null : /*#__PURE__*/_react["default"].createElement("li", {
38
+ key: id,
39
+ style: {
40
+ width: tabWidth
41
+ },
42
+ className: "menuitem ".concat(selectedTabId === id && 'selected')
43
+ }, /*#__PURE__*/_react["default"].createElement(_buttons["default"], {
44
+ className: "btn menubutton",
45
+ boxShadow: false,
46
+ onClick: function onClick() {
47
+ return selectTab(id);
48
+ },
49
+ iconAlign: iconAlign,
50
+ iconName: iconName,
51
+ icon: icon,
52
+ disabled: disabled || !!onDenied.disabled,
53
+ label: title,
54
+ size: tabMenuSize,
55
+ tooltip: tooltip || title,
56
+ tooltipPosition: tooltipPosition,
57
+ tooltipWidth: tooltipWidth
58
+ }), closeable && tabsCount > 1 && /*#__PURE__*/_react["default"].createElement("button", {
59
+ className: "closepanel",
60
+ onClick: function onClick() {
61
+ return removeTab(id);
62
+ }
63
+ }));
64
+ };
65
+ var MenuTabs = /*#__PURE__*/_react["default"].forwardRef(function (_ref2, ref) {
66
+ var _ref2$tabs = _ref2.tabs,
67
+ tabs = _ref2$tabs === void 0 ? [] : _ref2$tabs,
68
+ _ref2$tabWidth = _ref2.tabWidth,
69
+ tabWidth = _ref2$tabWidth === void 0 ? 'auto' : _ref2$tabWidth,
70
+ _ref2$tabMenuSize = _ref2.tabMenuSize,
71
+ tabMenuSize = _ref2$tabMenuSize === void 0 ? 'medium' : _ref2$tabMenuSize,
72
+ _ref2$tabMenuAlign = _ref2.tabMenuAlign,
73
+ tabMenuAlign = _ref2$tabMenuAlign === void 0 ? 'left' : _ref2$tabMenuAlign,
74
+ _ref2$firstTabIdent = _ref2.firstTabIdent,
75
+ firstTabIdent = _ref2$firstTabIdent === void 0 ? false : _ref2$firstTabIdent;
76
+ return /*#__PURE__*/_react["default"].createElement("ul", {
77
+ className: "menu ".concat(firstTabIdent && '-firsttabident'),
78
+ style: helpers.menuStyles(tabMenuAlign),
79
+ ref: ref
80
+ }, tabs.map(function (tab) {
81
+ return /*#__PURE__*/_react["default"].createElement(MenuTab, _extends({
82
+ key: tab.id,
83
+ menuTabsLength: tabs.length,
84
+ tabMenuSize: tabMenuSize,
85
+ tabWidth: tabWidth
86
+ }, tab));
87
+ }));
88
+ });
89
+ MenuTabs.displayName = 'MenuTabs';
90
+ var _default = exports["default"] = MenuTabs;