linear-react-components-ui 0.4.76-rc.11 → 0.4.76-rc.15

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 (70) hide show
  1. package/.DS_Store +0 -0
  2. package/.tool-versions +1 -0
  3. package/.vscode/settings.json +1 -2
  4. package/README.md +33 -0
  5. package/lib/assets/styles/dropdown.scss +28 -2
  6. package/lib/assets/styles/effects.scss +12 -0
  7. package/lib/assets/styles/floatMenu.scss +0 -1
  8. package/lib/assets/styles/multiSelect.scss +105 -0
  9. package/lib/assets/styles/panel.scss +0 -1
  10. package/lib/assets/styles/periodpicker.scss +65 -0
  11. package/lib/assets/styles/progress.scss +8 -1
  12. package/lib/assets/styles/select.scss +1 -0
  13. package/lib/assets/styles/table.scss +13 -5
  14. package/lib/assets/styles/tabs.scss +79 -44
  15. package/lib/assets/styles/treeview.scss +32 -0
  16. package/lib/avatar/avatar.spec.js +17 -6
  17. package/lib/avatar/index.js +1 -1
  18. package/lib/buttons/DefaultButton.js +7 -1
  19. package/lib/checkbox/Label.js +37 -0
  20. package/lib/checkbox/index.js +20 -6
  21. package/lib/dialog/base/index.js +15 -6
  22. package/lib/dialog/form/index.js +16 -3
  23. package/lib/drawer/index.js +4 -1
  24. package/lib/form/Field.js +2 -0
  25. package/lib/form/FieldNumber.js +10 -2
  26. package/lib/form/FieldPeriod.js +100 -0
  27. package/lib/form/helpers.js +9 -1
  28. package/lib/form/index.js +209 -222
  29. package/lib/form/withFieldHOC.js +2 -0
  30. package/lib/form/withFormSecurity.js +106 -0
  31. package/lib/icons/helper.js +16 -0
  32. package/lib/inputs/base/helpers.js +12 -4
  33. package/lib/inputs/multiSelect/ActionButtons.js +68 -0
  34. package/lib/inputs/multiSelect/Dropdown.js +200 -0
  35. package/lib/inputs/multiSelect/helper.js +18 -0
  36. package/lib/inputs/multiSelect/index.js +343 -0
  37. package/lib/inputs/number/BaseNumber.js +1 -1
  38. package/lib/inputs/number/index.js +7 -5
  39. package/lib/inputs/period/Dialog.js +38 -0
  40. package/lib/inputs/period/Dropdown.js +90 -0
  41. package/lib/inputs/period/PeriodList.js +79 -0
  42. package/lib/inputs/period/helper.js +118 -0
  43. package/lib/inputs/period/index.js +490 -0
  44. package/lib/inputs/select/Dropdown.js +4 -4
  45. package/lib/inputs/select/index.js +26 -3
  46. package/lib/inputs/select/multiple/index.js +9 -7
  47. package/lib/inputs/select/simple/index.js +30 -18
  48. package/lib/internals/withTooltip.js +85 -81
  49. package/lib/list/Item.js +3 -3
  50. package/lib/list/index.js +20 -10
  51. package/lib/list/list.spec.js +129 -85
  52. package/lib/menus/float/MenuItem.js +25 -8
  53. package/lib/menus/sidenav/index.js +7 -3
  54. package/lib/menus/sidenav/popup_menu_search/index.js +1 -1
  55. package/lib/progress/Bar.js +40 -9
  56. package/lib/progress/index.js +12 -4
  57. package/lib/spinner/index.js +6 -1
  58. package/lib/split/Split.js +5 -11
  59. package/lib/table/Row.js +1 -1
  60. package/lib/tabs/DropdownItems.js +84 -0
  61. package/lib/tabs/Menu.js +18 -5
  62. package/lib/tabs/MenuItems.js +7 -7
  63. package/lib/tabs/Panel.js +1 -3
  64. package/lib/tabs/index.js +151 -20
  65. package/lib/tabs/tabs.spec.js +8 -5
  66. package/lib/toolbar/index.js +8 -4
  67. package/lib/tooltip/index.js +20 -7
  68. package/lib/treeview/Node.js +347 -48
  69. package/lib/treeview/index.js +456 -35
  70. package/package.json +9 -8
package/lib/tabs/index.js CHANGED
@@ -33,6 +33,14 @@ function _interopRequireWildcard(obj, nodeInterop) { if (!nodeInterop && obj &&
33
33
 
34
34
  function _extends() { _extends = Object.assign || 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); }
35
35
 
36
+ function _toConsumableArray(arr) { return _arrayWithoutHoles(arr) || _iterableToArray(arr) || _unsupportedIterableToArray(arr) || _nonIterableSpread(); }
37
+
38
+ function _nonIterableSpread() { throw new TypeError("Invalid attempt to spread non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); }
39
+
40
+ function _iterableToArray(iter) { if (typeof Symbol !== "undefined" && iter[Symbol.iterator] != null || iter["@@iterator"] != null) return Array.from(iter); }
41
+
42
+ function _arrayWithoutHoles(arr) { if (Array.isArray(arr)) return _arrayLikeToArray(arr); }
43
+
36
44
  function _slicedToArray(arr, i) { return _arrayWithHoles(arr) || _iterableToArrayLimit(arr, i) || _unsupportedIterableToArray(arr, i) || _nonIterableRest(); }
37
45
 
38
46
  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."); }
@@ -51,48 +59,160 @@ var Tabs = function Tabs(props) {
51
59
  handlerCloseTab = props.handlerCloseTab,
52
60
  tabMenuPosition = props.tabMenuPosition,
53
61
  style = props.style,
54
- selectedTab = props.selectedTab;
62
+ selectedTab = props.selectedTab,
63
+ toolbar = props.toolbar;
55
64
 
56
65
  var _useState = (0, _react.useState)((0, _tabHelpers.buildPanels)(children) || []),
57
66
  _useState2 = _slicedToArray(_useState, 2),
58
67
  panels = _useState2[0],
59
68
  setPanels = _useState2[1];
60
69
 
61
- var _useState3 = (0, _react.useState)(selectedTab || panels[0].props.id),
70
+ var _useState3 = (0, _react.useState)([]),
62
71
  _useState4 = _slicedToArray(_useState3, 2),
63
- selectedTabId = _useState4[0],
64
- setSelectedTabId = _useState4[1];
72
+ currentPanels = _useState4[0],
73
+ setCurrentPanels = _useState4[1];
65
74
 
66
- var _useState5 = (0, _react.useState)(''),
67
- _useState6 = _slicedToArray(_useState5, 1),
68
- customClass = _useState6[0];
75
+ var _useState5 = (0, _react.useState)([]),
76
+ _useState6 = _slicedToArray(_useState5, 2),
77
+ dropdownPanels = _useState6[0],
78
+ setDropdownPanels = _useState6[1];
69
79
 
70
- var _useState7 = (0, _react.useState)(undefined),
80
+ var _useState7 = (0, _react.useState)(selectedTab || panels[0].props.id),
71
81
  _useState8 = _slicedToArray(_useState7, 2),
72
- contentHeight = _useState8[0],
73
- setContentHeight = _useState8[1];
82
+ selectedTabId = _useState8[0],
83
+ setSelectedTabId = _useState8[1];
84
+
85
+ var _useState9 = (0, _react.useState)(''),
86
+ _useState10 = _slicedToArray(_useState9, 1),
87
+ customClass = _useState10[0];
88
+
89
+ var _useState11 = (0, _react.useState)(undefined),
90
+ _useState12 = _slicedToArray(_useState11, 2),
91
+ contentHeight = _useState12[0],
92
+ setContentHeight = _useState12[1];
93
+
94
+ var _useState13 = (0, _react.useState)(0),
95
+ _useState14 = _slicedToArray(_useState13, 2),
96
+ tabsContentWidth = _useState14[0],
97
+ setTabsContentWidth = _useState14[1];
98
+
99
+ var _useState15 = (0, _react.useState)(false),
100
+ _useState16 = _slicedToArray(_useState15, 2),
101
+ hasMenuAttributes = _useState16[0],
102
+ setHasMenuAttributes = _useState16[1];
103
+
104
+ var _useState17 = (0, _react.useState)(0),
105
+ _useState18 = _slicedToArray(_useState17, 2),
106
+ dropdownWidth = _useState18[0],
107
+ setDropdownWidth = _useState18[1];
108
+
109
+ var componentRef = (0, _react.useRef)(null);
110
+
111
+ var _menuRef = (0, _react.useRef)(null);
112
+
113
+ var _toolBarRef = (0, _react.useRef)(null);
114
+
115
+ var getTabListWidth = function getTabListWidth() {
116
+ var tabMenu = _menuRef.current.children[0];
117
+
118
+ var tabList = _toConsumableArray(tabMenu.children);
119
+
120
+ var tabsListWidth = tabList.reduce(function (total, tab) {
121
+ return total + tab.clientWidth;
122
+ }, 0);
123
+ return tabsListWidth;
124
+ };
125
+
126
+ var getMenuAttributes = function getMenuAttributes() {
127
+ var menuSize = _menuRef.current.clientWidth;
128
+ var toolbarSize = toolbar && _toolBarRef ? _toolBarRef.current.clientWidth : 0;
129
+ var contentWidth = (toolbar ? menuSize - toolbarSize : menuSize) - dropdownWidth;
130
+ setTabsContentWidth(contentWidth);
131
+ };
132
+
133
+ var getTabsList = function getTabsList() {
134
+ var tabsListWidth = getTabListWidth();
74
135
 
75
- var componentRef = (0, _react.useRef)();
136
+ var newDropdownPanels = _toConsumableArray(dropdownPanels);
76
137
 
77
- var _menuRef = (0, _react.useRef)();
138
+ var newCurrentPanels = _toConsumableArray(panels);
139
+
140
+ if (newDropdownPanels.length) {
141
+ var newDropdownPanelsIds = newDropdownPanels.map(function (dd) {
142
+ return dd.props.id;
143
+ });
144
+ newCurrentPanels = newCurrentPanels.filter(function (tab) {
145
+ return !newDropdownPanelsIds.includes(tab.props.id);
146
+ });
147
+ }
148
+
149
+ if (tabsListWidth > tabsContentWidth) {
150
+ var lastPanel = newCurrentPanels[newCurrentPanels.length - 1];
151
+ newDropdownPanels.push(lastPanel);
152
+ newCurrentPanels.pop();
153
+ } else if (tabsListWidth + 110 < tabsContentWidth && newDropdownPanels.length) {
154
+ newCurrentPanels.push(newDropdownPanels[0]);
155
+ newDropdownPanels.shift();
156
+ }
157
+
158
+ setCurrentPanels(newCurrentPanels);
159
+ setDropdownPanels(newDropdownPanels);
160
+ };
78
161
 
79
162
  var onMenuClick = function onMenuClick(tabId) {
80
- setSelectedTabId(tabId);
163
+ var includedInDropdown = dropdownPanels.filter(function (item) {
164
+ return item.props.id === tabId;
165
+ });
166
+
167
+ if (includedInDropdown.length > 0 && getTabListWidth() > 0) {
168
+ var newDropdownPanels = dropdownPanels.filter(function (item) {
169
+ return item.props.id !== tabId;
170
+ });
171
+ var newPanels = panels.filter(function (item) {
172
+ return item.props.id !== tabId;
173
+ });
174
+ var newCurrentPanels = currentPanels.slice(0, -1);
175
+ newDropdownPanels.push(currentPanels.pop());
176
+ newPanels.unshift(includedInDropdown[0]);
177
+ newCurrentPanels.unshift(includedInDropdown[0]);
178
+ setPanels(newPanels);
179
+ setDropdownPanels(newDropdownPanels);
180
+ setCurrentPanels(newCurrentPanels);
181
+ }
182
+
81
183
  if (handlerTabClick) handlerTabClick(tabId);
184
+ setSelectedTabId(tabId);
82
185
  };
83
186
 
84
187
  var onRemovePanel = function onRemovePanel(closedPanelId, panelIndex) {
85
- var remainPanels = panels.filter(function (panel) {
86
- return panel.props.id !== closedPanelId;
87
- });
88
- var newSelectedTabId = selectedTabId === closedPanelId ? remainPanels[panelIndex - (panelIndex === 0 ? 0 : 1)].props.id : selectedTabId;
89
- setSelectedTabId(newSelectedTabId);
188
+ var fromDropdownPanels = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : false;
189
+ var newSelectedTabId = selectedTabId;
190
+ var remainPanels;
191
+
192
+ if (!fromDropdownPanels) {
193
+ remainPanels = panels.filter(function (panel) {
194
+ return panel.props.id !== closedPanelId;
195
+ });
196
+ newSelectedTabId = selectedTabId === closedPanelId ? remainPanels[panelIndex - (panelIndex === 0 ? 0 : 1)].props.id : selectedTabId;
197
+ setSelectedTabId(newSelectedTabId);
198
+ } else {
199
+ remainPanels = dropdownPanels.filter(function (panel) {
200
+ return panel.props.id !== closedPanelId;
201
+ });
202
+ setDropdownPanels(remainPanels);
203
+ }
204
+
90
205
  if (handlerCloseTab) handlerCloseTab(closedPanelId, newSelectedTabId);
91
206
  };
92
207
 
93
208
  var onResize = function onResize() {
94
209
  if (componentRef.current && _menuRef.current) {
95
210
  setContentHeight(componentRef.current.offsetHeight - _menuRef.current.offsetHeight);
211
+
212
+ if (!hasMenuAttributes && _menuRef.current && _menuRef.current.clientWidth > 0 && dropdownWidth) {
213
+ getMenuAttributes();
214
+ setHasMenuAttributes(true);
215
+ }
96
216
  }
97
217
  };
98
218
 
@@ -101,8 +221,12 @@ var Tabs = function Tabs(props) {
101
221
  menuRef: function menuRef(ref) {
102
222
  _menuRef.current = ref;
103
223
  },
224
+ toolBarRef: function toolBarRef(ref) {
225
+ _toolBarRef.current = ref;
226
+ },
104
227
  customClass: customClass,
105
- panels: panels,
228
+ currentPanels: currentPanels,
229
+ dropdownPanels: dropdownPanels,
106
230
  selectedTabId: selectedTabId,
107
231
  handlerClick: onMenuClick,
108
232
  handlerRemovePanel: onRemovePanel
@@ -125,11 +249,18 @@ var Tabs = function Tabs(props) {
125
249
  return function () {
126
250
  return window.removeEventListener('resize', onResize);
127
251
  };
128
- }, []);
252
+ }, [_menuRef.current, dropdownWidth]);
129
253
  (0, _react.useEffect)(function () {
130
254
  if (selectedTab) setSelectedTabId(selectedTab);
131
255
  if (children) setPanels((0, _tabHelpers.buildPanels)(children));
132
256
  }, [selectedTab, children]);
257
+ (0, _react.useEffect)(function () {
258
+ getTabsList();
259
+ }, [panels.length, currentPanels.length, tabsContentWidth]);
260
+ (0, _react.useEffect)(function () {
261
+ var currentDropdownWidth = dropdownPanels.length > 0 ? _menuRef.current.children[1].clientWidth : 0;
262
+ setDropdownWidth(currentDropdownWidth);
263
+ }, [dropdownPanels.length]);
133
264
 
134
265
  var getContextValues = function getContextValues() {
135
266
  return {
@@ -135,7 +135,7 @@ describe('Tabs', function () {
135
135
  container = _render10.container;
136
136
 
137
137
  expect(container.querySelector('.tabs-component')).toHaveClass('menu-bottom');
138
- expect(container.querySelector('.tabs-component').lastChild).toHaveClass('menu');
138
+ expect(container.querySelector('.tabs-component').lastChild).toHaveClass('menucontainer');
139
139
  });
140
140
  it('should apply tabMenuAlign', function () {
141
141
  var _render11 = (0, _react2.render)(tabsMockRender({
@@ -328,7 +328,8 @@ describe('Tabs', function () {
328
328
  })),
329
329
  container = _render23.container;
330
330
 
331
- expect(container.querySelector('ul.menu li.menuitem button')).not.toHaveAttribute('disabled');
331
+ var noPermissionComponent = container.querySelector('.no-permission-component');
332
+ expect(noPermissionComponent).toBeFalsy();
332
333
  });
333
334
  it('should check permission and be unavailable', function () {
334
335
  Object.defineProperty(window, 'sessionStorage', {
@@ -336,11 +337,13 @@ describe('Tabs', function () {
336
337
  });
337
338
 
338
339
  var _render24 = (0, _react2.render)(tabsMockRender({}, {
339
- permissionAttr: (0, _storageMock.permissionAttrMockUnauthorized)('disabled')
340
+ permissionAttr: (0, _storageMock.permissionAttrMockUnauthorized)('hideContent')
340
341
  })),
341
- container = _render24.container;
342
+ container = _render24.container; // debug();
342
343
 
343
- expect(container.querySelector('ul.menu li.menuitem button')).toHaveAttribute('disabled');
344
+
345
+ var noPermissionComponent = container.querySelector('.no-permission-component');
346
+ expect(noPermissionComponent).toBeTruthy();
344
347
  });
345
348
  });
346
349
  });
@@ -49,10 +49,12 @@ var ToolBar = function ToolBar(_ref) {
49
49
  var size = _ref.size,
50
50
  customClass = _ref.customClass,
51
51
  style = _ref.style,
52
- children = _ref.children;
52
+ children = _ref.children,
53
+ innerRef = _ref.innerRef;
53
54
  return /*#__PURE__*/_react["default"].createElement("div", {
54
55
  className: "toolbar-component ".concat(size && "".concat(size, "-bar"), " ").concat(customClass),
55
- style: style
56
+ style: style,
57
+ ref: innerRef
56
58
  }, children);
57
59
  };
58
60
 
@@ -60,12 +62,14 @@ ToolBar.propTypes = {
60
62
  size: _propTypes["default"].oneOf(['small', 'large']),
61
63
  style: _propTypes["default"].object,
62
64
  children: _propTypes["default"].any.isRequired,
63
- customClass: _propTypes["default"].string
65
+ customClass: _propTypes["default"].string,
66
+ innerRef: _propTypes["default"].func
64
67
  };
65
68
  ToolBar.defaultProps = {
66
69
  size: null,
67
70
  style: {},
68
- customClass: ''
71
+ customClass: '',
72
+ innerRef: null
69
73
  };
70
74
  var _default = ToolBar;
71
75
  exports["default"] = _default;
@@ -25,27 +25,38 @@ function _interopRequireWildcard(obj, nodeInterop) { if (!nodeInterop && obj &&
25
25
 
26
26
  var Tooltip = function Tooltip(props) {
27
27
  var className = props.className,
28
+ tooltipDimensions = props.tooltipDimensions,
28
29
  handlerSetDimensions = props.handlerSetDimensions,
29
30
  style = props.style,
30
- text = props.text;
31
+ text = props.text,
32
+ tooltipRef = props.tooltipRef;
31
33
  var tooltipComponent = (0, _react.useRef)(document.createElement('div'));
32
- tooltipComponent.current.id = "tooltip-".concat(_uuid["default"].v1());
33
- tooltipComponent.current.className = "tooltip-component ".concat(className, " ");
34
- tooltipComponent.current.dataset.testid = 'tooltip-component';
35
- tooltipComponent.current.style = style;
36
34
  (0, _react.useEffect)(function () {
35
+ tooltipComponent.current.id = "tooltip-".concat(_uuid["default"].v1());
36
+ tooltipComponent.current.className = "tooltip-component ".concat(className, " ");
37
+ tooltipComponent.current.dataset.testid = 'tooltip-component';
38
+ tooltipComponent.current.style = style;
37
39
  document.body.appendChild(tooltipComponent.current);
38
40
  var tooltipEl = document.querySelector("div#".concat(tooltipComponent.current.id));
39
41
  var width = tooltipEl.offsetWidth;
42
+
43
+ if (tooltipDimensions.width) {
44
+ width = tooltipDimensions.width;
45
+ }
46
+
40
47
  var height = tooltipEl.offsetHeight;
41
48
  handlerSetDimensions({
42
49
  width: width,
43
50
  height: height
44
51
  });
52
+ if (tooltipRef) tooltipRef.current = tooltipEl;
45
53
  return function () {
46
54
  return document.body.removeChild(tooltipComponent.current);
47
55
  };
48
56
  }, []);
57
+ (0, _react.useEffect)(function () {
58
+ tooltipComponent.current.className = "tooltip-component ".concat(className, " ");
59
+ }, [className]);
49
60
  (0, _react.useEffect)(function () {
50
61
  tooltipComponent.current.style = style;
51
62
  }, [style]);
@@ -63,13 +74,15 @@ Tooltip.propTypes = {
63
74
  text: _propTypes["default"].string,
64
75
  style: _propTypes["default"].string,
65
76
  className: _propTypes["default"].string,
66
- handlerSetDimensions: _propTypes["default"].func
77
+ handlerSetDimensions: _propTypes["default"].func,
78
+ tooltipRef: _propTypes["default"].object
67
79
  };
68
80
  Tooltip.defaultProps = {
69
81
  text: undefined,
70
82
  className: 'bottom',
71
83
  style: '',
72
- handlerSetDimensions: undefined
84
+ handlerSetDimensions: undefined,
85
+ tooltipRef: null
73
86
  };
74
87
  var _default = Tooltip;
75
88
  exports["default"] = _default;