intelicoreact 1.4.9 → 1.4.11
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/dist/Atomic/FormElements/Dropdown/Dropdown.js +2 -1
- package/dist/Atomic/FormElements/Dropdown/Dropdown.scss +5 -0
- package/dist/Atomic/FormElements/DropdownLiveSearch/DropdownLiveSearch.js +2 -1
- package/dist/Atomic/FormElements/DropdownLiveSearch/DropdownLiveSearch.scss +5 -0
- package/dist/Atomic/FormElements/Input/Input.js +9 -3
- package/dist/Atomic/FormElements/TagListToDropdown/TagListToDropdown.js +125 -0
- package/dist/Atomic/FormElements/TagsDropdown/TagsDropdown.js +503 -258
- package/dist/Atomic/FormElements/TagsDropdown/TagsDropdown.scss +256 -7
- package/dist/Atomic/UI/Tag/Tag.js +2 -4
- package/dist/Atomic/UI/TagList/TagList.js +55 -39
- package/dist/Atomic/UI/TagList/TagList.scss +15 -0
- package/package.json +1 -1
|
@@ -527,7 +527,8 @@ const Dropdown = _ref => {
|
|
|
527
527
|
return /*#__PURE__*/_react.default.createElement("div", {
|
|
528
528
|
className: (0, _classnames.default)(RC, className, {
|
|
529
529
|
disabled,
|
|
530
|
-
["".concat(RC, "-mobile")]: isMobile
|
|
530
|
+
["".concat(RC, "-mobile")]: isMobile,
|
|
531
|
+
["".concat(RC, "--focused")]: isOpen
|
|
531
532
|
}),
|
|
532
533
|
ref: dropdownRef,
|
|
533
534
|
onKeyDown: onKeyDown,
|
|
@@ -378,7 +378,8 @@ const DropdownLiveSearch = _ref => {
|
|
|
378
378
|
return /*#__PURE__*/_react.default.createElement("div", {
|
|
379
379
|
className: (0, _classnames.default)(RC, className, {
|
|
380
380
|
disabled,
|
|
381
|
-
["".concat(RC, "-mobile")]: isMobile
|
|
381
|
+
["".concat(RC, "-mobile")]: isMobile,
|
|
382
|
+
["".concat(RC, "--focused")]: isOpen
|
|
382
383
|
}),
|
|
383
384
|
ref: dropdownLiveSearchRef
|
|
384
385
|
}, /*#__PURE__*/_react.default.createElement("button", {
|
|
@@ -345,12 +345,18 @@ const Input = /*#__PURE__*/_react.default.forwardRef((_ref, ref) => {
|
|
|
345
345
|
}, uniProps, {
|
|
346
346
|
ref: inputRef,
|
|
347
347
|
type: getInputType(),
|
|
348
|
-
autoComplete: isPseudoPasswordMode ? "off" : autocomplete
|
|
348
|
+
autoComplete: isPseudoPasswordMode ? "off" : autocomplete
|
|
349
|
+
}, attributesOfNativeInput, {
|
|
349
350
|
onFocus: function () {
|
|
351
|
+
var _attributesOfNativeIn;
|
|
352
|
+
for (var _len = arguments.length, params = new Array(_len), _key = 0; _key < _len; _key++) {
|
|
353
|
+
params[_key] = arguments[_key];
|
|
354
|
+
}
|
|
355
|
+
attributesOfNativeInput === null || attributesOfNativeInput === void 0 || (_attributesOfNativeIn = attributesOfNativeInput.onFocus) === null || _attributesOfNativeIn === void 0 || _attributesOfNativeIn.call(attributesOfNativeInput, ...params);
|
|
350
356
|
if (isUseAutoSelect) inputRef.current.select();
|
|
351
|
-
if (uniProps.onFocus) uniProps.onFocus(...
|
|
357
|
+
if (uniProps.onFocus) uniProps.onFocus(...params);
|
|
352
358
|
}
|
|
353
|
-
}
|
|
359
|
+
})), DynamicIconComponent !== null && DynamicIconComponent !== void 0 ? DynamicIconComponent : icon, action, withDelete && onInputHover && /*#__PURE__*/_react.default.createElement("span", {
|
|
354
360
|
"data-testid": "icon-close",
|
|
355
361
|
className: (0, _classnames.default)("input__close", {
|
|
356
362
|
hidden: !(0, _fieldValueFormatters.getSafelyValue)(value)
|
|
@@ -0,0 +1,125 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
|
|
4
|
+
Object.defineProperty(exports, "__esModule", {
|
|
5
|
+
value: true
|
|
6
|
+
});
|
|
7
|
+
exports.default = void 0;
|
|
8
|
+
var _extends2 = _interopRequireDefault(require("@babel/runtime/helpers/extends"));
|
|
9
|
+
var _react = _interopRequireWildcard(require("react"));
|
|
10
|
+
var _TagList = _interopRequireDefault(require("../../UI/TagList/TagList"));
|
|
11
|
+
var _TagsDropdown = _interopRequireDefault(require("../TagsDropdown/TagsDropdown"));
|
|
12
|
+
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); }
|
|
13
|
+
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 && Object.prototype.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; }
|
|
14
|
+
const TagListToDropdown = _ref => {
|
|
15
|
+
let {
|
|
16
|
+
options: optionsProp = [],
|
|
17
|
+
value = [],
|
|
18
|
+
dropdownProps = {},
|
|
19
|
+
listProps = {},
|
|
20
|
+
onChange,
|
|
21
|
+
useDropdownCompactMode
|
|
22
|
+
} = _ref;
|
|
23
|
+
const preparedValue = value.map(_ref2 => {
|
|
24
|
+
let {
|
|
25
|
+
value
|
|
26
|
+
} = _ref2;
|
|
27
|
+
return value;
|
|
28
|
+
});
|
|
29
|
+
const [isEditMode, setIsEditMode] = (0, _react.useState)(false);
|
|
30
|
+
const [isRenderAllTags, setIsRenderAllTags] = (0, _react.useState)(false);
|
|
31
|
+
const [newValue, setNewValue] = (0, _react.useState)(preparedValue);
|
|
32
|
+
const [options, setOptions] = (0, _react.useState)([]);
|
|
33
|
+
const tagListRef = (0, _react.useRef)(null);
|
|
34
|
+
const onOptionCreate = newOption => {
|
|
35
|
+
setOptions(state => [...state, newOption]);
|
|
36
|
+
};
|
|
37
|
+
const onOptionEdit = option => {
|
|
38
|
+
setOptions(state => state.map(item => {
|
|
39
|
+
if (item.value === option.value) return option;
|
|
40
|
+
return item;
|
|
41
|
+
}));
|
|
42
|
+
};
|
|
43
|
+
const onOptionDelete = option => {
|
|
44
|
+
setOptions(state => state.filter(item => item.value !== option.value));
|
|
45
|
+
};
|
|
46
|
+
const onConfirmChangesClick = () => {
|
|
47
|
+
onChange(options.filter(_ref3 => {
|
|
48
|
+
let {
|
|
49
|
+
value
|
|
50
|
+
} = _ref3;
|
|
51
|
+
return newValue.includes(value);
|
|
52
|
+
}));
|
|
53
|
+
setIsEditMode(false);
|
|
54
|
+
};
|
|
55
|
+
const onDropdownClose = () => {};
|
|
56
|
+
(0, _react.useEffect)(() => {
|
|
57
|
+
setNewValue(preparedValue);
|
|
58
|
+
// eslint-disable-next-line react-hooks/exhaustive-deps
|
|
59
|
+
}, [isEditMode]);
|
|
60
|
+
(0, _react.useEffect)(() => {
|
|
61
|
+
setOptions(optionsProp);
|
|
62
|
+
}, [optionsProp]);
|
|
63
|
+
const renderTagsDropdown = props => {
|
|
64
|
+
return /*#__PURE__*/_react.default.createElement(_TagsDropdown.default, (0, _extends2.default)({}, dropdownProps, {
|
|
65
|
+
options: options,
|
|
66
|
+
chosenOptions: newValue,
|
|
67
|
+
renderOptionsAsTags: true,
|
|
68
|
+
withCreateLogic: true,
|
|
69
|
+
onOptionEdit: option => {
|
|
70
|
+
var _dropdownProps$onOpti;
|
|
71
|
+
onOptionEdit(option);
|
|
72
|
+
dropdownProps === null || dropdownProps === void 0 || (_dropdownProps$onOpti = dropdownProps.onOptionEdit) === null || _dropdownProps$onOpti === void 0 || _dropdownProps$onOpti.call(dropdownProps, option);
|
|
73
|
+
},
|
|
74
|
+
onOptionDelete: option => {
|
|
75
|
+
var _dropdownProps$onOpti2;
|
|
76
|
+
onOptionDelete(option);
|
|
77
|
+
dropdownProps === null || dropdownProps === void 0 || (_dropdownProps$onOpti2 = dropdownProps.onOptionDelete) === null || _dropdownProps$onOpti2 === void 0 || _dropdownProps$onOpti2.call(dropdownProps, option);
|
|
78
|
+
},
|
|
79
|
+
onOptionCreate: option => {
|
|
80
|
+
var _dropdownProps$onOpti3;
|
|
81
|
+
onOptionCreate(option);
|
|
82
|
+
dropdownProps === null || dropdownProps === void 0 || (_dropdownProps$onOpti3 = dropdownProps.onOptionCreate) === null || _dropdownProps$onOpti3 === void 0 || _dropdownProps$onOpti3.call(dropdownProps, option);
|
|
83
|
+
},
|
|
84
|
+
onActionConfirmClick: onConfirmChangesClick,
|
|
85
|
+
onActionCancelClick: () => setIsEditMode(v => !v),
|
|
86
|
+
onChange: setNewValue
|
|
87
|
+
}, props));
|
|
88
|
+
};
|
|
89
|
+
const renderTagsList = props => {
|
|
90
|
+
return /*#__PURE__*/_react.default.createElement(_TagList.default, (0, _extends2.default)({
|
|
91
|
+
refProp: tagListRef
|
|
92
|
+
}, listProps, {
|
|
93
|
+
items: value,
|
|
94
|
+
onEditClick: () => setIsEditMode(v => !v)
|
|
95
|
+
}, props));
|
|
96
|
+
};
|
|
97
|
+
const renderCompactMode = () => {
|
|
98
|
+
return renderTagsDropdown({
|
|
99
|
+
withActions: false,
|
|
100
|
+
withSearchInputInList: true,
|
|
101
|
+
customTriggerRef: tagListRef,
|
|
102
|
+
recalculateListContainerStylesTrigger: isRenderAllTags,
|
|
103
|
+
onDropdownListClose: onConfirmChangesClick,
|
|
104
|
+
renderCustomTrigger: _ref4 => {
|
|
105
|
+
let {
|
|
106
|
+
isOpen,
|
|
107
|
+
setIsOpen,
|
|
108
|
+
inputRef
|
|
109
|
+
} = _ref4;
|
|
110
|
+
return renderTagsList({
|
|
111
|
+
onToggleRenderAll: v => setTimeout(() => setIsRenderAllTags(v), 1),
|
|
112
|
+
onEditClick: () => {
|
|
113
|
+
setIsOpen(!isEditMode);
|
|
114
|
+
if (isEditMode) onConfirmChangesClick();else setIsEditMode(true);
|
|
115
|
+
}
|
|
116
|
+
});
|
|
117
|
+
}
|
|
118
|
+
});
|
|
119
|
+
};
|
|
120
|
+
if (!value.length) return null;
|
|
121
|
+
return useDropdownCompactMode ? renderCompactMode() : isEditMode ? renderTagsDropdown({
|
|
122
|
+
withActions: true
|
|
123
|
+
}) : renderTagsList();
|
|
124
|
+
};
|
|
125
|
+
var _default = exports.default = TagListToDropdown;
|