@megafon/ui-core 9.2.2 → 9.4.0
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/es/components/Badges/PromoBadge/PromoBadge.css +1 -1
- package/dist/es/components/Badges/PromoBadge/PromoBadge.d.ts +7 -0
- package/dist/es/components/Badges/PromoBadge/PromoBadge.js +44 -4
- package/dist/es/components/Chips/Chips/Chip.css +1 -1
- package/dist/es/components/Chips/Chips/Chip.d.ts +14 -3
- package/dist/es/components/Chips/Chips/Chip.js +31 -5
- package/dist/es/components/Chips/Chips/ChipBadge.css +1 -0
- package/dist/es/components/Chips/Chips/ChipBadge.d.ts +8 -0
- package/dist/es/components/Chips/Chips/ChipBadge.js +29 -0
- package/dist/es/components/Chips/Chips/Chips.css +1 -1
- package/dist/es/components/Chips/Chips/Chips.d.ts +6 -6
- package/dist/es/components/Chips/Chips/Chips.js +2 -2
- package/dist/es/components/Chips/Chips/components/ChipsDropdown/ChipsDropdown.css +1 -1
- package/dist/es/components/Chips/Chips/components/ChipsDropdown/ChipsDropdown.d.ts +6 -6
- package/dist/es/components/Chips/Chips/components/ChipsDropdown/ChipsDropdown.js +5 -9
- package/dist/es/components/Chips/Chips/components/ChipsScrollPanel/ChipsScrollPanel.css +1 -1
- package/dist/es/components/Chips/Chips/components/ChipsScrollPanel/ChipsScrollPanel.d.ts +6 -6
- package/dist/es/components/Chips/Chips/components/ChipsScrollPanel/ChipsScrollPanel.js +2 -2
- package/dist/es/components/Modal/Modal.css +1 -1
- package/dist/es/components/Modal/Modal.js +42 -10
- package/dist/es/components/Modal/_ModalMobile/ModalMobile.css +1 -1
- package/dist/es/components/Modal/_ModalMobile/ModalMobile.d.ts +1 -0
- package/dist/es/components/Modal/_ModalMobile/ModalMobile.js +9 -4
- package/dist/es/components/Modal/utils/usePreventScroll.d.ts +17 -0
- package/dist/es/components/Modal/utils/usePreventScroll.js +252 -0
- package/dist/es/components/Modal/utils/utils.d.ts +2 -1
- package/dist/es/components/Modal/utils/utils.js +8 -3
- package/dist/es/components/MultipleSelect/MultipleSelect.css +1 -0
- package/dist/es/components/MultipleSelect/MultipleSelect.d.ts +63 -0
- package/dist/es/components/MultipleSelect/MultipleSelect.js +235 -0
- package/dist/es/components/Tooltip/Tooltip.d.ts +6 -0
- package/dist/es/components/Tooltip/Tooltip.js +19 -6
- package/dist/es/hooks/useEvent.d.ts +3 -0
- package/dist/es/hooks/useEvent.js +11 -0
- package/dist/es/hooks/useLatest.d.ts +2 -0
- package/dist/es/hooks/useLatest.js +8 -0
- package/dist/es/hooks/useVisualViewport.d.ts +10 -0
- package/dist/es/hooks/useVisualViewport.js +55 -0
- package/dist/es/index.d.ts +3 -0
- package/dist/es/index.js +3 -0
- package/dist/es/utils/browser.d.ts +7 -0
- package/dist/es/utils/browser.js +30 -0
- package/dist/es/utils/is.d.ts +19 -0
- package/dist/es/utils/is.js +70 -0
- package/dist/lib/components/Badges/PromoBadge/PromoBadge.css +1 -1
- package/dist/lib/components/Badges/PromoBadge/PromoBadge.d.ts +7 -0
- package/dist/lib/components/Badges/PromoBadge/PromoBadge.js +45 -5
- package/dist/lib/components/Chips/Chips/Chip.css +1 -1
- package/dist/lib/components/Chips/Chips/Chip.d.ts +14 -3
- package/dist/lib/components/Chips/Chips/Chip.js +32 -6
- package/dist/lib/components/Chips/Chips/ChipBadge.css +1 -0
- package/dist/lib/components/Chips/Chips/ChipBadge.d.ts +8 -0
- package/dist/lib/components/Chips/Chips/ChipBadge.js +38 -0
- package/dist/lib/components/Chips/Chips/Chips.css +1 -1
- package/dist/lib/components/Chips/Chips/Chips.d.ts +6 -6
- package/dist/lib/components/Chips/Chips/Chips.js +2 -2
- package/dist/lib/components/Chips/Chips/components/ChipsDropdown/ChipsDropdown.css +1 -1
- package/dist/lib/components/Chips/Chips/components/ChipsDropdown/ChipsDropdown.d.ts +6 -6
- package/dist/lib/components/Chips/Chips/components/ChipsDropdown/ChipsDropdown.js +5 -9
- package/dist/lib/components/Chips/Chips/components/ChipsScrollPanel/ChipsScrollPanel.css +1 -1
- package/dist/lib/components/Chips/Chips/components/ChipsScrollPanel/ChipsScrollPanel.d.ts +6 -6
- package/dist/lib/components/Chips/Chips/components/ChipsScrollPanel/ChipsScrollPanel.js +2 -2
- package/dist/lib/components/Modal/Modal.css +1 -1
- package/dist/lib/components/Modal/Modal.js +41 -9
- package/dist/lib/components/Modal/_ModalMobile/ModalMobile.css +1 -1
- package/dist/lib/components/Modal/_ModalMobile/ModalMobile.d.ts +1 -0
- package/dist/lib/components/Modal/_ModalMobile/ModalMobile.js +9 -4
- package/dist/lib/components/Modal/utils/usePreventScroll.d.ts +17 -0
- package/dist/lib/components/Modal/utils/usePreventScroll.js +263 -0
- package/dist/lib/components/Modal/utils/utils.d.ts +2 -1
- package/dist/lib/components/Modal/utils/utils.js +9 -4
- package/dist/lib/components/MultipleSelect/MultipleSelect.css +1 -0
- package/dist/lib/components/MultipleSelect/MultipleSelect.d.ts +63 -0
- package/dist/lib/components/MultipleSelect/MultipleSelect.js +244 -0
- package/dist/lib/components/Tooltip/Tooltip.d.ts +6 -0
- package/dist/lib/components/Tooltip/Tooltip.js +19 -6
- package/dist/lib/hooks/useEvent.d.ts +3 -0
- package/dist/lib/hooks/useEvent.js +17 -0
- package/dist/lib/hooks/useLatest.d.ts +2 -0
- package/dist/lib/hooks/useLatest.js +14 -0
- package/dist/lib/hooks/useVisualViewport.d.ts +10 -0
- package/dist/lib/hooks/useVisualViewport.js +62 -0
- package/dist/lib/index.d.ts +3 -0
- package/dist/lib/index.js +21 -0
- package/dist/lib/utils/browser.d.ts +7 -0
- package/dist/lib/utils/browser.js +42 -0
- package/dist/lib/utils/is.d.ts +19 -0
- package/dist/lib/utils/is.js +92 -0
- package/package.json +2 -2
|
@@ -0,0 +1,235 @@
|
|
|
1
|
+
import _toConsumableArray from "@babel/runtime/helpers/toConsumableArray";
|
|
2
|
+
import _slicedToArray from "@babel/runtime/helpers/slicedToArray";
|
|
3
|
+
import _extends from "@babel/runtime/helpers/extends";
|
|
4
|
+
import "core-js/modules/es.array.concat.js";
|
|
5
|
+
import "core-js/modules/es.array.filter.js";
|
|
6
|
+
import "core-js/modules/es.array.includes.js";
|
|
7
|
+
import "core-js/modules/es.array.map.js";
|
|
8
|
+
import "core-js/modules/es.array.some.js";
|
|
9
|
+
import "core-js/modules/es.object.to-string.js";
|
|
10
|
+
import "core-js/modules/es.string.includes.js";
|
|
11
|
+
import * as React from 'react';
|
|
12
|
+
import { cnCreate, filterDataAttrs } from '@megafon/ui-helpers';
|
|
13
|
+
import debounce from 'lodash.debounce';
|
|
14
|
+
import Dropdown from "../Dropdown/Dropdown";
|
|
15
|
+
import "./MultipleSelect.css";
|
|
16
|
+
var ClearIcon = function ClearIcon(props) {
|
|
17
|
+
return /*#__PURE__*/React.createElement("svg", _extends({
|
|
18
|
+
viewBox: "0 0 20 20"
|
|
19
|
+
}, props), /*#__PURE__*/React.createElement("path", {
|
|
20
|
+
d: "M5.762 5.76a1 1 0 011.415 0l2.795 2.79 2.788-2.785a1.001 1.001 0 011.415 1.414l-2.788 2.785 2.789 2.787a1 1 0 01-1.414 1.414l-2.79-2.787-2.796 2.794A1 1 0 115.76 12.76l2.796-2.794-2.795-2.792a1 1 0 010-1.414z"
|
|
21
|
+
}));
|
|
22
|
+
};
|
|
23
|
+
var ArrowIcon = function ArrowIcon(props) {
|
|
24
|
+
return /*#__PURE__*/React.createElement("svg", _extends({
|
|
25
|
+
viewBox: "0 0 32 32"
|
|
26
|
+
}, props), /*#__PURE__*/React.createElement("path", {
|
|
27
|
+
d: "M16.774 18.697a1.092 1.092 0 01-1.51 0l-3.953-3.82c-.682-.66-.165-1.877.794-1.877h7.798c.96 0 1.465 1.217.783 1.876l-3.912 3.82z"
|
|
28
|
+
}));
|
|
29
|
+
};
|
|
30
|
+
var isItemSelected = function isItemSelected(item, selectedItems) {
|
|
31
|
+
return selectedItems.some(function (selectedItem) {
|
|
32
|
+
return selectedItem.value === item.value;
|
|
33
|
+
});
|
|
34
|
+
};
|
|
35
|
+
var cn = cnCreate('mfui-9-multiple-select');
|
|
36
|
+
var MultipleSelect = function MultipleSelect(_ref) {
|
|
37
|
+
var items = _ref.items,
|
|
38
|
+
_ref$selectedItems = _ref.selectedItems,
|
|
39
|
+
selectedItems = _ref$selectedItems === void 0 ? [] : _ref$selectedItems,
|
|
40
|
+
placeholder = _ref.placeholder,
|
|
41
|
+
selectLimit = _ref.selectLimit,
|
|
42
|
+
maxLength = _ref.maxLength,
|
|
43
|
+
className = _ref.className,
|
|
44
|
+
_ref$notFoundText = _ref.notFoundText,
|
|
45
|
+
notFoundText = _ref$notFoundText === void 0 ? 'Ничего не нашлось' : _ref$notFoundText,
|
|
46
|
+
noticeText = _ref.noticeText,
|
|
47
|
+
_ref$disabled = _ref.disabled,
|
|
48
|
+
disabled = _ref$disabled === void 0 ? false : _ref$disabled,
|
|
49
|
+
customSearchFilter = _ref.customSearchFilter,
|
|
50
|
+
onSelect = _ref.onSelect,
|
|
51
|
+
onBlur = _ref.onBlur,
|
|
52
|
+
onFocus = _ref.onFocus,
|
|
53
|
+
onSearch = _ref.onSearch,
|
|
54
|
+
searchDelay = _ref.searchDelay,
|
|
55
|
+
isControlled = _ref.isControlled,
|
|
56
|
+
_ref$classes = _ref.classes,
|
|
57
|
+
classes = _ref$classes === void 0 ? {} : _ref$classes,
|
|
58
|
+
dataAttrs = _ref.dataAttrs;
|
|
59
|
+
var _React$useState = React.useState(false),
|
|
60
|
+
_React$useState2 = _slicedToArray(_React$useState, 2),
|
|
61
|
+
isDropdownOpen = _React$useState2[0],
|
|
62
|
+
setIsDropdownOpen = _React$useState2[1];
|
|
63
|
+
var _React$useState3 = React.useState(selectedItems),
|
|
64
|
+
_React$useState4 = _slicedToArray(_React$useState3, 2),
|
|
65
|
+
innerSelectedItems = _React$useState4[0],
|
|
66
|
+
setInnerSelectedItems = _React$useState4[1];
|
|
67
|
+
var _React$useState5 = React.useState(items),
|
|
68
|
+
_React$useState6 = _slicedToArray(_React$useState5, 2),
|
|
69
|
+
innerCurrentItems = _React$useState6[0],
|
|
70
|
+
setInnerCurrentItems = _React$useState6[1];
|
|
71
|
+
var _React$useState7 = React.useState(''),
|
|
72
|
+
_React$useState8 = _slicedToArray(_React$useState7, 2),
|
|
73
|
+
searchQuery = _React$useState8[0],
|
|
74
|
+
setSearchQuery = _React$useState8[1];
|
|
75
|
+
var containerRef = React.useRef(null);
|
|
76
|
+
var inputRef = React.useRef(null);
|
|
77
|
+
var currentItems = isControlled ? items : innerCurrentItems;
|
|
78
|
+
var currentSelectedItems = isControlled ? selectedItems : innerSelectedItems;
|
|
79
|
+
var isSelectActive = !selectLimit || currentSelectedItems.length < selectLimit;
|
|
80
|
+
var filteredItems = currentSelectedItems.length ? currentItems.filter(function (item) {
|
|
81
|
+
return !isItemSelected(item, currentSelectedItems);
|
|
82
|
+
}) : currentItems;
|
|
83
|
+
var showItemsList = isDropdownOpen && isSelectActive;
|
|
84
|
+
var debouncedSearch = React.useMemo(function () {
|
|
85
|
+
return debounce(function (query) {
|
|
86
|
+
return onSearch === null || onSearch === void 0 ? void 0 : onSearch(query);
|
|
87
|
+
}, searchDelay);
|
|
88
|
+
}, [onSearch, searchDelay]);
|
|
89
|
+
var filterItemsBySearch = React.useCallback(function (itemsToFilter, query) {
|
|
90
|
+
if (!query) {
|
|
91
|
+
return itemsToFilter;
|
|
92
|
+
}
|
|
93
|
+
if (customSearchFilter) {
|
|
94
|
+
return itemsToFilter.filter(function (item) {
|
|
95
|
+
return customSearchFilter(item, query);
|
|
96
|
+
});
|
|
97
|
+
}
|
|
98
|
+
return itemsToFilter.filter(function (item) {
|
|
99
|
+
return item.title.toLowerCase().includes(query.toLowerCase());
|
|
100
|
+
});
|
|
101
|
+
}, [customSearchFilter]);
|
|
102
|
+
var handleInputChange = React.useCallback(function (e) {
|
|
103
|
+
var _e$target$value = e.target.value,
|
|
104
|
+
inputValue = _e$target$value === void 0 ? '' : _e$target$value;
|
|
105
|
+
setSearchQuery(inputValue);
|
|
106
|
+
if (!isControlled) {
|
|
107
|
+
var matchesItems = filterItemsBySearch(items, inputValue);
|
|
108
|
+
setInnerCurrentItems(matchesItems);
|
|
109
|
+
}
|
|
110
|
+
if (!searchDelay) {
|
|
111
|
+
onSearch === null || onSearch === void 0 ? void 0 : onSearch(inputValue);
|
|
112
|
+
} else {
|
|
113
|
+
debouncedSearch(inputValue);
|
|
114
|
+
}
|
|
115
|
+
}, [debouncedSearch, filterItemsBySearch, isControlled, items, onSearch, searchDelay]);
|
|
116
|
+
var handleSelectItem = React.useCallback(function (item) {
|
|
117
|
+
if (!isSelectActive) {
|
|
118
|
+
return;
|
|
119
|
+
}
|
|
120
|
+
var newSelectedItems = [].concat(_toConsumableArray(currentSelectedItems), [item]);
|
|
121
|
+
!isControlled && setInnerSelectedItems(newSelectedItems);
|
|
122
|
+
setSearchQuery('');
|
|
123
|
+
inputRef.current && inputRef.current.focus();
|
|
124
|
+
onSelect === null || onSelect === void 0 ? void 0 : onSelect(newSelectedItems);
|
|
125
|
+
}, [isControlled, isSelectActive, onSelect, currentSelectedItems]);
|
|
126
|
+
var handleSelect = function handleSelect(index) {
|
|
127
|
+
return function () {
|
|
128
|
+
var targetItem = filteredItems[index];
|
|
129
|
+
handleSelectItem(targetItem);
|
|
130
|
+
};
|
|
131
|
+
};
|
|
132
|
+
var handleFocus = React.useCallback(function (e) {
|
|
133
|
+
setIsDropdownOpen(true);
|
|
134
|
+
onFocus === null || onFocus === void 0 ? void 0 : onFocus(e);
|
|
135
|
+
}, [onFocus]);
|
|
136
|
+
var handleBlur = React.useCallback(function (e) {
|
|
137
|
+
onBlur === null || onBlur === void 0 ? void 0 : onBlur(e);
|
|
138
|
+
}, [onBlur]);
|
|
139
|
+
var removeSelectedItem = React.useCallback(function (itemToRemove) {
|
|
140
|
+
return function () {
|
|
141
|
+
var newSelectedItems = currentSelectedItems.filter(function (item) {
|
|
142
|
+
return item.value !== itemToRemove.value;
|
|
143
|
+
});
|
|
144
|
+
!isControlled && setInnerSelectedItems(newSelectedItems);
|
|
145
|
+
setIsDropdownOpen(true);
|
|
146
|
+
onSelect === null || onSelect === void 0 ? void 0 : onSelect(newSelectedItems);
|
|
147
|
+
};
|
|
148
|
+
}, [currentSelectedItems, isControlled, onSelect]);
|
|
149
|
+
var handleToggleDropdown = React.useCallback(function () {
|
|
150
|
+
setIsDropdownOpen(function (prev) {
|
|
151
|
+
return !prev;
|
|
152
|
+
});
|
|
153
|
+
}, []);
|
|
154
|
+
var handleDropdownClose = function handleDropdownClose() {
|
|
155
|
+
setIsDropdownOpen(false);
|
|
156
|
+
};
|
|
157
|
+
React.useEffect(function () {
|
|
158
|
+
if (!searchQuery && !isControlled) {
|
|
159
|
+
setInnerCurrentItems(items);
|
|
160
|
+
}
|
|
161
|
+
}, [isControlled, items, searchQuery]);
|
|
162
|
+
var renderList = function renderList() {
|
|
163
|
+
return /*#__PURE__*/React.createElement(Dropdown, {
|
|
164
|
+
isOpen: showItemsList,
|
|
165
|
+
targetRef: containerRef,
|
|
166
|
+
items: filteredItems,
|
|
167
|
+
emptyText: notFoundText,
|
|
168
|
+
onItemClick: handleSelect,
|
|
169
|
+
onClose: handleDropdownClose,
|
|
170
|
+
classes: {
|
|
171
|
+
list: classes === null || classes === void 0 ? void 0 : classes.list,
|
|
172
|
+
item: classes === null || classes === void 0 ? void 0 : classes.listItem
|
|
173
|
+
},
|
|
174
|
+
dataAttrs: {
|
|
175
|
+
list: dataAttrs === null || dataAttrs === void 0 ? void 0 : dataAttrs.list,
|
|
176
|
+
item: dataAttrs === null || dataAttrs === void 0 ? void 0 : dataAttrs.listItem
|
|
177
|
+
}
|
|
178
|
+
});
|
|
179
|
+
};
|
|
180
|
+
var renderItemTag = function renderItemTag(item, i) {
|
|
181
|
+
return /*#__PURE__*/React.createElement("div", _extends({
|
|
182
|
+
key: item.value,
|
|
183
|
+
className: cn('tag', [classes === null || classes === void 0 ? void 0 : classes.tag])
|
|
184
|
+
}, filterDataAttrs(dataAttrs === null || dataAttrs === void 0 ? void 0 : dataAttrs.tag, i + 1)), /*#__PURE__*/React.createElement("span", {
|
|
185
|
+
className: cn('tag-title')
|
|
186
|
+
}, item.title), /*#__PURE__*/React.createElement("button", _extends({
|
|
187
|
+
className: cn('tag-button', [classes === null || classes === void 0 ? void 0 : classes.tagButton])
|
|
188
|
+
}, filterDataAttrs(dataAttrs === null || dataAttrs === void 0 ? void 0 : dataAttrs.tagButton, i + 1), {
|
|
189
|
+
type: "button",
|
|
190
|
+
disabled: disabled,
|
|
191
|
+
onClick: removeSelectedItem(item)
|
|
192
|
+
}), /*#__PURE__*/React.createElement(ClearIcon, {
|
|
193
|
+
className: cn('tag-button-icon')
|
|
194
|
+
})));
|
|
195
|
+
};
|
|
196
|
+
return /*#__PURE__*/React.createElement("div", _extends({
|
|
197
|
+
className: cn({
|
|
198
|
+
open: showItemsList,
|
|
199
|
+
disabled: disabled
|
|
200
|
+
}, [className, classes.root])
|
|
201
|
+
}, filterDataAttrs(dataAttrs === null || dataAttrs === void 0 ? void 0 : dataAttrs.root)), /*#__PURE__*/React.createElement("div", {
|
|
202
|
+
className: cn('control', {
|
|
203
|
+
active: isSelectActive
|
|
204
|
+
}),
|
|
205
|
+
ref: containerRef
|
|
206
|
+
}, /*#__PURE__*/React.createElement("div", {
|
|
207
|
+
className: cn('input-container')
|
|
208
|
+
}, currentSelectedItems === null || currentSelectedItems === void 0 ? void 0 : currentSelectedItems.map(function (item, i) {
|
|
209
|
+
return renderItemTag(item, i);
|
|
210
|
+
}), isSelectActive && /*#__PURE__*/React.createElement("input", _extends({
|
|
211
|
+
className: cn('input', [classes.input])
|
|
212
|
+
}, filterDataAttrs(dataAttrs === null || dataAttrs === void 0 ? void 0 : dataAttrs.input), {
|
|
213
|
+
id: "search",
|
|
214
|
+
placeholder: placeholder,
|
|
215
|
+
value: searchQuery,
|
|
216
|
+
maxLength: maxLength,
|
|
217
|
+
disabled: disabled,
|
|
218
|
+
onChange: handleInputChange,
|
|
219
|
+
onFocus: handleFocus,
|
|
220
|
+
onBlur: handleBlur,
|
|
221
|
+
type: "text",
|
|
222
|
+
autoComplete: "off",
|
|
223
|
+
ref: inputRef
|
|
224
|
+
}))), /*#__PURE__*/React.createElement("button", {
|
|
225
|
+
className: cn('arrow-button'),
|
|
226
|
+
type: "button",
|
|
227
|
+
disabled: !isSelectActive || disabled,
|
|
228
|
+
onClick: handleToggleDropdown
|
|
229
|
+
}, /*#__PURE__*/React.createElement(ArrowIcon, {
|
|
230
|
+
className: cn('arrow-icon')
|
|
231
|
+
})), renderList()), noticeText && /*#__PURE__*/React.createElement("div", {
|
|
232
|
+
className: cn('notice-text')
|
|
233
|
+
}, noticeText));
|
|
234
|
+
};
|
|
235
|
+
export default MultipleSelect;
|
|
@@ -58,6 +58,12 @@ export interface ITooltipProps {
|
|
|
58
58
|
title?: string;
|
|
59
59
|
/** Текст кнопки */
|
|
60
60
|
buttonText?: string;
|
|
61
|
+
/** Ссылка кнопки */
|
|
62
|
+
buttonHref?: string;
|
|
63
|
+
/** Target - свойство тега <a> кнопки */
|
|
64
|
+
buttonTarget?: '_self' | '_blank' | '_parent' | '_top';
|
|
65
|
+
/** Rel - атрибут тега <a> кнопки */
|
|
66
|
+
buttonRel?: string;
|
|
61
67
|
/** Текст */
|
|
62
68
|
text?: string;
|
|
63
69
|
/** Наличие кнопки-крестика "Закрыть" */
|
|
@@ -98,6 +98,10 @@ var Tooltip = function Tooltip(_ref) {
|
|
|
98
98
|
_ref$size = _ref.size,
|
|
99
99
|
size = _ref$size === void 0 ? 'big' : _ref$size,
|
|
100
100
|
buttonText = _ref.buttonText,
|
|
101
|
+
buttonHref = _ref.buttonHref,
|
|
102
|
+
_ref$buttonTarget = _ref.buttonTarget,
|
|
103
|
+
buttonTarget = _ref$buttonTarget === void 0 ? '_self' : _ref$buttonTarget,
|
|
104
|
+
buttonRel = _ref.buttonRel,
|
|
101
105
|
hasCloseButton = _ref.hasCloseButton,
|
|
102
106
|
_ref$colorTheme = _ref.colorTheme,
|
|
103
107
|
theme = _ref$colorTheme === void 0 ? 'white' : _ref$colorTheme,
|
|
@@ -316,25 +320,34 @@ var Tooltip = function Tooltip(_ref) {
|
|
|
316
320
|
var renderedFullContent = useMemo(function () {
|
|
317
321
|
var hasButtonMargin = !!title || !!text;
|
|
318
322
|
var hasChildrenMargin = hasButtonMargin || !!buttonText;
|
|
323
|
+
var isLink = !!buttonHref;
|
|
324
|
+
var ButtonElementType = isLink ? 'a' : 'button';
|
|
325
|
+
var linkProps = {
|
|
326
|
+
href: buttonHref,
|
|
327
|
+
target: buttonTarget,
|
|
328
|
+
rel: buttonRel,
|
|
329
|
+
onClick: onClick
|
|
330
|
+
};
|
|
331
|
+
var buttonProps = {
|
|
332
|
+
onClick: onClick,
|
|
333
|
+
type: 'button'
|
|
334
|
+
};
|
|
319
335
|
return /*#__PURE__*/React.createElement(React.Fragment, null, !!title && /*#__PURE__*/React.createElement(Header, {
|
|
320
336
|
className: cn('title'),
|
|
321
337
|
as: "h5",
|
|
322
338
|
space: "tight"
|
|
323
|
-
}, title), !!text && renderedText, !!buttonText && /*#__PURE__*/React.createElement(
|
|
324
|
-
type: "button",
|
|
339
|
+
}, title), !!text && renderedText, !!buttonText && /*#__PURE__*/React.createElement(ButtonElementType, _extends({
|
|
325
340
|
className: cn('button', {
|
|
326
341
|
margin: hasButtonMargin
|
|
327
342
|
}, [buttonClassName])
|
|
328
|
-
}, filterDataAttrs(dataAttrs === null || dataAttrs === void 0 ? void 0 : dataAttrs.button), {
|
|
329
|
-
onClick: onClick
|
|
330
|
-
}), buttonText, /*#__PURE__*/React.createElement(RightArrow, {
|
|
343
|
+
}, filterDataAttrs(dataAttrs === null || dataAttrs === void 0 ? void 0 : dataAttrs.button), isLink ? linkProps : buttonProps), buttonText, /*#__PURE__*/React.createElement(RightArrow, {
|
|
331
344
|
className: cn('button-arrow')
|
|
332
345
|
})), !!children && /*#__PURE__*/React.createElement("div", {
|
|
333
346
|
className: cn('addititonal-content', {
|
|
334
347
|
margin: hasChildrenMargin
|
|
335
348
|
})
|
|
336
349
|
}, children));
|
|
337
|
-
}, [title, text, buttonText,
|
|
350
|
+
}, [title, text, buttonText, buttonHref, buttonTarget, buttonRel, onClick, renderedText, buttonClassName, dataAttrs === null || dataAttrs === void 0 ? void 0 : dataAttrs.button, children]);
|
|
338
351
|
var template = /*#__PURE__*/React.createElement("div", _extends({}, filterDataAttrs(dataAttrs === null || dataAttrs === void 0 ? void 0 : dataAttrs.root), {
|
|
339
352
|
className: cn({
|
|
340
353
|
theme: theme,
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import { useMemo } from 'react';
|
|
2
|
+
import { useLatest } from "./useLatest";
|
|
3
|
+
export var useEvent = function useEvent(fn) {
|
|
4
|
+
var ref = useLatest(fn);
|
|
5
|
+
return useMemo(function () {
|
|
6
|
+
return function () {
|
|
7
|
+
var current = ref.current;
|
|
8
|
+
return current.apply(void 0, arguments);
|
|
9
|
+
};
|
|
10
|
+
}, [ref]);
|
|
11
|
+
};
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
type Metrics = {
|
|
2
|
+
keyboardOffset: number;
|
|
3
|
+
viewportHeight: number;
|
|
4
|
+
isKeyboardOpen: boolean;
|
|
5
|
+
};
|
|
6
|
+
declare function useVisualViewport({ enabled, onChange, }: {
|
|
7
|
+
enabled?: boolean;
|
|
8
|
+
onChange: (metrics: Metrics) => void;
|
|
9
|
+
}): Metrics;
|
|
10
|
+
export default useVisualViewport;
|
|
@@ -0,0 +1,55 @@
|
|
|
1
|
+
import _slicedToArray from "@babel/runtime/helpers/slicedToArray";
|
|
2
|
+
import { useEffect, useState } from 'react';
|
|
3
|
+
import { useEvent } from "./useEvent";
|
|
4
|
+
var getDefaultMetrics = function getDefaultMetrics() {
|
|
5
|
+
return {
|
|
6
|
+
keyboardOffset: 0,
|
|
7
|
+
viewportHeight: window.innerHeight,
|
|
8
|
+
isKeyboardOpen: false
|
|
9
|
+
};
|
|
10
|
+
};
|
|
11
|
+
var getMetrics = function getMetrics() {
|
|
12
|
+
var viewport = window.visualViewport;
|
|
13
|
+
if (!viewport) {
|
|
14
|
+
return getDefaultMetrics();
|
|
15
|
+
}
|
|
16
|
+
var keyboardOffset = Math.max(0, window.innerHeight - viewport.height - viewport.offsetTop);
|
|
17
|
+
var isKeyboardOpen = viewport.height < window.innerHeight && window.innerHeight - viewport.height > 150;
|
|
18
|
+
return {
|
|
19
|
+
keyboardOffset: keyboardOffset,
|
|
20
|
+
viewportHeight: viewport.height,
|
|
21
|
+
isKeyboardOpen: isKeyboardOpen
|
|
22
|
+
};
|
|
23
|
+
};
|
|
24
|
+
function useVisualViewport(_ref) {
|
|
25
|
+
var _ref$enabled = _ref.enabled,
|
|
26
|
+
enabled = _ref$enabled === void 0 ? true : _ref$enabled,
|
|
27
|
+
onChange = _ref.onChange;
|
|
28
|
+
var _useState = useState(function () {
|
|
29
|
+
return getMetrics();
|
|
30
|
+
}),
|
|
31
|
+
_useState2 = _slicedToArray(_useState, 2),
|
|
32
|
+
metrics = _useState2[0],
|
|
33
|
+
setMetrics = _useState2[1];
|
|
34
|
+
var onChangeMetrics = useEvent(onChange);
|
|
35
|
+
useEffect(function () {
|
|
36
|
+
if (!enabled) {
|
|
37
|
+
return undefined;
|
|
38
|
+
}
|
|
39
|
+
var updateMetrics = function updateMetrics() {
|
|
40
|
+
var currentMetrics = getMetrics();
|
|
41
|
+
setMetrics(currentMetrics);
|
|
42
|
+
onChangeMetrics(currentMetrics);
|
|
43
|
+
};
|
|
44
|
+
updateMetrics();
|
|
45
|
+
var viewport = window.visualViewport;
|
|
46
|
+
viewport === null || viewport === void 0 ? void 0 : viewport.addEventListener('resize', updateMetrics);
|
|
47
|
+
viewport === null || viewport === void 0 ? void 0 : viewport.addEventListener('scroll', updateMetrics);
|
|
48
|
+
return function () {
|
|
49
|
+
viewport === null || viewport === void 0 ? void 0 : viewport.removeEventListener('resize', updateMetrics);
|
|
50
|
+
viewport === null || viewport === void 0 ? void 0 : viewport.removeEventListener('scroll', updateMetrics);
|
|
51
|
+
};
|
|
52
|
+
}, [enabled, onChangeMetrics]);
|
|
53
|
+
return metrics;
|
|
54
|
+
}
|
|
55
|
+
export default useVisualViewport;
|
package/dist/es/index.d.ts
CHANGED
|
@@ -10,6 +10,7 @@ export { default as Carousel } from './components/Carousel/Carousel';
|
|
|
10
10
|
export { default as Checkbox } from './components/Checkbox/Checkbox';
|
|
11
11
|
export { default as checkBreakpointsPropTypes } from './components/Carousel/checkBreakpointsPropTypes';
|
|
12
12
|
export { default as Chip } from './components/Chips/Chips/Chip';
|
|
13
|
+
export { default as ChipBadge } from './components/Chips/Chips/ChipBadge';
|
|
13
14
|
export { default as Chips } from './components/Chips/Chips/Chips';
|
|
14
15
|
export { default as ChipsDropdown } from './components/Chips/Chips/components/ChipsDropdown/ChipsDropdown';
|
|
15
16
|
export { default as ChipsScrollPanel } from './components/Chips/Chips/components/ChipsScrollPanel/ChipsScrollPanel';
|
|
@@ -40,6 +41,7 @@ export { default as ModalContent } from './components/Modal/_ModalContent/ModalC
|
|
|
40
41
|
export { default as ModalDesktop } from './components/Modal/_ModalDesktop/ModalDesktop';
|
|
41
42
|
export { default as ModalMobile } from './components/Modal/_ModalMobile/ModalMobile';
|
|
42
43
|
export { default as Month } from './components/Calendar/components/_Month/Month';
|
|
44
|
+
export { default as MultipleSelect } from './components/MultipleSelect/MultipleSelect';
|
|
43
45
|
export { default as NavArrow } from './components/NavArrow/NavArrow';
|
|
44
46
|
export { default as Notification } from './components/Notification/Notification';
|
|
45
47
|
export { default as NotificationBadge } from './components/Badges/NotificationBadge/NotificationBadge';
|
|
@@ -87,5 +89,6 @@ export { default as UploadFileItemIcon } from './components/UploadForm/UploadFil
|
|
|
87
89
|
export { default as useDragAndDrop } from './components/UploadForm/UploadField/components/useDragAndDrop';
|
|
88
90
|
export { default as useGradient } from './components/Carousel/useGradient';
|
|
89
91
|
export { default as usePagination } from './components/Pagination/usePagination';
|
|
92
|
+
export { default as usePreventScroll } from './components/Modal/utils/usePreventScroll';
|
|
90
93
|
export { default as utils } from './components/Modal/utils/utils';
|
|
91
94
|
export { default as ValueField } from './components/ValueField/ValueField';
|
package/dist/es/index.js
CHANGED
|
@@ -10,6 +10,7 @@ export { default as Carousel } from "./components/Carousel/Carousel";
|
|
|
10
10
|
export { default as Checkbox } from "./components/Checkbox/Checkbox";
|
|
11
11
|
export { default as checkBreakpointsPropTypes } from "./components/Carousel/checkBreakpointsPropTypes";
|
|
12
12
|
export { default as Chip } from "./components/Chips/Chips/Chip";
|
|
13
|
+
export { default as ChipBadge } from "./components/Chips/Chips/ChipBadge";
|
|
13
14
|
export { default as Chips } from "./components/Chips/Chips/Chips";
|
|
14
15
|
export { default as ChipsDropdown } from "./components/Chips/Chips/components/ChipsDropdown/ChipsDropdown";
|
|
15
16
|
export { default as ChipsScrollPanel } from "./components/Chips/Chips/components/ChipsScrollPanel/ChipsScrollPanel";
|
|
@@ -40,6 +41,7 @@ export { default as ModalContent } from "./components/Modal/_ModalContent/ModalC
|
|
|
40
41
|
export { default as ModalDesktop } from "./components/Modal/_ModalDesktop/ModalDesktop";
|
|
41
42
|
export { default as ModalMobile } from "./components/Modal/_ModalMobile/ModalMobile";
|
|
42
43
|
export { default as Month } from "./components/Calendar/components/_Month/Month";
|
|
44
|
+
export { default as MultipleSelect } from "./components/MultipleSelect/MultipleSelect";
|
|
43
45
|
export { default as NavArrow } from "./components/NavArrow/NavArrow";
|
|
44
46
|
export { default as Notification } from "./components/Notification/Notification";
|
|
45
47
|
export { default as NotificationBadge } from "./components/Badges/NotificationBadge/NotificationBadge";
|
|
@@ -87,5 +89,6 @@ export { default as UploadFileItemIcon } from "./components/UploadForm/UploadFil
|
|
|
87
89
|
export { default as useDragAndDrop } from "./components/UploadForm/UploadField/components/useDragAndDrop";
|
|
88
90
|
export { default as useGradient } from "./components/Carousel/useGradient";
|
|
89
91
|
export { default as usePagination } from "./components/Pagination/usePagination";
|
|
92
|
+
export { default as usePreventScroll } from "./components/Modal/utils/usePreventScroll";
|
|
90
93
|
export { default as utils } from "./components/Modal/utils/utils";
|
|
91
94
|
export { default as ValueField } from "./components/ValueField/ValueField";
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
export declare function isMobileFirefox(): boolean | undefined;
|
|
2
|
+
export declare function testPlatform(re: RegExp): boolean | undefined;
|
|
3
|
+
export declare function isMac(): boolean | undefined;
|
|
4
|
+
export declare function isIPhone(): boolean | undefined;
|
|
5
|
+
export declare function isSafari(): boolean | undefined;
|
|
6
|
+
export declare function isIPad(): boolean | undefined;
|
|
7
|
+
export declare function isIOS(): boolean | undefined;
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
import "core-js/modules/es.regexp.exec.js";
|
|
2
|
+
import "core-js/modules/es.regexp.test.js";
|
|
3
|
+
export function isMobileFirefox() {
|
|
4
|
+
var _navigator = navigator,
|
|
5
|
+
userAgent = _navigator.userAgent;
|
|
6
|
+
return typeof window !== 'undefined' && (/Firefox/.test(userAgent) && /Mobile/.test(userAgent) ||
|
|
7
|
+
// Android Firefox
|
|
8
|
+
/FxiOS/.test(userAgent)) // iOS Firefox
|
|
9
|
+
;
|
|
10
|
+
}
|
|
11
|
+
export function testPlatform(re) {
|
|
12
|
+
return typeof window !== 'undefined' && window.navigator != null ? re.test(window.navigator.platform) : undefined;
|
|
13
|
+
}
|
|
14
|
+
export function isMac() {
|
|
15
|
+
return testPlatform(/^Mac/);
|
|
16
|
+
}
|
|
17
|
+
export function isIPhone() {
|
|
18
|
+
return testPlatform(/^iPhone/);
|
|
19
|
+
}
|
|
20
|
+
export function isSafari() {
|
|
21
|
+
return /^((?!chrome|android).)*safari/i.test(navigator.userAgent);
|
|
22
|
+
}
|
|
23
|
+
export function isIPad() {
|
|
24
|
+
return testPlatform(/^iPad/) ||
|
|
25
|
+
// iPadOS 13 lies and says it's a Mac, but we can distinguish by detecting touch support.
|
|
26
|
+
isMac() && navigator.maxTouchPoints > 1;
|
|
27
|
+
}
|
|
28
|
+
export function isIOS() {
|
|
29
|
+
return isIPhone() || isIPad();
|
|
30
|
+
}
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
export declare function isNumber(value: unknown): value is number;
|
|
2
|
+
export declare function isInteger(v: unknown): boolean;
|
|
3
|
+
export declare function isArray<T>(value: unknown): value is Array<T>;
|
|
4
|
+
export declare function isEmptyArray(value: unknown): boolean;
|
|
5
|
+
type AnyFunction = (...args: unknown[]) => unknown;
|
|
6
|
+
export declare function isFunction<T extends AnyFunction = AnyFunction>(value: unknown): value is T;
|
|
7
|
+
export declare function isDefined(value: unknown): boolean;
|
|
8
|
+
export declare function isUndefined(value: unknown): value is undefined;
|
|
9
|
+
export declare function isObject(value: unknown): value is Record<string, unknown>;
|
|
10
|
+
export declare function isEmptyObject(value: unknown): boolean;
|
|
11
|
+
export declare function isNull(value: unknown): value is null;
|
|
12
|
+
export declare function isString(value: unknown): value is string;
|
|
13
|
+
export declare function isCssVar(value: string): boolean;
|
|
14
|
+
export declare function isEmpty(value: unknown): boolean;
|
|
15
|
+
export declare const isBoolean: (value: unknown) => value is boolean;
|
|
16
|
+
type Falsy = false | 0 | '' | null | undefined | bigint;
|
|
17
|
+
export declare const isTruthy: <T>(value: T) => value is Exclude<T, Falsy>;
|
|
18
|
+
export declare const isHTMLElement: (value: unknown) => value is HTMLElement;
|
|
19
|
+
export {};
|
|
@@ -0,0 +1,70 @@
|
|
|
1
|
+
import _typeof from "@babel/runtime/helpers/typeof";
|
|
2
|
+
import "core-js/modules/es.array.is-array.js";
|
|
3
|
+
import "core-js/modules/es.date.to-string.js";
|
|
4
|
+
import "core-js/modules/es.number.constructor.js";
|
|
5
|
+
import "core-js/modules/es.number.is-finite.js";
|
|
6
|
+
import "core-js/modules/es.number.is-nan.js";
|
|
7
|
+
import "core-js/modules/es.object.keys.js";
|
|
8
|
+
import "core-js/modules/es.object.to-string.js";
|
|
9
|
+
import "core-js/modules/es.regexp.exec.js";
|
|
10
|
+
import "core-js/modules/es.regexp.test.js";
|
|
11
|
+
import "core-js/modules/es.regexp.to-string.js";
|
|
12
|
+
export function isNumber(value) {
|
|
13
|
+
return typeof value === 'number';
|
|
14
|
+
}
|
|
15
|
+
export function isInteger(v) {
|
|
16
|
+
var value = Number(v);
|
|
17
|
+
return typeof value === 'number' && !Number.isNaN(value) && Number.isFinite(value) && Math.floor(value) === value;
|
|
18
|
+
}
|
|
19
|
+
export function isArray(value) {
|
|
20
|
+
return Array.isArray(value);
|
|
21
|
+
}
|
|
22
|
+
export function isEmptyArray(value) {
|
|
23
|
+
return isArray(value) && value.length === 0;
|
|
24
|
+
}
|
|
25
|
+
export function isFunction(value) {
|
|
26
|
+
return typeof value === 'function';
|
|
27
|
+
}
|
|
28
|
+
export function isDefined(value) {
|
|
29
|
+
return typeof value !== 'undefined' && value !== undefined;
|
|
30
|
+
}
|
|
31
|
+
export function isUndefined(value) {
|
|
32
|
+
return typeof value === 'undefined' || value === undefined;
|
|
33
|
+
}
|
|
34
|
+
export function isObject(value) {
|
|
35
|
+
var type = _typeof(value);
|
|
36
|
+
return value != null && (type === 'object' || type === 'function') && !isArray(value);
|
|
37
|
+
}
|
|
38
|
+
export function isEmptyObject(value) {
|
|
39
|
+
return isObject(value) && Object.keys(value).length === 0;
|
|
40
|
+
}
|
|
41
|
+
export function isNull(value) {
|
|
42
|
+
return value === null;
|
|
43
|
+
}
|
|
44
|
+
export function isString(value) {
|
|
45
|
+
return Object.prototype.toString.call(value) === '[object String]';
|
|
46
|
+
}
|
|
47
|
+
export function isCssVar(value) {
|
|
48
|
+
return /^var\(--.+\)$/.test(value);
|
|
49
|
+
}
|
|
50
|
+
export function isEmpty(value) {
|
|
51
|
+
if (isArray(value)) {
|
|
52
|
+
return isEmptyArray(value);
|
|
53
|
+
}
|
|
54
|
+
if (isObject(value)) {
|
|
55
|
+
return isEmptyObject(value);
|
|
56
|
+
}
|
|
57
|
+
if (value == null || value === '') {
|
|
58
|
+
return true;
|
|
59
|
+
}
|
|
60
|
+
return false;
|
|
61
|
+
}
|
|
62
|
+
export var isBoolean = function isBoolean(value) {
|
|
63
|
+
return typeof value === 'boolean';
|
|
64
|
+
};
|
|
65
|
+
export var isTruthy = function isTruthy(value) {
|
|
66
|
+
return Boolean(value);
|
|
67
|
+
};
|
|
68
|
+
export var isHTMLElement = function isHTMLElement(value) {
|
|
69
|
+
return value instanceof HTMLElement;
|
|
70
|
+
};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
h1,h2,h3,h4,h5{margin:0}.mfui-9-promo-badge{display:-webkit-box;display:-ms-flexbox;display:flex;-webkit-box-align:center;-ms-flex-align:center;align-items:center;border-radius:8px;color:var(--stcWhite);padding:
|
|
1
|
+
h1,h2,h3,h4,h5{margin:0}.mfui-9-promo-badge{display:-webkit-box;display:-ms-flexbox;display:flex;-webkit-box-align:center;-ms-flex-align:center;align-items:center;border-radius:8px;color:var(--stcWhite);padding:3px 10px;width:-webkit-fit-content;width:-moz-fit-content;width:fit-content}.mfui-9-promo-badge_color_berry{background-color:var(--berry)}.mfui-9-promo-badge_color_brand-purple-20{background-color:var(--brandPurple20);color:var(--brandPurple)}.mfui-9-promo-badge_color_brand-purple{background-color:var(--brandPurple)}.mfui-9-promo-badge_color_night{background-color:var(--night)}.mfui-9-promo-badge_color_sky{background-color:var(--sky)}.mfui-9-promo-badge_color_flamingo{background-color:var(--flamingo)}.mfui-9-promo-badge_color_gradient-purple{background:var(--gradientPurple1);color:var(--stcWhite)}.mfui-9-promo-badge_color_gray{background:var(--spbSky0);color:var(--content)}.mfui-9-promo-badge_color_white{background:var(--base);color:var(--content)}.mfui-9-promo-badge_icon{padding:3px 8px}.mfui-9-promo-badge_size_small{border-radius:8px;height:20px;padding:0 8px}.mfui-9-promo-badge__text{font-family:inherit;font-size:12px;font-weight:500;line-height:18px}.mfui-9-promo-badge__text_size_small{font-size:10px;line-height:12px}.mfui-9-promo-badge__icon{display:-webkit-box;display:-ms-flexbox;display:flex;margin-right:4px}.mfui-9-promo-badge__icon_size_small{margin-left:-4px;margin-right:2px}
|
|
@@ -9,6 +9,7 @@ export declare const PromoBadgeColors: {
|
|
|
9
9
|
readonly FLAMINGO: "flamingo";
|
|
10
10
|
readonly GRADIENT_PURPLE: "gradient-purple";
|
|
11
11
|
readonly GRAY: "gray";
|
|
12
|
+
readonly WHITE: "white";
|
|
12
13
|
};
|
|
13
14
|
type PromoBadgeColorsType = (typeof PromoBadgeColors)[keyof typeof PromoBadgeColors];
|
|
14
15
|
export declare const PromoBadgeSize: {
|
|
@@ -16,11 +17,17 @@ export declare const PromoBadgeSize: {
|
|
|
16
17
|
readonly MEDIUM: "medium";
|
|
17
18
|
};
|
|
18
19
|
type PromoBadgeSizeType = (typeof PromoBadgeSize)[keyof typeof PromoBadgeSize];
|
|
20
|
+
export declare const PromoBadgeIcon: {
|
|
21
|
+
readonly PERSONAL: "personal";
|
|
22
|
+
};
|
|
23
|
+
type PromoBadgeIconType = (typeof PromoBadgeIcon)[keyof typeof PromoBadgeIcon];
|
|
19
24
|
export interface IPromoBadgeProps {
|
|
20
25
|
/** Цвет промо-бэйджа */
|
|
21
26
|
color?: PromoBadgeColorsType;
|
|
22
27
|
/** Размер промо-бэйджа */
|
|
23
28
|
size?: PromoBadgeSizeType;
|
|
29
|
+
/** Иконка промо-бэйджа */
|
|
30
|
+
icon?: PromoBadgeIconType;
|
|
24
31
|
/** Дополнительный класс корневого элемента */
|
|
25
32
|
className?: string;
|
|
26
33
|
/** Дополнительные data-атрибуты к внутренним элементам */
|