linear-react-components-ui 1.1.18-beta.2 → 1.1.18-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.
@@ -7,7 +7,6 @@
7
7
  ".eslintrc.js": true,
8
8
  ".gitignore": true,
9
9
  "package-lock.json": true,
10
- // ".gitlab-ci.yml": true,
11
10
  ".nvmrc": true,
12
11
  ".npmignore": true,
13
12
  ".editorconfig": true,
@@ -20,7 +19,4 @@
20
19
  "editor.codeActionsOnSave": {
21
20
  "source.fixAll.eslint": "explicit"
22
21
  },
23
- "cSpell.words": [
24
- "licenca"
25
- ]
26
22
  }
@@ -354,12 +354,9 @@ que utilizam. Em caso de mudança, ficar atento para os refatores.
354
354
  }
355
355
  }
356
356
 
357
- .helpmenu {
358
- border: solid 1px $component-border-color;
359
- border-radius: 4px;
360
- width: 300px;
361
- position: absolute;
362
-
357
+ .popup-help {
358
+ border: 1px solid $list-container-border;
359
+
363
360
  >.list-component {
364
361
  box-shadow: none;
365
362
  overflow: hidden;
@@ -369,15 +366,19 @@ que utilizam. Em caso de mudança, ficar atento para os refatores.
369
366
  background-color: #77777736 !important;
370
367
 
371
368
  >.title {
372
- line-height: 40px;
369
+ line-height: 35px;
373
370
  }
374
371
  }
372
+
373
+ >.item-container >.item >.text {
374
+ font-size: 12px;
375
+ }
375
376
  }
376
377
 
377
- >.popup-help>.infomartion>.help-information {
378
+ .infomartion>.help-information {
378
379
  color: rgba(0, 0, 0, 0.54);
379
380
  font-size: 12px;
380
- padding-bottom: 10px;
381
+ line-height: 16px;
381
382
  }
382
383
  }
383
384
 
@@ -404,4 +405,4 @@ que utilizam. Em caso de mudança, ficar atento para os refatores.
404
405
  font-size: 15px;
405
406
  margin-top: 5px;
406
407
  }
407
- }
408
+ }
@@ -27,13 +27,16 @@ const NavMenuItem = props => {
27
27
  minWidth = 500,
28
28
  columnsQtty,
29
29
  targetRef,
30
+ disableDefaultStyle = false,
31
+ showDropdownOnClick = false,
30
32
  style
31
33
  } = props;
32
34
  const [showSubMenu, setShowSubMenu] = (0, _react.useState)(false);
33
35
  const [targetDimensions, setTargetDimensions] = (0, _react.useState)({});
34
- const [isFinalWindow, setIsFinalWindow] = (0, _react.useState)(false);
36
+ const [isOnEndWindow, setIsOnEndWindow] = (0, _react.useState)(false);
35
37
  const submenuContainerRef = (0, _react.useRef)(null);
36
38
  const submenuContentRef = (0, _react.useRef)(null);
39
+ const menuItemRef = (0, _react.useRef)(null);
37
40
  const options = [_permissionValidations.OPTIONS_ON_DENIED.disabled, _permissionValidations.OPTIONS_ON_DENIED.unvisible];
38
41
  const [onDenied] = (0, _react.useState)((0, _permissionValidations.actionsOnPermissionDenied)(options, permissionAttr));
39
42
  const {
@@ -46,39 +49,65 @@ const NavMenuItem = props => {
46
49
  disabled
47
50
  } = onDenied;
48
51
  const onMouseEnter = e => {
52
+ if (showDropdownOnClick) return;
49
53
  const windowHeight = window.innerHeight;
50
54
  const eventTarget = e.target;
51
55
  const position = eventTarget.getBoundingClientRect();
52
56
  setShowSubMenu(true);
53
57
  setTargetDimensions(position);
54
- if (position.bottom >= windowHeight - 150) setIsFinalWindow(true);
58
+ if (position.bottom >= windowHeight - 150) setIsOnEndWindow(true);
55
59
  };
56
- const toggleSubMenu = () => {
57
- setShowSubMenu(!showSubMenu);
60
+ const toggleSubMenu = e => {
61
+ if (showDropdownOnClick && e) {
62
+ const eventTarget = e.target;
63
+ if (eventTarget === menuItemRef.current) {
64
+ const windowHeight = window.innerHeight;
65
+ const position = eventTarget.getBoundingClientRect();
66
+ setShowSubMenu(!showSubMenu);
67
+ setTargetDimensions(position);
68
+ if (position.bottom >= windowHeight - 150) setIsOnEndWindow(true);
69
+ }
70
+ }
58
71
  };
59
72
  const contextValues = {
60
73
  toggleSubMenu
61
74
  };
75
+ (0, _react.useEffect)(() => {
76
+ if (showSubMenu && showDropdownOnClick) {
77
+ document.addEventListener('click', e => {
78
+ var _menuItemRef$current;
79
+ const target = e.target;
80
+ const insideMenu = (_menuItemRef$current = menuItemRef.current) === null || _menuItemRef$current === void 0 ? void 0 : _menuItemRef$current.contains(target);
81
+ if (!insideMenu) setShowSubMenu(false);
82
+ });
83
+ }
84
+ }, [showSubMenu, showDropdownOnClick]);
62
85
  (0, _react.useEffect)(() => {
63
86
  var _submenuContainerRef$, _submenuContentRef$cu, _submenuContentRef$cu2;
64
87
  const heigthSubmenuContainer = ((_submenuContainerRef$ = submenuContainerRef.current) === null || _submenuContainerRef$ === void 0 ? void 0 : _submenuContainerRef$.clientHeight) || 0;
65
88
  const heigthSubmenuContent = ((_submenuContentRef$cu = submenuContentRef.current) === null || _submenuContentRef$cu === void 0 ? void 0 : _submenuContentRef$cu.clientHeight) || 0;
66
- const maxHeigthSubMenu = isFinalWindow ? '100%' : (window.innerHeight - targetDimensions.top - (heigthSubmenuContainer - heigthSubmenuContent) - 1).toString().concat('px') || '0px';
89
+ const maxHeigthSubMenu = isOnEndWindow ? '100%' : (window.innerHeight - targetDimensions.top - (heigthSubmenuContainer - heigthSubmenuContent) - 1).toString().concat('px') || '0px';
67
90
  (_submenuContentRef$cu2 = submenuContentRef.current) === null || _submenuContentRef$cu2 === void 0 ? void 0 : _submenuContentRef$cu2.style.setProperty('max-height', maxHeigthSubMenu);
68
91
  }, [showSubMenu]);
69
92
  if (unvisible) return null;
70
93
  return /*#__PURE__*/_react.default.createElement(_helpers.SubMenuContext.Provider, {
71
94
  value: contextValues
72
95
  }, /*#__PURE__*/_react.default.createElement("li", {
73
- ref: targetRef,
74
96
  style: style,
75
- className: "item ".concat(url && !disabled && '-withlink', " ").concat(customClass, " ").concat(disabled && '-disabled'),
76
- onMouseEnter: e => {
77
- onMouseEnter(e);
97
+ ref: r => {
98
+ menuItemRef.current = r;
99
+ if (targetRef) targetRef(r);
78
100
  },
101
+ className: "item ".concat(url && !disabled && '-withlink', " ").concat(customClass, " ").concat(disabled && '-disabled'),
102
+ onMouseEnter: onMouseEnter,
79
103
  onMouseLeave: () => {
104
+ if (showDropdownOnClick) return;
80
105
  setShowSubMenu(false);
81
- setIsFinalWindow(false);
106
+ setIsOnEndWindow(false);
107
+ },
108
+ onClick: e => {
109
+ if (!showDropdownOnClick) return;
110
+ toggleSubMenu(e);
82
111
  }
83
112
  }, /*#__PURE__*/_react.default.createElement(_MenuLink.default, _extends({
84
113
  disabled: disabled
@@ -93,12 +122,13 @@ const NavMenuItem = props => {
93
122
  className: "title"
94
123
  }, title), !childrenIsSubMenu && children)), showSubMenu && children && childrenIsSubMenu && !disabled && !openSearchMenuPopup && /*#__PURE__*/_react.default.createElement("div", {
95
124
  ref: submenuContainerRef,
96
- className: "submenu-container",
97
- style: isFinalWindow ? {
125
+ className: disableDefaultStyle ? '' : 'submenu-container',
126
+ style: isOnEndWindow ? {
98
127
  marginLeft: targetDimensions.width,
99
128
  bottom: '0',
100
129
  paddingBottom: '10px',
101
- position: 'fixed'
130
+ position: 'fixed',
131
+ width: '20%'
102
132
  } : {
103
133
  marginLeft: targetDimensions.width,
104
134
  top: targetDimensions.top,
@@ -39,7 +39,6 @@ var _helpers = require("./helpers");
39
39
  var _icons = _interopRequireDefault(require("../../icons"));
40
40
  var constants = _interopRequireWildcard(require("../../internals/constants"));
41
41
  var _popup_menu_search = _interopRequireDefault(require("./popup_menu_search"));
42
- var _popup_menu_help = _interopRequireDefault(require("./popup_menu_help"));
43
42
  function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; }
44
43
  function _getRequireWildcardCache(e) { if ("function" != typeof WeakMap) return null; var r = new WeakMap(), t = new WeakMap(); return (_getRequireWildcardCache = function (e) { return e ? t : r; })(e); }
45
44
  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 && {}.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; }
@@ -59,9 +58,7 @@ const SideNav = props => {
59
58
  const [menuItemsContent, setMenuItemsContent] = (0, _react.useState)([]);
60
59
  const [sideNavDimensions, setSideNavDimensions] = (0, _react.useState)({});
61
60
  const [openSearchMenuPopup, setOpenSearchMenuPopup] = (0, _react.useState)(false);
62
- const [openHelpMenuPopup, setOpenHelpMenuPopup] = (0, _react.useState)(false);
63
61
  const sideNavRef = (0, _react.useRef)(null);
64
- const helpRef = (0, _react.useRef)(null);
65
62
  const onHeaderClick = () => {
66
63
  setIsExpanded(!isExpanded);
67
64
  if (onExpandMenuClick) onExpandMenuClick(!isExpanded);
@@ -76,20 +73,9 @@ const SideNav = props => {
76
73
  const style = "left: ".concat(left + width + 5, "px; top: ").concat(top + 1, "px; height: ").concat(height - 8, "px;");
77
74
  return style;
78
75
  };
79
- const getPopupMenuHelpStyle = () => {
80
- const {
81
- left,
82
- width
83
- } = sideNavDimensions;
84
- const style = "left: ".concat(left + width, "px; \n bottom: 0px; \n height: auto; width: 22%;\n position: fixed;");
85
- return style;
86
- };
87
76
  const closeSearchMenuPopup = () => {
88
77
  setOpenSearchMenuPopup(false);
89
78
  };
90
- const closeHelpMenuPopup = () => {
91
- setOpenHelpMenuPopup(false);
92
- };
93
79
  const compareChild = child => {
94
80
  const {
95
81
  type
@@ -118,20 +104,12 @@ const SideNav = props => {
118
104
  const openSearchMenu = () => {
119
105
  setOpenSearchMenuPopup(true);
120
106
  };
121
- const openHelpMenu = () => {
122
- setOpenHelpMenuPopup(true);
123
- };
124
107
  const onKeyDown = e => {
125
108
  if ([constants.keyCodes.F].includes(e.keyCode) && e.ctrlKey && e.shiftKey) {
126
109
  e.preventDefault();
127
110
  openSearchMenu();
128
111
  }
129
112
  };
130
- const handleClickOutside = event => {
131
- if (helpRef.current && !helpRef.current.contains(event.target)) {
132
- setOpenHelpMenuPopup(false);
133
- }
134
- };
135
113
  (0, _react.useEffect)(() => {
136
114
  document.addEventListener('keydown', onKeyDown);
137
115
  return () => {
@@ -147,12 +125,6 @@ const SideNav = props => {
147
125
  (0, _react.useEffect)(() => {
148
126
  setIsExpanded(expanded);
149
127
  }, [expanded]);
150
- (0, _react.useEffect)(() => {
151
- document.addEventListener("mousedown", handleClickOutside);
152
- return () => {
153
- document.removeEventListener("mousedown", handleClickOutside);
154
- };
155
- }, []);
156
128
  const returnMenuItems = () => menuItemsContent.filter(item => item.content !== '');
157
129
  const getPopupMenuSearch = () => /*#__PURE__*/_react.default.createElement(_NavMenuGroup.default, {
158
130
  key: "popup-menusearch-".concat(uuid.v1())
@@ -179,41 +151,10 @@ const SideNav = props => {
179
151
  handlerClose: closeSearchMenuPopup,
180
152
  menuItemsContent: menuItemsContent && returnMenuItems()
181
153
  }))));
182
- const getPopupMenuHelp = () => /*#__PURE__*/_react.default.createElement(_NavMenuGroup.default, {
183
- style: {
184
- flexGrow: 1,
185
- alignContent: 'flex-end'
186
- },
187
- key: "popup-menuhelp-".concat(uuid.v1())
188
- }, /*#__PURE__*/_react.default.createElement(_NavMenuItem.default, {
189
- childrenIsSubMenu: false,
190
- customClass: "-customsidenavitem help-item",
191
- tooltip: "Ajuda",
192
- tooltipPosition: "right"
193
- }, /*#__PURE__*/_react.default.createElement("div", {
194
- key: "helpMenuIcon",
195
- className: "helpmenubutton",
196
- role: "button",
197
- tabIndex: -1,
198
- onKeyDown: () => {},
199
- onClick: () => {
200
- openHelpMenu();
201
- }
202
- }, /*#__PURE__*/_react.default.createElement(_icons.default, {
203
- name: "question",
204
- customClass: "helphmenuicon",
205
- size: menuSize === 'small' && 16 || menuSize === 'medium' && 22 || menuSize === 'large' && 32 || 16
206
- })), openHelpMenuPopup && /*#__PURE__*/_react.default.createElement(_popup_menu_help.default, _extends({}, props, {
207
- helpRef: helpRef,
208
- style: getPopupMenuHelpStyle(),
209
- handlerClose: closeHelpMenuPopup,
210
- menuItemsContent: menuItemsContent && returnMenuItems()
211
- }))));
212
154
  const getSideNavContent = () => {
213
155
  if (!enableMenuSearch) return children;
214
156
  const items = [...children];
215
157
  items.splice(1, 0, getPopupMenuSearch());
216
- items.splice(items.length, 0, getPopupMenuHelp());
217
158
  return items;
218
159
  };
219
160
  const contextValues = {
@@ -1,4 +1,4 @@
1
- import { ReactNode, ReactElement, CSSProperties, Ref, RefObject } from 'react';
1
+ import { ReactNode, ReactElement, CSSProperties } from 'react';
2
2
  import { PermissionAttr } from '../../@types/PermissionAttr.js';
3
3
  import { Size } from '../../@types/Size.js';
4
4
  import { WithTooltipProps } from '../../internals/types.js';
@@ -17,14 +17,6 @@ interface ISideNavProps {
17
17
  enableMenuSearch?: boolean;
18
18
  menuSearchEmptyMessage?: string;
19
19
  menuSearchPlaceholder?: string;
20
- helpList?: IHelpItem[];
21
- copyright: string;
22
- version: string;
23
- }
24
- interface IHelpItem {
25
- id: string;
26
- title: string;
27
- url?: string;
28
20
  }
29
21
  interface ISideNavDimensions {
30
22
  left: number;
@@ -59,7 +51,9 @@ interface INavMenuItemProps extends WithTooltipProps {
59
51
  minWidth?: string | number;
60
52
  maxWidth?: string | number;
61
53
  columnsQtty?: number;
62
- targetRef?: Ref<HTMLLIElement>;
54
+ targetRef?: (ref: HTMLLIElement | null) => void;
55
+ disableDefaultStyle?: boolean;
56
+ showDropdownOnClick?: boolean;
63
57
  style?: CSSProperties;
64
58
  }
65
59
  interface INavSubMenuItemProps {
@@ -81,17 +75,6 @@ interface IPopupMenuSearchProps extends ISideNavProps {
81
75
  handlerClose: () => void;
82
76
  style?: CSSProperties | string;
83
77
  }
84
- interface IPopupMenuHelpProps extends ISideNavProps {
85
- menuItemsContent?: IMenuItemContent[];
86
- handlerClose: () => void;
87
- style?: CSSProperties | string;
88
- helpList?: IHelpItem[];
89
- copyright: string;
90
- version: string;
91
- dropdown?: boolean;
92
- isDropdownOpened?: boolean;
93
- helpRef: RefObject<HTMLDivElement>;
94
- }
95
78
  interface ISubMenuContext {
96
79
  toggleSubMenu: () => void;
97
80
  }
@@ -102,4 +85,4 @@ interface ISideNavContext {
102
85
  }
103
86
  type ITargetDimensions = DOMRect;
104
87
 
105
- export { IEmptyListProps, IExpandMenuProps, IHelpItem, IMenuItemContent, IMenuLinkProps, INavMenuGroupProps, INavMenuItemProps, INavSubMenuItemProps, IPopupMenuHelpProps, IPopupMenuSearchProps, ISideNavContext, ISideNavDimensions, ISideNavProps, ISubMenuContext, ITargetDimensions };
88
+ export { IEmptyListProps, IExpandMenuProps, IMenuItemContent, IMenuLinkProps, INavMenuGroupProps, INavMenuItemProps, INavSubMenuItemProps, IPopupMenuSearchProps, ISideNavContext, ISideNavDimensions, ISideNavProps, ISubMenuContext, ITargetDimensions };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "linear-react-components-ui",
3
- "version": "1.1.18-beta.2",
3
+ "version": "1.1.18-beta.4",
4
4
  "description": "Linear Sistemas ReactJs Components",
5
5
  "main": "lib/index.js",
6
6
  "module": "lib/index.cjs",
@@ -1,12 +0,0 @@
1
- import React__default from 'react';
2
- import { IPopupMenuHelpProps } from '../types.js';
3
- import '../../../@types/PermissionAttr.js';
4
- import '../../../@types/Size.js';
5
- import '../../../internals/types.js';
6
- import '../../../@types/Position.js';
7
- import '../../../@types/Icon.js';
8
- import '../../../icons/helper.js';
9
-
10
- declare const PopupMenuHelp: (props: IPopupMenuHelpProps) => React__default.ReactPortal;
11
-
12
- export { PopupMenuHelp as default };