linear-react-components-ui 0.4.76-beta.27 → 0.4.76-beta.28
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.
- package/README.md +7 -5
- package/lib/assets/styles/select.scss +3 -3
- package/lib/assets/styles/sidenav.scss +1 -7
- package/lib/assets/styles/treeview.scss +4 -0
- package/lib/dropdown/Popup.js +3 -2
- package/lib/form/form.spec.js +8 -0
- package/lib/form/index.js +40 -21
- package/lib/inputs/mask/Phone.js +10 -1
- package/lib/inputs/mask/input_mask.spec.js +21 -4
- package/lib/inputs/select/Dropdown.js +48 -62
- package/lib/inputs/select/helper.js +65 -2
- package/lib/inputs/select/multiple/index.js +7 -4
- package/lib/inputs/select/simple/index.js +7 -4
- package/lib/internals/constants.js +3 -4
- package/lib/list/Item.js +7 -31
- package/lib/list/index.js +10 -88
- package/lib/list/list.spec.js +102 -230
- package/lib/menus/sidenav/NavMenuItem.js +4 -12
- package/lib/menus/sidenav/index.js +81 -47
- package/lib/menus/sidenav/popup_menu_search/index.js +15 -21
- package/lib/menus/sidenav/sidenav.spec.js +19 -86
- package/lib/treeview/Node.js +25 -5
- package/lib/treeview/index.js +11 -3
- package/lib/treeview/treeview.spec.js +18 -0
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -71,14 +71,16 @@ ficando da seguinte maneira:
|
|
|
71
71
|
|
|
72
72
|
### Publicar versão de demonstração no Heroku
|
|
73
73
|
|
|
74
|
+
Pré-requesistos
|
|
75
|
+
- Ter um conta no heroku
|
|
76
|
+
- Ser um colaborador do projeto no Heroku
|
|
77
|
+
- Ter o heroku cli instalado: https://devcenter.heroku.com/articles/heroku-cli#install-the-heroku-cli
|
|
74
78
|
|
|
75
|
-
No diretorio da aplicação clonar
|
|
76
|
-
`heroku git:clone -a linear-react-comp-demo`
|
|
77
|
-
|
|
78
|
-
Renomear a pastar `linear-react-comp-demo` para `demo`
|
|
79
|
-
|
|
80
79
|
Fazer login no Heroku
|
|
81
80
|
`heroku login`
|
|
81
|
+
|
|
82
|
+
No diretorio da aplicação clonar
|
|
83
|
+
`heroku git:clone -a linear-react-comp-demo demo`
|
|
82
84
|
|
|
83
85
|
Executar o comando
|
|
84
86
|
`npm run deploy:heroku`
|
|
@@ -48,7 +48,7 @@
|
|
|
48
48
|
}
|
|
49
49
|
}
|
|
50
50
|
|
|
51
|
-
.
|
|
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;
|
|
@@ -26,16 +26,10 @@ que utilizam. Em caso de mudança, ficar atento para os refatores.
|
|
|
26
26
|
align-items: center;
|
|
27
27
|
justify-content: center;
|
|
28
28
|
padding-left: 0px;
|
|
29
|
-
> .searchmenubutton {
|
|
30
|
-
width: 100%;
|
|
31
|
-
height: 100%;
|
|
32
|
-
display: flex;
|
|
33
|
-
align-items: center;
|
|
34
|
-
justify-content: center;
|
|
35
|
-
}
|
|
36
29
|
}
|
|
37
30
|
&.-customsidenavitem:hover {
|
|
38
31
|
background-color: white;
|
|
32
|
+
cursor: text;
|
|
39
33
|
}
|
|
40
34
|
&.-disabled {
|
|
41
35
|
@extend %component-disabled;
|
|
@@ -45,6 +45,8 @@
|
|
|
45
45
|
display: flex;
|
|
46
46
|
justify-content: flex-start;
|
|
47
47
|
align-items: center;
|
|
48
|
+
min-height: 25px;
|
|
49
|
+
color: $font-color-soft;
|
|
48
50
|
>.node-menu {
|
|
49
51
|
animation: revealelement 0.3s forwards ease-in-out;
|
|
50
52
|
margin-left: 10px;
|
|
@@ -62,7 +64,9 @@
|
|
|
62
64
|
margin-left: 10px;
|
|
63
65
|
}
|
|
64
66
|
&:hover {
|
|
67
|
+
cursor: pointer;
|
|
65
68
|
background-color: rgb(209, 209, 209);
|
|
69
|
+
text-decoration: underline;
|
|
66
70
|
}
|
|
67
71
|
}
|
|
68
72
|
> .nodelist {
|
package/lib/dropdown/Popup.js
CHANGED
|
@@ -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
|
-
|
|
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;");
|
package/lib/form/form.spec.js
CHANGED
|
@@ -189,6 +189,14 @@ describe('Form', function () {
|
|
|
189
189
|
}));
|
|
190
190
|
expect(mockHandlerReset).toHaveBeenCalled();
|
|
191
191
|
});
|
|
192
|
+
it('should apply disabled', function () {
|
|
193
|
+
var mockHandlerReset = jest.fn();
|
|
194
|
+
(0, _react2.render)(mockForm({
|
|
195
|
+
disabled: true,
|
|
196
|
+
handlerReset: mockHandlerReset
|
|
197
|
+
}));
|
|
198
|
+
expect(mockHandlerReset).not.toHaveBeenCalled();
|
|
199
|
+
});
|
|
192
200
|
});
|
|
193
201
|
describe('Field', function () {
|
|
194
202
|
describe('Default & Number', function () {
|
package/lib/form/index.js
CHANGED
|
@@ -91,7 +91,8 @@ var Form = function Form(_ref) {
|
|
|
91
91
|
onValidateForm = _ref.onValidateForm,
|
|
92
92
|
externalFieldErrors = _ref.externalFieldErrors,
|
|
93
93
|
onSubmit = _ref.onSubmit,
|
|
94
|
-
skeletonize = _ref.skeletonize
|
|
94
|
+
skeletonize = _ref.skeletonize,
|
|
95
|
+
disabled = _ref.disabled;
|
|
95
96
|
|
|
96
97
|
var _useState = (0, _react.useState)(dataSource),
|
|
97
98
|
_useState2 = _slicedToArray(_useState, 2),
|
|
@@ -231,10 +232,29 @@ var Form = function Form(_ref) {
|
|
|
231
232
|
};
|
|
232
233
|
};
|
|
233
234
|
|
|
235
|
+
var formProps = function formProps() {
|
|
236
|
+
var propsForm = null;
|
|
237
|
+
|
|
238
|
+
if (!disabled) {
|
|
239
|
+
propsForm = {
|
|
240
|
+
onSubmit: function onSubmit(e) {
|
|
241
|
+
return e.preventDefault();
|
|
242
|
+
},
|
|
243
|
+
onKeyPress: function onKeyPress(e) {
|
|
244
|
+
return submitOnEnter(e);
|
|
245
|
+
}
|
|
246
|
+
};
|
|
247
|
+
}
|
|
248
|
+
|
|
249
|
+
return propsForm;
|
|
250
|
+
};
|
|
251
|
+
|
|
234
252
|
(0, _react.useEffect)(function () {
|
|
235
|
-
|
|
236
|
-
|
|
237
|
-
|
|
253
|
+
if (!disabled) {
|
|
254
|
+
handlerSubmit(onFormSubmit);
|
|
255
|
+
if (handlerReset) handlerReset(onReset);
|
|
256
|
+
if (handlerValidates) handlerValidates(checkIsValid);
|
|
257
|
+
}
|
|
238
258
|
}, [data]);
|
|
239
259
|
(0, _react.useEffect)(function () {
|
|
240
260
|
if (securityBeforeUnload) {
|
|
@@ -247,27 +267,24 @@ var Form = function Form(_ref) {
|
|
|
247
267
|
};
|
|
248
268
|
}, [securityBeforeUnload, onBeforeUnload]);
|
|
249
269
|
(0, _react.useEffect)(function () {
|
|
250
|
-
if (
|
|
251
|
-
|
|
252
|
-
|
|
253
|
-
|
|
254
|
-
|
|
255
|
-
|
|
270
|
+
if (!disabled) {
|
|
271
|
+
if (submitOnPressEnterKey !== submitFormOnEnter || dataSource !== originalData) {
|
|
272
|
+
setData(dataSource);
|
|
273
|
+
setOriginalData(function (prevState) {
|
|
274
|
+
return prevState || dataSource;
|
|
275
|
+
});
|
|
276
|
+
setSubmitFormOnEnter(submitOnPressEnterKey);
|
|
277
|
+
}
|
|
256
278
|
}
|
|
257
279
|
}, [submitOnPressEnterKey, dataSource]);
|
|
258
280
|
return /*#__PURE__*/_react["default"].createElement(_react.Fragment, null, /*#__PURE__*/_react["default"].createElement(_helpers.FormContext.Provider, {
|
|
259
281
|
value: getContextValue()
|
|
260
|
-
}, /*#__PURE__*/_react["default"].createElement("form", {
|
|
261
|
-
style: style
|
|
262
|
-
|
|
263
|
-
return e.preventDefault();
|
|
264
|
-
},
|
|
265
|
-
onKeyPress: function onKeyPress(e) {
|
|
266
|
-
return submitOnEnter(e);
|
|
267
|
-
},
|
|
282
|
+
}, /*#__PURE__*/_react["default"].createElement("form", _extends({
|
|
283
|
+
style: style
|
|
284
|
+
}, formProps(), {
|
|
268
285
|
role: "presentation",
|
|
269
286
|
className: "form-component ".concat(customClass)
|
|
270
|
-
}, children)), /*#__PURE__*/_react["default"].createElement(_dialog.DialogQuestion, {
|
|
287
|
+
}), children)), /*#__PURE__*/_react["default"].createElement(_dialog.DialogQuestion, {
|
|
271
288
|
zIndex: "99999999",
|
|
272
289
|
title: securityTitle || 'Dados Alterados',
|
|
273
290
|
text: securityText || 'Você possui dados alterados, confirma o fechamento?',
|
|
@@ -293,7 +310,8 @@ Form.propTypes = {
|
|
|
293
310
|
securityTitle: _propTypes["default"].string,
|
|
294
311
|
securityText: _propTypes["default"].string,
|
|
295
312
|
externalFieldErrors: _propTypes["default"].object,
|
|
296
|
-
skeletonize: _propTypes["default"].bool
|
|
313
|
+
skeletonize: _propTypes["default"].bool,
|
|
314
|
+
disabled: _propTypes["default"].bool
|
|
297
315
|
};
|
|
298
316
|
Form.defaultProps = {
|
|
299
317
|
onValidateForm: undefined,
|
|
@@ -307,7 +325,8 @@ Form.defaultProps = {
|
|
|
307
325
|
securityTitle: null,
|
|
308
326
|
securityText: null,
|
|
309
327
|
externalFieldErrors: {},
|
|
310
|
-
skeletonize: false
|
|
328
|
+
skeletonize: false,
|
|
329
|
+
disabled: false
|
|
311
330
|
};
|
|
312
331
|
var _default = Form;
|
|
313
332
|
exports["default"] = _default;
|
package/lib/inputs/mask/Phone.js
CHANGED
|
@@ -7,6 +7,8 @@ exports["default"] = void 0;
|
|
|
7
7
|
|
|
8
8
|
var _react = _interopRequireDefault(require("react"));
|
|
9
9
|
|
|
10
|
+
var _propTypes = _interopRequireDefault(require("prop-types"));
|
|
11
|
+
|
|
10
12
|
var _BaseMask = _interopRequireDefault(require("./BaseMask"));
|
|
11
13
|
|
|
12
14
|
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { "default": obj }; }
|
|
@@ -14,10 +16,17 @@ function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { "d
|
|
|
14
16
|
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); }
|
|
15
17
|
|
|
16
18
|
var PhoneField = function PhoneField(props) {
|
|
19
|
+
var cellNumber = props.cellNumber;
|
|
17
20
|
return /*#__PURE__*/_react["default"].createElement(_BaseMask["default"], _extends({}, props, {
|
|
18
|
-
mask:
|
|
21
|
+
mask: cellNumber ? '(00) 00000-0000' : '(00) 0000-0000'
|
|
19
22
|
}));
|
|
20
23
|
};
|
|
21
24
|
|
|
25
|
+
PhoneField.propTypes = {
|
|
26
|
+
cellNumber: _propTypes["default"].bool
|
|
27
|
+
};
|
|
28
|
+
PhoneField.defaultProps = {
|
|
29
|
+
cellNumber: false
|
|
30
|
+
};
|
|
22
31
|
var _default = PhoneField;
|
|
23
32
|
exports["default"] = _default;
|
|
@@ -562,18 +562,35 @@ describe('Input Masked', function () {
|
|
|
562
562
|
|
|
563
563
|
expect(input).toHaveValue('(11) 1111-1111');
|
|
564
564
|
});
|
|
565
|
+
it('should apply cellNumber', function () {
|
|
566
|
+
var _render38 = (0, _react2.render)( /*#__PURE__*/_react["default"].createElement(_.PhoneField, {
|
|
567
|
+
cellNumber: true
|
|
568
|
+
})),
|
|
569
|
+
container = _render38.container;
|
|
570
|
+
|
|
571
|
+
var input = container.querySelector('.input-base-component .inputwrapper .inputcontent input.textinput');
|
|
572
|
+
expect(input).toHaveValue('(__) _____-____');
|
|
573
|
+
|
|
574
|
+
_react2.fireEvent.change(input, {
|
|
575
|
+
target: {
|
|
576
|
+
value: '11111111111'
|
|
577
|
+
}
|
|
578
|
+
});
|
|
579
|
+
|
|
580
|
+
expect(input).toHaveValue('(11) 11111-1111');
|
|
581
|
+
});
|
|
565
582
|
});
|
|
566
583
|
describe('Zip Code', function () {
|
|
567
584
|
it('should render correctly', function () {
|
|
568
|
-
var
|
|
569
|
-
container =
|
|
585
|
+
var _render39 = (0, _react2.render)( /*#__PURE__*/_react["default"].createElement(_.ZipCodeField, null)),
|
|
586
|
+
container = _render39.container;
|
|
570
587
|
|
|
571
588
|
expect(container.firstChild).toBeTruthy();
|
|
572
589
|
expect(container.firstChild).toHaveClass('input-base-component');
|
|
573
590
|
});
|
|
574
591
|
it('should apply zipcode mask', function () {
|
|
575
|
-
var
|
|
576
|
-
container =
|
|
592
|
+
var _render40 = (0, _react2.render)( /*#__PURE__*/_react["default"].createElement(_.ZipCodeField, null)),
|
|
593
|
+
container = _render40.container;
|
|
577
594
|
|
|
578
595
|
var input = container.querySelector('.input-base-component .inputwrapper .inputcontent input.textinput');
|
|
579
596
|
expect(input).toHaveValue('_____-___');
|
|
@@ -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
|
|
41
|
-
var
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
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
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
}
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
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
|
-
|
|
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
|
+
inputValue: _propTypes["default"].string.isRequired,
|
|
160
|
+
dropdownRef: _propTypes["default"].object.isRequired,
|
|
174
161
|
currents: _propTypes["default"].arrayOf(_propTypes["default"].object),
|
|
175
162
|
imageAlign: _propTypes["default"].oneOf(['left', 'right']),
|
|
176
163
|
striped: _propTypes["default"].bool,
|
|
177
164
|
gridWrapperStyle: _propTypes["default"].object,
|
|
178
165
|
selectFieldRef: _propTypes["default"].object,
|
|
179
|
-
dropdownMaxHeight: _propTypes["default"].number
|
|
180
|
-
inputValue: _propTypes["default"].string.isRequired
|
|
166
|
+
dropdownMaxHeight: _propTypes["default"].number
|
|
181
167
|
};
|
|
182
168
|
Dropdown.defaultProps = {
|
|
183
169
|
selected: null,
|
|
@@ -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
|
});
|
|
@@ -270,12 +272,12 @@ var MultipleSelect = /*#__PURE__*/function (_Component) {
|
|
|
270
272
|
|
|
271
273
|
if (e.keyCode === constants.keyCodes.ENTER) {
|
|
272
274
|
this.onSelect(selected);
|
|
273
|
-
} else if ([constants.keyCodes.
|
|
275
|
+
} else if ([constants.keyCodes.ARROW_DOWN, constants.keyCodes.ARROW_UP].includes(e.keyCode)) {
|
|
274
276
|
var index = dataSource.findIndex(function (d) {
|
|
275
277
|
return d === selected;
|
|
276
278
|
});
|
|
277
279
|
|
|
278
|
-
if (e.keyCode === constants.keyCodes.
|
|
280
|
+
if (e.keyCode === constants.keyCodes.ARROW_UP) {
|
|
279
281
|
index = index === dataSource.length - 1 ? 0 : index + 1;
|
|
280
282
|
} else {
|
|
281
283
|
index = index === 0 ? dataSource.length - 1 : index - 1;
|
|
@@ -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,
|
|
@@ -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
|
});
|
|
@@ -385,12 +388,12 @@ var _initialiseProps = function _initialiseProps() {
|
|
|
385
388
|
e.preventDefault();
|
|
386
389
|
|
|
387
390
|
_this3.onSelect(selected);
|
|
388
|
-
} else if ([constants.keyCodes.
|
|
391
|
+
} else if ([constants.keyCodes.ARROW_DOWN, constants.keyCodes.ARROW_UP].includes(e.keyCode)) {
|
|
389
392
|
var index = dataSource.findIndex(function (d) {
|
|
390
393
|
return d[idKey] === selected[idKey];
|
|
391
394
|
});
|
|
392
395
|
|
|
393
|
-
if (e.keyCode === constants.keyCodes.
|
|
396
|
+
if (e.keyCode === constants.keyCodes.ARROW_UP) {
|
|
394
397
|
index = index === dataSource.length - 1 ? 0 : index + 1;
|
|
395
398
|
} else {
|
|
396
399
|
index = index === 0 ? dataSource.length - 1 : index - 1;
|
|
@@ -7,10 +7,9 @@ exports.PARA_ENGANAR_O_ESLINT_JA_QUE_TENHO_SO_UMA_CONSTANTE = exports.keyCodes =
|
|
|
7
7
|
var keyCodes = {
|
|
8
8
|
TAB: 9,
|
|
9
9
|
ENTER: 13,
|
|
10
|
-
ARROW_UP:
|
|
11
|
-
ARROW_DOWN:
|
|
12
|
-
BACKSPACE: 8
|
|
13
|
-
F: 70
|
|
10
|
+
ARROW_UP: 40,
|
|
11
|
+
ARROW_DOWN: 38,
|
|
12
|
+
BACKSPACE: 8
|
|
14
13
|
};
|
|
15
14
|
exports.keyCodes = keyCodes;
|
|
16
15
|
var PARA_ENGANAR_O_ESLINT_JA_QUE_TENHO_SO_UMA_CONSTANTE = 1;
|