linear-react-components-ui 1.1.2-beta.8 → 1.1.2-beta.9
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/assets/styles/checkbox.scss +0 -8
- package/lib/assets/styles/colors.scss +1 -1
- package/lib/assets/styles/dialog.scss +10 -27
- package/lib/assets/styles/icon.scss +31 -4
- package/lib/assets/styles/multiSelect.scss +1 -6
- package/lib/assets/styles/radio.scss +35 -37
- package/lib/assets/styles/select.scss +7 -13
- package/lib/assets/styles/tabs.scss +0 -3
- package/lib/assets/styles/textContent.scss +9 -0
- package/lib/checkbox/index.d.ts +2 -2
- package/lib/checkbox/index.js +11 -12
- package/lib/checkbox/types.d.ts +1 -2
- package/lib/dialog/Custom.js +4 -2
- package/lib/dialog/base/Content.js +0 -1
- package/lib/dialog/base/Header.js +4 -4
- package/lib/dialog/base/index.js +4 -6
- package/lib/dialog/form/index.js +3 -3
- package/lib/drawer/Drawer.js +4 -5
- package/lib/drawer/Header.js +1 -1
- package/lib/dropdown/Popup.d.ts +1 -1
- package/lib/dropdown/Popup.js +2 -5
- package/lib/dropdown/types.d.ts +0 -1
- package/lib/icons/helper.js +1 -1
- package/lib/icons/index.d.ts +3 -2
- package/lib/icons/index.js +10 -3
- package/lib/icons/types.d.ts +22 -9
- package/lib/index.d.ts +1 -0
- package/lib/inputs/base/InputTextBase.js +1 -3
- package/lib/inputs/base/types.d.ts +0 -1
- package/lib/inputs/multiSelect/ActionButtons.js +8 -10
- package/lib/inputs/multiSelect/Dropdown.js +6 -2
- package/lib/inputs/multiSelect/index.js +2 -2
- package/lib/inputs/select/ActionButtons.js +27 -18
- package/lib/inputs/select/Dropdown.js +6 -2
- package/lib/inputs/select/multiple/Selecteds.d.ts +1 -1
- package/lib/inputs/select/multiple/Selecteds.js +5 -3
- package/lib/inputs/select/multiple/index.js +21 -34
- package/lib/inputs/select/simple/index.js +32 -55
- package/lib/inputs/select/types.d.ts +1 -2
- package/lib/inputs/types.d.ts +2 -2
- package/lib/menus/float/types.d.ts +1 -1
- package/lib/menus/sidenav/index.js +3 -3
- package/lib/menus/sidenav/popup_menu_help/index.js +78 -0
- package/lib/menus/sidenav/popup_menu_search/index.js +2 -3
- package/lib/menus/sidenav/types.d.ts +1 -1
- package/lib/table/HeaderColumn.d.ts +1 -1
- package/lib/table/HeaderColumn.js +1 -5
- package/lib/table/types.d.ts +0 -2
- package/lib/tabs/context.js +1 -1
- package/lib/tabs/types.d.ts +3 -3
- package/lib/textContent/index.d.ts +8 -0
- package/lib/textContent/index.js +30 -0
- package/lib/tooltip/index.js +2 -2
- package/lib/treeview/Node.js +2 -2
- package/package.json +2 -2
package/lib/icons/index.js
CHANGED
|
@@ -24,17 +24,23 @@ const Icon = _ref => {
|
|
|
24
24
|
disabled = false,
|
|
25
25
|
customClass = '',
|
|
26
26
|
customClassForContainer = '',
|
|
27
|
-
|
|
27
|
+
colorStyle = 'default',
|
|
28
|
+
color,
|
|
29
|
+
viewBox,
|
|
28
30
|
pointerEvents = 'none',
|
|
29
31
|
targetRef,
|
|
30
32
|
tooltip
|
|
31
33
|
} = _ref;
|
|
34
|
+
const isUsingColorStyle = colorStyle !== 'default';
|
|
35
|
+
const colorFromProp = isUsingColorStyle || !color ? undefined : color;
|
|
32
36
|
const refSvg = (0, _react.useRef)(null);
|
|
37
|
+
const viewBoxFromIconOrSvgStrcut = name ? listIcon[name].viewbox : svgStruct === null || svgStruct === void 0 ? void 0 : svgStruct.viewbox;
|
|
33
38
|
const getPaths = () => name ? listIcon[name].paths : svgStruct === null || svgStruct === void 0 ? void 0 : svgStruct.paths;
|
|
34
39
|
const getSvg = () => {
|
|
35
40
|
var _getPaths;
|
|
36
41
|
return /*#__PURE__*/_react.default.createElement("svg", {
|
|
37
42
|
"data-testid": "icon",
|
|
43
|
+
"data-color-style": colorStyle,
|
|
38
44
|
onClick: () => {
|
|
39
45
|
if (onClick && !disabled) onClick();
|
|
40
46
|
},
|
|
@@ -43,8 +49,8 @@ const Icon = _ref => {
|
|
|
43
49
|
},
|
|
44
50
|
width: "".concat(size, "px"),
|
|
45
51
|
height: "".concat(size, "px"),
|
|
46
|
-
fill: disabled ? disabledIconColor :
|
|
47
|
-
viewBox:
|
|
52
|
+
fill: disabled ? disabledIconColor : colorFromProp,
|
|
53
|
+
viewBox: viewBox || viewBoxFromIconOrSvgStrcut,
|
|
48
54
|
className: "icon-component ".concat(customClass),
|
|
49
55
|
pointerEvents: pointerEvents,
|
|
50
56
|
style: style
|
|
@@ -54,6 +60,7 @@ const Icon = _ref => {
|
|
|
54
60
|
key: value
|
|
55
61
|
})));
|
|
56
62
|
};
|
|
63
|
+
if (color && colorStyle !== 'default') throw new Error('Expected only one of the two properties: colorStyle or color');
|
|
57
64
|
if (!name && !svgStruct) throw new Error('One of the "name" and "svgStruct" props must be filled');
|
|
58
65
|
if (!visible) return null;
|
|
59
66
|
if (!tooltip) return getSvg();
|
package/lib/icons/types.d.ts
CHANGED
|
@@ -3,6 +3,7 @@ import { PointerEvents } from '../@types/PointerEvents.js';
|
|
|
3
3
|
import { SizePixels } from '../@types/SizePixels.js';
|
|
4
4
|
import { IconNames } from '../@types/Icon.js';
|
|
5
5
|
import { Position } from '../@types/Position.js';
|
|
6
|
+
import { ColorStyles } from '../@types/ColorStyles.js';
|
|
6
7
|
import './helper.js';
|
|
7
8
|
|
|
8
9
|
type ListIconType = {
|
|
@@ -11,26 +12,38 @@ type ListIconType = {
|
|
|
11
12
|
paths: Array<string>;
|
|
12
13
|
};
|
|
13
14
|
};
|
|
14
|
-
|
|
15
|
+
type SvgStruct = {
|
|
16
|
+
viewbox: string;
|
|
17
|
+
paths: Array<string>;
|
|
18
|
+
};
|
|
19
|
+
type BaseIconProps = {
|
|
15
20
|
size?: SizePixels;
|
|
16
|
-
color?: string;
|
|
17
21
|
customClass?: string;
|
|
18
22
|
customClassForContainer?: string;
|
|
19
23
|
style?: CSSProperties;
|
|
20
24
|
visible?: boolean;
|
|
21
25
|
disabled?: boolean;
|
|
22
26
|
pointerEvents?: PointerEvents;
|
|
23
|
-
name?: IconNames;
|
|
24
27
|
viewBox?: string;
|
|
25
|
-
svgStruct?: {
|
|
26
|
-
viewbox: string;
|
|
27
|
-
paths: Array<string>;
|
|
28
|
-
};
|
|
29
28
|
onClick?: () => void;
|
|
30
29
|
tooltipPosition?: Exclude<Position, 'center'>;
|
|
31
30
|
tooltipWidth?: string | number;
|
|
32
31
|
tooltip?: string;
|
|
33
32
|
targetRef?: (ref: HTMLDivElement) => void;
|
|
34
|
-
}
|
|
33
|
+
};
|
|
34
|
+
type ColorProps = ({
|
|
35
|
+
colorStyle?: ColorStyles | 'default';
|
|
36
|
+
color?: null;
|
|
37
|
+
} | {
|
|
38
|
+
color?: string;
|
|
39
|
+
colorStyle?: undefined;
|
|
40
|
+
});
|
|
41
|
+
type IconProps = BaseIconProps & ColorProps & ({
|
|
42
|
+
name: IconNames;
|
|
43
|
+
svgStruct?: null;
|
|
44
|
+
} | {
|
|
45
|
+
svgStruct: SvgStruct;
|
|
46
|
+
name?: null;
|
|
47
|
+
});
|
|
35
48
|
|
|
36
|
-
export type {
|
|
49
|
+
export type { IconProps, ListIconType };
|
package/lib/index.d.ts
CHANGED
|
@@ -64,8 +64,7 @@ const InputTextBase = props => {
|
|
|
64
64
|
onDragOver,
|
|
65
65
|
onDrop,
|
|
66
66
|
onDragLeave,
|
|
67
|
-
readOnlyClass
|
|
68
|
-
autoComplete = 'on'
|
|
67
|
+
readOnlyClass
|
|
69
68
|
} = props;
|
|
70
69
|
let propsInput;
|
|
71
70
|
const options = [_permissionValidations.OPTIONS_ON_DENIED.disabled, _permissionValidations.OPTIONS_ON_DENIED.unvisible, _permissionValidations.OPTIONS_ON_DENIED.readOnly, _permissionValidations.OPTIONS_ON_DENIED.hideContent];
|
|
@@ -176,7 +175,6 @@ const InputTextBase = props => {
|
|
|
176
175
|
rows: props.rows,
|
|
177
176
|
cols: props.cols
|
|
178
177
|
}, inputProps())) : /*#__PURE__*/_react.default.createElement("input", _extends({
|
|
179
|
-
autoComplete: autoComplete,
|
|
180
178
|
tabIndex: applyTabIndex()
|
|
181
179
|
}, inputProps())), children), helpers.getRightElements(errorMessages || [], skeletonize, rightElements)), /*#__PURE__*/_react.default.createElement(_hint.default, {
|
|
182
180
|
visible: !!hint,
|
|
@@ -20,24 +20,22 @@ const ActionButtons = _ref => {
|
|
|
20
20
|
dropdownAlignButton = 'left'
|
|
21
21
|
} = _ref;
|
|
22
22
|
return /*#__PURE__*/_react.default.createElement(_react.Fragment, null, /*#__PURE__*/_react.default.createElement(_buttons.default, {
|
|
23
|
-
transparent: true,
|
|
24
|
-
tabIndex: -1,
|
|
25
23
|
disabled: disabled,
|
|
26
|
-
boxShadow: false,
|
|
27
24
|
size: "small",
|
|
25
|
+
iconName: dropdownOpened ? 'up' : 'down',
|
|
28
26
|
onClick: handleOpenClose,
|
|
29
27
|
customClass: "actionbutton",
|
|
30
|
-
iconName: dropdownOpened ? 'up' : 'down'
|
|
31
|
-
}), /*#__PURE__*/_react.default.createElement(_buttons.default, {
|
|
32
|
-
dropdown: true,
|
|
33
28
|
transparent: true,
|
|
29
|
+
boxShadow: false
|
|
30
|
+
}), /*#__PURE__*/_react.default.createElement(_buttons.default, {
|
|
34
31
|
disabled: disabled,
|
|
35
|
-
tabIndex: -1,
|
|
36
|
-
boxShadow: false,
|
|
37
|
-
showIconDropdown: false,
|
|
38
32
|
iconName: "more1",
|
|
33
|
+
transparent: true,
|
|
34
|
+
boxShadow: false,
|
|
39
35
|
customClass: "actionbutton",
|
|
40
|
-
|
|
36
|
+
dropdown: true,
|
|
37
|
+
dropdownAlign: dropdownAlignButton,
|
|
38
|
+
showIconDropdown: false
|
|
41
39
|
}, /*#__PURE__*/_react.default.createElement(_list.default, null, /*#__PURE__*/_react.default.createElement(_list.ListItem, {
|
|
42
40
|
itemId: "1",
|
|
43
41
|
text: "Marcar Todos",
|
|
@@ -94,9 +94,11 @@ const Dropdown = props => {
|
|
|
94
94
|
className: "listcontainer"
|
|
95
95
|
}, dataCombo && dataCombo.length > 0 && /*#__PURE__*/_react.default.createElement("div", {
|
|
96
96
|
className: "item selectall"
|
|
97
|
-
}, /*#__PURE__*/_react.default.createElement("
|
|
97
|
+
}, /*#__PURE__*/_react.default.createElement("span", {
|
|
98
|
+
role: "button",
|
|
98
99
|
className: "menubutton",
|
|
99
100
|
tabIndex: -1,
|
|
101
|
+
onKeyPress: () => {},
|
|
100
102
|
onClick: () => isAllChecked ? onUncheckAll(true) : onCheckAll(true)
|
|
101
103
|
}, /*#__PURE__*/_react.default.createElement(_icons.default, {
|
|
102
104
|
name: isAllChecked && dataCombo.length > 0 ? 'checkboxChecked2' : 'checkboxUnchecked2',
|
|
@@ -108,9 +110,11 @@ const Dropdown = props => {
|
|
|
108
110
|
return /*#__PURE__*/_react.default.createElement("div", {
|
|
109
111
|
key: "dropdowmItem ".concat(item[idKey], "}"),
|
|
110
112
|
className: "item ".concat(isChecked && '-selected')
|
|
111
|
-
}, /*#__PURE__*/_react.default.createElement("
|
|
113
|
+
}, /*#__PURE__*/_react.default.createElement("span", {
|
|
114
|
+
role: "button",
|
|
112
115
|
className: "menubutton",
|
|
113
116
|
tabIndex: -1,
|
|
117
|
+
onKeyPress: () => {},
|
|
114
118
|
onClick: () => {
|
|
115
119
|
onSelect(item);
|
|
116
120
|
}
|
|
@@ -6,7 +6,7 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
6
6
|
exports.default = void 0;
|
|
7
7
|
var _lodash = _interopRequireDefault(require("lodash"));
|
|
8
8
|
var _react = _interopRequireWildcard(require("react"));
|
|
9
|
-
var
|
|
9
|
+
var uuid = _interopRequireWildcard(require("uuid"));
|
|
10
10
|
var _InputTextBase = _interopRequireDefault(require("../base/InputTextBase"));
|
|
11
11
|
var _ActionButtons = _interopRequireDefault(require("./ActionButtons"));
|
|
12
12
|
var _Dropdown = _interopRequireDefault(require("./Dropdown"));
|
|
@@ -33,7 +33,7 @@ const MultiSelectField = props => {
|
|
|
33
33
|
gridLayout,
|
|
34
34
|
dropdownAlignButton = 'left'
|
|
35
35
|
} = props;
|
|
36
|
-
const componentId = "multiSelect-component".concat(
|
|
36
|
+
const componentId = "multiSelect-component".concat(uuid.v1());
|
|
37
37
|
const [dataCombo, setDataCombo] = (0, _react.useState)(dataSource);
|
|
38
38
|
const [selecteds, setSelecteds] = (0, _react.useState)();
|
|
39
39
|
const [inputValue, setInputValue] = (0, _react.useState)('');
|
|
@@ -11,28 +11,37 @@ const ActionButtons = props => {
|
|
|
11
11
|
const {
|
|
12
12
|
disabled = false,
|
|
13
13
|
showClearButton = true,
|
|
14
|
-
dropDownOpened
|
|
15
|
-
handlerOpenClose,
|
|
16
|
-
handlerClear
|
|
14
|
+
dropDownOpened
|
|
17
15
|
} = props;
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
16
|
+
const returnOnClick = () => {
|
|
17
|
+
if (!disabled) {
|
|
18
|
+
return props.handleOpenClose();
|
|
19
|
+
}
|
|
20
|
+
return undefined;
|
|
21
|
+
};
|
|
22
|
+
return /*#__PURE__*/_react.default.createElement(_react.default.Fragment, null, showClearButton && /*#__PURE__*/_react.default.createElement("span", {
|
|
23
|
+
role: "button",
|
|
24
|
+
className: "actionbutton",
|
|
25
|
+
onClick: () => {
|
|
26
|
+
props.handleClear();
|
|
27
|
+
},
|
|
28
|
+
onKeyPress: () => {},
|
|
29
|
+
tabIndex: -1
|
|
25
30
|
}, /*#__PURE__*/_react.default.createElement(_icons.default, {
|
|
31
|
+
pointerEvents: "none",
|
|
26
32
|
name: "cancel",
|
|
27
|
-
|
|
28
|
-
})), /*#__PURE__*/_react.default.createElement("
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
+
customClass: "iconclear"
|
|
34
|
+
})), /*#__PURE__*/_react.default.createElement("span", {
|
|
35
|
+
role: "button",
|
|
36
|
+
className: "actionbutton",
|
|
37
|
+
onClick: () => {
|
|
38
|
+
returnOnClick();
|
|
39
|
+
},
|
|
40
|
+
onKeyPress: () => {},
|
|
41
|
+
tabIndex: -1
|
|
33
42
|
}, /*#__PURE__*/_react.default.createElement(_icons.default, {
|
|
34
|
-
|
|
35
|
-
|
|
43
|
+
name: dropDownOpened ? 'mini_up' : 'mini_down',
|
|
44
|
+
pointerEvents: "none"
|
|
36
45
|
})));
|
|
37
46
|
};
|
|
38
47
|
var _default = exports.default = ActionButtons;
|
|
@@ -29,6 +29,7 @@ const Dropdown = props => {
|
|
|
29
29
|
dropdownWidth,
|
|
30
30
|
gridWrapperStyle,
|
|
31
31
|
handleOnSelect,
|
|
32
|
+
handleOnBlur,
|
|
32
33
|
inputValue,
|
|
33
34
|
handleOnFocus,
|
|
34
35
|
opened,
|
|
@@ -82,12 +83,15 @@ const Dropdown = props => {
|
|
|
82
83
|
return /*#__PURE__*/_react.default.createElement("div", {
|
|
83
84
|
key: "dropdowmIten ".concat(item[idKey], "}"),
|
|
84
85
|
className: helper.getDropdownItemCssClass(itemSelected, disabled, striped)
|
|
85
|
-
}, /*#__PURE__*/_react.default.createElement("
|
|
86
|
+
}, /*#__PURE__*/_react.default.createElement("span", {
|
|
87
|
+
role: "button",
|
|
86
88
|
className: "menubutton",
|
|
87
89
|
tabIndex: -1,
|
|
88
|
-
|
|
90
|
+
onKeyPress: () => {},
|
|
91
|
+
onClick: () => {
|
|
89
92
|
if (!disabled) {
|
|
90
93
|
handleOnSelect(item);
|
|
94
|
+
handleOnBlur(item);
|
|
91
95
|
}
|
|
92
96
|
}
|
|
93
97
|
}, item.iconName && /*#__PURE__*/_react.default.createElement(_icons.default, {
|
|
@@ -6,6 +6,6 @@ import '../../base/types.js';
|
|
|
6
6
|
import 'react';
|
|
7
7
|
import '../../../@types/Period.js';
|
|
8
8
|
|
|
9
|
-
declare const Selecteds: ({ currents, descriptionKey, idKey,
|
|
9
|
+
declare const Selecteds: ({ currents, descriptionKey, idKey, handleOnUnselect, }: ISelectedsMultipleProps) => JSX.Element;
|
|
10
10
|
|
|
11
11
|
export { Selecteds as default };
|
|
@@ -11,15 +11,17 @@ const Selecteds = _ref => {
|
|
|
11
11
|
currents,
|
|
12
12
|
descriptionKey,
|
|
13
13
|
idKey,
|
|
14
|
-
|
|
14
|
+
handleOnUnselect
|
|
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
18
|
key: "selected-".concat(selected[idKey])
|
|
19
|
-
}, typeof descriptionKey === 'string' ? selected[descriptionKey] : descriptionKey(selected), /*#__PURE__*/_react.default.createElement("
|
|
19
|
+
}, typeof descriptionKey === 'string' ? selected[descriptionKey] : descriptionKey(selected), /*#__PURE__*/_react.default.createElement("span", {
|
|
20
20
|
className: "close",
|
|
21
|
+
role: "button",
|
|
21
22
|
tabIndex: -1,
|
|
22
|
-
|
|
23
|
+
onKeyPress: () => {},
|
|
24
|
+
onClick: () => handleOnUnselect(selected[idKey])
|
|
23
25
|
}))));
|
|
24
26
|
};
|
|
25
27
|
var _default = exports.default = Selecteds;
|
|
@@ -6,7 +6,7 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
6
6
|
exports.default = void 0;
|
|
7
7
|
var _react = _interopRequireWildcard(require("react"));
|
|
8
8
|
var _lodash = _interopRequireDefault(require("lodash"));
|
|
9
|
-
var
|
|
9
|
+
var uuid = _interopRequireWildcard(require("uuid"));
|
|
10
10
|
var _Dropdown = _interopRequireDefault(require("../Dropdown"));
|
|
11
11
|
var _ActionButtons = _interopRequireDefault(require("../ActionButtons"));
|
|
12
12
|
var _Selecteds = _interopRequireDefault(require("./Selecteds"));
|
|
@@ -24,8 +24,7 @@ const MultipleSelect = props => {
|
|
|
24
24
|
handlerClear,
|
|
25
25
|
value = [],
|
|
26
26
|
remoteSearch = false,
|
|
27
|
-
descriptionKey
|
|
28
|
-
showClearButton
|
|
27
|
+
descriptionKey
|
|
29
28
|
} = props;
|
|
30
29
|
const [dataCombo, setDataCombo] = (0, _react.useState)(dataSource);
|
|
31
30
|
const [currents, setCurrents] = (0, _react.useState)([]);
|
|
@@ -36,12 +35,11 @@ const MultipleSelect = props => {
|
|
|
36
35
|
const [insideComponent, setInsideComponent] = (0, _react.useState)(false);
|
|
37
36
|
const [onDenied, setOnDeniedSelect] = (0, _react.useState)();
|
|
38
37
|
const [valueFromProps, setValueFromProps] = (0, _react.useState)([]);
|
|
39
|
-
const componentId = "select-component".concat(
|
|
38
|
+
const componentId = "select-component".concat(uuid.v1());
|
|
40
39
|
const componentRef = (0, _react.useRef)(null);
|
|
41
40
|
const dropdownRef = (0, _react.useRef)(null);
|
|
42
41
|
const selectWrapper = (0, _react.useRef)();
|
|
43
42
|
const gridElRef = (0, _react.useRef)();
|
|
44
|
-
const inputTextRef = (0, _react.useRef)(null);
|
|
45
43
|
const descriptionKeyIsString = typeof descriptionKey === 'string';
|
|
46
44
|
const onScreenResize = () => {
|
|
47
45
|
if (selectWrapper.current) setDropdownWidth(selectWrapper.current.clientWidth);
|
|
@@ -55,12 +53,12 @@ const MultipleSelect = props => {
|
|
|
55
53
|
}
|
|
56
54
|
};
|
|
57
55
|
const onMouseMove = event => {
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
const
|
|
63
|
-
setInsideComponent(
|
|
56
|
+
const {
|
|
57
|
+
target
|
|
58
|
+
} = event;
|
|
59
|
+
if (target.className === '') return;
|
|
60
|
+
const insideComponents = ['item', 'menubutton', 'filterinput', 'filtercontainer', 'label'].includes(target.className);
|
|
61
|
+
setInsideComponent(insideComponents);
|
|
64
62
|
};
|
|
65
63
|
const onClearClick = () => {
|
|
66
64
|
setSelected(undefined);
|
|
@@ -96,7 +94,6 @@ const MultipleSelect = props => {
|
|
|
96
94
|
setCurrents(currentsSelect);
|
|
97
95
|
setDataCombo(dataSource);
|
|
98
96
|
setInputValue([]);
|
|
99
|
-
if (inputTextRef && inputTextRef.current) inputTextRef.current.focus();
|
|
100
97
|
setOpened(false);
|
|
101
98
|
if (props.onSelect) setSelected(props.onSelect(currentsSelect.map(i => i[idKey])));
|
|
102
99
|
};
|
|
@@ -104,13 +101,11 @@ const MultipleSelect = props => {
|
|
|
104
101
|
if (currents) {
|
|
105
102
|
const result = currents.filter(item => item[idKey] !== id);
|
|
106
103
|
setCurrents(result);
|
|
107
|
-
if (inputTextRef && inputTextRef.current) inputTextRef.current.focus();
|
|
108
|
-
setOpened(false);
|
|
109
104
|
if (props.onSelect) setSelected(props.onSelect(result.map(i => i[idKey])));
|
|
110
105
|
}
|
|
111
106
|
};
|
|
112
107
|
const onOpenClose = () => {
|
|
113
|
-
setOpened(
|
|
108
|
+
setOpened(!opened);
|
|
114
109
|
if (selectWrapper.current) setDropdownWidth(selectWrapper.current.clientWidth);
|
|
115
110
|
};
|
|
116
111
|
const onFocus = () => {
|
|
@@ -120,16 +115,11 @@ const MultipleSelect = props => {
|
|
|
120
115
|
};
|
|
121
116
|
const onBlur = e => {
|
|
122
117
|
if (props.onBlur) props.onBlur(e);
|
|
123
|
-
if (!insideComponent)
|
|
124
|
-
setOpened(false);
|
|
125
|
-
setDataCombo(dataSource);
|
|
126
|
-
}
|
|
118
|
+
if (!insideComponent) setOpened(false);
|
|
127
119
|
};
|
|
128
120
|
const onInputKeyDown = e => {
|
|
129
121
|
if (e.keyCode) {
|
|
130
122
|
if (e.keyCode === constants.keyCodes.ENTER && selected) {
|
|
131
|
-
var _e$preventDefault;
|
|
132
|
-
(_e$preventDefault = e.preventDefault) === null || _e$preventDefault === void 0 ? void 0 : _e$preventDefault.call(e);
|
|
133
123
|
if (!currents.includes(selected)) onSelect(selected);
|
|
134
124
|
} else if ([constants.keyCodes.ARROW_UP, constants.keyCodes.ARROW_DOWN].includes(e.keyCode)) {
|
|
135
125
|
if (!opened) setOpened(true);
|
|
@@ -200,11 +190,6 @@ const MultipleSelect = props => {
|
|
|
200
190
|
ref: componentRef,
|
|
201
191
|
className: "select-component"
|
|
202
192
|
}, /*#__PURE__*/_react.default.createElement(_InputTextBase.default, _extends({}, props, {
|
|
203
|
-
inputRef: ref => {
|
|
204
|
-
if (props.inputRef) props.inputRef(ref);
|
|
205
|
-
inputTextRef.current = ref;
|
|
206
|
-
},
|
|
207
|
-
autoComplete: "off",
|
|
208
193
|
value: inputValue.toString(),
|
|
209
194
|
readOnly: shouldBeReadOnly(),
|
|
210
195
|
onFocus: () => {
|
|
@@ -223,19 +208,21 @@ const MultipleSelect = props => {
|
|
|
223
208
|
selectWrapper.current = r;
|
|
224
209
|
},
|
|
225
210
|
handlerSetOnDenied: setOnDenied,
|
|
226
|
-
rightElements: /*#__PURE__*/_react.default.createElement(_ActionButtons.default, {
|
|
227
|
-
showClearButton: showClearButton,
|
|
211
|
+
rightElements: /*#__PURE__*/_react.default.createElement(_ActionButtons.default, _extends({}, props, {
|
|
228
212
|
disabled: shouldDisable() || shouldBeReadOnly(),
|
|
229
213
|
dropDownOpened: opened,
|
|
230
|
-
|
|
214
|
+
handleClear: () => {
|
|
231
215
|
if (shouldDisable()) return null;
|
|
232
216
|
return onClearClick();
|
|
233
217
|
},
|
|
234
|
-
|
|
235
|
-
|
|
236
|
-
|
|
237
|
-
|
|
238
|
-
|
|
218
|
+
handleOpenClose: () => {
|
|
219
|
+
onOpenClose();
|
|
220
|
+
}
|
|
221
|
+
}))
|
|
222
|
+
}), /*#__PURE__*/_react.default.createElement(_Selecteds.default, _extends({
|
|
223
|
+
currents: currents
|
|
224
|
+
}, props, {
|
|
225
|
+
handleOnUnselect: onUnselect
|
|
239
226
|
}))), opened && /*#__PURE__*/_react.default.createElement(_Dropdown.default, _extends({}, props, {
|
|
240
227
|
selected: selected,
|
|
241
228
|
selectFieldRef: componentRef,
|
|
@@ -5,7 +5,7 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
5
5
|
});
|
|
6
6
|
exports.default = void 0;
|
|
7
7
|
var _react = _interopRequireWildcard(require("react"));
|
|
8
|
-
var
|
|
8
|
+
var uuid = _interopRequireWildcard(require("uuid"));
|
|
9
9
|
var _lodash = _interopRequireDefault(require("lodash"));
|
|
10
10
|
var _Dropdown = _interopRequireDefault(require("../Dropdown"));
|
|
11
11
|
var _ActionButtons = _interopRequireDefault(require("../ActionButtons"));
|
|
@@ -19,7 +19,7 @@ function _extends() { _extends = Object.assign ? Object.assign.bind() : function
|
|
|
19
19
|
const SimpleSelect = props => {
|
|
20
20
|
const {
|
|
21
21
|
value,
|
|
22
|
-
descriptionKey,
|
|
22
|
+
descriptionKey = '',
|
|
23
23
|
dataSource = [],
|
|
24
24
|
gridLayout,
|
|
25
25
|
onSearch,
|
|
@@ -32,9 +32,7 @@ const SimpleSelect = props => {
|
|
|
32
32
|
name = '',
|
|
33
33
|
undigitable,
|
|
34
34
|
searchOnDropdown = false,
|
|
35
|
-
allOptions = undefined
|
|
36
|
-
showClearButton = false,
|
|
37
|
-
searchNotFoundText
|
|
35
|
+
allOptions = undefined
|
|
38
36
|
} = props;
|
|
39
37
|
const descriptionKeyIsString = typeof descriptionKey === 'string';
|
|
40
38
|
const dataSourceWithAllOptions = allOptions ? [{
|
|
@@ -50,11 +48,15 @@ const SimpleSelect = props => {
|
|
|
50
48
|
const [onDenied, setOnDeniedSelect] = (0, _react.useState)();
|
|
51
49
|
const [isTyping, setIsTyping] = (0, _react.useState)(false);
|
|
52
50
|
const dropdownRef = (0, _react.useRef)(null);
|
|
53
|
-
const componentId = "select-component
|
|
51
|
+
const componentId = "select-component".concat(uuid.v1());
|
|
54
52
|
const componentRef = (0, _react.useRef)(null);
|
|
55
53
|
const selectWrapper = (0, _react.useRef)();
|
|
56
54
|
const gridElement = (0, _react.useRef)();
|
|
57
|
-
const
|
|
55
|
+
const clearSelected = () => {
|
|
56
|
+
setInputText('');
|
|
57
|
+
setSelected(null);
|
|
58
|
+
setDataCombo(dataSourceWithAllOptions);
|
|
59
|
+
};
|
|
58
60
|
const onScreenResize = () => {
|
|
59
61
|
if (selectWrapper.current) setDropdownWidth(selectWrapper.current.clientWidth);
|
|
60
62
|
};
|
|
@@ -68,12 +70,10 @@ const SimpleSelect = props => {
|
|
|
68
70
|
}
|
|
69
71
|
};
|
|
70
72
|
const onMouseMove = event => {
|
|
71
|
-
var _dropdownRef$current2, _dropdownRef$current3;
|
|
72
73
|
const target = event.target;
|
|
73
|
-
|
|
74
|
-
const
|
|
75
|
-
|
|
76
|
-
setInsideComponent(keepDropdownOpen);
|
|
74
|
+
if (target.className === '') return;
|
|
75
|
+
const insideComponents = ['item', 'menubutton', 'filterinput', 'filtercontainer', 'label'].includes(target.className);
|
|
76
|
+
setInsideComponent(insideComponents);
|
|
77
77
|
};
|
|
78
78
|
const getSelectEvent = selectedEvent => ({
|
|
79
79
|
target: {
|
|
@@ -99,12 +99,12 @@ const SimpleSelect = props => {
|
|
|
99
99
|
});
|
|
100
100
|
if (dataComboFilter && dataComboFilter.length > 0) {
|
|
101
101
|
selectedFilter = dataComboFilter[0];
|
|
102
|
-
setSelected(selectedFilter);
|
|
103
102
|
}
|
|
104
103
|
setDataCombo(dataComboFilter);
|
|
105
104
|
}
|
|
106
105
|
setOpened(true);
|
|
107
106
|
setInputText(valueFilter);
|
|
107
|
+
setSelected(selectedFilter);
|
|
108
108
|
if (selectedFilter) {
|
|
109
109
|
if (descriptionKeyIsString && valueFilter === selectedFilter[descriptionKey] || !descriptionKeyIsString && valueFilter === descriptionKey(selectedFilter)) {
|
|
110
110
|
onChange(selectedFilter);
|
|
@@ -112,22 +112,18 @@ const SimpleSelect = props => {
|
|
|
112
112
|
}
|
|
113
113
|
};
|
|
114
114
|
const onSelect = selectedDropdown => {
|
|
115
|
-
if (
|
|
115
|
+
if (selectedDropdown === undefined) return;
|
|
116
|
+
setOpened(false);
|
|
116
117
|
setSelected(selectedDropdown);
|
|
117
118
|
if (descriptionKeyIsString) setInputText(selectedDropdown[descriptionKey]);else setInputText(descriptionKey(selectedDropdown));
|
|
118
|
-
|
|
119
|
-
resolve(onChange(selectedDropdown));
|
|
120
|
-
}).finally(() => {
|
|
121
|
-
if (inputTextRef && inputTextRef.current) inputTextRef.current.focus();
|
|
122
|
-
setOpened(false);
|
|
123
|
-
});
|
|
119
|
+
onChange(selectedDropdown);
|
|
124
120
|
};
|
|
125
121
|
const onOpenClose = () => {
|
|
126
|
-
setOpened(
|
|
122
|
+
setOpened(!opened);
|
|
127
123
|
if (selectWrapper.current) setDropdownWidth(selectWrapper.current.clientWidth);
|
|
128
124
|
};
|
|
129
125
|
const onFocus = () => {
|
|
130
|
-
|
|
126
|
+
setOpened(openDropdownOnFocus);
|
|
131
127
|
if (selectWrapper) {
|
|
132
128
|
const dropdownWidthFocus = selectWrapper.current ? selectWrapper.current.clientWidth : 0;
|
|
133
129
|
setDropdownWidth(dropdownWidthFocus);
|
|
@@ -137,20 +133,15 @@ const SimpleSelect = props => {
|
|
|
137
133
|
if (props.onBlur) {
|
|
138
134
|
const event = getSelectEvent(selected);
|
|
139
135
|
props.onBlur(event);
|
|
140
|
-
if (selected
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
resolve(onChange(null));
|
|
145
|
-
}).finally(() => {
|
|
146
|
-
onChange();
|
|
147
|
-
});
|
|
136
|
+
if (selected) {
|
|
137
|
+
if (descriptionKeyIsString && inputText !== selected[descriptionKey] || !descriptionKeyIsString && inputText !== descriptionKey(selected)) {
|
|
138
|
+
clearSelected();
|
|
139
|
+
}
|
|
148
140
|
}
|
|
149
141
|
}
|
|
150
142
|
if (!insideComponent) {
|
|
151
143
|
setOpened(false);
|
|
152
144
|
setIsTyping(false);
|
|
153
|
-
setDataCombo(dataSourceWithAllOptions);
|
|
154
145
|
}
|
|
155
146
|
};
|
|
156
147
|
const onInputKeyDown = e => {
|
|
@@ -168,22 +159,13 @@ const SimpleSelect = props => {
|
|
|
168
159
|
index = dataCombo && index === 0 ? (dataCombo === null || dataCombo === void 0 ? void 0 : dataCombo.length) - 1 : index - 1;
|
|
169
160
|
}
|
|
170
161
|
setSelected(dataCombo[index]);
|
|
171
|
-
if (descriptionKeyIsString) setInputText(dataCombo[index][descriptionKey]);
|
|
172
|
-
if (!descriptionKeyIsString) setInputText(descriptionKey(dataCombo[index]));
|
|
173
162
|
}
|
|
174
163
|
}
|
|
175
164
|
if (!isTyping) setIsTyping(true);
|
|
176
165
|
};
|
|
177
166
|
const onClearClick = () => {
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
}).finally(() => {
|
|
181
|
-
setSelected(null);
|
|
182
|
-
setInputText('');
|
|
183
|
-
onChange();
|
|
184
|
-
if (inputTextRef && inputTextRef.current) inputTextRef.current.focus();
|
|
185
|
-
setOpened(false);
|
|
186
|
-
});
|
|
167
|
+
setSelected(undefined);
|
|
168
|
+
setInputText('');
|
|
187
169
|
};
|
|
188
170
|
const setOnDenied = onDeniedSelect => {
|
|
189
171
|
setOnDeniedSelect(onDeniedSelect);
|
|
@@ -246,11 +228,6 @@ const SimpleSelect = props => {
|
|
|
246
228
|
ref: componentRef,
|
|
247
229
|
className: "select-component"
|
|
248
230
|
}, /*#__PURE__*/_react.default.createElement(_InputTextBase.default, _extends({}, props, {
|
|
249
|
-
inputRef: ref => {
|
|
250
|
-
if (props.inputRef) props.inputRef(ref);
|
|
251
|
-
inputTextRef.current = ref;
|
|
252
|
-
},
|
|
253
|
-
autoComplete: "off",
|
|
254
231
|
readOnly: undigitable || shouldBeReadOnly(),
|
|
255
232
|
value: inputText,
|
|
256
233
|
onFocus: onFocus,
|
|
@@ -265,18 +242,18 @@ const SimpleSelect = props => {
|
|
|
265
242
|
selectWrapper.current = r;
|
|
266
243
|
},
|
|
267
244
|
handlerSetOnDenied: inputOnDenied => setOnDenied(inputOnDenied),
|
|
268
|
-
rightElements: /*#__PURE__*/_react.default.createElement(_ActionButtons.default, {
|
|
245
|
+
rightElements: /*#__PURE__*/_react.default.createElement(_ActionButtons.default, _extends({}, props, {
|
|
269
246
|
disabled: shouldDisable() || shouldBeReadOnly(),
|
|
270
|
-
showClearButton: showClearButton,
|
|
271
247
|
dropDownOpened: opened,
|
|
272
|
-
|
|
248
|
+
handleClear: () => {
|
|
273
249
|
if (shouldDisable()) return null;
|
|
274
250
|
return onClearClick();
|
|
275
251
|
},
|
|
276
|
-
|
|
277
|
-
|
|
252
|
+
handleOpenClose: () => {
|
|
253
|
+
onOpenClose();
|
|
254
|
+
}
|
|
255
|
+
}))
|
|
278
256
|
})), opened && /*#__PURE__*/_react.default.createElement(_Dropdown.default, _extends({}, props, {
|
|
279
|
-
opened: opened,
|
|
280
257
|
selected: selected,
|
|
281
258
|
inputValue: inputText,
|
|
282
259
|
selectFieldRef: componentRef,
|
|
@@ -290,9 +267,9 @@ const SimpleSelect = props => {
|
|
|
290
267
|
handleOnKeydown: onInputKeyDown,
|
|
291
268
|
handleOnBlur: () => onBlur,
|
|
292
269
|
handleOnFocus: onFocus,
|
|
270
|
+
opened: opened,
|
|
293
271
|
dataCombo: dataCombo,
|
|
294
|
-
dropdownWidth: dropdownWidth || 0
|
|
295
|
-
searchNotFoundText: searchNotFoundText
|
|
272
|
+
dropdownWidth: dropdownWidth || 0
|
|
296
273
|
})));
|
|
297
274
|
};
|
|
298
275
|
var _default = exports.default = SimpleSelect;
|