@megafon/ui-core 6.4.4 → 6.6.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/CHANGELOG.md +20 -4
- package/dist/es/components/Banner/Banner.css +3 -0
- package/dist/es/components/Banner/Banner.d.ts +2 -0
- package/dist/es/components/Banner/Banner.js +5 -1
- package/dist/es/components/Calendar/Calendar.css +2 -3
- package/dist/es/components/Calendar/Calendar.js +2 -2
- package/dist/es/components/Calendar/components/Day/Day.css +10 -7
- package/dist/es/components/Calendar/components/Month/Month.css +5 -5
- package/dist/es/components/Search/Search.css +76 -4
- package/dist/es/components/Search/Search.d.ts +15 -2
- package/dist/es/components/Search/Search.js +204 -25
- package/dist/es/components/Search/i/textarea-resizer.svg +4 -0
- package/dist/es/components/Tooltip/Tooltip.css +56 -0
- package/dist/es/components/Tooltip/Tooltip.d.ts +8 -0
- package/dist/es/components/Tooltip/Tooltip.js +11 -2
- package/dist/lib/components/Banner/Banner.css +3 -0
- package/dist/lib/components/Banner/Banner.d.ts +2 -0
- package/dist/lib/components/Banner/Banner.js +5 -1
- package/dist/lib/components/Calendar/Calendar.css +2 -3
- package/dist/lib/components/Calendar/Calendar.js +2 -2
- package/dist/lib/components/Calendar/components/Day/Day.css +10 -7
- package/dist/lib/components/Calendar/components/Month/Month.css +5 -5
- package/dist/lib/components/Search/Search.css +76 -4
- package/dist/lib/components/Search/Search.d.ts +15 -2
- package/dist/lib/components/Search/Search.js +217 -26
- package/dist/lib/components/Search/i/textarea-resizer.svg +4 -0
- package/dist/lib/components/Tooltip/Tooltip.css +56 -0
- package/dist/lib/components/Tooltip/Tooltip.d.ts +8 -0
- package/dist/lib/components/Tooltip/Tooltip.js +13 -3
- package/package.json +2 -2
|
@@ -45,7 +45,10 @@
|
|
|
45
45
|
width: 38px;
|
|
46
46
|
height: 38px;
|
|
47
47
|
}
|
|
48
|
-
.mfui-v6-day_active-modern:hover:after
|
|
48
|
+
.mfui-v6-day_active-modern:hover:after,
|
|
49
|
+
.mfui-v6-day_active-modern:focus:after {
|
|
50
|
+
width: 38px !important;
|
|
51
|
+
height: 38px !important;
|
|
49
52
|
background-color: var(--brandGreen) !important;
|
|
50
53
|
}
|
|
51
54
|
.mfui-v6-day:not(:disabled):not(.mfui-v6-day_active):hover:after {
|
|
@@ -67,7 +70,7 @@
|
|
|
67
70
|
.mfui-v6-day:not(:disabled):not(.mfui-v6-day_active):focus {
|
|
68
71
|
color: var(--stcWhite);
|
|
69
72
|
}
|
|
70
|
-
.mfui-v6-day_active + .mfui-v6-day_active:before,
|
|
73
|
+
.mfui-v6-day_active + .mfui-v6-day:not(.mfui-v6-day_monday).mfui-v6-day_active:before,
|
|
71
74
|
.mfui-v6-day_between:hover + .mfui-v6-day:not(.mfui-v6-day_monday).mfui-v6-day_active:before {
|
|
72
75
|
content: '';
|
|
73
76
|
position: absolute;
|
|
@@ -137,7 +140,7 @@
|
|
|
137
140
|
z-index: 99;
|
|
138
141
|
}
|
|
139
142
|
.mfui-v6-day_modern {
|
|
140
|
-
width:
|
|
143
|
+
width: 100%;
|
|
141
144
|
height: 38px;
|
|
142
145
|
}
|
|
143
146
|
.mfui-v6-day_modern:not(:disabled):not(.mfui-v6-day_modern_active-modern):hover:after,
|
|
@@ -166,7 +169,7 @@
|
|
|
166
169
|
.mfui-v6-day:not(:disabled):focus {
|
|
167
170
|
color: var(--stcWhite);
|
|
168
171
|
}
|
|
169
|
-
.mfui-v6-day_active-modern + .mfui-v6-day_active-modern:before,
|
|
172
|
+
.mfui-v6-day_active-modern + .mfui-v6-day:not(.mfui-v6-day_monday-modern).mfui-v6-day_active-modern:before,
|
|
170
173
|
.mfui-v6-day_between-modern:hover + .mfui-v6-day:not(.mfui-v6-day_monday-modern).mfui-v6-day_active-modern:before {
|
|
171
174
|
content: '';
|
|
172
175
|
position: absolute;
|
|
@@ -186,7 +189,7 @@
|
|
|
186
189
|
content: '';
|
|
187
190
|
position: absolute;
|
|
188
191
|
top: 0;
|
|
189
|
-
left: -
|
|
192
|
+
left: -20px;
|
|
190
193
|
z-index: -1;
|
|
191
194
|
display: block;
|
|
192
195
|
height: 38px;
|
|
@@ -197,7 +200,7 @@
|
|
|
197
200
|
content: '';
|
|
198
201
|
position: absolute;
|
|
199
202
|
top: 0;
|
|
200
|
-
right: -
|
|
203
|
+
right: -12px;
|
|
201
204
|
z-index: -1;
|
|
202
205
|
display: block;
|
|
203
206
|
width: 45px;
|
|
@@ -210,7 +213,7 @@
|
|
|
210
213
|
}
|
|
211
214
|
.mfui-v6-day_sunday-modern:before,
|
|
212
215
|
.mfui-v6-day_last-modern:before {
|
|
213
|
-
padding-left:
|
|
216
|
+
padding-left: 8px;
|
|
214
217
|
}
|
|
215
218
|
.mfui-v6-day_sunday-modern:after,
|
|
216
219
|
.mfui-v6-day_last-modern:after {
|
|
@@ -80,8 +80,8 @@ svg.mfui-v6-month__arrow_disabled {
|
|
|
80
80
|
opacity: 0.5;
|
|
81
81
|
}
|
|
82
82
|
.mfui-v6-month_modern {
|
|
83
|
-
width:
|
|
84
|
-
padding: 0
|
|
83
|
+
width: 100%;
|
|
84
|
+
padding: 0 16px 24px 0;
|
|
85
85
|
}
|
|
86
86
|
.mfui-v6-month_modern .mfui-v6-month__header {
|
|
87
87
|
display: -webkit-box;
|
|
@@ -90,7 +90,7 @@ svg.mfui-v6-month__arrow_disabled {
|
|
|
90
90
|
-webkit-box-align: center;
|
|
91
91
|
-ms-flex-align: center;
|
|
92
92
|
align-items: center;
|
|
93
|
-
width:
|
|
93
|
+
width: 100%;
|
|
94
94
|
margin-bottom: 16px;
|
|
95
95
|
text-transform: capitalize;
|
|
96
96
|
}
|
|
@@ -105,7 +105,7 @@ svg.mfui-v6-month__arrow_disabled {
|
|
|
105
105
|
.mfui-v6-month_modern .mfui-v6-month__weekday-labels {
|
|
106
106
|
display: grid;
|
|
107
107
|
grid-template-columns: repeat(7, 1fr);
|
|
108
|
-
width:
|
|
108
|
+
width: 100%;
|
|
109
109
|
padding-bottom: 0;
|
|
110
110
|
border-bottom: none;
|
|
111
111
|
-webkit-column-gap: 8px;
|
|
@@ -126,7 +126,7 @@ svg.mfui-v6-month__arrow_disabled {
|
|
|
126
126
|
.mfui-v6-month_modern .mfui-v6-month__days {
|
|
127
127
|
display: grid;
|
|
128
128
|
grid-template-columns: repeat(7, 1fr);
|
|
129
|
-
width:
|
|
129
|
+
width: 100%;
|
|
130
130
|
margin-top: 10px;
|
|
131
131
|
-webkit-column-gap: 0;
|
|
132
132
|
-moz-column-gap: 0;
|
|
@@ -130,7 +130,7 @@
|
|
|
130
130
|
color: var(--content);
|
|
131
131
|
font-size: 100%;
|
|
132
132
|
font-family: inherit;
|
|
133
|
-
line-height:
|
|
133
|
+
line-height: 24px;
|
|
134
134
|
background-color: transparent;
|
|
135
135
|
outline: none;
|
|
136
136
|
-webkit-box-shadow: none;
|
|
@@ -140,6 +140,7 @@
|
|
|
140
140
|
-webkit-appearance: none;
|
|
141
141
|
-moz-appearance: none;
|
|
142
142
|
appearance: none;
|
|
143
|
+
resize: none;
|
|
143
144
|
caret-color: var(--brandGreen);
|
|
144
145
|
}
|
|
145
146
|
@media screen and (max-width: 767px) {
|
|
@@ -153,8 +154,10 @@
|
|
|
153
154
|
display: block;
|
|
154
155
|
overflow: auto;
|
|
155
156
|
color: var(--spbSky3);
|
|
156
|
-
-webkit-transition
|
|
157
|
-
|
|
157
|
+
-webkit-transition: scale 0.5s, top 0.01s, -webkit-transform 0.5s;
|
|
158
|
+
transition: scale 0.5s, top 0.01s, -webkit-transform 0.5s;
|
|
159
|
+
transition: transform 0.5s, scale 0.5s, top 0.01s;
|
|
160
|
+
transition: transform 0.5s, scale 0.5s, top 0.01s, -webkit-transform 0.5s;
|
|
158
161
|
pointer-events: none;
|
|
159
162
|
font-family: inherit;
|
|
160
163
|
font-size: 15px;
|
|
@@ -338,6 +341,7 @@
|
|
|
338
341
|
border-radius: 12px;
|
|
339
342
|
background-color: var(--base);
|
|
340
343
|
}
|
|
344
|
+
.mfui-v6-search_type_textfield .mfui-v6-search__control_focused,
|
|
341
345
|
.mfui-v6-search_type_textfield .mfui-v6-search__control:hover {
|
|
342
346
|
border-color: var(--content);
|
|
343
347
|
}
|
|
@@ -348,15 +352,54 @@
|
|
|
348
352
|
.mfui-v6-search_type_textfield .mfui-v6-search__field:focus + .mfui-v6-search__label {
|
|
349
353
|
-webkit-transform: scale(0.8) translate(-12.5%, -75%);
|
|
350
354
|
transform: scale(0.8) translate(-12.5%, -75%);
|
|
355
|
+
-webkit-transition: scale 0.2s, top 0.01s, -webkit-transform 0.2s;
|
|
356
|
+
transition: scale 0.2s, top 0.01s, -webkit-transform 0.2s;
|
|
357
|
+
transition: transform 0.2s, scale 0.2s, top 0.01s;
|
|
358
|
+
transition: transform 0.2s, scale 0.2s, top 0.01s, -webkit-transform 0.2s;
|
|
351
359
|
}
|
|
352
360
|
.mfui-v6-search_type_textfield .mfui-v6-search__field_labeled {
|
|
353
|
-
padding-top:
|
|
361
|
+
padding-top: 25px;
|
|
362
|
+
padding-bottom: 9px;
|
|
354
363
|
}
|
|
355
364
|
.mfui-v6-search_type_textfield .mfui-v6-search__submit-icon {
|
|
356
365
|
width: 32px;
|
|
357
366
|
height: 32px;
|
|
358
367
|
fill: var(--content);
|
|
359
368
|
}
|
|
369
|
+
.mfui-v6-search_textarea .mfui-v6-search__control {
|
|
370
|
+
height: auto;
|
|
371
|
+
min-height: 60px;
|
|
372
|
+
}
|
|
373
|
+
.mfui-v6-search_textarea .mfui-v6-search__field {
|
|
374
|
+
-webkit-box-sizing: content-box;
|
|
375
|
+
box-sizing: content-box;
|
|
376
|
+
max-height: 204px;
|
|
377
|
+
padding-top: 17px;
|
|
378
|
+
padding-bottom: 9px;
|
|
379
|
+
scrollbar-width: thin;
|
|
380
|
+
scrollbar-color: var(--spbSky2) transparent;
|
|
381
|
+
}
|
|
382
|
+
.mfui-v6-search_textarea .mfui-v6-search__field_labeled {
|
|
383
|
+
padding-top: 25px;
|
|
384
|
+
padding-bottom: 9px;
|
|
385
|
+
}
|
|
386
|
+
.mfui-v6-search_textarea .mfui-v6-search__icons {
|
|
387
|
+
height: 58px;
|
|
388
|
+
margin-left: 8px;
|
|
389
|
+
}
|
|
390
|
+
.mfui-v6-search_textarea .mfui-v6-search__field_resized {
|
|
391
|
+
-webkit-transition: height 0.1s;
|
|
392
|
+
transition: height 0.1s;
|
|
393
|
+
will-change: height;
|
|
394
|
+
}
|
|
395
|
+
.mfui-v6-search__textarea-wrapper {
|
|
396
|
+
position: relative;
|
|
397
|
+
-webkit-box-flex: 1;
|
|
398
|
+
-ms-flex-positive: 1;
|
|
399
|
+
flex-grow: 1;
|
|
400
|
+
width: 100%;
|
|
401
|
+
overflow: hidden;
|
|
402
|
+
}
|
|
360
403
|
.mfui-v6-search_type_textfield.mfui-v6-search_disabled .mfui-v6-search__control {
|
|
361
404
|
border-color: var(--spbSky1);
|
|
362
405
|
background-color: var(--spbSky1);
|
|
@@ -451,3 +494,32 @@
|
|
|
451
494
|
.mfui-v6-search_success .mfui-v6-search__control {
|
|
452
495
|
border-color: var(--brandGreen);
|
|
453
496
|
}
|
|
497
|
+
.mfui-v6-search__resizer {
|
|
498
|
+
position: absolute;
|
|
499
|
+
right: 0;
|
|
500
|
+
bottom: 0;
|
|
501
|
+
display: -webkit-box;
|
|
502
|
+
display: -ms-flexbox;
|
|
503
|
+
display: flex;
|
|
504
|
+
-webkit-box-align: center;
|
|
505
|
+
-ms-flex-align: center;
|
|
506
|
+
align-items: center;
|
|
507
|
+
-webkit-box-pack: center;
|
|
508
|
+
-ms-flex-pack: center;
|
|
509
|
+
justify-content: center;
|
|
510
|
+
-webkit-box-sizing: content-box;
|
|
511
|
+
box-sizing: content-box;
|
|
512
|
+
width: 12px;
|
|
513
|
+
height: 12px;
|
|
514
|
+
padding: 4px;
|
|
515
|
+
cursor: ns-resize;
|
|
516
|
+
}
|
|
517
|
+
.mfui-v6-search__resizer svg {
|
|
518
|
+
-webkit-transition: stroke 0.3s;
|
|
519
|
+
transition: stroke 0.3s;
|
|
520
|
+
stroke: var(--spbSky2);
|
|
521
|
+
}
|
|
522
|
+
.mfui-v6-search__resizer:hover svg,
|
|
523
|
+
.mfui-v6-search__resizer:active svg {
|
|
524
|
+
stroke: var(--spbSky3);
|
|
525
|
+
}
|
|
@@ -1,5 +1,10 @@
|
|
|
1
1
|
import React from 'react';
|
|
2
2
|
import './Search.less';
|
|
3
|
+
export declare const MinTextareaHeight: {
|
|
4
|
+
readonly ONE_ROW: 24;
|
|
5
|
+
readonly THREE_ROWS: number;
|
|
6
|
+
};
|
|
7
|
+
declare type MinTextareaHeightType = typeof MinTextareaHeight[keyof typeof MinTextareaHeight];
|
|
3
8
|
export declare const Verification: {
|
|
4
9
|
readonly VALID: "valid";
|
|
5
10
|
readonly ERROR: "error";
|
|
@@ -40,11 +45,14 @@ export interface ISearchProps {
|
|
|
40
45
|
notice?: Record<string, string>;
|
|
41
46
|
popularItem?: Record<string, string>;
|
|
42
47
|
clearButton?: Record<string, string>;
|
|
48
|
+
resizer?: Record<string, string>;
|
|
43
49
|
};
|
|
44
50
|
/** Значение */
|
|
45
51
|
value?: string;
|
|
46
52
|
/** Вид отображения */
|
|
47
53
|
type?: 'textfield' | 'compact';
|
|
54
|
+
/** Включить режим textarea */
|
|
55
|
+
textarea?: boolean;
|
|
48
56
|
/** Заголовок поля */
|
|
49
57
|
label?: string;
|
|
50
58
|
/** HTML идентификатор поля поиска */
|
|
@@ -78,6 +86,7 @@ export interface ISearchProps {
|
|
|
78
86
|
textNotFound?: string;
|
|
79
87
|
popularTitle?: string;
|
|
80
88
|
popularItem?: string;
|
|
89
|
+
resizer?: string;
|
|
81
90
|
};
|
|
82
91
|
/** Отображение загрузки */
|
|
83
92
|
showLoader?: boolean;
|
|
@@ -91,14 +100,18 @@ export interface ISearchProps {
|
|
|
91
100
|
popularTitle?: string;
|
|
92
101
|
/** Ссылка на элемент списка с результатами */
|
|
93
102
|
listRef?: React.Ref<HTMLDivElement>;
|
|
103
|
+
/** Минимальная высота textarea, px */
|
|
104
|
+
minTextareaHeight?: MinTextareaHeightType;
|
|
105
|
+
/** Показать хендлер для ресайза текстового поля */
|
|
106
|
+
showResizer?: boolean;
|
|
94
107
|
/** Обработчик изменения поля */
|
|
95
108
|
onChange?: (value: string) => void;
|
|
96
109
|
/** Обработчик нажатия на enter */
|
|
97
110
|
onSubmit?: (value: string) => void;
|
|
98
111
|
/** Обработчик выхода из фокуса */
|
|
99
|
-
onBlur?: (e: React.FocusEvent<HTMLInputElement>) => void;
|
|
112
|
+
onBlur?: (e: React.FocusEvent<HTMLInputElement | HTMLTextAreaElement>) => void;
|
|
100
113
|
/** Обработчик входа в фокус */
|
|
101
|
-
onFocus?: (e: React.FocusEvent<HTMLInputElement>) => void;
|
|
114
|
+
onFocus?: (e: React.FocusEvent<HTMLInputElement | HTMLTextAreaElement>) => void;
|
|
102
115
|
/** Обработчик нажатия на популярный элемент */
|
|
103
116
|
onPopularItemClick?: (popularItemValue?: string) => void;
|
|
104
117
|
}
|
|
@@ -5,7 +5,7 @@ function _typeof(obj) { "@babel/helpers - typeof"; if (typeof Symbol === "functi
|
|
|
5
5
|
Object.defineProperty(exports, "__esModule", {
|
|
6
6
|
value: true
|
|
7
7
|
});
|
|
8
|
-
exports["default"] = exports.SearchItemsPaddings = exports.Verification = void 0;
|
|
8
|
+
exports["default"] = exports.SearchItemsPaddings = exports.Verification = exports.MinTextareaHeight = void 0;
|
|
9
9
|
|
|
10
10
|
var _slicedToArray2 = _interopRequireDefault(require("@babel/runtime/helpers/slicedToArray"));
|
|
11
11
|
|
|
@@ -13,6 +13,8 @@ var _extends2 = _interopRequireDefault(require("@babel/runtime/helpers/extends")
|
|
|
13
13
|
|
|
14
14
|
require("core-js/modules/es.array.slice.js");
|
|
15
15
|
|
|
16
|
+
require("core-js/modules/es.parse-float.js");
|
|
17
|
+
|
|
16
18
|
require("core-js/modules/es.regexp.exec.js");
|
|
17
19
|
|
|
18
20
|
require("core-js/modules/es.string.replace.js");
|
|
@@ -33,6 +35,8 @@ var _uiHelpers = require("@megafon/ui-helpers");
|
|
|
33
35
|
|
|
34
36
|
var _lodash = _interopRequireDefault(require("lodash.debounce"));
|
|
35
37
|
|
|
38
|
+
var _lodash2 = _interopRequireDefault(require("lodash.throttle"));
|
|
39
|
+
|
|
36
40
|
var PropTypes = _interopRequireWildcard(require("prop-types"));
|
|
37
41
|
|
|
38
42
|
var _Caption = _interopRequireDefault(require("../Caption/Caption"));
|
|
@@ -41,6 +45,8 @@ var _Header = _interopRequireDefault(require("../Header/Header"));
|
|
|
41
45
|
|
|
42
46
|
var _Preloader = _interopRequireDefault(require("../Preloader/Preloader"));
|
|
43
47
|
|
|
48
|
+
var _throttleTime = _interopRequireDefault(require("../../constants/throttleTime"));
|
|
49
|
+
|
|
44
50
|
function _getRequireWildcardCache(nodeInterop) { if (typeof WeakMap !== "function") return null; var cacheBabelInterop = new WeakMap(); var cacheNodeInterop = new WeakMap(); return (_getRequireWildcardCache = function _getRequireWildcardCache(nodeInterop) { return nodeInterop ? cacheNodeInterop : cacheBabelInterop; })(nodeInterop); }
|
|
45
51
|
|
|
46
52
|
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; }
|
|
@@ -72,8 +78,27 @@ var ClearIcon = function ClearIcon(props) {
|
|
|
72
78
|
}));
|
|
73
79
|
};
|
|
74
80
|
|
|
81
|
+
var ResizeIcon = function ResizeIcon(props) {
|
|
82
|
+
return /*#__PURE__*/_react["default"].createElement("svg", (0, _extends2["default"])({
|
|
83
|
+
width: 12,
|
|
84
|
+
height: 12
|
|
85
|
+
}, props), /*#__PURE__*/_react["default"].createElement("path", {
|
|
86
|
+
d: "M1 11L11 1M7 11l4-4"
|
|
87
|
+
}));
|
|
88
|
+
};
|
|
89
|
+
|
|
90
|
+
var DEFAULT_ROW_COUNT = 3;
|
|
91
|
+
var MAX_ROW_COUNT = 6;
|
|
92
|
+
var TEXTAREA_ROW_HEIGHT = 24;
|
|
93
|
+
var TEXTAREA_MAX_HEIGHT = TEXTAREA_ROW_HEIGHT * MAX_ROW_COUNT;
|
|
94
|
+
var DEFAULT_LABEL_TOP_POSITION = 16;
|
|
75
95
|
var SEARCH_QUERY_REGEX = /[^A-Z-a-zА-ЯЁа-яё0-9]/g;
|
|
76
96
|
var MAX_POPULAR_ITEMS_LENGTH = 5;
|
|
97
|
+
var MinTextareaHeight = {
|
|
98
|
+
ONE_ROW: TEXTAREA_ROW_HEIGHT,
|
|
99
|
+
THREE_ROWS: TEXTAREA_ROW_HEIGHT * DEFAULT_ROW_COUNT
|
|
100
|
+
};
|
|
101
|
+
exports.MinTextareaHeight = MinTextareaHeight;
|
|
77
102
|
var Verification = {
|
|
78
103
|
VALID: 'valid',
|
|
79
104
|
ERROR: 'error'
|
|
@@ -107,6 +132,7 @@ var Search = function Search(_ref) {
|
|
|
107
132
|
classes = _ref.classes,
|
|
108
133
|
_ref$type = _ref.type,
|
|
109
134
|
type = _ref$type === void 0 ? 'textfield' : _ref$type,
|
|
135
|
+
textarea = _ref.textarea,
|
|
110
136
|
showLoader = _ref.showLoader,
|
|
111
137
|
showNotFound = _ref.showNotFound,
|
|
112
138
|
textNotFound = _ref.textNotFound,
|
|
@@ -114,6 +140,9 @@ var Search = function Search(_ref) {
|
|
|
114
140
|
popularItems = _ref$popularItems === void 0 ? [] : _ref$popularItems,
|
|
115
141
|
popularTitle = _ref.popularTitle,
|
|
116
142
|
listRef = _ref.listRef,
|
|
143
|
+
_ref$minTextareaHeigh = _ref.minTextareaHeight,
|
|
144
|
+
minTextareaHeight = _ref$minTextareaHeigh === void 0 ? MinTextareaHeight.ONE_ROW : _ref$minTextareaHeigh,
|
|
145
|
+
showResizer = _ref.showResizer,
|
|
117
146
|
onChange = _ref.onChange,
|
|
118
147
|
onSubmit = _ref.onSubmit,
|
|
119
148
|
onBlur = _ref.onBlur,
|
|
@@ -140,24 +169,76 @@ var Search = function Search(_ref) {
|
|
|
140
169
|
popularActiveIndex = _React$useState8[0],
|
|
141
170
|
setPopularActiveIndex = _React$useState8[1];
|
|
142
171
|
|
|
172
|
+
var _React$useState9 = _react["default"].useState(TEXTAREA_ROW_HEIGHT),
|
|
173
|
+
_React$useState10 = (0, _slicedToArray2["default"])(_React$useState9, 2),
|
|
174
|
+
textareaHeight = _React$useState10[0],
|
|
175
|
+
setTextareaHeight = _React$useState10[1];
|
|
176
|
+
|
|
177
|
+
var _React$useState11 = _react["default"].useState(false),
|
|
178
|
+
_React$useState12 = (0, _slicedToArray2["default"])(_React$useState11, 2),
|
|
179
|
+
isTextareaResizing = _React$useState12[0],
|
|
180
|
+
setIsTextareaResizing = _React$useState12[1];
|
|
181
|
+
|
|
182
|
+
var _React$useState13 = _react["default"].useState(false),
|
|
183
|
+
_React$useState14 = (0, _slicedToArray2["default"])(_React$useState13, 2),
|
|
184
|
+
isTextareaResized = _React$useState14[0],
|
|
185
|
+
setIsTextareaResized = _React$useState14[1];
|
|
186
|
+
|
|
143
187
|
var debouncedOnChange = _react["default"].useRef((0, _lodash["default"])(function (inputValue) {
|
|
144
188
|
return onChange && onChange(inputValue);
|
|
145
189
|
}, changeDelay));
|
|
146
190
|
|
|
147
191
|
var highlightedItem = _react["default"].useRef(null);
|
|
148
192
|
|
|
149
|
-
var
|
|
193
|
+
var containerRef = _react["default"].useRef(null);
|
|
194
|
+
|
|
195
|
+
var fieldRef = _react["default"].useRef(null);
|
|
196
|
+
|
|
197
|
+
var labelRef = _react["default"].useRef(null);
|
|
198
|
+
|
|
199
|
+
var resizerRef = _react["default"].useRef(null);
|
|
150
200
|
|
|
151
201
|
var correctPopularItems = _react["default"].useMemo(function () {
|
|
152
202
|
return popularItems.slice(0, MAX_POPULAR_ITEMS_LENGTH);
|
|
153
203
|
}, [popularItems]);
|
|
154
204
|
|
|
155
205
|
var isCompact = type === 'compact';
|
|
206
|
+
var isTextarea = textarea && !isCompact;
|
|
156
207
|
var showClearIcon = isCompact && !!searchQuery;
|
|
157
208
|
var showTextFieldSubmit = !hideIcon && !isCompact && !showLoader;
|
|
158
209
|
var showAdditionalElement = !hideIcon || showLoader || showClearIcon;
|
|
159
210
|
var showPopularItems = !!correctPopularItems.length;
|
|
160
211
|
|
|
212
|
+
var getFieldRef = function getFieldRef(node) {
|
|
213
|
+
if (!node) {
|
|
214
|
+
return;
|
|
215
|
+
}
|
|
216
|
+
|
|
217
|
+
fieldRef.current = node;
|
|
218
|
+
};
|
|
219
|
+
|
|
220
|
+
var textareaResize = _react["default"].useCallback(function () {
|
|
221
|
+
if (!isTextarea || !fieldRef.current || !containerRef.current || isTextareaResized) {
|
|
222
|
+
return;
|
|
223
|
+
}
|
|
224
|
+
|
|
225
|
+
fieldRef.current.style.height = "".concat(minTextareaHeight, "px");
|
|
226
|
+
var scrollHeight = fieldRef.current.scrollHeight;
|
|
227
|
+
|
|
228
|
+
var _window$getComputedSt = window.getComputedStyle(fieldRef.current),
|
|
229
|
+
paddingTop = _window$getComputedSt.paddingTop,
|
|
230
|
+
paddingBottom = _window$getComputedSt.paddingBottom;
|
|
231
|
+
|
|
232
|
+
var innerHeight = scrollHeight - parseFloat(paddingTop) - parseFloat(paddingBottom);
|
|
233
|
+
|
|
234
|
+
if (innerHeight >= TEXTAREA_MAX_HEIGHT) {
|
|
235
|
+
fieldRef.current.style.height = "".concat(TEXTAREA_MAX_HEIGHT, "px");
|
|
236
|
+
return;
|
|
237
|
+
}
|
|
238
|
+
|
|
239
|
+
fieldRef.current.style.height = "".concat(innerHeight, "px");
|
|
240
|
+
}, [isTextareaResized, minTextareaHeight, isTextarea]);
|
|
241
|
+
|
|
161
242
|
var handleChange = _react["default"].useCallback(function (e) {
|
|
162
243
|
var _e$target$value = e.target.value,
|
|
163
244
|
inputValue = _e$target$value === void 0 ? '' : _e$target$value;
|
|
@@ -171,7 +252,9 @@ var Search = function Search(_ref) {
|
|
|
171
252
|
// @ts-ignore
|
|
172
253
|
debouncedOnChange.current(inputValue);
|
|
173
254
|
}
|
|
174
|
-
|
|
255
|
+
|
|
256
|
+
textareaResize();
|
|
257
|
+
}, [changeDelay, onChange, textareaResize]);
|
|
175
258
|
|
|
176
259
|
var handleHoverItem = _react["default"].useCallback(function (index) {
|
|
177
260
|
return function () {
|
|
@@ -232,7 +315,7 @@ var Search = function Search(_ref) {
|
|
|
232
315
|
var _a;
|
|
233
316
|
|
|
234
317
|
var chosenValue = popularItems[popularActiveIndex].title;
|
|
235
|
-
(_a =
|
|
318
|
+
(_a = fieldRef === null || fieldRef === void 0 ? void 0 : fieldRef.current) === null || _a === void 0 ? void 0 : _a.blur();
|
|
236
319
|
onPopularItemClick === null || onPopularItemClick === void 0 ? void 0 : onPopularItemClick(chosenValue);
|
|
237
320
|
}, [onPopularItemClick, popularActiveIndex, popularItems]);
|
|
238
321
|
|
|
@@ -258,6 +341,7 @@ var Search = function Search(_ref) {
|
|
|
258
341
|
{
|
|
259
342
|
var currentHref = (_a = popularItems[popularActiveIndex]) === null || _a === void 0 ? void 0 : _a.href;
|
|
260
343
|
handlePopularItemMouseUp();
|
|
344
|
+
e.preventDefault();
|
|
261
345
|
|
|
262
346
|
if (currentHref) {
|
|
263
347
|
window.location.href = currentHref;
|
|
@@ -295,7 +379,12 @@ var Search = function Search(_ref) {
|
|
|
295
379
|
break;
|
|
296
380
|
|
|
297
381
|
case e.key === 'Enter' && activeIndex === -1:
|
|
382
|
+
if (isTextarea && e.shiftKey) {
|
|
383
|
+
return false;
|
|
384
|
+
}
|
|
385
|
+
|
|
298
386
|
handleSearchSubmit();
|
|
387
|
+
e.preventDefault();
|
|
299
388
|
break;
|
|
300
389
|
|
|
301
390
|
default:
|
|
@@ -303,7 +392,7 @@ var Search = function Search(_ref) {
|
|
|
303
392
|
}
|
|
304
393
|
|
|
305
394
|
return false;
|
|
306
|
-
}, [activeIndex, handleItemSubmit, handleSearchSubmit, items.length]);
|
|
395
|
+
}, [activeIndex, handleItemSubmit, handleSearchSubmit, items.length, isTextarea]);
|
|
307
396
|
|
|
308
397
|
var handleKeyDown = _react["default"].useCallback(function (e) {
|
|
309
398
|
if (showNotFound && showPopularItems) {
|
|
@@ -322,9 +411,70 @@ var Search = function Search(_ref) {
|
|
|
322
411
|
!!debouncedOnChange.current && debouncedOnChange.current.cancel();
|
|
323
412
|
onChange === null || onChange === void 0 ? void 0 : onChange('');
|
|
324
413
|
setSearchQuery('');
|
|
325
|
-
(_a =
|
|
414
|
+
(_a = fieldRef === null || fieldRef === void 0 ? void 0 : fieldRef.current) === null || _a === void 0 ? void 0 : _a.focus();
|
|
326
415
|
};
|
|
327
416
|
|
|
417
|
+
var handleTextareaScroll = function handleTextareaScroll() {
|
|
418
|
+
if (!(fieldRef === null || fieldRef === void 0 ? void 0 : fieldRef.current) || !(labelRef === null || labelRef === void 0 ? void 0 : labelRef.current)) {
|
|
419
|
+
return;
|
|
420
|
+
}
|
|
421
|
+
|
|
422
|
+
var scrollTop = fieldRef.current.scrollTop;
|
|
423
|
+
|
|
424
|
+
if (!scrollTop) {
|
|
425
|
+
labelRef.current.style.top = '';
|
|
426
|
+
return;
|
|
427
|
+
}
|
|
428
|
+
|
|
429
|
+
labelRef.current.style.top = "".concat(DEFAULT_LABEL_TOP_POSITION - scrollTop, "px");
|
|
430
|
+
};
|
|
431
|
+
|
|
432
|
+
_react["default"].useEffect(function () {
|
|
433
|
+
textareaResize();
|
|
434
|
+
}, [textareaResize]);
|
|
435
|
+
|
|
436
|
+
_react["default"].useEffect(function () {
|
|
437
|
+
if (!resizerRef.current || !isTextarea || !showResizer) {
|
|
438
|
+
return;
|
|
439
|
+
}
|
|
440
|
+
|
|
441
|
+
var originalHeight;
|
|
442
|
+
var originalCoordinateY;
|
|
443
|
+
var handleResize = (0, _lodash2["default"])(function (moveEvent) {
|
|
444
|
+
var currentCoordinateY = moveEvent.clientY || moveEvent.touches[0].clientY;
|
|
445
|
+
var resizeHeight = originalHeight + (currentCoordinateY - originalCoordinateY);
|
|
446
|
+
var updatedHeight = resizeHeight < minTextareaHeight ? minTextareaHeight : resizeHeight;
|
|
447
|
+
setTextareaHeight(updatedHeight);
|
|
448
|
+
setIsTextareaResized(true);
|
|
449
|
+
}, _throttleTime["default"].resizeTextarea);
|
|
450
|
+
|
|
451
|
+
var handleResizeCancel = function handleResizeCancel() {
|
|
452
|
+
setIsTextareaResizing(false);
|
|
453
|
+
window.removeEventListener('mousemove', handleResize);
|
|
454
|
+
window.removeEventListener('touchmove', handleResize);
|
|
455
|
+
window.removeEventListener('mouseup', handleResizeCancel);
|
|
456
|
+
window.removeEventListener('touchend', handleResizeCancel);
|
|
457
|
+
};
|
|
458
|
+
|
|
459
|
+
var handleStartResize = function handleStartResize(event) {
|
|
460
|
+
if (!fieldRef.current) {
|
|
461
|
+
return;
|
|
462
|
+
}
|
|
463
|
+
|
|
464
|
+
setIsTextareaResizing(true);
|
|
465
|
+
event.preventDefault();
|
|
466
|
+
originalHeight = parseFloat(getComputedStyle(fieldRef.current).getPropertyValue('height').replace('px', ''));
|
|
467
|
+
originalCoordinateY = event.clientY || event.touches[0].clientY;
|
|
468
|
+
window.addEventListener('mousemove', handleResize);
|
|
469
|
+
window.addEventListener('touchmove', handleResize);
|
|
470
|
+
window.addEventListener('mouseup', handleResizeCancel);
|
|
471
|
+
window.addEventListener('touchend', handleResizeCancel);
|
|
472
|
+
};
|
|
473
|
+
|
|
474
|
+
resizerRef.current.addEventListener('mousedown', handleStartResize);
|
|
475
|
+
resizerRef.current.addEventListener('touchstart', handleStartResize);
|
|
476
|
+
}, [isTextarea, minTextareaHeight, showResizer]);
|
|
477
|
+
|
|
328
478
|
_react["default"].useEffect(function () {
|
|
329
479
|
return setSearchQuery(value);
|
|
330
480
|
}, [value]);
|
|
@@ -460,17 +610,15 @@ var Search = function Search(_ref) {
|
|
|
460
610
|
}, popularTitle || 'Популярные действия'), renderPopularItems())));
|
|
461
611
|
};
|
|
462
612
|
|
|
463
|
-
|
|
464
|
-
className: cn(
|
|
465
|
-
|
|
466
|
-
|
|
467
|
-
|
|
468
|
-
|
|
469
|
-
|
|
470
|
-
|
|
471
|
-
|
|
472
|
-
className: cn('control', [classes === null || classes === void 0 ? void 0 : classes.control])
|
|
473
|
-
}), isCompact && renderSubmitButton(), /*#__PURE__*/_react["default"].createElement("input", (0, _extends2["default"])({}, (0, _uiHelpers.filterDataAttrs)(dataAttrs === null || dataAttrs === void 0 ? void 0 : dataAttrs.searchField), {
|
|
613
|
+
var renderLabel = /*#__PURE__*/_react["default"].createElement("label", {
|
|
614
|
+
className: cn('label', [classes === null || classes === void 0 ? void 0 : classes.label]),
|
|
615
|
+
htmlFor: searchId,
|
|
616
|
+
ref: labelRef
|
|
617
|
+
}, label, required && /*#__PURE__*/_react["default"].createElement("span", {
|
|
618
|
+
className: cn('require-mark')
|
|
619
|
+
}, "*"));
|
|
620
|
+
|
|
621
|
+
var renderInput = /*#__PURE__*/_react["default"].createElement(_react["default"].Fragment, null, /*#__PURE__*/_react["default"].createElement("input", (0, _extends2["default"])({}, (0, _uiHelpers.filterDataAttrs)(dataAttrs === null || dataAttrs === void 0 ? void 0 : dataAttrs.searchField), {
|
|
474
622
|
id: searchId,
|
|
475
623
|
className: cn('field', {
|
|
476
624
|
filled: !!searchQuery,
|
|
@@ -486,13 +634,50 @@ var Search = function Search(_ref) {
|
|
|
486
634
|
disabled: disabled,
|
|
487
635
|
type: "text",
|
|
488
636
|
autoComplete: "off",
|
|
489
|
-
ref:
|
|
490
|
-
})), label &&
|
|
491
|
-
|
|
492
|
-
|
|
493
|
-
|
|
494
|
-
|
|
495
|
-
}, "
|
|
637
|
+
ref: getFieldRef
|
|
638
|
+
})), label && renderLabel);
|
|
639
|
+
|
|
640
|
+
var renderTextarea = /*#__PURE__*/_react["default"].createElement(_react["default"].Fragment, null, showResizer && /*#__PURE__*/_react["default"].createElement("div", (0, _extends2["default"])({
|
|
641
|
+
className: cn('resizer', [classes === null || classes === void 0 ? void 0 : classes.resizer]),
|
|
642
|
+
ref: resizerRef
|
|
643
|
+
}, (0, _uiHelpers.filterDataAttrs)(dataAttrs === null || dataAttrs === void 0 ? void 0 : dataAttrs.resizer)), /*#__PURE__*/_react["default"].createElement(ResizeIcon, null)), /*#__PURE__*/_react["default"].createElement("div", {
|
|
644
|
+
className: cn('textarea-wrapper')
|
|
645
|
+
}, /*#__PURE__*/_react["default"].createElement("textarea", (0, _extends2["default"])({}, (0, _uiHelpers.filterDataAttrs)(dataAttrs === null || dataAttrs === void 0 ? void 0 : dataAttrs.searchField), {
|
|
646
|
+
id: searchId,
|
|
647
|
+
className: cn('field', {
|
|
648
|
+
filled: !!searchQuery,
|
|
649
|
+
labeled: !!label
|
|
650
|
+
}, [classes === null || classes === void 0 ? void 0 : classes.input]),
|
|
651
|
+
style: {
|
|
652
|
+
height: "".concat(textareaHeight, "px")
|
|
653
|
+
},
|
|
654
|
+
placeholder: placeholder,
|
|
655
|
+
value: searchQuery,
|
|
656
|
+
onChange: handleChange,
|
|
657
|
+
onFocus: handleFocus,
|
|
658
|
+
onBlur: handleBlur,
|
|
659
|
+
onKeyDown: handleKeyDown,
|
|
660
|
+
onClick: handleClick,
|
|
661
|
+
onScroll: handleTextareaScroll,
|
|
662
|
+
autoComplete: "off",
|
|
663
|
+
ref: getFieldRef
|
|
664
|
+
})), label && renderLabel));
|
|
665
|
+
|
|
666
|
+
return /*#__PURE__*/_react["default"].createElement("div", (0, _extends2["default"])({}, (0, _uiHelpers.filterDataAttrs)(dataAttrs === null || dataAttrs === void 0 ? void 0 : dataAttrs.root), {
|
|
667
|
+
className: cn({
|
|
668
|
+
open: isFocused,
|
|
669
|
+
disabled: disabled,
|
|
670
|
+
type: type,
|
|
671
|
+
textarea: isTextarea,
|
|
672
|
+
error: verification === Verification.ERROR,
|
|
673
|
+
success: verification === Verification.VALID
|
|
674
|
+
}, [className])
|
|
675
|
+
}), /*#__PURE__*/_react["default"].createElement("div", (0, _extends2["default"])({}, (0, _uiHelpers.filterDataAttrs)(dataAttrs === null || dataAttrs === void 0 ? void 0 : dataAttrs.control), {
|
|
676
|
+
className: cn('control', {
|
|
677
|
+
focused: isTextareaResizing
|
|
678
|
+
}, [classes === null || classes === void 0 ? void 0 : classes.control]),
|
|
679
|
+
ref: containerRef
|
|
680
|
+
}), isCompact && renderSubmitButton(), isTextarea ? renderTextarea : renderInput, showAdditionalElement && /*#__PURE__*/_react["default"].createElement("div", {
|
|
496
681
|
className: cn('icons')
|
|
497
682
|
}, showTextFieldSubmit && renderSubmitButton(), showLoader && /*#__PURE__*/_react["default"].createElement(_Preloader["default"], {
|
|
498
683
|
delay: false,
|
|
@@ -515,9 +700,12 @@ Search.propTypes = {
|
|
|
515
700
|
item: PropTypes.objectOf(PropTypes.string.isRequired),
|
|
516
701
|
itemTitle: PropTypes.objectOf(PropTypes.string.isRequired),
|
|
517
702
|
notice: PropTypes.objectOf(PropTypes.string.isRequired),
|
|
518
|
-
popularItem: PropTypes.objectOf(PropTypes.string.isRequired)
|
|
703
|
+
popularItem: PropTypes.objectOf(PropTypes.string.isRequired),
|
|
704
|
+
resizer: PropTypes.objectOf(PropTypes.string.isRequired)
|
|
519
705
|
}),
|
|
520
706
|
value: PropTypes.string,
|
|
707
|
+
type: PropTypes.oneOf(['textfield', 'compact']),
|
|
708
|
+
textarea: PropTypes.bool,
|
|
521
709
|
label: PropTypes.string,
|
|
522
710
|
searchId: PropTypes.string,
|
|
523
711
|
placeholder: PropTypes.string,
|
|
@@ -542,7 +730,8 @@ Search.propTypes = {
|
|
|
542
730
|
icon: PropTypes.string,
|
|
543
731
|
textNotFound: PropTypes.string,
|
|
544
732
|
popularTitle: PropTypes.string,
|
|
545
|
-
popularItem: PropTypes.string
|
|
733
|
+
popularItem: PropTypes.string,
|
|
734
|
+
resizer: PropTypes.string
|
|
546
735
|
}),
|
|
547
736
|
showNotFound: PropTypes.bool,
|
|
548
737
|
textNotFound: PropTypes.string,
|
|
@@ -555,6 +744,8 @@ Search.propTypes = {
|
|
|
555
744
|
listRef: PropTypes.oneOfType([PropTypes.func, PropTypes.oneOfType([PropTypes.shape({
|
|
556
745
|
current: PropTypes.elementType
|
|
557
746
|
}), PropTypes.any])]),
|
|
747
|
+
minTextareaHeight: PropTypes.oneOf([MinTextareaHeight.ONE_ROW, MinTextareaHeight.THREE_ROWS]),
|
|
748
|
+
showResizer: PropTypes.bool,
|
|
558
749
|
onChange: PropTypes.func,
|
|
559
750
|
onSubmit: PropTypes.func,
|
|
560
751
|
onBlur: PropTypes.func,
|