intelicoreact 1.4.39 → 1.4.40
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/UI/TagList/TagList.js +100 -165
- package/package.json +1 -1
|
@@ -25,184 +25,119 @@ function _getRequireWildcardCache(nodeInterop) { if (typeof WeakMap !== "functio
|
|
|
25
25
|
|
|
26
26
|
function _interopRequireWildcard(obj, nodeInterop) { if (!nodeInterop && obj && obj.__esModule) { return obj; } if (obj === null || typeof obj !== "object" && typeof obj !== "function") { return { default: obj }; } var cache = _getRequireWildcardCache(nodeInterop); if (cache && cache.has(obj)) { return cache.get(obj); } var newObj = {}; var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var key in obj) { if (key !== "default" && Object.prototype.hasOwnProperty.call(obj, key)) { var desc = hasPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : null; if (desc && (desc.get || desc.set)) { Object.defineProperty(newObj, key, desc); } else { newObj[key] = obj[key]; } } } newObj.default = obj; if (cache) { cache.set(obj, newObj); } return newObj; }
|
|
27
27
|
|
|
28
|
-
const
|
|
29
|
-
var _wrapperRef$current$g, _wrapperRef$current, _wrapperRef$current$g2;
|
|
30
|
-
|
|
28
|
+
const TagListToDropdown = _ref => {
|
|
31
29
|
let {
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
disableShowMore = false,
|
|
39
|
-
shownItemsCount = "auto",
|
|
40
|
-
testId = "test-taglist",
|
|
41
|
-
refProp,
|
|
42
|
-
renderOrder,
|
|
43
|
-
onEditClick,
|
|
44
|
-
onToggleRenderAll
|
|
30
|
+
options,
|
|
31
|
+
value = [],
|
|
32
|
+
dropdownProps = {},
|
|
33
|
+
listProps = {},
|
|
34
|
+
onChange,
|
|
35
|
+
useDropdownCompactMode
|
|
45
36
|
} = _ref;
|
|
46
|
-
const
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
const
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
37
|
+
const preparedValue = value.map(_ref2 => {
|
|
38
|
+
let {
|
|
39
|
+
value
|
|
40
|
+
} = _ref2;
|
|
41
|
+
return value;
|
|
42
|
+
});
|
|
43
|
+
const [isEditMode, setIsEditMode] = (0, _react.useState)(false);
|
|
44
|
+
const [isRenderAllTags, setIsRenderAllTags] = (0, _react.useState)(false);
|
|
45
|
+
const [newValue, setNewValue] = (0, _react.useState)(preparedValue);
|
|
46
|
+
const [isValueChanged, setIsValueChanged] = (0, _react.useState)(false);
|
|
47
|
+
const [isLoading, setIsLoading] = (0, _react.useState)(false);
|
|
48
|
+
const tagListRef = (0, _react.useRef)(null);
|
|
49
|
+
|
|
50
|
+
const onConfirmChangesClick = () => {
|
|
51
|
+
if (isValueChanged) {
|
|
52
|
+
var _Promise;
|
|
53
|
+
|
|
54
|
+
setIsLoading(true);
|
|
55
|
+
setIsValueChanged(false);
|
|
56
|
+
(_Promise = new Promise(r => {
|
|
57
|
+
const onChangeResult = onChange(options.filter(_ref3 => {
|
|
58
|
+
let {
|
|
59
|
+
value
|
|
60
|
+
} = _ref3;
|
|
61
|
+
return newValue.includes(value);
|
|
62
|
+
}));
|
|
63
|
+
|
|
64
|
+
if (onChangeResult instanceof Promise) {
|
|
65
|
+
onChangeResult.then(data => r(data));
|
|
66
|
+
} else {
|
|
67
|
+
r();
|
|
68
|
+
}
|
|
69
|
+
})) === null || _Promise === void 0 ? void 0 : _Promise.finally(() => {
|
|
70
|
+
setIsEditMode(false);
|
|
71
|
+
setIsLoading(false);
|
|
72
|
+
});
|
|
73
|
+
} else {
|
|
74
|
+
setIsEditMode(false);
|
|
75
|
+
}
|
|
69
76
|
};
|
|
70
77
|
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
r: itemRef === null || itemRef === void 0 ? void 0 : itemRef.current
|
|
92
|
-
}]
|
|
93
|
-
};
|
|
78
|
+
(0, _react.useEffect)(() => {
|
|
79
|
+
setNewValue(preparedValue); // eslint-disable-next-line react-hooks/exhaustive-deps
|
|
80
|
+
}, [isEditMode]);
|
|
81
|
+
|
|
82
|
+
const renderTagsDropdown = props => {
|
|
83
|
+
return /*#__PURE__*/_react.default.createElement(TagsDropdown, (0, _extends2.default)({}, dropdownProps, {
|
|
84
|
+
disabled: isLoading,
|
|
85
|
+
options: options,
|
|
86
|
+
chosenOptions: newValue,
|
|
87
|
+
renderOptionsAsTags: true,
|
|
88
|
+
withCreateLogic: true,
|
|
89
|
+
isUseLocalOptionsStore: false,
|
|
90
|
+
onOptionEdit: dropdownProps === null || dropdownProps === void 0 ? void 0 : dropdownProps.onOptionEdit,
|
|
91
|
+
onOptionDelete: dropdownProps === null || dropdownProps === void 0 ? void 0 : dropdownProps.onOptionDelete,
|
|
92
|
+
onOptionCreate: dropdownProps === null || dropdownProps === void 0 ? void 0 : dropdownProps.onOptionCreate,
|
|
93
|
+
onActionConfirmClick: onConfirmChangesClick,
|
|
94
|
+
onActionCancelClick: () => setIsEditMode(v => !v),
|
|
95
|
+
onChange: data => {
|
|
96
|
+
setNewValue(data);
|
|
97
|
+
setIsValueChanged(true);
|
|
94
98
|
}
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
}
|
|
98
|
-
count: 0,
|
|
99
|
-
width: 0,
|
|
100
|
-
items: []
|
|
101
|
-
});
|
|
102
|
-
return result === null || result === void 0 ? void 0 : result.count;
|
|
99
|
+
}, props, {
|
|
100
|
+
isDefaultOpened: isEditMode
|
|
101
|
+
}));
|
|
103
102
|
};
|
|
104
103
|
|
|
105
|
-
const
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
104
|
+
const renderTagsList = props => {
|
|
105
|
+
return /*#__PURE__*/_react.default.createElement(TagList, (0, _extends2.default)({
|
|
106
|
+
disabled: isLoading,
|
|
107
|
+
refProp: tagListRef
|
|
108
|
+
}, listProps, {
|
|
109
|
+
items: value,
|
|
110
|
+
onEditClick: () => setIsEditMode(v => !v)
|
|
111
|
+
}, props));
|
|
110
112
|
};
|
|
111
113
|
|
|
112
|
-
const
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
return tagsRenderOrder.map((v, i) => {
|
|
121
|
-
var _item$id, _item$id2;
|
|
122
|
-
|
|
123
|
-
const item = tagList.find(_ref5 => {
|
|
114
|
+
const renderCompactMode = () => {
|
|
115
|
+
return renderTagsDropdown({
|
|
116
|
+
withActions: false,
|
|
117
|
+
withSearchInputInList: true,
|
|
118
|
+
customTriggerRef: tagListRef,
|
|
119
|
+
recalculateListContainerStylesTrigger: isRenderAllTags,
|
|
120
|
+
onDropdownListClose: onConfirmChangesClick,
|
|
121
|
+
renderCustomTrigger: _ref4 => {
|
|
124
122
|
let {
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
}
|
|
137
|
-
testId: "test-taglist-item-".concat((_item$id2 = item === null || item === void 0 ? void 0 : item.id) !== null && _item$id2 !== void 0 ? _item$id2 : item === null || item === void 0 ? void 0 : item.value)
|
|
138
|
-
}, item, {
|
|
139
|
-
onClick: onTagClick,
|
|
140
|
-
removeItem: removeItem
|
|
141
|
-
})));
|
|
142
|
-
});
|
|
143
|
-
};
|
|
144
|
-
|
|
145
|
-
const renderMoreTags = () => {
|
|
146
|
-
if ((tagList === null || tagList === void 0 ? void 0 : tagList.length) < shownItemsCount || !(tagList !== null && tagList !== void 0 && tagList.length) || disableShowMore) return null;
|
|
147
|
-
const restItems = tagList.length - renderItemsCount;
|
|
148
|
-
if (restItems === 0 || !withToggle || staticTagsCount === -1) return null;
|
|
149
|
-
return /*#__PURE__*/_react.default.createElement(_Tag.default, {
|
|
150
|
-
label: "+".concat(restItems),
|
|
151
|
-
className: "tag-list_wrapper_render-more",
|
|
152
|
-
onClick: disableShowMore ? () => {} : e => cancelDefault(e, () => setRenderAllInterceptor(true))
|
|
123
|
+
isOpen,
|
|
124
|
+
setIsOpen,
|
|
125
|
+
inputRef
|
|
126
|
+
} = _ref4;
|
|
127
|
+
return renderTagsList({
|
|
128
|
+
onToggleRenderAll: v => setTimeout(() => setIsRenderAllTags(v), 1),
|
|
129
|
+
onEditClick: () => {
|
|
130
|
+
setIsOpen(!isEditMode);
|
|
131
|
+
if (isEditMode) onConfirmChangesClick();else setIsEditMode(true);
|
|
132
|
+
}
|
|
133
|
+
});
|
|
134
|
+
}
|
|
153
135
|
});
|
|
154
136
|
};
|
|
155
137
|
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
label: "...",
|
|
160
|
-
className: "tag-list_wrapper_hide-more",
|
|
161
|
-
onClick: e => cancelDefault(e, () => setRenderAllInterceptor(false))
|
|
162
|
-
});
|
|
163
|
-
}; // Set TagList Items
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
(0, _react.useEffect)(() => {
|
|
167
|
-
setStaticTagsCount(-1);
|
|
168
|
-
setRenderItemsCount(-1);
|
|
169
|
-
setRenderAllInterceptor(false);
|
|
170
|
-
setTagList(items.map(item => ({ ...item,
|
|
171
|
-
itemRef: /*#__PURE__*/(0, _react.createRef)()
|
|
172
|
-
})));
|
|
173
|
-
}, [items]); // Count Row Tags
|
|
174
|
-
|
|
175
|
-
(0, _react.useLayoutEffect)(() => {
|
|
176
|
-
if (withToggle && wrapperWidth !== -1) {
|
|
177
|
-
setStaticTagsCount(getStaticTagsCount());
|
|
178
|
-
}
|
|
179
|
-
}, [tagList, wrapperWidth, withToggle]); //
|
|
180
|
-
|
|
181
|
-
(0, _react.useLayoutEffect)(() => {
|
|
182
|
-
setRenderItemsCount(staticTagsCount);
|
|
183
|
-
}, [staticTagsCount]); // Toggle Show/Hide More Tags
|
|
184
|
-
|
|
185
|
-
(0, _react.useEffect)(() => {
|
|
186
|
-
setRenderItemsCount(renderAll ? tagList === null || tagList === void 0 ? void 0 : tagList.length : staticTagsCount);
|
|
187
|
-
}, [renderAll]);
|
|
188
|
-
(0, _react.useEffect)(() => {
|
|
189
|
-
// eslint-disable-next-line react-hooks/exhaustive-deps
|
|
190
|
-
if (wrapperRef !== null && wrapperRef !== void 0 && wrapperRef.current && refProp) refProp.current = wrapperRef === null || wrapperRef === void 0 ? void 0 : wrapperRef.current;
|
|
191
|
-
}, [wrapperRef === null || wrapperRef === void 0 ? void 0 : wrapperRef.current]);
|
|
192
|
-
return /*#__PURE__*/_react.default.createElement("div", {
|
|
193
|
-
className: (0, _classnames.default)("tag-list_wrapper", "".concat(renderItemsCount !== (tagList === null || tagList === void 0 ? void 0 : tagList.length) || !withToggle || staticTagsCount === -1 || staticTagsCount === (tagList === null || tagList === void 0 ? void 0 : tagList.length) ? "tag-list_wrapper--only-static-items" : "tag-list_wrapper--all-items"), className, {
|
|
194
|
-
"tag-list_wrapper--disabled": disabled
|
|
195
|
-
}),
|
|
196
|
-
style: {
|
|
197
|
-
visibility: staticTagsCount === -1 ? "hidden" : "visible",
|
|
198
|
-
zIndex: staticTagsCount === -1 ? "-1" : "auto"
|
|
199
|
-
},
|
|
200
|
-
ref: wrapperRef
|
|
201
|
-
}, renderTags(), renderMoreTags(), renderHideTags(), typeof onEditClick === "function" && /*#__PURE__*/_react.default.createElement("div", {
|
|
202
|
-
className: "tag-list__edit-trigger"
|
|
203
|
-
}, /*#__PURE__*/_react.default.createElement(_reactFeather.Edit3, {
|
|
204
|
-
onClick: onEditClick
|
|
205
|
-
})));
|
|
138
|
+
return useDropdownCompactMode ? renderCompactMode() : isEditMode ? renderTagsDropdown({
|
|
139
|
+
withActions: true
|
|
140
|
+
}) : renderTagsList();
|
|
206
141
|
};
|
|
207
142
|
|
|
208
143
|
var _default = TagList;
|