linear-react-components-ui 1.1.20-beta.2 → 1.1.20-beta.21
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/lib/alerts/BaseAlert.js +1 -1
- package/lib/alerts/Message.js +1 -1
- package/lib/assets/styles/input.scss +2 -2
- package/lib/assets/styles/popover.scss +3 -0
- package/lib/assets/styles/select.scss +2 -1
- package/lib/assets/styles/wizard.scss +125 -0
- package/lib/avatar/index.js +9 -8
- package/lib/badge/index.js +4 -4
- package/lib/buttons/DangerButton.js +1 -1
- package/lib/buttons/DefaultButton.js +13 -3
- package/lib/buttons/InfoButton.js +1 -1
- package/lib/buttons/PrimaryButton.js +1 -1
- package/lib/buttons/SuccessButton.js +1 -1
- package/lib/buttons/WarningButton.js +1 -1
- package/lib/buttons/button_container/index.js +1 -1
- package/lib/buttons/split_button/index.js +1 -1
- package/lib/calendar/base/Day.js +1 -1
- package/lib/calendar/base/Month.js +1 -1
- package/lib/calendar/base/helpers.js +2 -2
- package/lib/calendar/base/index.js +1 -1
- package/lib/checkbox/index.js +46 -19
- package/lib/checkbox/types.d.ts +4 -0
- package/lib/dialog/Custom.js +4 -2
- package/lib/dialog/Question.js +18 -2
- package/lib/dialog/base/Content.d.ts +1 -1
- package/lib/dialog/base/Content.js +3 -2
- package/lib/dialog/base/Header.js +2 -2
- package/lib/dialog/base/index.js +8 -9
- package/lib/dialog/form/index.js +8 -3
- package/lib/dialog/types.d.ts +38 -4
- package/lib/dialog/wizard/index.d.ts +13 -0
- package/lib/dialog/wizard/index.js +74 -0
- package/lib/dialog/wizard/progressbar.d.ts +13 -0
- package/lib/dialog/wizard/progressbar.js +36 -0
- package/lib/dialog/wizard/step.d.ts +9 -0
- package/lib/dialog/wizard/step.js +22 -0
- package/lib/dialog/wizard/useWizard.d.ts +9 -0
- package/lib/dialog/wizard/useWizard.js +48 -0
- package/lib/drawer/Drawer.js +3 -3
- package/lib/drawer/Header.js +1 -1
- package/lib/dropdown/Popup.js +6 -6
- package/lib/dropdown/helper.js +1 -1
- package/lib/dropdown/withDropdown.js +2 -2
- package/lib/fieldset/index.js +7 -7
- package/lib/form/FieldArray.js +1 -1
- package/lib/form/FieldNumber.js +4 -4
- package/lib/form/FieldPeriod.js +2 -2
- package/lib/form/index.js +2 -2
- package/lib/form/types.d.ts +14 -1
- package/lib/gridlayout/GridCol.js +5 -5
- package/lib/gridlayout/GridRow.js +4 -1
- package/lib/hint/index.js +7 -1
- package/lib/icons/helper.d.ts +8 -0
- package/lib/icons/helper.js +8 -0
- package/lib/icons/index.js +24 -27
- package/lib/inputs/base/InputTextBase.js +41 -16
- package/lib/inputs/base/Label.js +1 -1
- package/lib/inputs/base/helpers.js +7 -3
- package/lib/inputs/base/types.d.ts +3 -0
- package/lib/inputs/color/types.d.ts +5 -0
- package/lib/inputs/date/helpers.js +4 -1
- package/lib/inputs/date/index.js +9 -15
- package/lib/inputs/date/types.d.ts +4 -0
- package/lib/inputs/errorMessage/index.js +1 -1
- package/lib/inputs/file/DefaultFile.js +5 -6
- package/lib/inputs/file/DragDropFile.js +17 -18
- package/lib/inputs/file/File.js +3 -4
- package/lib/inputs/file/types.d.ts +3 -0
- package/lib/inputs/mask/BaseMask.js +1 -1
- package/lib/inputs/mask/helpers.d.ts +4 -0
- package/lib/inputs/mask/types.d.ts +4 -0
- package/lib/inputs/multiSelect/Dropdown.js +9 -10
- package/lib/inputs/multiSelect/helper.js +1 -2
- package/lib/inputs/multiSelect/index.js +7 -9
- package/lib/inputs/multiSelect/types.d.ts +4 -0
- package/lib/inputs/number/BaseNumber.d.ts +1 -1
- package/lib/inputs/number/Currency.d.ts +1 -1
- package/lib/inputs/number/Decimal.d.ts +1 -1
- package/lib/inputs/number/index.d.ts +1 -1
- package/lib/inputs/number/index.js +7 -3
- package/lib/inputs/number/types.d.ts +14 -2
- package/lib/inputs/period/PeriodList.js +1 -1
- package/lib/inputs/period/helper.js +3 -1
- package/lib/inputs/period/index.js +40 -18
- package/lib/inputs/period/types.d.ts +3 -0
- package/lib/inputs/search/index.js +1 -1
- package/lib/inputs/select/Dropdown.js +1 -1
- package/lib/inputs/select/helper.js +10 -13
- package/lib/inputs/select/multiple/Selecteds.js +1 -1
- package/lib/inputs/select/multiple/index.js +22 -18
- package/lib/inputs/select/simple/index.js +15 -20
- package/lib/inputs/select/types.d.ts +7 -0
- package/lib/inputs/textarea/index.js +1 -1
- package/lib/internals/withTooltip.js +9 -9
- package/lib/labelMessages/index.js +4 -3
- package/lib/labels/DefaultLabel.js +4 -1
- package/lib/labels/label_container/index.js +1 -1
- package/lib/list/Header.d.ts +1 -0
- package/lib/list/Header.js +1 -1
- package/lib/list/Item.d.ts +6 -2
- package/lib/list/Item.js +24 -10
- package/lib/list/helpers.d.ts +1 -0
- package/lib/list/index.d.ts +1 -0
- package/lib/list/index.js +3 -2
- package/lib/list/types.d.ts +6 -0
- package/lib/menus/float/MenuItem.js +2 -2
- package/lib/menus/float/SubMenuContainer.js +1 -1
- package/lib/menus/float/index.js +1 -1
- package/lib/menus/sidenav/ExpandMenu.js +1 -1
- package/lib/menus/sidenav/NavMenuGroup.js +1 -1
- package/lib/menus/sidenav/NavMenuItem.js +7 -9
- package/lib/menus/sidenav/NavSubMenuItem.js +1 -1
- package/lib/menus/sidenav/helpers.js +1 -1
- package/lib/menus/sidenav/index.js +5 -5
- package/lib/panel/Content.js +5 -7
- package/lib/panel/Default.js +2 -2
- package/lib/panel/Header.js +3 -3
- package/lib/permissionValidations.js +1 -1
- package/lib/popover/index.js +4 -6
- package/lib/popover/types.d.ts +2 -1
- package/lib/progress/Bar.js +6 -6
- package/lib/radio/index.d.ts +1 -1
- package/lib/radio/index.js +36 -5
- package/lib/radio/types.d.ts +8 -1
- package/lib/shortcuts/index.js +1 -1
- package/lib/skeleton/SkeletonContainer.js +2 -1
- package/lib/skeleton/index.js +4 -1
- package/lib/spinner/index.js +2 -2
- package/lib/split/Split.js +1 -1
- package/lib/split/SplitSide.js +3 -3
- package/lib/table/Body.js +3 -3
- package/lib/table/Header.js +8 -11
- package/lib/table/HeaderColumn.js +7 -7
- package/lib/table/Row.js +3 -3
- package/lib/table/RowColumn.js +1 -1
- package/lib/table/index.js +6 -1
- package/lib/table/types.d.ts +0 -2
- package/lib/tabs/DropdownTabs.js +1 -1
- package/lib/tabs/Menu.js +1 -1
- package/lib/tabs/MenuTabs.js +2 -2
- package/lib/tabs/Panel.js +5 -7
- package/lib/tabs/context.js +3 -6
- package/lib/textContent/index.d.ts +18 -4
- package/lib/textContent/index.js +15 -5
- package/lib/toolbar/ButtonBar.js +1 -1
- package/lib/toolbar/index.js +1 -1
- package/lib/tooltip/index.js +7 -7
- package/lib/treetable/Body.js +1 -1
- package/lib/treetable/Header.js +2 -2
- package/lib/treetable/Row.js +10 -13
- package/lib/treeview/Header.js +1 -1
- package/lib/treeview/Node.js +5 -5
- package/lib/treeview/index.js +4 -4
- package/lib/uitour/index.js +6 -8
- package/package.json +1 -1
- package/lib/checkbox/Label.d.ts +0 -11
- package/lib/checkbox/Label.js +0 -31
|
@@ -4,7 +4,7 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
4
4
|
value: true
|
|
5
5
|
});
|
|
6
6
|
exports.returnDropdownDynamicStyles = exports.getFilteredSimpleDataCombo = exports.getFilteredMultipleDataCombo = exports.getDropdownItemCssClass = exports.contentClass = void 0;
|
|
7
|
-
const contentClass = props =>
|
|
7
|
+
const contentClass = props => `content ${props.showClearButton ? '' : 'noclear'}`;
|
|
8
8
|
exports.contentClass = contentClass;
|
|
9
9
|
const getDropdownItemCssClass = (selected, disabled, striped) => {
|
|
10
10
|
let className = 'item';
|
|
@@ -21,12 +21,10 @@ const getFilteredSimpleDataCombo = _ref => {
|
|
|
21
21
|
inputText
|
|
22
22
|
} = _ref;
|
|
23
23
|
return dataSource && dataSource.filter(item => {
|
|
24
|
-
var _descriptionKey;
|
|
25
24
|
if (typeof descriptionKey === 'string') {
|
|
26
|
-
|
|
27
|
-
return ((_item$descriptionKey = item[descriptionKey]) === null || _item$descriptionKey === void 0 ? void 0 : _item$descriptionKey.toLowerCase().indexOf(inputText === null || inputText === void 0 ? void 0 : inputText.toString().toLowerCase())) > -1;
|
|
25
|
+
return item[descriptionKey]?.toLowerCase().indexOf(inputText?.toString().toLowerCase()) > -1;
|
|
28
26
|
}
|
|
29
|
-
return
|
|
27
|
+
return descriptionKey(item)?.toLowerCase().indexOf(inputText?.toString().toLowerCase()) > -1;
|
|
30
28
|
});
|
|
31
29
|
};
|
|
32
30
|
exports.getFilteredSimpleDataCombo = getFilteredSimpleDataCombo;
|
|
@@ -38,11 +36,10 @@ const getFilteredMultipleDataCombo = _ref2 => {
|
|
|
38
36
|
currents
|
|
39
37
|
} = _ref2;
|
|
40
38
|
return dataSource.filter(item => {
|
|
41
|
-
var _descriptionKey2;
|
|
42
39
|
if (typeof descriptionKey === 'string') {
|
|
43
|
-
return item[descriptionKey].toLowerCase().indexOf(inputText
|
|
40
|
+
return item[descriptionKey].toLowerCase().indexOf(inputText?.toString().toLowerCase()) > -1 && !currents.includes(item);
|
|
44
41
|
}
|
|
45
|
-
return
|
|
42
|
+
return descriptionKey(item)?.toLowerCase().indexOf(inputText?.toString().toLowerCase()) > -1 && !currents.includes(item);
|
|
46
43
|
});
|
|
47
44
|
};
|
|
48
45
|
exports.getFilteredMultipleDataCombo = getFilteredMultipleDataCombo;
|
|
@@ -54,7 +51,7 @@ const returnDropdownPosition = function (_ref3) {
|
|
|
54
51
|
} = _ref3;
|
|
55
52
|
let aboveDropdown = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : false;
|
|
56
53
|
const DEFAULT_MARGIN_BOTTOM = 10;
|
|
57
|
-
if (aboveDropdown && dropdownRef
|
|
54
|
+
if (aboveDropdown && dropdownRef?.current && dropdownRects?.height) {
|
|
58
55
|
return selectFieldRects.top + window.scrollY - (dropdownRef.current && dropdownRects.height) - DEFAULT_MARGIN_BOTTOM;
|
|
59
56
|
}
|
|
60
57
|
return selectFieldRects.top + window.scrollY + selectFieldRects.height;
|
|
@@ -65,10 +62,10 @@ const returnDropdownDynamicStyles = _ref4 => {
|
|
|
65
62
|
dropdownMaxHeight,
|
|
66
63
|
dropdownRef
|
|
67
64
|
} = _ref4;
|
|
68
|
-
const selectFieldRects = selectFieldRef
|
|
69
|
-
const dropdownRects = dropdownRef
|
|
70
|
-
const selectFieldRectsBottom = selectFieldRects ? selectFieldRects
|
|
71
|
-
const selectFieldRectsTop = selectFieldRects ? selectFieldRects
|
|
65
|
+
const selectFieldRects = selectFieldRef?.current ? selectFieldRef.current.getBoundingClientRect() : undefined;
|
|
66
|
+
const dropdownRects = dropdownRef?.current ? dropdownRef.current.getBoundingClientRect() : undefined;
|
|
67
|
+
const selectFieldRectsBottom = selectFieldRects ? selectFieldRects?.bottom : 0;
|
|
68
|
+
const selectFieldRectsTop = selectFieldRects ? selectFieldRects?.top : 0;
|
|
72
69
|
const dropdownBottomDistance = window.innerHeight - selectFieldRectsBottom;
|
|
73
70
|
const bottomOffset = 30;
|
|
74
71
|
let maxDropdownBottomDistance = 200;
|
|
@@ -15,7 +15,7 @@ const Selecteds = _ref => {
|
|
|
15
15
|
} = _ref;
|
|
16
16
|
return /*#__PURE__*/_react.default.createElement(_react.default.Fragment, null, currents.map(selected => /*#__PURE__*/_react.default.createElement("div", {
|
|
17
17
|
className: "selecteditem",
|
|
18
|
-
key:
|
|
18
|
+
key: `selected-${selected[idKey]}`
|
|
19
19
|
}, typeof descriptionKey === 'string' ? selected[descriptionKey] : descriptionKey(selected), /*#__PURE__*/_react.default.createElement("button", {
|
|
20
20
|
className: "close",
|
|
21
21
|
tabIndex: -1,
|
|
@@ -13,6 +13,7 @@ var _Selecteds = _interopRequireDefault(require("./Selecteds"));
|
|
|
13
13
|
var constants = _interopRequireWildcard(require("../../../internals/constants"));
|
|
14
14
|
var _InputTextBase = _interopRequireDefault(require("../../base/InputTextBase"));
|
|
15
15
|
var _helper = require("../helper");
|
|
16
|
+
var _hint = _interopRequireDefault(require("../../../hint"));
|
|
16
17
|
function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; }
|
|
17
18
|
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); }
|
|
18
19
|
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; }
|
|
@@ -25,7 +26,10 @@ const MultipleSelect = props => {
|
|
|
25
26
|
value = [],
|
|
26
27
|
remoteSearch = false,
|
|
27
28
|
descriptionKey,
|
|
28
|
-
showClearButton
|
|
29
|
+
showClearButton,
|
|
30
|
+
rightElements = [],
|
|
31
|
+
hint,
|
|
32
|
+
hintPosition = 'below'
|
|
29
33
|
} = props;
|
|
30
34
|
const [dataCombo, setDataCombo] = (0, _react.useState)(dataSource);
|
|
31
35
|
const [currents, setCurrents] = (0, _react.useState)([]);
|
|
@@ -36,7 +40,7 @@ const MultipleSelect = props => {
|
|
|
36
40
|
const [insideComponent, setInsideComponent] = (0, _react.useState)(false);
|
|
37
41
|
const [onDenied, setOnDeniedSelect] = (0, _react.useState)();
|
|
38
42
|
const [valueFromProps, setValueFromProps] = (0, _react.useState)([]);
|
|
39
|
-
const componentId =
|
|
43
|
+
const componentId = `select-component${uuid.v1()}`;
|
|
40
44
|
const componentRef = (0, _react.useRef)(null);
|
|
41
45
|
const dropdownRef = (0, _react.useRef)(null);
|
|
42
46
|
const selectWrapper = (0, _react.useRef)();
|
|
@@ -56,11 +60,10 @@ const MultipleSelect = props => {
|
|
|
56
60
|
}
|
|
57
61
|
};
|
|
58
62
|
const onMouseMove = event => {
|
|
59
|
-
var _dropdownRef$current, _dropdownRef$current$;
|
|
60
63
|
const target = event.target;
|
|
61
|
-
const idDropdown =
|
|
64
|
+
const idDropdown = dropdownRef.current?.parentElement?.id || '';
|
|
62
65
|
const dropdownElement = document.getElementById(idDropdown);
|
|
63
|
-
const keepDropdownOpen = Boolean(dropdownElement
|
|
66
|
+
const keepDropdownOpen = Boolean(dropdownElement?.contains(target));
|
|
64
67
|
setInsideComponent(keepDropdownOpen);
|
|
65
68
|
};
|
|
66
69
|
const onClearClick = () => {
|
|
@@ -97,7 +100,6 @@ const MultipleSelect = props => {
|
|
|
97
100
|
setDropdownWidth(dropdownWidthFocus);
|
|
98
101
|
};
|
|
99
102
|
const onSelect = select => {
|
|
100
|
-
var _dropdownRef$current2;
|
|
101
103
|
if (select === null) return;
|
|
102
104
|
const currentsSelect = [...currents, select];
|
|
103
105
|
setCurrents(currentsSelect);
|
|
@@ -105,17 +107,16 @@ const MultipleSelect = props => {
|
|
|
105
107
|
setInputValue([]);
|
|
106
108
|
if (inputTextRef && inputTextRef.current) inputTextRef.current.focus();
|
|
107
109
|
if (props.onSelect) setSelected(props.onSelect(currentsSelect.map(i => i[idKey])));
|
|
108
|
-
|
|
110
|
+
dropdownRef.current?.focus();
|
|
109
111
|
};
|
|
110
112
|
const onUnselect = id => {
|
|
111
113
|
if (currents) {
|
|
112
|
-
var _dropdownRef$current3;
|
|
113
114
|
const result = currents.filter(item => item[idKey] !== id);
|
|
114
115
|
setCurrents(result);
|
|
115
116
|
if (inputTextRef && inputTextRef.current) inputTextRef.current.focus();
|
|
116
117
|
setOpened(false);
|
|
117
118
|
if (props.onSelect) setSelected(props.onSelect(result.map(i => i[idKey])));
|
|
118
|
-
|
|
119
|
+
dropdownRef.current?.focus();
|
|
119
120
|
}
|
|
120
121
|
};
|
|
121
122
|
const onOpenClose = () => {
|
|
@@ -132,11 +133,9 @@ const MultipleSelect = props => {
|
|
|
132
133
|
const onInputKeyDown = e => {
|
|
133
134
|
if (e.keyCode) {
|
|
134
135
|
if (e.keyCode === constants.keyCodes.ENTER && selected && opened) {
|
|
135
|
-
|
|
136
|
-
(_e$preventDefault = e.preventDefault) === null || _e$preventDefault === void 0 ? void 0 : _e$preventDefault.call(e);
|
|
136
|
+
e.preventDefault?.();
|
|
137
137
|
if (!currents.some(current => current[idKey] === selected[idKey])) {
|
|
138
|
-
|
|
139
|
-
(_e$preventDefault2 = e.preventDefault) === null || _e$preventDefault2 === void 0 ? void 0 : _e$preventDefault2.call(e);
|
|
138
|
+
e.preventDefault?.();
|
|
140
139
|
onSelect(selected);
|
|
141
140
|
}
|
|
142
141
|
} else if ([constants.keyCodes.ARROW_UP, constants.keyCodes.ARROW_DOWN].includes(e.keyCode)) {
|
|
@@ -182,7 +181,7 @@ const MultipleSelect = props => {
|
|
|
182
181
|
}, []);
|
|
183
182
|
(0, _react.useEffect)(() => {
|
|
184
183
|
if (props.gridLayout) {
|
|
185
|
-
const gridEl = document.querySelector(
|
|
184
|
+
const gridEl = document.querySelector(`#${componentId}>.-withinput.grid-container`);
|
|
186
185
|
if (gridElRef.current !== gridEl && gridEl) gridElRef.current = gridEl;
|
|
187
186
|
}
|
|
188
187
|
}, []);
|
|
@@ -234,13 +233,14 @@ const MultipleSelect = props => {
|
|
|
234
233
|
},
|
|
235
234
|
onClick: onFocus,
|
|
236
235
|
onKeyDown: onInputKeyDown,
|
|
237
|
-
customClassForWrapper:
|
|
236
|
+
customClassForWrapper: `selectwrapper ${(props.readOnly || shouldDisable() || shouldBeReadOnly()) && ' -undigitable'}`,
|
|
238
237
|
customClassForInputContent: "multiselect",
|
|
239
238
|
inputBaseRef: r => {
|
|
240
239
|
selectWrapper.current = r;
|
|
241
240
|
},
|
|
242
241
|
handlerSetOnDenied: setOnDenied,
|
|
243
|
-
rightElements: /*#__PURE__*/_react.default.createElement(_ActionButtons.default, {
|
|
242
|
+
rightElements: [...rightElements, /*#__PURE__*/_react.default.createElement(_ActionButtons.default, {
|
|
243
|
+
key: "action-buttons-multiselect",
|
|
244
244
|
showClearButton: showClearButton,
|
|
245
245
|
disabled: shouldDisable() || shouldBeReadOnly(),
|
|
246
246
|
dropDownOpened: opened,
|
|
@@ -249,7 +249,7 @@ const MultipleSelect = props => {
|
|
|
249
249
|
return onClearClick();
|
|
250
250
|
},
|
|
251
251
|
handlerOpenClose: onOpenClose
|
|
252
|
-
})
|
|
252
|
+
})]
|
|
253
253
|
}), /*#__PURE__*/_react.default.createElement(_Selecteds.default, _extends({}, props, {
|
|
254
254
|
currents: currents,
|
|
255
255
|
handlerOnUnselect: onUnselect
|
|
@@ -267,6 +267,10 @@ const MultipleSelect = props => {
|
|
|
267
267
|
dataCombo: dataCombo,
|
|
268
268
|
currents: currents,
|
|
269
269
|
dropdownWidth: dropdownWidth || 0
|
|
270
|
-
}))
|
|
270
|
+
})), /*#__PURE__*/_react.default.createElement(_hint.default, {
|
|
271
|
+
visible: !!hint && hintPosition === 'below',
|
|
272
|
+
customClass: "hint",
|
|
273
|
+
description: hint
|
|
274
|
+
}));
|
|
271
275
|
};
|
|
272
276
|
var _default = exports.default = MultipleSelect;
|
|
@@ -34,7 +34,8 @@ const SimpleSelect = props => {
|
|
|
34
34
|
searchOnDropdown = false,
|
|
35
35
|
allOptions = undefined,
|
|
36
36
|
showClearButton = false,
|
|
37
|
-
searchNotFoundText
|
|
37
|
+
searchNotFoundText,
|
|
38
|
+
rightElements = []
|
|
38
39
|
} = props;
|
|
39
40
|
const descriptionKeyIsString = typeof descriptionKey === 'string';
|
|
40
41
|
const dataSourceWithAllOptions = allOptions ? [{
|
|
@@ -50,7 +51,7 @@ const SimpleSelect = props => {
|
|
|
50
51
|
const [onDenied, setOnDeniedSelect] = (0, _react.useState)();
|
|
51
52
|
const [isTyping, setIsTyping] = (0, _react.useState)(false);
|
|
52
53
|
const dropdownRef = (0, _react.useRef)(null);
|
|
53
|
-
const componentId =
|
|
54
|
+
const componentId = `select-component-${name}-${uuid.v1()}`;
|
|
54
55
|
const componentRef = (0, _react.useRef)(null);
|
|
55
56
|
const selectWrapper = (0, _react.useRef)();
|
|
56
57
|
const gridElement = (0, _react.useRef)();
|
|
@@ -59,20 +60,18 @@ const SimpleSelect = props => {
|
|
|
59
60
|
if (selectWrapper.current) setDropdownWidth(selectWrapper.current.clientWidth);
|
|
60
61
|
};
|
|
61
62
|
const onClickOutside = event => {
|
|
62
|
-
var _selectWrapper$curren, _dropdownRef$current;
|
|
63
63
|
const {
|
|
64
64
|
target
|
|
65
65
|
} = event;
|
|
66
|
-
if (target !== selectWrapper.current && !
|
|
66
|
+
if (target !== selectWrapper.current && !selectWrapper.current?.contains(target) && !dropdownRef.current?.contains(target)) {
|
|
67
67
|
setOpened(false);
|
|
68
68
|
}
|
|
69
69
|
};
|
|
70
70
|
const onMouseMove = event => {
|
|
71
|
-
var _dropdownRef$current2, _dropdownRef$current3;
|
|
72
71
|
const target = event.target;
|
|
73
|
-
const idDropdown =
|
|
72
|
+
const idDropdown = dropdownRef.current?.parentElement?.id || '';
|
|
74
73
|
const dropdownElement = document.getElementById(idDropdown);
|
|
75
|
-
const keepDropdownOpen = Boolean(dropdownElement
|
|
74
|
+
const keepDropdownOpen = Boolean(dropdownElement?.contains(target));
|
|
76
75
|
setInsideComponent(keepDropdownOpen);
|
|
77
76
|
};
|
|
78
77
|
const getSelectEvent = selectedEvent => ({
|
|
@@ -112,7 +111,6 @@ const SimpleSelect = props => {
|
|
|
112
111
|
}
|
|
113
112
|
};
|
|
114
113
|
const onSelect = selectedDropdown => {
|
|
115
|
-
var _dropdownRef$current4;
|
|
116
114
|
if (!selectedDropdown) return;
|
|
117
115
|
setSelected(selectedDropdown);
|
|
118
116
|
if (descriptionKeyIsString) setInputText(selectedDropdown[descriptionKey]);else setInputText(descriptionKey(selectedDropdown));
|
|
@@ -122,7 +120,7 @@ const SimpleSelect = props => {
|
|
|
122
120
|
if (inputTextRef && inputTextRef.current) inputTextRef.current.focus();
|
|
123
121
|
setOpened(false);
|
|
124
122
|
});
|
|
125
|
-
|
|
123
|
+
dropdownRef.current?.focus();
|
|
126
124
|
};
|
|
127
125
|
const onOpenClose = () => {
|
|
128
126
|
setOpened(prevState => !prevState);
|
|
@@ -158,8 +156,7 @@ const SimpleSelect = props => {
|
|
|
158
156
|
const onInputKeyDown = e => {
|
|
159
157
|
if (e.keyCode) {
|
|
160
158
|
if (e.keyCode === constants.keyCodes.ENTER && selected && opened) {
|
|
161
|
-
|
|
162
|
-
(_e$preventDefault = e.preventDefault) === null || _e$preventDefault === void 0 ? void 0 : _e$preventDefault.call(e);
|
|
159
|
+
e.preventDefault?.();
|
|
163
160
|
onSelect(selected);
|
|
164
161
|
} else if ([constants.keyCodes.ARROW_UP, constants.keyCodes.ARROW_DOWN].includes(e.keyCode)) {
|
|
165
162
|
if (!opened) setOpened(true);
|
|
@@ -167,7 +164,7 @@ const SimpleSelect = props => {
|
|
|
167
164
|
if (e.keyCode === constants.keyCodes.ARROW_DOWN) {
|
|
168
165
|
index = dataCombo && index === dataCombo.length - 1 ? 0 : index + 1;
|
|
169
166
|
} else {
|
|
170
|
-
index = dataCombo && index === 0 ?
|
|
167
|
+
index = dataCombo && index === 0 ? dataCombo?.length - 1 : index - 1;
|
|
171
168
|
}
|
|
172
169
|
setSelected(dataCombo[index]);
|
|
173
170
|
if (descriptionKeyIsString) setInputText(dataCombo[index][descriptionKey]);
|
|
@@ -204,7 +201,7 @@ const SimpleSelect = props => {
|
|
|
204
201
|
}, []);
|
|
205
202
|
(0, _react.useEffect)(() => {
|
|
206
203
|
if (gridLayout) {
|
|
207
|
-
const gridEl = document.querySelector(
|
|
204
|
+
const gridEl = document.querySelector(`#${componentId}>.-withinput.grid-container`);
|
|
208
205
|
if (gridElement.current !== gridEl && gridEl) gridElement.current = gridEl;
|
|
209
206
|
}
|
|
210
207
|
}, [gridLayout]);
|
|
@@ -212,10 +209,7 @@ const SimpleSelect = props => {
|
|
|
212
209
|
if (dataSourceWithAllOptions.length > 0) {
|
|
213
210
|
let newCurrent = null;
|
|
214
211
|
if (value || value === 0) {
|
|
215
|
-
newCurrent = dataSourceWithAllOptions.find(i =>
|
|
216
|
-
var _i$idKey;
|
|
217
|
-
return (value || value === 0) && ((_i$idKey = i[idKey]) === null || _i$idKey === void 0 ? void 0 : _i$idKey.toString().toLowerCase()) === (value === null || value === void 0 ? void 0 : value.toString().toLowerCase());
|
|
218
|
-
});
|
|
212
|
+
newCurrent = dataSourceWithAllOptions.find(i => (value || value === 0) && i[idKey]?.toString().toLowerCase() === value?.toString().toLowerCase());
|
|
219
213
|
} else if (dataSourceWithAllOptions.length > 0 && selectFirstOnEnter) {
|
|
220
214
|
newCurrent = dataSourceWithAllOptions[0];
|
|
221
215
|
}
|
|
@@ -268,13 +262,14 @@ const SimpleSelect = props => {
|
|
|
268
262
|
},
|
|
269
263
|
onClick: onFocus,
|
|
270
264
|
onKeyDown: onInputKeyDown,
|
|
271
|
-
customClassForWrapper:
|
|
265
|
+
customClassForWrapper: `selectwrapper ${(undigitable || searchOnDropdown || shouldBeReadOnly()) && ' -undigitable'}`,
|
|
272
266
|
customClassForInputContent: "multiselect",
|
|
273
267
|
inputBaseRef: r => {
|
|
274
268
|
selectWrapper.current = r;
|
|
275
269
|
},
|
|
276
270
|
handlerSetOnDenied: inputOnDenied => setOnDenied(inputOnDenied),
|
|
277
|
-
rightElements: /*#__PURE__*/_react.default.createElement(_ActionButtons.default, {
|
|
271
|
+
rightElements: [...rightElements, /*#__PURE__*/_react.default.createElement(_ActionButtons.default, {
|
|
272
|
+
key: "action-buttons-simpleselect",
|
|
278
273
|
disabled: shouldDisable() || shouldBeReadOnly(),
|
|
279
274
|
showClearButton: showClearButton,
|
|
280
275
|
dropDownOpened: opened,
|
|
@@ -283,7 +278,7 @@ const SimpleSelect = props => {
|
|
|
283
278
|
return onClearClick();
|
|
284
279
|
},
|
|
285
280
|
handlerOpenClose: onOpenClose
|
|
286
|
-
})
|
|
281
|
+
})]
|
|
287
282
|
})), opened && /*#__PURE__*/_react.default.createElement(_Dropdown.default, _extends({}, props, {
|
|
288
283
|
opened: opened,
|
|
289
284
|
selected: selected,
|
|
@@ -50,6 +50,10 @@ interface ISimpleSelectProps {
|
|
|
50
50
|
onFocus?: () => void;
|
|
51
51
|
allOptions?: AllOptions;
|
|
52
52
|
inputRef?: MutableRefObject<HTMLInputElement | HTMLTextAreaElement | null> | ((ref: HTMLInputElement | HTMLTextAreaElement | null) => void);
|
|
53
|
+
rightElements?: JSX.Element[];
|
|
54
|
+
hintPosition?: 'below' | 'onLabelRight';
|
|
55
|
+
themePopover?: 'light' | 'dark';
|
|
56
|
+
popoverAlign?: 'right' | 'left';
|
|
53
57
|
}
|
|
54
58
|
interface ISelectFieldProps extends Omit<ISimpleSelectProps, 'idKey' | 'value' | 'descriptionKey'> {
|
|
55
59
|
multiple?: boolean;
|
|
@@ -90,6 +94,9 @@ interface IMultipleSelectProps extends Omit<ISimpleSelectProps, 'idKey' | 'value
|
|
|
90
94
|
handlerClear?: () => void;
|
|
91
95
|
disabled?: boolean;
|
|
92
96
|
gridLayout?: string;
|
|
97
|
+
hintPosition?: 'below' | 'onLabelRight';
|
|
98
|
+
themePopover?: 'light' | 'dark';
|
|
99
|
+
popoverAlign?: 'right' | 'left';
|
|
93
100
|
}
|
|
94
101
|
interface ISelectedsMultipleProps {
|
|
95
102
|
idKey: string;
|
|
@@ -87,23 +87,23 @@ const withTooltip = WrappedComponent => {
|
|
|
87
87
|
const targetDimensions = targetElement.current.getBoundingClientRect();
|
|
88
88
|
const targetVerticalCenter = (targetDimensions.top + targetDimensions.bottom) / 2;
|
|
89
89
|
const tooltipClientWidth = tooltipElement.current.clientWidth;
|
|
90
|
-
let style =
|
|
90
|
+
let style = `width: ${typeof width === 'string' ? width : `${width}px`}`;
|
|
91
91
|
let left = targetDimensions.left + targetDimensions.width / 2 - tooltipClientWidth / 2;
|
|
92
92
|
left = Math.min(left, document.body.clientWidth - tooltipClientWidth - space);
|
|
93
|
-
style +=
|
|
93
|
+
style += `; left: ${Math.max(space, left)}px`;
|
|
94
94
|
switch (stateTooltipPosition) {
|
|
95
95
|
case 'top':
|
|
96
96
|
if (targetDimensions.top < height) {
|
|
97
97
|
setStateTooltipPosition('bottom');
|
|
98
98
|
} else {
|
|
99
|
-
style +=
|
|
99
|
+
style += `; top: ${targetDimensions.top + window.scrollY - height - 5}px`;
|
|
100
100
|
}
|
|
101
101
|
break;
|
|
102
102
|
case 'bottom':
|
|
103
103
|
if (window.innerHeight - targetDimensions.bottom < height) {
|
|
104
104
|
setStateTooltipPosition('top');
|
|
105
105
|
} else {
|
|
106
|
-
style +=
|
|
106
|
+
style += `; top: ${targetDimensions.top + window.scrollY + targetDimensions.height + 5}px`;
|
|
107
107
|
}
|
|
108
108
|
break;
|
|
109
109
|
case 'left':
|
|
@@ -114,16 +114,16 @@ const withTooltip = WrappedComponent => {
|
|
|
114
114
|
setStateTooltipPosition('right');
|
|
115
115
|
}
|
|
116
116
|
} else {
|
|
117
|
-
style +=
|
|
118
|
-
style +=
|
|
117
|
+
style += `; top: ${targetVerticalCenter + window.scrollY - height / 2}px`;
|
|
118
|
+
style += `; left: ${targetDimensions.left - tooltipClientWidth - 6}px`;
|
|
119
119
|
}
|
|
120
120
|
break;
|
|
121
121
|
case 'right':
|
|
122
122
|
if (window.innerWidth - targetDimensions.right < tooltipClientWidth) {
|
|
123
123
|
setStateTooltipPosition('left');
|
|
124
124
|
} else {
|
|
125
|
-
style +=
|
|
126
|
-
style +=
|
|
125
|
+
style += `; top: ${targetVerticalCenter + window.scrollY - height / 2}px`;
|
|
126
|
+
style += `; left: ${targetDimensions.left + targetDimensions.width + 5}px`;
|
|
127
127
|
}
|
|
128
128
|
break;
|
|
129
129
|
default:
|
|
@@ -166,7 +166,7 @@ const withTooltip = WrappedComponent => {
|
|
|
166
166
|
targetRef: getTarget
|
|
167
167
|
})), showTooltip && getTooltip());
|
|
168
168
|
};
|
|
169
|
-
EnhancedComponent.displayName =
|
|
169
|
+
EnhancedComponent.displayName = `withTooltip(${getDisplayName(WrappedComponent)})`;
|
|
170
170
|
return EnhancedComponent;
|
|
171
171
|
};
|
|
172
172
|
var _default = exports.default = withTooltip;
|
|
@@ -25,7 +25,8 @@ const LabelMessages = _ref => {
|
|
|
25
25
|
showCloseButton = false
|
|
26
26
|
} = _ref;
|
|
27
27
|
const [closed, setClosed] = (0, _react.useState)(false);
|
|
28
|
-
const getClass = () =>
|
|
28
|
+
const getClass = () => `labelmessages-component -${type} ${customClass}
|
|
29
|
+
${square && '-square'} ${flat && '-flat'}`;
|
|
29
30
|
const getIcon = () => {
|
|
30
31
|
if (icon) {
|
|
31
32
|
return icon;
|
|
@@ -34,14 +35,14 @@ const LabelMessages = _ref => {
|
|
|
34
35
|
name: iconName,
|
|
35
36
|
size: 16,
|
|
36
37
|
color: "#ffffff",
|
|
37
|
-
customClass:
|
|
38
|
+
customClass: `-${type}svg`
|
|
38
39
|
});
|
|
39
40
|
}
|
|
40
41
|
return null;
|
|
41
42
|
};
|
|
42
43
|
if (closed || !visible) return null;
|
|
43
44
|
return /*#__PURE__*/_react.default.createElement(_react.Fragment, null, /*#__PURE__*/_react.default.createElement("div", {
|
|
44
|
-
className:
|
|
45
|
+
className: `${getClass()} ${customClass}`,
|
|
45
46
|
style: style
|
|
46
47
|
}, /*#__PURE__*/_react.default.createElement("div", {
|
|
47
48
|
className: "labelmessagesitem text"
|
|
@@ -30,7 +30,10 @@ const DefaultLabel = _ref => {
|
|
|
30
30
|
} = _ref;
|
|
31
31
|
const options = [_permissionValidations.OPTIONS_ON_DENIED.disabled, _permissionValidations.OPTIONS_ON_DENIED.unvisible];
|
|
32
32
|
const [onDenied] = (0, _react.useState)((0, _permissionValidations.actionsOnPermissionDenied)(options, permissionAttr));
|
|
33
|
-
const getClass = () =>
|
|
33
|
+
const getClass = () => `label-component ${className} ${customClass} ${bordered ? '-bordered' : ''} ${disabled ? '-disabled' : ''}
|
|
34
|
+
${skeletonize ? '-skeletonized' : ''}
|
|
35
|
+
${size ? `-${size}` : ''}
|
|
36
|
+
${iconAlign ? `icon-${iconAlign}` : ''}`;
|
|
34
37
|
const getIcon = () => {
|
|
35
38
|
if (icon) {
|
|
36
39
|
return icon;
|
package/lib/list/Header.d.ts
CHANGED
package/lib/list/Header.js
CHANGED
|
@@ -14,7 +14,7 @@ const Header = _ref => {
|
|
|
14
14
|
customClass
|
|
15
15
|
} = _ref;
|
|
16
16
|
return /*#__PURE__*/_react.default.createElement("li", {
|
|
17
|
-
className:
|
|
17
|
+
className: `list-header ${customClass}`,
|
|
18
18
|
style: style
|
|
19
19
|
}, /*#__PURE__*/_react.default.createElement("h1", {
|
|
20
20
|
className: "title"
|
package/lib/list/Item.d.ts
CHANGED
|
@@ -3,7 +3,11 @@ import 'react';
|
|
|
3
3
|
import '../@types/PermissionAttr.js';
|
|
4
4
|
import '../@types/Icon.js';
|
|
5
5
|
import '../icons/helper.js';
|
|
6
|
+
import '../@types/Position.js';
|
|
6
7
|
|
|
7
|
-
declare const
|
|
8
|
+
declare const _default: {
|
|
9
|
+
(props: IListItemProps): JSX.Element;
|
|
10
|
+
displayName: string;
|
|
11
|
+
};
|
|
8
12
|
|
|
9
|
-
export {
|
|
13
|
+
export { _default as default };
|
package/lib/list/Item.js
CHANGED
|
@@ -11,6 +11,7 @@ var _checkbox = _interopRequireDefault(require("../checkbox"));
|
|
|
11
11
|
var _helpers = require("./helpers");
|
|
12
12
|
var _withDropdown = require("../dropdown/withDropdown");
|
|
13
13
|
var constants = _interopRequireWildcard(require("../internals/constants"));
|
|
14
|
+
var _withTooltip = _interopRequireWildcard(require("../internals/withTooltip"));
|
|
14
15
|
var _permissionValidations = require("../permissionValidations");
|
|
15
16
|
function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; }
|
|
16
17
|
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); }
|
|
@@ -38,7 +39,9 @@ const Item = props => {
|
|
|
38
39
|
separator = true,
|
|
39
40
|
visible = true,
|
|
40
41
|
permissionAttr,
|
|
41
|
-
skeletonize
|
|
42
|
+
skeletonize,
|
|
43
|
+
targetRef,
|
|
44
|
+
onDeniedText = 'Permissão Negada! Consulte o Administrador do sistema.'
|
|
42
45
|
} = props;
|
|
43
46
|
const {
|
|
44
47
|
handleSelectItem,
|
|
@@ -48,13 +51,17 @@ const Item = props => {
|
|
|
48
51
|
selectOnEnter
|
|
49
52
|
} = (0, _react.useContext)(_helpers.ListContext);
|
|
50
53
|
const dropdownContext = (0, _react.useContext)(_withDropdown.WithDropdownContext);
|
|
54
|
+
const {
|
|
55
|
+
handlerSetOnDeniedText
|
|
56
|
+
} = (0, _react.useContext)(_withTooltip.TooltipContext);
|
|
51
57
|
const options = [_permissionValidations.OPTIONS_ON_DENIED.disabled, _permissionValidations.OPTIONS_ON_DENIED.unvisible];
|
|
52
58
|
const [onDenied] = (0, _react.useState)((0, _permissionValidations.actionsOnPermissionDenied)(options, permissionAttr));
|
|
53
59
|
const navigate = (0, _reactRouterDom.useNavigate)();
|
|
54
60
|
const disabledByPermission = onDenied.disabled;
|
|
55
61
|
const shouldDisable = () => disabled || onDenied.disabled;
|
|
56
62
|
const disabledIconColor = 'rgb(193, 193, 193)';
|
|
57
|
-
const getClass = () =>
|
|
63
|
+
const getClass = () => `item ${customClass} ${separator && 'list-separator'} ${shouldDisable() && 'disabled'}
|
|
64
|
+
${displayCheckbox && 'list-checkbox'}`;
|
|
58
65
|
const getIcon = (iconName, icon) => {
|
|
59
66
|
const noIconDisabledByPermission = !icon && !displayCheckbox && !leftElement && !leftIconName && !leftIcon && onDenied.disabled;
|
|
60
67
|
if (icon) {
|
|
@@ -103,6 +110,9 @@ const Item = props => {
|
|
|
103
110
|
document.removeEventListener('keydown', onKeyDown);
|
|
104
111
|
};
|
|
105
112
|
}, [url, selectedItemId, itemId]);
|
|
113
|
+
(0, _react.useEffect)(() => {
|
|
114
|
+
if (disabledByPermission) handlerSetOnDeniedText(onDeniedText);
|
|
115
|
+
}, [disabledByPermission]);
|
|
106
116
|
const renderCheckBox = (0, _react.useMemo)(() => {
|
|
107
117
|
if (!disabledByPermission && displayCheckbox) {
|
|
108
118
|
return /*#__PURE__*/_react.default.createElement(_checkbox.default, {
|
|
@@ -117,24 +127,28 @@ const Item = props => {
|
|
|
117
127
|
}, [disabledByPermission && displayCheckbox]);
|
|
118
128
|
if (!visible || onDenied.unvisible) return null;
|
|
119
129
|
return /*#__PURE__*/_react.default.createElement("li", _extends({
|
|
120
|
-
ref:
|
|
130
|
+
ref: ref => {
|
|
131
|
+
if (targetRef) targetRef(ref);
|
|
132
|
+
return itemId && selectedItemId === itemId ? selectedItemRef : null;
|
|
133
|
+
},
|
|
121
134
|
style: style,
|
|
122
|
-
className:
|
|
135
|
+
className: `item-container ${hovered && 'hovered'}
|
|
136
|
+
${itemId && selectedItemId === itemId ? '-activedlist' : ''}`
|
|
123
137
|
}, getProps(), {
|
|
124
138
|
key: itemId
|
|
125
139
|
}), url && !shouldDisable() && /*#__PURE__*/_react.default.createElement(_reactRouterDom.Link, {
|
|
126
140
|
className: "linkitem",
|
|
127
141
|
to: url
|
|
128
142
|
}), (displayCheckbox || leftElement || leftIconName || leftIcon) && /*#__PURE__*/_react.default.createElement("div", {
|
|
129
|
-
className:
|
|
143
|
+
className: `${getClass()} -icon-left`
|
|
130
144
|
}, renderCheckBox, leftElement, getIcon(leftIconName, leftIcon)), (text || subText || children) && /*#__PURE__*/_react.default.createElement("div", {
|
|
131
|
-
className:
|
|
145
|
+
className: `${getClass()}`
|
|
132
146
|
}, /*#__PURE__*/_react.default.createElement("p", {
|
|
133
|
-
className:
|
|
147
|
+
className: `${text && 'text'}`
|
|
134
148
|
}, text), /*#__PURE__*/_react.default.createElement("p", {
|
|
135
|
-
className:
|
|
149
|
+
className: `${subText && 'subtext'}`
|
|
136
150
|
}, subText), children), (rightIconName || rightIcon || rightElement || disabledByPermission) && /*#__PURE__*/_react.default.createElement("div", {
|
|
137
|
-
className:
|
|
151
|
+
className: `${getClass()} -icon-right`
|
|
138
152
|
}, getIcon(rightIconName, rightIcon), rightElement));
|
|
139
153
|
};
|
|
140
|
-
var _default = exports.default = Item;
|
|
154
|
+
var _default = exports.default = (0, _withTooltip.default)(Item);
|
package/lib/list/helpers.d.ts
CHANGED
|
@@ -3,6 +3,7 @@ import { IListContext } from './types.js';
|
|
|
3
3
|
import '../@types/PermissionAttr.js';
|
|
4
4
|
import '../@types/Icon.js';
|
|
5
5
|
import '../icons/helper.js';
|
|
6
|
+
import '../@types/Position.js';
|
|
6
7
|
|
|
7
8
|
declare const ListContext: React__default.Context<IListContext>;
|
|
8
9
|
declare const LIST_ITEMS_TYPES: {
|
package/lib/list/index.d.ts
CHANGED
package/lib/list/index.js
CHANGED
|
@@ -36,7 +36,7 @@ function _interopRequireWildcard(e, r) { if (!r && e && e.__esModule) return e;
|
|
|
36
36
|
const List = props => {
|
|
37
37
|
const {
|
|
38
38
|
children,
|
|
39
|
-
customClass
|
|
39
|
+
customClass,
|
|
40
40
|
condensed,
|
|
41
41
|
transparent,
|
|
42
42
|
style,
|
|
@@ -175,7 +175,8 @@ const List = props => {
|
|
|
175
175
|
"data-testid": "list-component",
|
|
176
176
|
style: style,
|
|
177
177
|
ref: listRef,
|
|
178
|
-
className:
|
|
178
|
+
className: `list-component ${condensed && '-condensed'}
|
|
179
|
+
${customClass} ${!transparent && '-listbackground'}`
|
|
179
180
|
}, newChildren));
|
|
180
181
|
};
|
|
181
182
|
var _default = exports.default = List;
|