linear-react-components-ui 0.4.76-beta.31 → 0.4.76-beta.32

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.
@@ -48,7 +48,7 @@
48
48
  }
49
49
  }
50
50
 
51
- .select-component > .dropdown {
51
+ .dropdown-component > .select-dropdown {
52
52
  animation: 0.5s ease-in 0s 1 slideDown;
53
53
  background-color: #FFF;
54
54
  border: $component-border-color;
@@ -58,17 +58,17 @@
58
58
  height: auto;
59
59
  overflow-y: auto;
60
60
  overflow-x: hidden;
61
- position: absolute;
62
61
  margin-top: 2px;
63
- z-index: 99999999999;
64
62
  > .filtercontainer {
65
63
  display: grid;
66
64
  grid-template-columns: 1fr 20px;
65
+ align-items: center;
67
66
  border: 1px solid $component-border-color;
68
67
  margin: 4px;
69
68
  }
70
69
  > .filtercontainer > .filterinput {
71
70
  border: 0;
71
+ width: 100%;
72
72
  font-size: 13px;
73
73
  text-indent: 4px;
74
74
  padding: 10px 5px;
@@ -18,8 +18,9 @@ var getCalendarDropdownStyle = function getCalendarDropdownStyle(_ref) {
18
18
  leftPosition = _ref.leftPosition,
19
19
  rightPosition = _ref.rightPosition,
20
20
  align = _ref.align,
21
- isFloatMenu = _ref.isFloatMenu;
22
- var style = "top: ".concat(topPosition + (isFloatMenu ? 6 : 2), "px;");
21
+ isFloatMenu = _ref.isFloatMenu,
22
+ minWidth = _ref.minWidth;
23
+ var style = "top: ".concat(topPosition + (isFloatMenu ? 6 : 2), "px; min-width: ").concat(minWidth, "px;");
23
24
 
24
25
  if (align === 'left') {
25
26
  style += "left: ".concat(leftPosition, "px;");
@@ -17,6 +17,8 @@ var _avatar = _interopRequireDefault(require("../../avatar"));
17
17
 
18
18
  var helper = _interopRequireWildcard(require("./helper"));
19
19
 
20
+ var _Popup = _interopRequireDefault(require("../../dropdown/Popup"));
21
+
20
22
  function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { "default": obj }; }
21
23
 
22
24
  function _getRequireWildcardCache(nodeInterop) { if (typeof WeakMap !== "function") return null; var cacheBabelInterop = new WeakMap(); var cacheNodeInterop = new WeakMap(); return (_getRequireWildcardCache = function _getRequireWildcardCache(nodeInterop) { return nodeInterop ? cacheNodeInterop : cacheBabelInterop; })(nodeInterop); }
@@ -37,67 +39,50 @@ function _iterableToArrayLimit(arr, i) { var _i = arr && (typeof Symbol !== "und
37
39
 
38
40
  function _arrayWithHoles(arr) { if (Array.isArray(arr)) return arr; }
39
41
 
40
- var returnDropdownDynamicStyles = function returnDropdownDynamicStyles(selectFieldRef, dropdownMaxHeight) {
41
- var selectFieldRects = selectFieldRef.current.getBoundingClientRect();
42
- var dropdownBottomDistance = window.innerHeight - selectFieldRects.bottom;
43
- var maxDropdownBottomDistance = 200;
44
- var height = dropdownMaxHeight;
45
- var dropdownPosition;
46
-
47
- if (!height || height <= 0) {
48
- if (dropdownBottomDistance < maxDropdownBottomDistance) {
49
- height = selectFieldRects.top;
50
- dropdownPosition = window.innerHeight - selectFieldRef.current.offsetTop + 10;
51
- } else {
52
- height = dropdownBottomDistance;
53
- }
54
- } else {
55
- maxDropdownBottomDistance = height;
56
-
57
- if (dropdownBottomDistance < maxDropdownBottomDistance) {
58
- dropdownPosition = window.innerHeight - selectFieldRef.current.offsetTop + 10;
42
+ var Dropdown = function Dropdown(props) {
43
+ var dataCombo = props.dataCombo,
44
+ dropdownWidth = props.dropdownWidth,
45
+ selected = props.selected,
46
+ handleOnSelect = props.handleOnSelect,
47
+ handleOnFilter = props.handleOnFilter,
48
+ searchOnDropdown = props.searchOnDropdown,
49
+ handleOnKeydown = props.handleOnKeydown,
50
+ searchNotFoundText = props.searchNotFoundText,
51
+ handleOnBlur = props.handleOnBlur,
52
+ handleOnFocus = props.handleOnFocus,
53
+ opened = props.opened,
54
+ idKey = props.idKey,
55
+ descriptionKey = props.descriptionKey,
56
+ currents = props.currents,
57
+ imageAlign = props.imageAlign,
58
+ striped = props.striped,
59
+ imgSrcKey = props.imgSrcKey,
60
+ gridWrapperStyle = props.gridWrapperStyle,
61
+ inputValue = props.inputValue,
62
+ dropdownRef = props.dropdownRef;
63
+
64
+ var _useState = (0, _react.useState)(helper.returnDropdownDynamicStyles(_extends({}, props))),
65
+ _useState2 = _slicedToArray(_useState, 2),
66
+ dropdownDynamicStyles = _useState2[0],
67
+ setDropdownDynamicStyles = _useState2[1];
68
+
69
+ (0, _react.useEffect)(function () {
70
+ if (dropdownRef.current) {
71
+ setDropdownDynamicStyles(helper.returnDropdownDynamicStyles(_extends({}, props)));
59
72
  }
60
- }
61
-
62
- return {
63
- maxHeight: "".concat(height - 30, "px"),
64
- bottom: dropdownBottomDistance < maxDropdownBottomDistance && "".concat(dropdownPosition, "px")
65
- };
66
- };
67
-
68
- var Dropdown = function Dropdown(_ref) {
69
- var dataCombo = _ref.dataCombo,
70
- dropdownWidth = _ref.dropdownWidth,
71
- selected = _ref.selected,
72
- handleOnSelect = _ref.handleOnSelect,
73
- handleOnFilter = _ref.handleOnFilter,
74
- searchOnDropdown = _ref.searchOnDropdown,
75
- handleOnKeydown = _ref.handleOnKeydown,
76
- searchNotFoundText = _ref.searchNotFoundText,
77
- handleOnBlur = _ref.handleOnBlur,
78
- handleOnFocus = _ref.handleOnFocus,
79
- opened = _ref.opened,
80
- idKey = _ref.idKey,
81
- descriptionKey = _ref.descriptionKey,
82
- currents = _ref.currents,
83
- imageAlign = _ref.imageAlign,
84
- striped = _ref.striped,
85
- imgSrcKey = _ref.imgSrcKey,
86
- gridWrapperStyle = _ref.gridWrapperStyle,
87
- selectFieldRef = _ref.selectFieldRef,
88
- dropdownMaxHeight = _ref.dropdownMaxHeight,
89
- inputValue = _ref.inputValue;
90
-
91
- var _useState = (0, _react.useState)(returnDropdownDynamicStyles(selectFieldRef, dropdownMaxHeight)),
92
- _useState2 = _slicedToArray(_useState, 1),
93
- dropdownDynamicStyles = _useState2[0];
94
-
95
- return /*#__PURE__*/_react["default"].createElement("div", {
96
- className: "dropdown",
97
- style: _extends({
73
+ }, [dropdownRef.current, dataCombo]);
74
+ return /*#__PURE__*/_react["default"].createElement(_Popup["default"], {
75
+ leftPosition: dropdownDynamicStyles.left,
76
+ topPosition: dropdownDynamicStyles.top,
77
+ minWidth: dropdownWidth
78
+ }, /*#__PURE__*/_react["default"].createElement("div", {
79
+ className: "select-dropdown",
80
+ ref: dropdownRef,
81
+ style: {
98
82
  width: dropdownWidth,
99
- marginLeft: gridWrapperStyle ? gridWrapperStyle.paddingLeft : '0'
100
- }, dropdownDynamicStyles)
83
+ marginLeft: gridWrapperStyle ? gridWrapperStyle.paddingLeft : '0',
84
+ maxHeight: dropdownDynamicStyles.maxHeight
85
+ }
101
86
  }, searchOnDropdown && /*#__PURE__*/_react["default"].createElement("div", {
102
87
  className: "filtercontainer"
103
88
  }, /*#__PURE__*/_react["default"].createElement("input", {
@@ -153,7 +138,7 @@ var Dropdown = function Dropdown(_ref) {
153
138
  }, item[descriptionKey])));
154
139
  }), dataCombo.length === 0 && /*#__PURE__*/_react["default"].createElement("div", {
155
140
  className: "notfound"
156
- }, searchNotFoundText));
141
+ }, searchNotFoundText)));
157
142
  };
158
143
 
159
144
  Dropdown.propTypes = {
@@ -171,13 +156,14 @@ Dropdown.propTypes = {
171
156
  handleOnBlur: _propTypes["default"].func.isRequired,
172
157
  handleOnFocus: _propTypes["default"].func.isRequired,
173
158
  opened: _propTypes["default"].bool.isRequired,
159
+ dropdownRef: _propTypes["default"].object.isRequired,
174
160
  currents: _propTypes["default"].arrayOf(_propTypes["default"].object),
175
161
  imageAlign: _propTypes["default"].oneOf(['left', 'right']),
176
162
  striped: _propTypes["default"].bool,
177
163
  gridWrapperStyle: _propTypes["default"].object,
178
164
  selectFieldRef: _propTypes["default"].object,
179
165
  dropdownMaxHeight: _propTypes["default"].number,
180
- inputValue: _propTypes["default"].string.isRequired
166
+ inputValue: _propTypes["default"].string
181
167
  };
182
168
  Dropdown.defaultProps = {
183
169
  selected: null,
@@ -187,7 +173,8 @@ Dropdown.defaultProps = {
187
173
  imgSrcKey: undefined,
188
174
  gridWrapperStyle: undefined,
189
175
  selectFieldRef: undefined,
190
- dropdownMaxHeight: undefined
176
+ dropdownMaxHeight: undefined,
177
+ inputValue: undefined
191
178
  };
192
179
  var _default = Dropdown;
193
180
  exports["default"] = _default;
@@ -3,7 +3,7 @@
3
3
  Object.defineProperty(exports, "__esModule", {
4
4
  value: true
5
5
  });
6
- exports.getFilteredMultipleDataCombo = exports.getFilteredSimpleDataCombo = exports.getDropdownItemCssClass = exports.contentClass = void 0;
6
+ exports.returnDropdownDynamicStyles = exports.getFilteredMultipleDataCombo = exports.getFilteredSimpleDataCombo = exports.getDropdownItemCssClass = exports.contentClass = void 0;
7
7
 
8
8
  var contentClass = function contentClass(props) {
9
9
  return "content ".concat(props.showClearButton ? '' : 'noclear');
@@ -42,4 +42,67 @@ var getFilteredMultipleDataCombo = function getFilteredMultipleDataCombo(_ref2)
42
42
  });
43
43
  };
44
44
 
45
- exports.getFilteredMultipleDataCombo = getFilteredMultipleDataCombo;
45
+ exports.getFilteredMultipleDataCombo = getFilteredMultipleDataCombo;
46
+
47
+ var returnDropdownPosition = function returnDropdownPosition(_ref3) {
48
+ var selectFieldRects = _ref3.selectFieldRects,
49
+ dropdownRef = _ref3.dropdownRef,
50
+ dropdownRects = _ref3.dropdownRects;
51
+ var aboveDropdown = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : false;
52
+ var DEFAULT_MARGIN_BOTTOM = 10;
53
+
54
+ if (aboveDropdown) {
55
+ return selectFieldRects.top + window.scrollY - (dropdownRef.current && dropdownRects.height) - DEFAULT_MARGIN_BOTTOM;
56
+ }
57
+
58
+ return selectFieldRects.top + window.scrollY + selectFieldRects.height;
59
+ };
60
+
61
+ var returnDropdownDynamicStyles = function returnDropdownDynamicStyles(_ref4) {
62
+ var selectFieldRef = _ref4.selectFieldRef,
63
+ dropdownMaxHeight = _ref4.dropdownMaxHeight,
64
+ dropdownRef = _ref4.dropdownRef;
65
+ var selectFieldRects = selectFieldRef.current.getBoundingClientRect();
66
+ var dropdownRects = dropdownRef.current && dropdownRef.current.getBoundingClientRect();
67
+ var dropdownBottomDistance = window.innerHeight - selectFieldRects.bottom;
68
+ var bottomOffset = 30;
69
+ var maxDropdownBottomDistance = 200;
70
+ var height = dropdownMaxHeight;
71
+ var dropdownPosition;
72
+
73
+ if (!height || height <= 0) {
74
+ if (dropdownBottomDistance < maxDropdownBottomDistance) {
75
+ height = selectFieldRects.top;
76
+ dropdownPosition = returnDropdownPosition({
77
+ selectFieldRects: selectFieldRects,
78
+ dropdownRef: dropdownRef,
79
+ dropdownRects: dropdownRects
80
+ }, true);
81
+ } else {
82
+ height = dropdownBottomDistance;
83
+ dropdownPosition = returnDropdownPosition({
84
+ selectFieldRects: selectFieldRects
85
+ });
86
+ }
87
+ } else {
88
+ maxDropdownBottomDistance = height;
89
+
90
+ if (dropdownBottomDistance < maxDropdownBottomDistance) {
91
+ dropdownPosition = returnDropdownPosition({
92
+ selectFieldRects: selectFieldRects,
93
+ dropdownRef: dropdownRef,
94
+ dropdownRects: dropdownRects
95
+ }, true);
96
+ } else {
97
+ dropdownPosition = returnDropdownPosition(selectFieldRects);
98
+ }
99
+ }
100
+
101
+ return {
102
+ maxHeight: height - bottomOffset,
103
+ top: dropdownPosition,
104
+ left: selectFieldRects.left
105
+ };
106
+ };
107
+
108
+ exports.returnDropdownDynamicStyles = returnDropdownDynamicStyles;
@@ -83,6 +83,7 @@ var MultipleSelect = /*#__PURE__*/function (_Component) {
83
83
 
84
84
  _this.componentId = "select-component".concat(_uuid["default"].v1());
85
85
  _this.componentRef = /*#__PURE__*/_react["default"].createRef();
86
+ _this.dropdownRef = /*#__PURE__*/_react["default"].createRef();
86
87
  _this.state = {
87
88
  valueFromProps: null,
88
89
  dataCombo: props.dataSource,
@@ -142,10 +143,11 @@ var MultipleSelect = /*#__PURE__*/function (_Component) {
142
143
  }, {
143
144
  key: "onClickOutside",
144
145
  value: function onClickOutside(event) {
145
- var selectWrapper = this.selectWrapper;
146
+ var selectWrapper = this.selectWrapper,
147
+ dropdownRef = this.dropdownRef;
146
148
  var target = event.target;
147
149
 
148
- if (target !== selectWrapper && !selectWrapper.contains(target)) {
150
+ if (target !== selectWrapper && !selectWrapper.contains(target) && dropdownRef.current && !dropdownRef.current.contains(target)) {
149
151
  this.setState({
150
152
  opened: false
151
153
  });
@@ -363,6 +365,7 @@ var MultipleSelect = /*#__PURE__*/function (_Component) {
363
365
  handleOnUnselect: this.onUnselect
364
366
  }))), opened && /*#__PURE__*/_react["default"].createElement(_Dropdown["default"], _extends({}, this.state, this.props, {
365
367
  selectFieldRef: this.componentRef,
368
+ dropdownRef: this.dropdownRef,
366
369
  gridWrapperStyle: gridLayout ? window.getComputedStyle(this.gridEl) : undefined,
367
370
  handleOnSelect: this.onSelect,
368
371
  handleOnFilter: this.onFilter,
@@ -78,6 +78,7 @@ var SimpleSelect = /*#__PURE__*/function (_Component) {
78
78
  onDenied: undefined,
79
79
  isTyping: false
80
80
  };
81
+ _this.dropdownRef = /*#__PURE__*/_react["default"].createRef();
81
82
  _this.componentId = "select-component".concat(_uuid["default"].v1());
82
83
  _this.componentRef = /*#__PURE__*/_react["default"].createRef();
83
84
  return _this;
@@ -152,6 +153,7 @@ var SimpleSelect = /*#__PURE__*/function (_Component) {
152
153
  }))
153
154
  })), opened && /*#__PURE__*/_react["default"].createElement(_Dropdown["default"], _extends({}, this.state, this.props, {
154
155
  selectFieldRef: this.componentRef,
156
+ dropdownRef: this.dropdownRef,
155
157
  gridWrapperStyle: gridLayout ? window.getComputedStyle(this.gridEl) : undefined,
156
158
  handleOnSelect: this.onSelect,
157
159
  handleOnFilter: this.onFilter,
@@ -172,14 +174,14 @@ Object.defineProperty(SimpleSelect, "getDerivedStateFromProps", {
172
174
  value: function value(props, state) {
173
175
  var value = props.value,
174
176
  dataSource = props.dataSource,
177
+ descriptionKey = props.descriptionKey,
175
178
  idKey = props.idKey,
176
179
  selectFirstOnEnter = props.selectFirstOnEnter,
177
- descriptionKey = props.descriptionKey,
178
180
  remoteSearch = props.remoteSearch,
179
181
  undigitable = props.undigitable;
180
182
  var current = null;
181
183
 
182
- if (value !== state.valueFromProps) {
184
+ if (value !== state.valueFromProps && dataSource.length > 0) {
183
185
  if (value !== null) {
184
186
  current = dataSource.find(function (i) {
185
187
  return i[idKey].toString().toLowerCase() === value.toString().toLowerCase();
@@ -227,10 +229,11 @@ var _initialiseProps = function _initialiseProps() {
227
229
  enumerable: true,
228
230
  writable: true,
229
231
  value: function value(event) {
230
- var selectWrapper = _this3.selectWrapper;
232
+ var selectWrapper = _this3.selectWrapper,
233
+ dropdownRef = _this3.dropdownRef;
231
234
  var target = event.target;
232
235
 
233
- if (target !== selectWrapper && !selectWrapper.contains(target)) {
236
+ if (target !== selectWrapper && !selectWrapper.contains(target) && dropdownRef.current && !dropdownRef.current.contains(target)) {
234
237
  _this3.setState({
235
238
  opened: false
236
239
  });
@@ -42,11 +42,11 @@ var getColumnsWidth = function getColumnsWidth(children) {
42
42
  };
43
43
 
44
44
  var getColumnsCount = function getColumnsCount(children) {
45
- if (children && children.props) {
46
- var columnsChildren = children.props.children;
47
- return columnsChildren.length;
45
+ if (_lodash["default"].isArray(children) && children.length > 0 && children[0].props) {
46
+ return children[0].props.children.length;
48
47
  }
49
48
 
49
+ if (children && children.props) return children.props.children.length;
50
50
  return undefined;
51
51
  };
52
52
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "linear-react-components-ui",
3
- "version": "0.4.76-beta.31",
3
+ "version": "0.4.76-beta.32",
4
4
  "description": "Linear Sistemas ReactJs Components",
5
5
  "main": "lib/index.js",
6
6
  "scripts": {
@@ -1,16 +0,0 @@
1
- "use strict";
2
-
3
- Object.defineProperty(exports, "__esModule", {
4
- value: true
5
- });
6
- exports["default"] = void 0;
7
-
8
- var getCalendarDropdownStyle = function getCalendarDropdownStyle(_ref) {
9
- var topPosition = _ref.topPosition,
10
- leftPosition = _ref.leftPosition,
11
- width = _ref.width;
12
- return "top: ".concat(topPosition, "px;\n left: ").concat(leftPosition, "px;\n width:").concat(width, "px");
13
- };
14
-
15
- var _default = getCalendarDropdownStyle;
16
- exports["default"] = _default;