kamotive_ui 2.3.26 → 3.6.26
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/components/AttachedFilesPreview/AttachedFilesPreview.d.ts +1 -0
- package/dist/components/AttachedFilesPreview/AttachedFilesPreview.js +4 -4
- package/dist/components/Breadcrumb/Breadcrumb.js +4 -4
- package/dist/components/Breadcrumbs/Breadcrumbs.js +10 -4
- package/dist/components/Button/Button.d.ts +1 -1
- package/dist/components/Button/Button.js +11 -10
- package/dist/components/Button/Button.module.css +2 -1
- package/dist/components/Checkbox/Checkbox.js +4 -4
- package/dist/components/ColorPicker/ColorPicker.js +9 -8
- package/dist/components/Comment/Comment.js +13 -13
- package/dist/components/DateInput/DateInput.js +20 -19
- package/dist/components/Dialog/Dialog.js +5 -5
- package/dist/components/Dropdown/Dropdown.d.ts +3 -2
- package/dist/components/Dropdown/Dropdown.js +142 -53
- package/dist/components/Dropdown/Dropdown.module.css +25 -4
- package/dist/components/FileAttach/FileAttach.js +4 -4
- package/dist/components/FileItem/FileItem.js +8 -8
- package/dist/components/FileListAttached/FileListAtta/321/201hed.js +5 -5
- package/dist/components/FileLoader/FileLoader.js +119 -119
- package/dist/components/IconButton/IconButton.js +5 -2
- package/dist/components/Input/Input.js +6 -6
- package/dist/components/Link/Link.js +5 -5
- package/dist/components/List/List.js +13 -11
- package/dist/components/ListItem/ListItem.js +8 -8
- package/dist/components/ProgressBar/ProgressBar.js +4 -4
- package/dist/components/ProgressLoader/ProgressLoader.js +4 -4
- package/dist/components/RadioButton/RadioButton.js +4 -4
- package/dist/components/SettingTag/SettingTag.js +4 -4
- package/dist/components/Snackbar/Snackbar.js +7 -7
- package/dist/components/Spinner/Spinner.js +3 -3
- package/dist/components/Tab/Tab.js +3 -3
- package/dist/components/TableFilterSidebar/TableFilterSidebar.js +11 -11
- package/dist/components/Tabs/Tabs.js +14 -8
- package/dist/components/Tag/Tag.js +7 -7
- package/dist/components/TextEditor/TextEditor.js +179 -578
- package/dist/components/TextEditor/TextEditor.module.css +8 -7
- package/dist/components/ToggleButton/ToggleButton.js +4 -4
- package/dist/components/Tooltip/Tooltip.js +4 -4
- package/dist/components/Typography/Typography.js +2 -2
- package/dist/fonts/Montserrat-Bold.woff2 +0 -0
- package/dist/fonts/Montserrat-Italic.woff2 +0 -0
- package/dist/fonts/Montserrat-Light.woff2 +0 -0
- package/dist/fonts/Montserrat-Medium.woff2 +0 -0
- package/dist/fonts/Montserrat-MediumItalic.woff2 +0 -0
- package/dist/fonts/Montserrat-Regular.woff2 +0 -0
- package/dist/fonts/Montserrat-SemiBold.woff2 +0 -0
- package/dist/fonts/Montserrat-SemiBoldItalic.woff2 +0 -0
- package/dist/fonts/OpenSans-Bold.woff2 +0 -0
- package/dist/fonts/OpenSans-BoldItalic.woff2 +0 -0
- package/dist/fonts/OpenSans-Italic.woff2 +0 -0
- package/dist/fonts/OpenSans-Italic_1.woff2 +0 -0
- package/dist/fonts/OpenSans-Light.woff2 +0 -0
- package/dist/fonts/OpenSans-LightItalic.woff2 +0 -0
- package/dist/fonts/OpenSans-Medium.woff2 +0 -0
- package/dist/fonts/OpenSans-MediumItalic.woff2 +0 -0
- package/dist/fonts/OpenSans-Regular.woff2 +0 -0
- package/dist/fonts/OpenSans-Regular_1.woff2 +0 -0
- package/dist/fonts/OpenSans-SemiBold.woff2 +0 -0
- package/dist/fonts/OpenSans-SemiBoldItalic.woff2 +0 -0
- package/dist/fonts.scss +144 -0
- package/dist/index.d.ts +0 -2
- package/dist/index.js +0 -2
- package/dist/types/global.d.ts +26 -0
- package/dist/types/index.d.ts +56 -14
- package/dist/types/pell.d.ts +29 -0
- package/dist/{colors.css → variables.scss} +34 -0
- package/package.json +6 -1
- package/dist/components/Checkbox/Checkbox.stories.d.ts +0 -66
- package/dist/components/Checkbox/Checkbox.stories.js +0 -75
- package/dist/fonts.css +0 -37
|
@@ -26,9 +26,15 @@ const getComparisonValue = (item, getOptionLabel) => {
|
|
|
26
26
|
if ('id' in item)
|
|
27
27
|
return item.id;
|
|
28
28
|
}
|
|
29
|
-
// Иначе используем сам объект
|
|
30
29
|
return item;
|
|
31
30
|
};
|
|
31
|
+
const getItemId = (item) => {
|
|
32
|
+
if (!item || typeof item !== 'object')
|
|
33
|
+
return null;
|
|
34
|
+
if ('id' in item)
|
|
35
|
+
return item.id;
|
|
36
|
+
return null;
|
|
37
|
+
};
|
|
32
38
|
function checkItem(item, getOptionLabel, disabled, isDivider) {
|
|
33
39
|
var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m, _o, _p, _q, _r, _s, _t, _u, _v, _w, _x, _y, _z;
|
|
34
40
|
if (typeof item === 'string' || typeof item === 'number') {
|
|
@@ -109,7 +115,7 @@ function checkItem(item, getOptionLabel, disabled, isDivider) {
|
|
|
109
115
|
}
|
|
110
116
|
return null;
|
|
111
117
|
}
|
|
112
|
-
export const DropdownListItem = ({ item, getOptionLabel, size = 'md', selectedItem, variant, onChange, isActive, activeIndex, index, isChild = false, }) => {
|
|
118
|
+
export const DropdownListItem = ({ item, getOptionLabel, size = 'md', selectedItem, variant, onChange, isActive, activeIndex, index, isChild = false, testId }) => {
|
|
113
119
|
var _a, _b;
|
|
114
120
|
const itemRef = useRef(null);
|
|
115
121
|
const [showTooltip, setShowTooltip] = useState(false);
|
|
@@ -140,9 +146,12 @@ export const DropdownListItem = ({ item, getOptionLabel, size = 'md', selectedIt
|
|
|
140
146
|
}, [item, onChange]);
|
|
141
147
|
const hasChildren = item !== null && typeof item === 'object' && 'children' in item && Array.isArray(item.children) && item.children.length > 0;
|
|
142
148
|
const isDisabled = item !== null && typeof item === 'object' && 'disabled' in item && item.disabled;
|
|
149
|
+
const itemId = getItemId(item);
|
|
143
150
|
const isSelectedItem = Array.isArray(selectedItem)
|
|
144
|
-
? selectedItem.some((i) => getComparisonValue(i, getOptionLabel) === getComparisonValue(item, getOptionLabel))
|
|
145
|
-
:
|
|
151
|
+
? selectedItem.some((i) => itemId !== null ? getItemId(i) === itemId : getComparisonValue(i, getOptionLabel) === getComparisonValue(item, getOptionLabel))
|
|
152
|
+
: itemId !== null
|
|
153
|
+
? getItemId(selectedItem) === itemId
|
|
154
|
+
: getComparisonValue(selectedItem, getOptionLabel) === getComparisonValue(item, getOptionLabel);
|
|
146
155
|
const itemContainerClasses = classNames(styles[`item--container`], {
|
|
147
156
|
[styles['item--container--active']]: isActive,
|
|
148
157
|
[styles['item--container--parent']]: hasChildren && !isChild,
|
|
@@ -163,7 +172,7 @@ export const DropdownListItem = ({ item, getOptionLabel, size = 'md', selectedIt
|
|
|
163
172
|
[styles['item-block--child']]: isChild,
|
|
164
173
|
});
|
|
165
174
|
const itemData = item !== null && typeof item === 'object' ? item : null;
|
|
166
|
-
const itemContent = (React.createElement("div", { className: itemContainerClasses, onClick: handleItemClick },
|
|
175
|
+
const itemContent = (React.createElement("div", { className: itemContainerClasses, onClick: handleItemClick, "data-test-id": `${testId}-item` },
|
|
167
176
|
React.createElement("div", { className: itemClassess },
|
|
168
177
|
React.createElement("div", { className: itemBlock },
|
|
169
178
|
variant === 'icons' && (itemData === null || itemData === void 0 ? void 0 : itemData.icon) &&
|
|
@@ -171,18 +180,21 @@ export const DropdownListItem = ({ item, getOptionLabel, size = 'md', selectedIt
|
|
|
171
180
|
strokeWidth: size === 'lg' ? '0.5' : size === 'md' ? '0.3' : '0.0',
|
|
172
181
|
}),
|
|
173
182
|
React.createElement("div", { className: styles.item, ref: itemRef },
|
|
174
|
-
React.createElement("span",
|
|
175
|
-
!hasChildren && isSelectedItem && (React.createElement(
|
|
183
|
+
React.createElement("span", { "data-test-id": `${testId}-item-title` }, getComparisonValue(item, getOptionLabel))),
|
|
184
|
+
!hasChildren && isSelectedItem && (React.createElement("span", { "data-test-id": `${testId}-checked-icon`, style: { display: 'inline-flex' } },
|
|
185
|
+
React.createElement(IconCheck, { strokeWidth: size === 'lg' ? '0.5' : size === 'md' ? '0.3' : '0.0', htmlColor: "#0D99FF" })))),
|
|
176
186
|
(itemData === null || itemData === void 0 ? void 0 : itemData.isDivider) && React.createElement("div", { className: styles.divider })),
|
|
177
|
-
hasChildren && (React.createElement("div", { className: styles.nestedMenu }, (_a = item.children) === null || _a === void 0 ? void 0 : _a.map((child, childIndex) => {
|
|
187
|
+
hasChildren && (React.createElement("div", { className: styles.nestedMenu, "data-test-id": `${testId}-nested-block` }, (_a = item.children) === null || _a === void 0 ? void 0 : _a.map((child, childIndex) => {
|
|
178
188
|
var _a;
|
|
179
|
-
return (React.createElement(DropdownListItem, { key: (_a = child === null || child === void 0 ? void 0 : child.id) !== null && _a !== void 0 ? _a : `${index}-${childIndex}`, item: child, getOptionLabel: getOptionLabel, size: size, selectedItem: selectedItem, onChange: onChange, isActive: false, activeIndex: activeIndex, index: childIndex, isChild: true }));
|
|
189
|
+
return (React.createElement(DropdownListItem, { key: (_a = child === null || child === void 0 ? void 0 : child.id) !== null && _a !== void 0 ? _a : `${index}-${childIndex}`, item: child, getOptionLabel: getOptionLabel, size: size, selectedItem: selectedItem, onChange: onChange, isActive: false, activeIndex: activeIndex, index: childIndex, isChild: true, testId: `${testId}-nested-${childIndex}` }));
|
|
180
190
|
})))));
|
|
181
|
-
return showTooltip ? (React.createElement(Tooltip, { label: ((_b = getComparisonValue(item, getOptionLabel)) === null || _b === void 0 ? void 0 : _b.toString()) || '', position: "bottom-left" }, itemContent)) : (itemContent);
|
|
191
|
+
return showTooltip ? (React.createElement(Tooltip, { label: ((_b = getComparisonValue(item, getOptionLabel)) === null || _b === void 0 ? void 0 : _b.toString()) || '', position: "bottom-left", testId: `${testId}`, className: variant === 'filter' ? styles.filterTooltipWidth : '' }, itemContent)) : (itemContent);
|
|
182
192
|
};
|
|
183
|
-
export const Dropdown = ({ options, id, label, placeholder, required = false, value, defaultValue, onChange, showLoadMore = false, loadMore, getOptionLabel, variant = 'text', size = 'lg', style, className, isLeftLabel = false, isDivider = false, disabled = false, readOnly = false, isOpened = false, error = false, helperText, onOpen, onClick, onBlur, onFocus, onClose, clearable = true, enableAutocomplete = false, onSearch,
|
|
193
|
+
export const Dropdown = ({ options, id, label, placeholder, required = false, value, defaultValue, onChange, showLoadMore = false, loadMore, getOptionLabel, variant = 'text', size = 'lg', style, className, isLeftLabel = false, isDivider = false, disabled = false, readOnly = false, isOpened = false, error = false, helperText, onOpen, onClick, onBlur, onFocus, onClose, clearable = true, enableAutocomplete = false, onSearch, isOptionsLoading, isSearchLoading, noOptionsText, lng = 'ru', multiple = false, limitTags = 1, testId = 'default' }) => {
|
|
184
194
|
const inputRef = useRef(null);
|
|
185
195
|
const containerRef = useRef(null);
|
|
196
|
+
const dropdownRef = useRef(null);
|
|
197
|
+
const hoveredIndexRef = useRef(-1);
|
|
186
198
|
const onCloseRef = useRef(onClose);
|
|
187
199
|
const labelChipRef = useRef(new Map());
|
|
188
200
|
const selectedItemRef = useRef(null);
|
|
@@ -266,6 +278,14 @@ export const Dropdown = ({ options, id, label, placeholder, required = false, va
|
|
|
266
278
|
setIsOpen(newIsOpen);
|
|
267
279
|
if (newIsOpen) {
|
|
268
280
|
onOpen === null || onOpen === void 0 ? void 0 : onOpen(event);
|
|
281
|
+
const currentItem = multiple ? null : selectedItem;
|
|
282
|
+
const initialIndex = currentItem
|
|
283
|
+
? displayOptions.findIndex((opt) => {
|
|
284
|
+
const id = getItemId(opt);
|
|
285
|
+
return id !== null ? id === getItemId(currentItem) : getComparisonValue(opt, getOptionLabel) === getComparisonValue(currentItem, getOptionLabel);
|
|
286
|
+
})
|
|
287
|
+
: -1;
|
|
288
|
+
setActiveIndex(initialIndex);
|
|
269
289
|
if (enableAutocomplete && onChange) {
|
|
270
290
|
const selectedValue = ((_a = getComparisonValue(selectedItem, getOptionLabel)) === null || _a === void 0 ? void 0 : _a.toString()) || '';
|
|
271
291
|
setIsInitialOpen(true);
|
|
@@ -280,6 +300,7 @@ export const Dropdown = ({ options, id, label, placeholder, required = false, va
|
|
|
280
300
|
else if (!newIsOpen) {
|
|
281
301
|
onClose === null || onClose === void 0 ? void 0 : onClose(event);
|
|
282
302
|
setSearchValue('');
|
|
303
|
+
hoveredIndexRef.current = -1;
|
|
283
304
|
}
|
|
284
305
|
};
|
|
285
306
|
const onChangeHandler = (event, item) => {
|
|
@@ -289,23 +310,32 @@ export const Dropdown = ({ options, id, label, placeholder, required = false, va
|
|
|
289
310
|
setErrorInput(false);
|
|
290
311
|
setSearchValue('');
|
|
291
312
|
setSelectedItems((selectedItems) => {
|
|
292
|
-
const
|
|
293
|
-
const
|
|
294
|
-
|
|
295
|
-
|
|
313
|
+
const itemId = getItemId(item);
|
|
314
|
+
const isSame = (i) => itemId !== null
|
|
315
|
+
? getItemId(i) === itemId
|
|
316
|
+
: getComparisonValue(i, getOptionLabel) === getComparisonValue(item, getOptionLabel);
|
|
317
|
+
const isSelected = selectedItems.some(isSame);
|
|
318
|
+
const newSelectedItems = isSelected
|
|
319
|
+
? selectedItems.filter((i) => !isSame(i))
|
|
320
|
+
: [...selectedItems, item];
|
|
296
321
|
const newEvent = Object.assign(Object.assign({}, event), { currentTarget: Object.assign(Object.assign({}, event.currentTarget), { value: newSelectedItems }) });
|
|
297
|
-
onChange === null || onChange === void 0 ? void 0 : onChange(
|
|
322
|
+
onChange === null || onChange === void 0 ? void 0 : onChange(event, newSelectedItems);
|
|
298
323
|
return newSelectedItems;
|
|
299
324
|
});
|
|
300
325
|
return;
|
|
301
326
|
}
|
|
302
327
|
const newEvent = Object.assign(Object.assign({}, event), { currentTarget: Object.assign(Object.assign({}, event.currentTarget), { value: item }) });
|
|
303
|
-
|
|
328
|
+
const selectedId = getItemId(selectedItem);
|
|
329
|
+
const itemId = getItemId(item);
|
|
330
|
+
const isDifferent = selectedId !== null && itemId !== null
|
|
331
|
+
? selectedId !== itemId
|
|
332
|
+
: getComparisonValue(selectedItem, getOptionLabel) !== getComparisonValue(item, getOptionLabel);
|
|
333
|
+
if (isDifferent) {
|
|
304
334
|
setSelectedItem(item);
|
|
305
335
|
setIsOpen(false);
|
|
306
336
|
setSearchValue('');
|
|
307
337
|
onSearch === null || onSearch === void 0 ? void 0 : onSearch('');
|
|
308
|
-
onChange === null || onChange === void 0 ? void 0 : onChange(
|
|
338
|
+
onChange === null || onChange === void 0 ? void 0 : onChange(event, item);
|
|
309
339
|
onClose === null || onClose === void 0 ? void 0 : onClose(event);
|
|
310
340
|
}
|
|
311
341
|
if (item) {
|
|
@@ -316,7 +346,11 @@ export const Dropdown = ({ options, id, label, placeholder, required = false, va
|
|
|
316
346
|
}
|
|
317
347
|
};
|
|
318
348
|
const handleSearchChange = (event) => {
|
|
319
|
-
|
|
349
|
+
let value = event.target.value;
|
|
350
|
+
const regex = /(\S+)\.\s+$/; //проверка автоматического подставления точки после двойных пробелов
|
|
351
|
+
if (regex.test(value)) {
|
|
352
|
+
value = value.replace(regex, '$1 ');
|
|
353
|
+
}
|
|
320
354
|
event.preventDefault();
|
|
321
355
|
event.stopPropagation();
|
|
322
356
|
if (value === '') {
|
|
@@ -332,6 +366,17 @@ export const Dropdown = ({ options, id, label, placeholder, required = false, va
|
|
|
332
366
|
};
|
|
333
367
|
//для выбора опции из списка с клавиатуры
|
|
334
368
|
const handleKeyDown = (event) => {
|
|
369
|
+
if (event.target instanceof HTMLInputElement) {
|
|
370
|
+
const inputTarget = event.target;
|
|
371
|
+
if (event.key === ' ' && !inputTarget.value.trim()) {
|
|
372
|
+
event.preventDefault();
|
|
373
|
+
return;
|
|
374
|
+
}
|
|
375
|
+
}
|
|
376
|
+
if (isOpen && (event.key === 'ArrowDown' || event.key === 'ArrowUp')) {
|
|
377
|
+
event.preventDefault();
|
|
378
|
+
event.stopPropagation();
|
|
379
|
+
}
|
|
335
380
|
if (!isOpen) {
|
|
336
381
|
if (event.key === 'Enter' || event.key === 'ArrowDown') {
|
|
337
382
|
event.preventDefault();
|
|
@@ -352,15 +397,26 @@ export const Dropdown = ({ options, id, label, placeholder, required = false, va
|
|
|
352
397
|
switch (event.key) {
|
|
353
398
|
case 'ArrowDown':
|
|
354
399
|
event.preventDefault();
|
|
355
|
-
displayOptions && setActiveIndex((prev) =>
|
|
400
|
+
displayOptions && setActiveIndex((prev) => {
|
|
401
|
+
const start = prev < 0 ? hoveredIndexRef.current : prev;
|
|
402
|
+
const hasLoadMore = showLoadMore && !!loadMore && !isSearchingNow && !showSpinner;
|
|
403
|
+
const max = displayOptions.length - 1 + (hasLoadMore ? 1 : 0);
|
|
404
|
+
return start <= max ? start + 1 : start;
|
|
405
|
+
});
|
|
356
406
|
break;
|
|
357
407
|
case 'ArrowUp':
|
|
358
408
|
event.preventDefault();
|
|
359
|
-
displayOptions && setActiveIndex((prev) =>
|
|
409
|
+
displayOptions && setActiveIndex((prev) => {
|
|
410
|
+
const start = prev < 0 ? hoveredIndexRef.current : prev;
|
|
411
|
+
return start > 0 ? start - 1 : start;
|
|
412
|
+
});
|
|
360
413
|
break;
|
|
361
414
|
case 'Enter':
|
|
362
415
|
event.preventDefault();
|
|
363
|
-
if (activeIndex
|
|
416
|
+
if (activeIndex === displayOptions.length && showLoadMore && loadMore) {
|
|
417
|
+
loadMore();
|
|
418
|
+
}
|
|
419
|
+
else if (activeIndex >= 0 && activeIndex < displayOptions.length) {
|
|
364
420
|
const selectedOption = displayOptions[activeIndex];
|
|
365
421
|
onChangeHandler(event, selectedOption);
|
|
366
422
|
setIsOpen(false);
|
|
@@ -397,7 +453,7 @@ export const Dropdown = ({ options, id, label, placeholder, required = false, va
|
|
|
397
453
|
}
|
|
398
454
|
setSearchValue('');
|
|
399
455
|
onSearch === null || onSearch === void 0 ? void 0 : onSearch('');
|
|
400
|
-
onChange === null || onChange === void 0 ? void 0 : onChange(event,
|
|
456
|
+
onChange === null || onChange === void 0 ? void 0 : onChange(event, []);
|
|
401
457
|
close && (onClose === null || onClose === void 0 ? void 0 : onClose(event));
|
|
402
458
|
setActiveIndex(-1);
|
|
403
459
|
if (required) {
|
|
@@ -409,9 +465,9 @@ export const Dropdown = ({ options, id, label, placeholder, required = false, va
|
|
|
409
465
|
event.preventDefault();
|
|
410
466
|
event.stopPropagation();
|
|
411
467
|
item && setSelectedItems((selectedItems) => {
|
|
412
|
-
const
|
|
413
|
-
const
|
|
414
|
-
onChange === null || onChange === void 0 ? void 0 : onChange(
|
|
468
|
+
const itemId = getItemId(item);
|
|
469
|
+
const newSelectedItems = selectedItems.filter((i) => itemId !== null ? getItemId(i) !== itemId : getComparisonValue(i, getOptionLabel) !== getComparisonValue(item, getOptionLabel));
|
|
470
|
+
onChange === null || onChange === void 0 ? void 0 : onChange(event, newSelectedItems);
|
|
415
471
|
if (required && newSelectedItems.length === 0) {
|
|
416
472
|
setErrorInput(true);
|
|
417
473
|
setErrorInputHelperText((helperText !== null && helperText !== void 0 ? helperText : lng === 'ru') ? 'Поле обязательно для заполнения' : 'Field is required');
|
|
@@ -436,9 +492,9 @@ export const Dropdown = ({ options, id, label, placeholder, required = false, va
|
|
|
436
492
|
const hidden = selectedItems.length - visible.length;
|
|
437
493
|
return (React.createElement("div", { className: styles.chipsWrap },
|
|
438
494
|
visible.map((opt) => {
|
|
439
|
-
var _a, _b;
|
|
440
|
-
const key = String((_a = getComparisonValue(opt, getOptionLabel)) !== null &&
|
|
441
|
-
const label = String((
|
|
495
|
+
var _a, _b, _c;
|
|
496
|
+
const key = String((_b = (_a = getItemId(opt)) !== null && _a !== void 0 ? _a : getComparisonValue(opt, getOptionLabel)) !== null && _b !== void 0 ? _b : getSelectedItemsText());
|
|
497
|
+
const label = String((_c = getComparisonValue(opt, getOptionLabel)) !== null && _c !== void 0 ? _c : '');
|
|
442
498
|
const chip = (React.createElement("span", { className: styles.chip, onMouseEnter: () => requestAnimationFrame(() => recalcChipTooltips()), onMouseDown: (e) => e.stopPropagation(), onClick: (e) => {
|
|
443
499
|
e.preventDefault();
|
|
444
500
|
e.stopPropagation();
|
|
@@ -467,15 +523,15 @@ export const Dropdown = ({ options, id, label, placeholder, required = false, va
|
|
|
467
523
|
if (isOpen && enableAutocomplete) {
|
|
468
524
|
(_a = inputRef.current) === null || _a === void 0 ? void 0 : _a.focus();
|
|
469
525
|
}
|
|
470
|
-
} },
|
|
526
|
+
}, "data-test-id": `${testId}-dropdown-value-wrapper` },
|
|
471
527
|
variant === 'icons' && !multiple &&
|
|
472
528
|
(selectedItem === null || selectedItem === void 0 ? void 0 : selectedItem.icon) &&
|
|
473
529
|
React.cloneElement(selectedItem.icon, {
|
|
474
530
|
strokeWidth: size === 'lg' ? '0.5' : size === 'md' ? '0.3' : '0.0',
|
|
475
531
|
}),
|
|
476
532
|
multiple && selectedItems.length > 0 && getChips(),
|
|
477
|
-
!multiple && selectedItem && (React.createElement("span", { style: { display: (isOpen && enableAutocomplete && searchValue) ? 'none' : 'block' } }, getComparisonValue(selectedItem, getOptionLabel))),
|
|
478
|
-
isOpen && enableAutocomplete && (React.createElement("input", { ref: inputRef, type: "text", value: searchValue, className: styles.inlineSearchInput, onChange: handleSearchChange, placeholder: !searchValue && !selectedItem
|
|
533
|
+
!multiple && selectedItem && (React.createElement("span", { "data-test-id": `${testId}-dropdown-current-value`, style: { display: (isOpen && enableAutocomplete && searchValue) ? 'none' : 'block' } }, getComparisonValue(selectedItem, getOptionLabel))),
|
|
534
|
+
isOpen && enableAutocomplete && (React.createElement("input", { ref: inputRef, type: "text", name: "text", value: searchValue, className: styles.inlineSearchInput, onChange: handleSearchChange, placeholder: !searchValue && !selectedItem
|
|
479
535
|
? (lng === 'ru' ? 'Поиск...' : 'Search...')
|
|
480
536
|
: '', onClick: (e) => {
|
|
481
537
|
e.stopPropagation();
|
|
@@ -488,35 +544,57 @@ export const Dropdown = ({ options, id, label, placeholder, required = false, va
|
|
|
488
544
|
}, onBlur: (e) => {
|
|
489
545
|
e.stopPropagation();
|
|
490
546
|
onBlur === null || onBlur === void 0 ? void 0 : onBlur(e);
|
|
491
|
-
}, onKeyDown: handleKeyDown, autoFocus: true })),
|
|
492
|
-
!isOpen && (React.createElement(
|
|
493
|
-
|
|
494
|
-
multiple && selectedItems.length === 0 && !isOpen && (React.createElement("span", null, (_b = placeholder !== null && placeholder !== void 0 ? placeholder : label) !== null && _b !== void 0 ? _b : (lng === 'ru' ? 'Выберите значения' : 'Select values')))))));
|
|
547
|
+
}, onKeyDown: handleKeyDown, autoFocus: true, "data-test-id": `${testId}-dropdown-search-input` })),
|
|
548
|
+
!multiple && !selectedItem && !searchValue && !(isOpen && enableAutocomplete) && (React.createElement("span", { "data-test-id": `${testId}-dropdown-placeholder` }, (_a = placeholder !== null && placeholder !== void 0 ? placeholder : label) !== null && _a !== void 0 ? _a : (lng === 'ru' ? 'Выберите значение' : 'Select value'))),
|
|
549
|
+
multiple && selectedItems.length === 0 && !searchValue && !(isOpen && enableAutocomplete) && (React.createElement("span", { "data-test-id": `${testId}-dropdown-placeholder` }, (_b = placeholder !== null && placeholder !== void 0 ? placeholder : label) !== null && _b !== void 0 ? _b : (lng === 'ru' ? 'Выберите значения' : 'Select values')))));
|
|
495
550
|
return showSelectedTooltip ? (React.createElement("div", { className: styles.textField },
|
|
496
|
-
React.createElement(Tooltip, { label: ((_c = getComparisonValue(selectedItem, getOptionLabel)) === null || _c === void 0 ? void 0 : _c.toString()) || '', position: "bottom-left", style: { width: '100% !important' } }, textFieldContent))) : (textFieldContent);
|
|
551
|
+
React.createElement(Tooltip, { label: ((_c = getComparisonValue(selectedItem, getOptionLabel)) === null || _c === void 0 ? void 0 : _c.toString()) || '', position: "bottom-left", style: { width: '100% !important' }, className: variant === 'filter' ? styles.filterTooltipWidth : '', "data-test-id": `${testId}-dropdown-tooltip` }, textFieldContent))) : (textFieldContent);
|
|
497
552
|
};
|
|
553
|
+
const isSearchingNow = !isInitialOpen && !!searchValue.trim();
|
|
554
|
+
const showSpinner = isSearchLoading || (isOptionsLoading && displayOptions.length === 0);
|
|
498
555
|
const getDropdownMenu = () => {
|
|
499
|
-
//const optionsToRender = enableAutocomplete && searchValue ? filteredOptions : modifiedOptions;
|
|
500
556
|
const optionsToRender = displayOptions;
|
|
501
|
-
const
|
|
502
|
-
|
|
503
|
-
|
|
504
|
-
|
|
557
|
+
const menu = isOpen && (React.createElement("div", { className: dropdownClassess, ref: dropdownRef, onMouseMove: (e) => {
|
|
558
|
+
var _a;
|
|
559
|
+
const items = (_a = dropdownRef.current) === null || _a === void 0 ? void 0 : _a.querySelectorAll('[class*="item--container"]');
|
|
560
|
+
if (!items)
|
|
561
|
+
return;
|
|
562
|
+
const target = e.target.closest('[class*="item--container"]');
|
|
563
|
+
if (!target)
|
|
564
|
+
return;
|
|
565
|
+
const idx = Array.from(items).indexOf(target);
|
|
566
|
+
if (idx !== -1)
|
|
567
|
+
hoveredIndexRef.current = idx;
|
|
568
|
+
setActiveIndex(-1);
|
|
569
|
+
}, "data-test-id": `${testId}-dropdown-options-list` },
|
|
570
|
+
showSpinner ? (React.createElement("div", { className: `${styles['item-block']}`, style: { padding: '10px', display: 'flex', flexDirection: "column", alignItems: 'center', justifyContent: 'center', margin: '0 auto' }, "data-test-id": `${testId}-dropdown-spinner` },
|
|
505
571
|
React.createElement(Spinner, null))) : (React.createElement(React.Fragment, null, optionsToRender && optionsToRender.length > 0 ? (optionsToRender.map((option, index) => {
|
|
506
572
|
var _a;
|
|
507
|
-
return (React.createElement(DropdownListItem, { key: (_a = option === null || option === void 0 ? void 0 : option.id) !== null && _a !== void 0 ? _a : index, item: option, getOptionLabel: getOptionLabel, size: size, selectedItem: multiple ? selectedItems : selectedItem, variant: variant, onChange: onChangeHandler, isActive: activeIndex === index, activeIndex: activeIndex, index: index }));
|
|
508
|
-
})) : (React.createElement("div", { className: `${styles['item-block']}`, style: { margin: '15px auto', textAlign: 'center', color: 'var(--text-grey)' } }, lng === 'ru' || lng.includes('ru')
|
|
573
|
+
return (React.createElement(DropdownListItem, { key: (_a = option === null || option === void 0 ? void 0 : option.id) !== null && _a !== void 0 ? _a : index, item: option, getOptionLabel: getOptionLabel, size: size, selectedItem: multiple ? selectedItems : selectedItem, variant: variant, onChange: onChangeHandler, isActive: activeIndex === index, activeIndex: activeIndex, index: index, testId: `${testId}-dropdown-option-${index}` }));
|
|
574
|
+
})) : (React.createElement("div", { className: `${styles['item-block']}`, style: { margin: '15px auto', textAlign: 'center', color: 'var(--text-grey)' }, "data-test-id": `${testId}-dropdown-empty` }, lng === 'ru' || lng.includes('ru')
|
|
509
575
|
? noOptionsText || 'Нет вариантов для выбора'
|
|
510
576
|
: noOptionsText || 'No options to select')))),
|
|
511
|
-
!showSpinner && !isSearchingNow && showLoadMore && loadMore && (React.createElement(Button, { style: { width: '97%', margin: '10px auto', display: 'block', boxSizing: 'border-box' }, disabled:
|
|
577
|
+
!showSpinner && !isSearchingNow && showLoadMore && loadMore && (React.createElement(Button, { ref: loadMoreRef, style: { width: '97%', margin: '10px auto', display: 'block', boxSizing: 'border-box' }, disabled: isOptionsLoading, variant: 'outline', active: activeIndex === displayOptions.length, onClick: (e) => {
|
|
512
578
|
e.preventDefault();
|
|
513
579
|
e.stopPropagation();
|
|
514
580
|
loadMore();
|
|
515
|
-
} },
|
|
581
|
+
}, testId: `${testId}-dropdown-loadmore` }, isOptionsLoading
|
|
516
582
|
? (lng === 'ru' ? 'Загрузка...' : 'Loading...')
|
|
517
583
|
: (lng === 'ru' ? 'Загрузить еще' : 'Load more')))));
|
|
518
584
|
return isOpen ? menu : null;
|
|
519
585
|
};
|
|
586
|
+
const loadMoreRef = useRef(null);
|
|
587
|
+
useEffect(() => {
|
|
588
|
+
var _a, _b;
|
|
589
|
+
if (activeIndex < 0 || !dropdownRef.current)
|
|
590
|
+
return;
|
|
591
|
+
if (activeIndex === displayOptions.length) {
|
|
592
|
+
(_a = loadMoreRef.current) === null || _a === void 0 ? void 0 : _a.scrollIntoView({ block: 'nearest' });
|
|
593
|
+
return;
|
|
594
|
+
}
|
|
595
|
+
const items = dropdownRef.current.querySelectorAll('[class*="item--container"]');
|
|
596
|
+
(_b = items[activeIndex]) === null || _b === void 0 ? void 0 : _b.scrollIntoView({ block: 'nearest' });
|
|
597
|
+
}, [activeIndex, displayOptions.length]);
|
|
520
598
|
useEffect(() => {
|
|
521
599
|
onCloseRef.current = onClose;
|
|
522
600
|
}, [onClose]);
|
|
@@ -565,7 +643,16 @@ export const Dropdown = ({ options, id, label, placeholder, required = false, va
|
|
|
565
643
|
}, [error]);
|
|
566
644
|
useEffect(() => {
|
|
567
645
|
const checkOverflow = () => {
|
|
568
|
-
|
|
646
|
+
if (!selectedItemRef.current)
|
|
647
|
+
return;
|
|
648
|
+
const firstChild = selectedItemRef.current.firstElementChild;
|
|
649
|
+
if (firstChild) {
|
|
650
|
+
const hasOverflow = firstChild.scrollWidth > selectedItemRef.current.clientWidth;
|
|
651
|
+
setShowSelectedTooltip(hasOverflow);
|
|
652
|
+
}
|
|
653
|
+
else {
|
|
654
|
+
setShowSelectedTooltip(isTextOverflowing(selectedItemRef.current));
|
|
655
|
+
}
|
|
569
656
|
};
|
|
570
657
|
checkOverflow();
|
|
571
658
|
window.addEventListener('resize', checkOverflow);
|
|
@@ -587,23 +674,25 @@ export const Dropdown = ({ options, id, label, placeholder, required = false, va
|
|
|
587
674
|
window.addEventListener('resize', recalcChipTooltips);
|
|
588
675
|
return () => window.removeEventListener('resize', recalcChipTooltips);
|
|
589
676
|
}, [multiple, selectedItems, limitTags, recalcChipTooltips]);
|
|
590
|
-
return (React.createElement("div", { id: id, className: wrapperClassess, ref: containerRef, onClick: onClick, style: style ? style : { width: isLeftLabel && containerWidth ? `${containerWidth}px` : '100%' } },
|
|
591
|
-
label && (React.createElement(Typography, { variant: "Caption", className: labelClasses }, label)),
|
|
677
|
+
return (React.createElement("div", { id: id, className: wrapperClassess, ref: containerRef, onClick: onClick, style: style ? style : { width: isLeftLabel && containerWidth ? `${containerWidth}px` : '100%' }, "data-test-id": `${testId}-dropdown-block` },
|
|
678
|
+
label && (React.createElement(Typography, { variant: "Caption", className: labelClasses, testId: `${testId}-dropdown` }, label)),
|
|
592
679
|
React.createElement("div", { className: buttonClassess, onClick: disabled || readOnly ? undefined : handleToggle, role: "button",
|
|
593
680
|
// disabled={disabled}
|
|
594
681
|
tabIndex: disabled ? -1 : 0, "aria-disabled": disabled, onKeyDown: (e) => {
|
|
595
682
|
if (disabled)
|
|
596
683
|
return;
|
|
684
|
+
if (enableAutocomplete && e.target instanceof HTMLInputElement)
|
|
685
|
+
return;
|
|
597
686
|
handleKeyDown(e);
|
|
598
|
-
} },
|
|
687
|
+
}, "data-test-id": `${testId}-dropdown-trigger-button` },
|
|
599
688
|
getTextField(),
|
|
600
689
|
React.createElement("div", { className: styles.actionButtons },
|
|
601
690
|
clearable &&
|
|
602
691
|
!readOnly &&
|
|
603
692
|
!disabled &&
|
|
604
|
-
(selectedItem || (multiple && selectedItems.length !== 0) || (enableAutocomplete && searchValue)) && (React.createElement("div", { className: styles.resetButton },
|
|
693
|
+
(selectedItem || (multiple && selectedItems.length !== 0) || (enableAutocomplete && searchValue)) && (React.createElement("div", { className: styles.resetButton, "data-test-id": `${testId}-dropdown-clear-button` },
|
|
605
694
|
React.createElement(IconClose, { strokeWidth: "0.2", htmlColor: "var(--text-light)", onClick: handleReset }))),
|
|
606
|
-
React.createElement("div", { className: styles.dropdownIcon }, !isOpen ? (React.createElement(ChevronDown, { strokeWidth: size === 'lg' ? '0.5' : '0.3', htmlColor: 'var(--icons-medium)' })) : (React.createElement(ChevronUp, { strokeWidth: size === 'lg' ? '0.5' : '0.3', htmlColor: 'var(--icons-medium)' })))),
|
|
695
|
+
React.createElement("div", { className: styles.dropdownIcon, "data-test-id": `${testId}-dropdown-open-button` }, !isOpen ? (React.createElement(ChevronDown, { strokeWidth: size === 'lg' ? '0.5' : '0.3', htmlColor: 'var(--icons-medium)' })) : (React.createElement(ChevronUp, { strokeWidth: size === 'lg' ? '0.5' : '0.3', htmlColor: 'var(--icons-medium)' })))),
|
|
607
696
|
getDropdownMenu()),
|
|
608
|
-
errorInput && errorInputHelperText && (React.createElement(Typography, { variant: "Caption", className: classNames(styles.helperText, styles[size]) }, helperText !== null && helperText !== void 0 ? helperText : errorInputHelperText))));
|
|
697
|
+
errorInput && errorInputHelperText && (React.createElement(Typography, { variant: "Caption", className: classNames(styles.helperText, styles[size]), testId: `${testId}-dropdown-error` }, helperText !== null && helperText !== void 0 ? helperText : errorInputHelperText))));
|
|
609
698
|
};
|
|
@@ -45,8 +45,11 @@
|
|
|
45
45
|
justify-content: space-between;
|
|
46
46
|
position: relative;
|
|
47
47
|
width: 100%;
|
|
48
|
+
min-width: 0;
|
|
49
|
+
max-width: 100%;
|
|
48
50
|
}
|
|
49
|
-
.button:hover
|
|
51
|
+
.button:hover,
|
|
52
|
+
.button--outline-default--active {
|
|
50
53
|
border: 1px solid #0d9aff00;
|
|
51
54
|
box-shadow: 0px 0px 0px 0.75px var(--blue-main);
|
|
52
55
|
/* outline: none; */
|
|
@@ -62,6 +65,7 @@
|
|
|
62
65
|
border-bottom: 1px solid var(--grey-mediumLight) !important;
|
|
63
66
|
border-radius: 0 !important;
|
|
64
67
|
padding: 0 !important;
|
|
68
|
+
min-width: 0;
|
|
65
69
|
}
|
|
66
70
|
|
|
67
71
|
.button--filter:hover {
|
|
@@ -194,9 +198,15 @@
|
|
|
194
198
|
|
|
195
199
|
}
|
|
196
200
|
|
|
197
|
-
.item--container:hover
|
|
201
|
+
.item--container:hover,
|
|
202
|
+
.item--container--active {
|
|
198
203
|
background-color: rgba(120, 120, 128, 0.08);
|
|
199
|
-
width: 97% !important;
|
|
204
|
+
width: 97% !important;
|
|
205
|
+
transition: background-color 0.15s ease;
|
|
206
|
+
}
|
|
207
|
+
|
|
208
|
+
.dropdown:has(.item--container--active) .item--container:not(.item--container--active):hover {
|
|
209
|
+
background-color: transparent;
|
|
200
210
|
}
|
|
201
211
|
.item--container:has(._item-block--disabled):hover {
|
|
202
212
|
background-color: transparent;
|
|
@@ -330,6 +340,9 @@
|
|
|
330
340
|
min-width: 0;
|
|
331
341
|
cursor: text;
|
|
332
342
|
overflow: hidden;
|
|
343
|
+
|
|
344
|
+
min-width: 0;
|
|
345
|
+
flex: 1
|
|
333
346
|
}
|
|
334
347
|
|
|
335
348
|
.item-selected span{
|
|
@@ -339,6 +352,7 @@
|
|
|
339
352
|
min-width: 0;
|
|
340
353
|
flex-shrink: 1;
|
|
341
354
|
width: 100%;
|
|
355
|
+
max-width: 100%;
|
|
342
356
|
}
|
|
343
357
|
.item-selected .chipsWrap span{
|
|
344
358
|
width: auto;
|
|
@@ -431,7 +445,8 @@
|
|
|
431
445
|
cursor: pointer;
|
|
432
446
|
|
|
433
447
|
}
|
|
434
|
-
.loadMore:hover
|
|
448
|
+
.loadMore:hover,
|
|
449
|
+
.loadMore--active {
|
|
435
450
|
color: var(--blue-dark);
|
|
436
451
|
}
|
|
437
452
|
|
|
@@ -496,3 +511,9 @@
|
|
|
496
511
|
user-select: none;
|
|
497
512
|
white-space: nowrap;
|
|
498
513
|
}
|
|
514
|
+
|
|
515
|
+
.filterTooltipWidth {
|
|
516
|
+
max-width: 320px !important;
|
|
517
|
+
white-space: normal !important;
|
|
518
|
+
word-break: break-word !important;
|
|
519
|
+
}
|
|
@@ -10,11 +10,11 @@ export const FileAttach = forwardRef(({ filesList = [], maxFileSize = 2, maxFile
|
|
|
10
10
|
'model/gltf-binary': ['.glb'],
|
|
11
11
|
'application/octet-stream': ['.prt', '.step', '.stp'],
|
|
12
12
|
'text/plain': ['.syslog'],
|
|
13
|
-
}, rejectedFormats, addedFiles, setAddedFiles, onDownload, onDelete, canAdd = true, canDelete = true, canDownload = true, position = 'bottom', lng = 'ru', className, style, fileValidator, }, ref) => {
|
|
13
|
+
}, rejectedFormats, addedFiles, setAddedFiles, onDownload, onDelete, canAdd = true, canDelete = true, canDownload = true, position = 'bottom', lng = 'ru', className, style, fileValidator, testId = 'default' }, ref) => {
|
|
14
14
|
const fileAttachClasses = classNames(styles['fileAttach'], className, {
|
|
15
15
|
[styles[`fileAttach_position_${position}`]]: position,
|
|
16
16
|
});
|
|
17
|
-
return (React.createElement("div", { className: fileAttachClasses, style: style },
|
|
18
|
-
React.createElement(FileLoader, { ref: ref, maxFileSize: maxFileSize, maxFileCount: maxFileCount, maxFileName: maxFileName, acceptedFormats: acceptedFormats, rejectedFormats: rejectedFormats, addedFiles: addedFiles, setAddedFiles: setAddedFiles, canAdd: canAdd, lng: lng, fileValidator: fileValidator }),
|
|
19
|
-
React.createElement(FileListAttaсhed, { filesList: filesList, onDelete: onDelete, onDownload: onDownload, canDelete: canDelete, canDownload: canDownload, lng: lng })));
|
|
17
|
+
return (React.createElement("div", { className: fileAttachClasses, style: style, "data-test-id": `${testId}-fileAttach-block` },
|
|
18
|
+
React.createElement(FileLoader, { ref: ref, maxFileSize: maxFileSize, maxFileCount: maxFileCount, maxFileName: maxFileName, acceptedFormats: acceptedFormats, rejectedFormats: rejectedFormats, addedFiles: addedFiles, setAddedFiles: setAddedFiles, canAdd: canAdd, lng: lng, fileValidator: fileValidator, testId: `${testId}-fileAttach` }),
|
|
19
|
+
React.createElement(FileListAttaсhed, { filesList: filesList, onDelete: onDelete, onDownload: onDownload, canDelete: canDelete, canDownload: canDownload, lng: lng, testId: `${testId}-fileAttach` })));
|
|
20
20
|
});
|
|
@@ -6,7 +6,7 @@ import { IconClose, IconDownload, IconFile } from '../../Icons';
|
|
|
6
6
|
import { Tooltip } from '../Tooltip/Tooltip';
|
|
7
7
|
import classNames from 'classnames';
|
|
8
8
|
import { formatFileSize } from '../AttachedFilesPreview/AttachedFilesPreview';
|
|
9
|
-
export const FileItem = ({ file, loading = false, error = '', onDownload, onDelete, canDelete = true, canDownload = true, style, isAddedFile, isRejectedFile, isComment = false, lng }) => {
|
|
9
|
+
export const FileItem = ({ file, loading = false, error = '', onDownload, onDelete, canDelete = true, canDownload = true, style, isAddedFile, isRejectedFile, isComment = false, lng, testId = 'default' }) => {
|
|
10
10
|
const [isLoadingFinished, setIsLoadingFinished] = useState(false);
|
|
11
11
|
const [animationDuration, setAnimationDuration] = useState(0);
|
|
12
12
|
const [maxLength, setMaxLength] = useState(30);
|
|
@@ -98,19 +98,19 @@ export const FileItem = ({ file, loading = false, error = '', onDownload, onDele
|
|
|
98
98
|
onDownload(file);
|
|
99
99
|
}
|
|
100
100
|
};
|
|
101
|
-
return (React.createElement("div", { className: fileItemClasses, style: style, ref: fileItemRef, onClick: () => !(isAddedFile || isRejectedFile) && canDownload && file && onDownload && onDownload(file) },
|
|
101
|
+
return (React.createElement("div", { "data-test-id": `${testId}-file-item`, className: fileItemClasses, style: style, ref: fileItemRef, onClick: () => !(isAddedFile || isRejectedFile) && canDownload && file && onDownload && onDownload(file) },
|
|
102
102
|
React.createElement("div", { className: styles['fileItemFile'] },
|
|
103
103
|
React.createElement("div", { className: styles['fileItemInfo'] },
|
|
104
104
|
React.createElement("div", { className: styles['fileItemIcon'] },
|
|
105
105
|
React.createElement(IconFile, { htmlColor: 'var(--icons-grey)' })),
|
|
106
106
|
React.createElement("div", { className: styles['fileItemName'], ref: fileNameRef },
|
|
107
|
-
(file === null || file === void 0 ? void 0 : file.filename) && (file === null || file === void 0 ? void 0 : file.filename.length) > maxLength ? (React.createElement(Tooltip, { label: file.filename, position: "bottom-center", displayDelay: 300 },
|
|
108
|
-
React.createElement(Typography, { variant: "Body1", color: "var(--text-dark)" }, croppedName(file.filename)))) : (React.createElement(Typography, { variant: "Body1", color: "var(--text-dark)" }, file.filename && croppedName(file.filename))),
|
|
109
|
-
file.size !== 0 && (React.createElement(Typography, { variant: "Caption", color: "var(--grey-medium)" }, formatFileSize(file.size, lng))))),
|
|
107
|
+
(file === null || file === void 0 ? void 0 : file.filename) && (file === null || file === void 0 ? void 0 : file.filename.length) > maxLength ? (React.createElement(Tooltip, { label: file.filename, position: "bottom-center", displayDelay: 300, testId: `${testId}-file-item` },
|
|
108
|
+
React.createElement(Typography, { testId: `${testId}-file-item`, variant: "Body1", color: "var(--text-dark)" }, croppedName(file.filename)))) : (React.createElement(Typography, { testId: `${testId}-file-item`, variant: "Body1", color: "var(--text-dark)" }, file.filename && croppedName(file.filename))),
|
|
109
|
+
file.size !== 0 && (React.createElement(Typography, { testId: `${testId}-file-item-size`, variant: "Caption", color: "var(--grey-medium)" }, formatFileSize(file.size, lng))))),
|
|
110
110
|
React.createElement("div", { className: styles['fileItemActions'] },
|
|
111
|
-
!(isAddedFile || isRejectedFile) && canDownload && !isComment && (React.createElement(IconButton, { className: fileIcons, icon: React.createElement(IconDownload, null), title: lng === 'ru' ? 'Скачать' : 'Download', onClick: (e) => handleDownloadClick(e, file), color: "var(--icons-grey)", size: "sm" })),
|
|
111
|
+
!(isAddedFile || isRejectedFile) && canDownload && !isComment && (React.createElement(IconButton, { className: fileIcons, icon: React.createElement(IconDownload, null), title: lng === 'ru' ? 'Скачать' : 'Download', onClick: (e) => handleDownloadClick(e, file), color: "var(--icons-grey)", size: "sm", "data-test-id": `${testId}-file-item-download-button` })),
|
|
112
112
|
canDelete && (React.createElement(IconButton, { className: fileIcons, icon: React.createElement(IconClose, null), title: lng === 'ru' ? 'Удалить' : 'Delete', onClick: (e) => handleDeleteClick(e, file.id || ''),
|
|
113
113
|
// color="var(--icons-grey)"
|
|
114
|
-
size: "sm" })))),
|
|
115
|
-
error && (React.createElement(Typography, { variant: "Caption", color: "var(--error-main)", style: { paddingLeft: "5px" } }, error))));
|
|
114
|
+
size: "sm", "data-test-id": `${testId}-file-item-close-button` })))),
|
|
115
|
+
error && (React.createElement(Typography, { variant: "Caption", color: "var(--error-main)", style: { paddingLeft: "5px" }, testId: `${testId}-file-item-error` }, error))));
|
|
116
116
|
};
|
|
@@ -3,12 +3,12 @@ import styles from './FileListAttached.module.css';
|
|
|
3
3
|
import { Typography } from '../Typography/Typography';
|
|
4
4
|
import { FileItem } from '../FileItem/FileItem';
|
|
5
5
|
import classNames from 'classnames';
|
|
6
|
-
export const FileListAttaсhed = ({ filesList, onDelete, onDownload, canDelete, canDownload, isInfoShown = true, lng = 'ru', className, style, }) => {
|
|
6
|
+
export const FileListAttaсhed = ({ filesList, onDelete, onDownload, canDelete, canDownload, isInfoShown = true, lng = 'ru', className, style, testId = 'default' }) => {
|
|
7
7
|
if (!filesList || filesList.length === 0) {
|
|
8
|
-
return lng === 'ru' || lng.includes('ru') ? (React.createElement(Typography, { variant: "Body2-SemiBold", color: "var(--grey-medium)", style: { marginTop: '5px' } }, "\u041D\u0435\u0442 \u043F\u0440\u0438\u043A\u0440\u0435\u043F\u043B\u0435\u043D\u043D\u044B\u0445 \u0444\u0430\u0439\u043B\u043E\u0432")) : (React.createElement(Typography, { variant: "Body2-SemiBold", color: "var(--grey-medium)", style: { marginTop: '5px' } }, "No attached files"));
|
|
8
|
+
return lng === 'ru' || lng.includes('ru') ? (React.createElement(Typography, { variant: "Body2-SemiBold", color: "var(--grey-medium)", style: { marginTop: '5px' }, testId: `${testId}-files-attached-empty` }, "\u041D\u0435\u0442 \u043F\u0440\u0438\u043A\u0440\u0435\u043F\u043B\u0435\u043D\u043D\u044B\u0445 \u0444\u0430\u0439\u043B\u043E\u0432")) : (React.createElement(Typography, { variant: "Body2-SemiBold", color: "var(--grey-medium)", style: { marginTop: '5px' }, testId: `${testId}-files-attached-empty` }, "No attached files"));
|
|
9
9
|
}
|
|
10
|
-
return (React.createElement("div", { className: classNames(styles['fileList'], className), style: style },
|
|
10
|
+
return (React.createElement("div", { className: classNames(styles['fileList'], className), style: style, "data-test-id": `${testId}-files-attached-block` },
|
|
11
11
|
isInfoShown &&
|
|
12
|
-
(lng === 'ru' || lng.includes('ru') ? (React.createElement(Typography, { variant: "Body2-SemiBold", color: "var(--text-dark)", style: { lineHeight: '20px' }, className: styles['fileListHeader'] }, `Прикрепленные файлы (${filesList.length})`)) : (React.createElement(Typography, { variant: "Body2-SemiBold", color: "var(--text-dark)", style: { lineHeight: '20px' }, className: styles['fileListHeader'] }, `Attached files (${filesList.length})`))),
|
|
13
|
-
React.createElement("div", { className: styles['fileListFiles'] }, filesList.map((file) => (React.createElement(FileItem, { key: file.id, file: file, onDownload: onDownload, onDelete: onDelete, canDelete: canDelete, canDownload: canDownload, lng: lng }))))));
|
|
12
|
+
(lng === 'ru' || lng.includes('ru') ? (React.createElement(Typography, { variant: "Body2-SemiBold", color: "var(--text-dark)", style: { lineHeight: '20px' }, className: styles['fileListHeader'], testId: `${testId}-files-attached` }, `Прикрепленные файлы (${filesList.length})`)) : (React.createElement(Typography, { variant: "Body2-SemiBold", color: "var(--text-dark)", style: { lineHeight: '20px' }, className: styles['fileListHeader'], testId: `${testId}-files-attached` }, `Attached files (${filesList.length})`))),
|
|
13
|
+
React.createElement("div", { className: styles['fileListFiles'], "data-test-id": `${testId}-files-attached-list` }, filesList.map((file, index) => (React.createElement(FileItem, { key: file.id, file: file, onDownload: onDownload, onDelete: onDelete, canDelete: canDelete, canDownload: canDownload, lng: lng, testId: `${testId}-files-attached-${index}` }))))));
|
|
14
14
|
};
|