@megafon/ui-core 4.14.0 → 4.14.2
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 -0
- package/dist/es/components/Collapse/Collapse.css +3 -0
- package/dist/es/components/Collapse/Collapse.d.ts +6 -23
- package/dist/es/components/Collapse/Collapse.js +21 -16
- package/dist/es/components/Search/Search.css +173 -106
- package/dist/es/components/Search/Search.d.ts +4 -0
- package/dist/es/components/Search/Search.js +104 -45
- package/dist/lib/components/Collapse/Collapse.css +3 -0
- package/dist/lib/components/Collapse/Collapse.d.ts +6 -23
- package/dist/lib/components/Collapse/Collapse.js +19 -15
- package/dist/lib/components/Search/Search.css +173 -106
- package/dist/lib/components/Search/Search.d.ts +4 -0
- package/dist/lib/components/Search/Search.js +106 -45
- package/package.json +3 -3
|
@@ -48,11 +48,7 @@
|
|
|
48
48
|
-webkit-box-sizing: border-box;
|
|
49
49
|
box-sizing: border-box;
|
|
50
50
|
width: 100%;
|
|
51
|
-
|
|
52
|
-
padding: 0 16px 0 16px;
|
|
53
|
-
border: 1px solid var(--spbSky2);
|
|
54
|
-
border-radius: 12px;
|
|
55
|
-
background-color: var(--base);
|
|
51
|
+
border: 1px solid;
|
|
56
52
|
outline: none;
|
|
57
53
|
cursor: pointer;
|
|
58
54
|
-webkit-transition: border-color 0.3s;
|
|
@@ -62,122 +58,64 @@
|
|
|
62
58
|
-ms-user-select: none;
|
|
63
59
|
user-select: none;
|
|
64
60
|
}
|
|
65
|
-
.mfui-
|
|
66
|
-
border-color: var(--content);
|
|
67
|
-
}
|
|
68
|
-
.mfui-search__control_success {
|
|
69
|
-
border-color: var(--brandGreen);
|
|
70
|
-
}
|
|
71
|
-
.mfui-search__control_error {
|
|
72
|
-
border-color: var(--fury);
|
|
73
|
-
}
|
|
74
|
-
.mfui-search__search-wrapper {
|
|
75
|
-
position: relative;
|
|
76
|
-
display: block;
|
|
77
|
-
width: 100%;
|
|
78
|
-
cursor: text;
|
|
79
|
-
}
|
|
80
|
-
.mfui-search__search-wrapper_labeled {
|
|
81
|
-
padding-top: 22px;
|
|
82
|
-
}
|
|
83
|
-
.mfui-search__label {
|
|
84
|
-
position: absolute;
|
|
85
|
-
top: 17px;
|
|
86
|
-
z-index: 1;
|
|
87
|
-
display: block;
|
|
88
|
-
overflow: auto;
|
|
89
|
-
color: var(--spbSky3);
|
|
90
|
-
-webkit-transition: top 0.5s, -webkit-transform 0.5s;
|
|
91
|
-
transition: top 0.5s, -webkit-transform 0.5s;
|
|
92
|
-
transition: transform 0.5s, top 0.5s;
|
|
93
|
-
transition: transform 0.5s, top 0.5s, -webkit-transform 0.5s;
|
|
94
|
-
pointer-events: none;
|
|
95
|
-
font-family: inherit;
|
|
96
|
-
font-size: 15px;
|
|
97
|
-
line-height: 24px;
|
|
98
|
-
}
|
|
99
|
-
.mfui-search__search-field::-webkit-input-placeholder {
|
|
61
|
+
.mfui-search__field_labeled::-webkit-input-placeholder {
|
|
100
62
|
color: var(--spbSky3);
|
|
101
63
|
opacity: 0;
|
|
102
64
|
-webkit-transition: opacity 0.2s;
|
|
103
65
|
transition: opacity 0.2s;
|
|
104
66
|
}
|
|
105
|
-
.mfui-
|
|
67
|
+
.mfui-search__field_labeled::-moz-placeholder {
|
|
106
68
|
color: var(--spbSky3);
|
|
107
69
|
opacity: 0;
|
|
108
70
|
-webkit-transition: opacity 0.2s;
|
|
109
71
|
transition: opacity 0.2s;
|
|
110
72
|
}
|
|
111
|
-
.mfui-
|
|
73
|
+
.mfui-search__field_labeled:-moz-placeholder {
|
|
112
74
|
color: var(--spbSky3);
|
|
113
75
|
opacity: 0;
|
|
114
76
|
-webkit-transition: opacity 0.2s;
|
|
115
77
|
transition: opacity 0.2s;
|
|
116
78
|
}
|
|
117
|
-
.mfui-
|
|
79
|
+
.mfui-search__field_labeled:-ms-input-placeholder {
|
|
118
80
|
color: var(--spbSky3);
|
|
119
81
|
opacity: 0;
|
|
120
82
|
-webkit-transition: opacity 0.2s;
|
|
121
83
|
transition: opacity 0.2s;
|
|
122
84
|
}
|
|
123
|
-
.mfui-
|
|
85
|
+
.mfui-search__field_labeled::-ms-input-placeholder {
|
|
124
86
|
color: var(--spbSky3);
|
|
125
87
|
opacity: 0;
|
|
126
88
|
-webkit-transition: opacity 0.2s;
|
|
127
89
|
transition: opacity 0.2s;
|
|
128
90
|
}
|
|
129
|
-
.mfui-
|
|
91
|
+
.mfui-search__field_labeled::placeholder {
|
|
130
92
|
color: var(--spbSky3);
|
|
131
93
|
opacity: 0;
|
|
132
94
|
-webkit-transition: opacity 0.2s;
|
|
133
95
|
transition: opacity 0.2s;
|
|
134
96
|
}
|
|
135
|
-
.mfui-
|
|
136
|
-
opacity: 1;
|
|
137
|
-
}
|
|
138
|
-
.mfui-search__search-field:focus::-moz-placeholder {
|
|
139
|
-
opacity: 1;
|
|
140
|
-
}
|
|
141
|
-
.mfui-search__search-field:focus:-moz-placeholder {
|
|
142
|
-
opacity: 1;
|
|
143
|
-
}
|
|
144
|
-
.mfui-search__search-field:focus:-ms-input-placeholder {
|
|
145
|
-
opacity: 1;
|
|
146
|
-
}
|
|
147
|
-
.mfui-search__search-field:focus::-ms-input-placeholder {
|
|
97
|
+
.mfui-search__field:focus::-webkit-input-placeholder {
|
|
148
98
|
opacity: 1;
|
|
149
99
|
}
|
|
150
|
-
.mfui-
|
|
100
|
+
.mfui-search__field:focus::-moz-placeholder {
|
|
151
101
|
opacity: 1;
|
|
152
102
|
}
|
|
153
|
-
.mfui-
|
|
103
|
+
.mfui-search__field:focus:-moz-placeholder {
|
|
154
104
|
opacity: 1;
|
|
155
105
|
}
|
|
156
|
-
.mfui-
|
|
106
|
+
.mfui-search__field:focus:-ms-input-placeholder {
|
|
157
107
|
opacity: 1;
|
|
158
108
|
}
|
|
159
|
-
.mfui-
|
|
109
|
+
.mfui-search__field:focus::-ms-input-placeholder {
|
|
160
110
|
opacity: 1;
|
|
161
111
|
}
|
|
162
|
-
.mfui-
|
|
112
|
+
.mfui-search__field:focus::placeholder {
|
|
163
113
|
opacity: 1;
|
|
164
114
|
}
|
|
165
|
-
.mfui-
|
|
166
|
-
opacity: 1;
|
|
167
|
-
}
|
|
168
|
-
.mfui-search__search-wrapper_no-label .mfui-search__search-field::placeholder {
|
|
169
|
-
opacity: 1;
|
|
170
|
-
}
|
|
171
|
-
.mfui-search__search-field_filled + .mfui-search__label,
|
|
172
|
-
.mfui-search__search-field:focus + .mfui-search__label {
|
|
173
|
-
-webkit-transform: scale(0.8) translate(-12.5%, -75%);
|
|
174
|
-
transform: scale(0.8) translate(-12.5%, -75%);
|
|
175
|
-
-webkit-transition-duration: 0.2s, 0.01s;
|
|
176
|
-
transition-duration: 0.2s, 0.01s;
|
|
177
|
-
}
|
|
178
|
-
.mfui-search__search-field {
|
|
115
|
+
.mfui-search__field {
|
|
179
116
|
position: relative;
|
|
180
117
|
z-index: 1;
|
|
118
|
+
display: block;
|
|
181
119
|
-webkit-box-flex: 1;
|
|
182
120
|
-ms-flex-positive: 1;
|
|
183
121
|
flex-grow: 1;
|
|
@@ -197,16 +135,31 @@
|
|
|
197
135
|
outline: none;
|
|
198
136
|
-webkit-box-shadow: none;
|
|
199
137
|
box-shadow: none;
|
|
138
|
+
cursor: text;
|
|
200
139
|
opacity: 1;
|
|
201
140
|
-webkit-appearance: none;
|
|
202
141
|
-moz-appearance: none;
|
|
203
142
|
appearance: none;
|
|
143
|
+
caret-color: var(--brandGreen);
|
|
204
144
|
}
|
|
205
145
|
@media screen and (max-width: 767px) {
|
|
206
|
-
.mfui-
|
|
146
|
+
.mfui-search__field {
|
|
207
147
|
width: 90%;
|
|
208
148
|
}
|
|
209
149
|
}
|
|
150
|
+
.mfui-search__label {
|
|
151
|
+
position: absolute;
|
|
152
|
+
z-index: 1;
|
|
153
|
+
display: block;
|
|
154
|
+
overflow: auto;
|
|
155
|
+
color: var(--spbSky3);
|
|
156
|
+
-webkit-transition-duration: 0.2s, 0.01s;
|
|
157
|
+
transition-duration: 0.2s, 0.01s;
|
|
158
|
+
pointer-events: none;
|
|
159
|
+
font-family: inherit;
|
|
160
|
+
font-size: 15px;
|
|
161
|
+
line-height: 24px;
|
|
162
|
+
}
|
|
210
163
|
.mfui-search__list {
|
|
211
164
|
position: absolute;
|
|
212
165
|
top: calc(100% + 1px);
|
|
@@ -219,17 +172,8 @@
|
|
|
219
172
|
-webkit-box-shadow: 0 4px 12px rgba(0, 0, 0, 0.08);
|
|
220
173
|
box-shadow: 0 4px 12px rgba(0, 0, 0, 0.08);
|
|
221
174
|
}
|
|
222
|
-
.mfui-
|
|
223
|
-
|
|
224
|
-
width: 32px;
|
|
225
|
-
height: 32px;
|
|
226
|
-
-webkit-user-select: none;
|
|
227
|
-
-moz-user-select: none;
|
|
228
|
-
-ms-user-select: none;
|
|
229
|
-
user-select: none;
|
|
230
|
-
fill: var(--content);
|
|
231
|
-
}
|
|
232
|
-
.mfui-search__icon-box {
|
|
175
|
+
.mfui-search__clear,
|
|
176
|
+
.mfui-search__submit-button {
|
|
233
177
|
display: -webkit-box;
|
|
234
178
|
display: -ms-flexbox;
|
|
235
179
|
display: flex;
|
|
@@ -240,8 +184,11 @@
|
|
|
240
184
|
-ms-flex-pack: center;
|
|
241
185
|
justify-content: center;
|
|
242
186
|
height: 100%;
|
|
187
|
+
padding: 0;
|
|
188
|
+
border: none;
|
|
243
189
|
text-align: center;
|
|
244
|
-
|
|
190
|
+
background-color: transparent;
|
|
191
|
+
cursor: pointer;
|
|
245
192
|
}
|
|
246
193
|
.mfui-search__list-inner {
|
|
247
194
|
-webkit-box-sizing: border-box;
|
|
@@ -291,6 +238,32 @@
|
|
|
291
238
|
background: -webkit-gradient(linear, left top, right top, from(rgba(255, 255, 255, 0)), to(var(--spbSky0)));
|
|
292
239
|
background: linear-gradient(to right, rgba(255, 255, 255, 0), var(--spbSky0));
|
|
293
240
|
}
|
|
241
|
+
.mfui-search__highlighted-fragment {
|
|
242
|
+
font-weight: bold;
|
|
243
|
+
}
|
|
244
|
+
.mfui-search__notice {
|
|
245
|
+
margin-top: 4px;
|
|
246
|
+
font-size: 12px;
|
|
247
|
+
line-height: 16px;
|
|
248
|
+
}
|
|
249
|
+
.mfui-search__notice_error {
|
|
250
|
+
color: var(--fury);
|
|
251
|
+
}
|
|
252
|
+
.mfui-search__notice_success {
|
|
253
|
+
color: var(--brandGreen);
|
|
254
|
+
}
|
|
255
|
+
.mfui-search__icons {
|
|
256
|
+
display: -webkit-box;
|
|
257
|
+
display: -ms-flexbox;
|
|
258
|
+
display: flex;
|
|
259
|
+
-webkit-box-align: center;
|
|
260
|
+
-ms-flex-align: center;
|
|
261
|
+
align-items: center;
|
|
262
|
+
height: 100%;
|
|
263
|
+
}
|
|
264
|
+
.mfui-search_open {
|
|
265
|
+
z-index: 12;
|
|
266
|
+
}
|
|
294
267
|
.mfui-search_open .mfui-search__list {
|
|
295
268
|
display: block;
|
|
296
269
|
-webkit-animation-name: listAppear;
|
|
@@ -300,29 +273,123 @@
|
|
|
300
273
|
-webkit-animation-timing-function: ease-in-out;
|
|
301
274
|
animation-timing-function: ease-in-out;
|
|
302
275
|
}
|
|
303
|
-
.mfui-
|
|
304
|
-
|
|
276
|
+
.mfui-search_type_textfield .mfui-search__control {
|
|
277
|
+
height: 60px;
|
|
278
|
+
padding: 0 16px 0 16px;
|
|
279
|
+
border-color: var(--spbSky2);
|
|
280
|
+
border-radius: 12px;
|
|
281
|
+
background-color: var(--base);
|
|
305
282
|
}
|
|
306
|
-
.mfui-
|
|
283
|
+
.mfui-search_type_textfield .mfui-search__control:hover {
|
|
284
|
+
border-color: var(--content);
|
|
285
|
+
}
|
|
286
|
+
.mfui-search_type_textfield .mfui-search__label {
|
|
287
|
+
top: 17px;
|
|
288
|
+
}
|
|
289
|
+
.mfui-search_type_textfield .mfui-search__field_filled + .mfui-search__label,
|
|
290
|
+
.mfui-search_type_textfield .mfui-search__field:focus + .mfui-search__label {
|
|
291
|
+
-webkit-transform: scale(0.8) translate(-12.5%, -75%);
|
|
292
|
+
transform: scale(0.8) translate(-12.5%, -75%);
|
|
293
|
+
}
|
|
294
|
+
.mfui-search_type_textfield .mfui-search__field_labeled {
|
|
295
|
+
padding-top: 22px;
|
|
296
|
+
}
|
|
297
|
+
.mfui-search_type_textfield .mfui-search__submit-icon {
|
|
298
|
+
width: 32px;
|
|
299
|
+
height: 32px;
|
|
300
|
+
fill: var(--content);
|
|
301
|
+
}
|
|
302
|
+
.mfui-search_type_textfield.mfui-search_disabled .mfui-search__control {
|
|
307
303
|
border-color: var(--spbSky1);
|
|
308
304
|
background-color: var(--spbSky1);
|
|
309
|
-
cursor: default;
|
|
310
|
-
pointer-events: none;
|
|
311
305
|
}
|
|
312
|
-
.mfui-search_disabled .mfui-
|
|
306
|
+
.mfui-search_type_textfield.mfui-search_disabled .mfui-search__submit-icon {
|
|
313
307
|
opacity: 0.5;
|
|
308
|
+
-webkit-user-select: none;
|
|
309
|
+
-moz-user-select: none;
|
|
310
|
+
-ms-user-select: none;
|
|
311
|
+
user-select: none;
|
|
314
312
|
}
|
|
315
|
-
.mfui-
|
|
316
|
-
|
|
313
|
+
.mfui-search_type_compact .mfui-search__control {
|
|
314
|
+
height: 40px;
|
|
315
|
+
padding: 0 12px;
|
|
316
|
+
border-color: var(--spbSky0);
|
|
317
|
+
border-radius: 24px;
|
|
318
|
+
background-color: var(--spbSky0);
|
|
319
|
+
-webkit-transition: background-color, border-color 0.3s;
|
|
320
|
+
transition: background-color, border-color 0.3s;
|
|
317
321
|
}
|
|
318
|
-
.mfui-
|
|
319
|
-
|
|
320
|
-
font-size: 12px;
|
|
321
|
-
line-height: 16px;
|
|
322
|
+
.mfui-search_type_compact .mfui-search__control:hover {
|
|
323
|
+
background-color: var(--spbSky1);
|
|
322
324
|
}
|
|
323
|
-
.mfui-
|
|
324
|
-
|
|
325
|
+
.mfui-search_type_compact .mfui-search__field {
|
|
326
|
+
height: 100%;
|
|
327
|
+
padding: 8px 0 8px 12px;
|
|
325
328
|
}
|
|
326
|
-
.mfui-
|
|
327
|
-
|
|
329
|
+
.mfui-search_type_compact .mfui-search__label {
|
|
330
|
+
top: 50%;
|
|
331
|
+
left: 44px;
|
|
332
|
+
-webkit-transform: translateY(-50%);
|
|
333
|
+
transform: translateY(-50%);
|
|
334
|
+
}
|
|
335
|
+
.mfui-search_type_compact .mfui-search__field_filled + .mfui-search__label,
|
|
336
|
+
.mfui-search_type_compact .mfui-search__field:focus + .mfui-search__label {
|
|
337
|
+
opacity: 0;
|
|
338
|
+
}
|
|
339
|
+
.mfui-search_type_compact .mfui-search__submit-icon {
|
|
340
|
+
width: 20px;
|
|
341
|
+
height: 20px;
|
|
342
|
+
fill: var(--spbSky3);
|
|
343
|
+
}
|
|
344
|
+
.mfui-search_type_compact .mfui-search__clear {
|
|
345
|
+
display: -webkit-box;
|
|
346
|
+
display: -ms-flexbox;
|
|
347
|
+
display: flex;
|
|
348
|
+
-webkit-box-align: center;
|
|
349
|
+
-ms-flex-align: center;
|
|
350
|
+
align-items: center;
|
|
351
|
+
-webkit-box-pack: center;
|
|
352
|
+
-ms-flex-pack: center;
|
|
353
|
+
justify-content: center;
|
|
354
|
+
width: 24px;
|
|
355
|
+
height: 24px;
|
|
356
|
+
margin-left: 12px;
|
|
357
|
+
padding: 0;
|
|
358
|
+
border: none;
|
|
359
|
+
background-color: transparent;
|
|
360
|
+
cursor: pointer;
|
|
361
|
+
}
|
|
362
|
+
.mfui-search_type_compact .mfui-search__clear-icon {
|
|
363
|
+
width: 24px;
|
|
364
|
+
height: 24px;
|
|
365
|
+
fill: var(--spbSky3);
|
|
366
|
+
}
|
|
367
|
+
.mfui-search_type_compact .mfui-search__clear-icon:hover {
|
|
368
|
+
fill: var(--content);
|
|
369
|
+
}
|
|
370
|
+
.mfui-search_type_compact .mfui-search__clear-icon:active {
|
|
371
|
+
fill: var(--buttonDown);
|
|
372
|
+
}
|
|
373
|
+
.mfui-search_type_compact.mfui-search_open .mfui-search__control {
|
|
374
|
+
background-color: var(--spbSky1);
|
|
375
|
+
}
|
|
376
|
+
.mfui-search_type_compact.mfui-search_open .mfui-search__submit-icon {
|
|
377
|
+
fill: var(--content);
|
|
378
|
+
}
|
|
379
|
+
.mfui-search_disabled .mfui-search__control {
|
|
380
|
+
cursor: default;
|
|
381
|
+
pointer-events: none;
|
|
382
|
+
}
|
|
383
|
+
.mfui-search_disabled .mfui-search__submit-icon {
|
|
384
|
+
opacity: 0.5;
|
|
385
|
+
-webkit-user-select: none;
|
|
386
|
+
-moz-user-select: none;
|
|
387
|
+
-ms-user-select: none;
|
|
388
|
+
user-select: none;
|
|
389
|
+
}
|
|
390
|
+
.mfui-search_error .mfui-search__control {
|
|
391
|
+
border-color: var(--fury);
|
|
392
|
+
}
|
|
393
|
+
.mfui-search_success .mfui-search__control {
|
|
394
|
+
border-color: var(--brandGreen);
|
|
328
395
|
}
|
|
@@ -31,6 +31,8 @@ export interface ISearchProps {
|
|
|
31
31
|
};
|
|
32
32
|
/** Значение */
|
|
33
33
|
value?: string;
|
|
34
|
+
/** Вид отображения */
|
|
35
|
+
type?: 'textfield' | 'compact';
|
|
34
36
|
/** Заголовок поля */
|
|
35
37
|
label?: string;
|
|
36
38
|
/** HTML идентификатор поля поиска */
|
|
@@ -61,6 +63,8 @@ export interface ISearchProps {
|
|
|
61
63
|
control?: string;
|
|
62
64
|
icon?: string;
|
|
63
65
|
};
|
|
66
|
+
/** Отображение загрузки */
|
|
67
|
+
showLoader?: boolean;
|
|
64
68
|
/** Обработчик изменения поля */
|
|
65
69
|
onChange?: (value: string) => void;
|
|
66
70
|
/** Обработчик нажатия на enter */
|
|
@@ -33,12 +33,22 @@ var _lodash = _interopRequireDefault(require("lodash.debounce"));
|
|
|
33
33
|
|
|
34
34
|
var PropTypes = _interopRequireWildcard(require("prop-types"));
|
|
35
35
|
|
|
36
|
+
var _Preloader = _interopRequireDefault(require("../Preloader/Preloader"));
|
|
37
|
+
|
|
36
38
|
function _getRequireWildcardCache() { if (typeof WeakMap !== "function") return null; var cache = new WeakMap(); _getRequireWildcardCache = function _getRequireWildcardCache() { return cache; }; return cache; }
|
|
37
39
|
|
|
38
40
|
function _interopRequireWildcard(obj) { if (obj && obj.__esModule) { return obj; } if (obj === null || _typeof(obj) !== "object" && typeof obj !== "function") { return { "default": obj }; } var cache = _getRequireWildcardCache(); if (cache && cache.has(obj)) { return cache.get(obj); } var newObj = {}; var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var key in obj) { if (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; }
|
|
39
41
|
|
|
40
42
|
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { "default": obj }; }
|
|
41
43
|
|
|
44
|
+
var SearchIcon16 = function SearchIcon16(props) {
|
|
45
|
+
return /*#__PURE__*/_react["default"].createElement("svg", (0, _extends2["default"])({
|
|
46
|
+
viewBox: "0 0 20 20"
|
|
47
|
+
}, props), /*#__PURE__*/_react["default"].createElement("path", {
|
|
48
|
+
d: "M17 9a7 7 0 10-3.32 6l2.49 3 .77-.64-2.47-3A7 7 0 0017 9zM4 9a6 6 0 116 6 6 6 0 01-6-6z"
|
|
49
|
+
}));
|
|
50
|
+
};
|
|
51
|
+
|
|
42
52
|
var SearchIcon = function SearchIcon(props) {
|
|
43
53
|
return /*#__PURE__*/_react["default"].createElement("svg", (0, _extends2["default"])({
|
|
44
54
|
viewBox: "0 0 32 32"
|
|
@@ -47,6 +57,16 @@ var SearchIcon = function SearchIcon(props) {
|
|
|
47
57
|
}));
|
|
48
58
|
};
|
|
49
59
|
|
|
60
|
+
var ClearIcon = function ClearIcon(props) {
|
|
61
|
+
return /*#__PURE__*/_react["default"].createElement("svg", (0, _extends2["default"])({
|
|
62
|
+
viewBox: "0 0 20 20"
|
|
63
|
+
}, props), /*#__PURE__*/_react["default"].createElement("path", {
|
|
64
|
+
className: "ClearIcon__st0",
|
|
65
|
+
d: "M10 8.8L6.2 5 5 6.2 8.8 10 5 13.8 6.2 15l3.8-3.8 3.8 3.8 1.2-1.2-3.8-3.8L15 6.2 13.8 5 10 8.8z"
|
|
66
|
+
}));
|
|
67
|
+
};
|
|
68
|
+
|
|
69
|
+
var SEARCH_QUERY_REGEX = /[^A-Z-a-zА-ЯЁа-яё0-9]/g;
|
|
50
70
|
var Verification = {
|
|
51
71
|
VALID: 'valid',
|
|
52
72
|
ERROR: 'error'
|
|
@@ -78,6 +98,9 @@ var Search = function Search(_ref) {
|
|
|
78
98
|
noticeText = _ref.noticeText,
|
|
79
99
|
className = _ref.className,
|
|
80
100
|
classes = _ref.classes,
|
|
101
|
+
_ref$type = _ref.type,
|
|
102
|
+
type = _ref$type === void 0 ? 'textfield' : _ref$type,
|
|
103
|
+
showLoader = _ref.showLoader,
|
|
81
104
|
onChange = _ref.onChange,
|
|
82
105
|
onSubmit = _ref.onSubmit,
|
|
83
106
|
onBlur = _ref.onBlur,
|
|
@@ -104,6 +127,13 @@ var Search = function Search(_ref) {
|
|
|
104
127
|
|
|
105
128
|
var highlightedItem = _react["default"].useRef(null);
|
|
106
129
|
|
|
130
|
+
var fieldNode = _react["default"].useRef(null);
|
|
131
|
+
|
|
132
|
+
var isCompact = type === 'compact';
|
|
133
|
+
var showClearIcon = isCompact && !!searchQuery;
|
|
134
|
+
var showTextFieldSubmit = !hideIcon && !isCompact && !showLoader;
|
|
135
|
+
var showAdditionalElement = !hideIcon || showLoader || showClearIcon;
|
|
136
|
+
|
|
107
137
|
var handleChange = _react["default"].useCallback(function (e) {
|
|
108
138
|
var _e$target$value = e.target.value,
|
|
109
139
|
inputValue = _e$target$value === void 0 ? '' : _e$target$value;
|
|
@@ -181,6 +211,14 @@ var Search = function Search(_ref) {
|
|
|
181
211
|
return false;
|
|
182
212
|
}, [activeIndex, items, handleItemSubmit, handleSearchSubmit]);
|
|
183
213
|
|
|
214
|
+
var handleClearClick = function handleClearClick() {
|
|
215
|
+
var _a;
|
|
216
|
+
|
|
217
|
+
onChange === null || onChange === void 0 ? void 0 : onChange('');
|
|
218
|
+
setSearchQuery('');
|
|
219
|
+
(_a = fieldNode === null || fieldNode === void 0 ? void 0 : fieldNode.current) === null || _a === void 0 ? void 0 : _a.focus();
|
|
220
|
+
};
|
|
221
|
+
|
|
184
222
|
_react["default"].useEffect(function () {
|
|
185
223
|
return setSearchQuery(value);
|
|
186
224
|
}, [value]);
|
|
@@ -209,7 +247,7 @@ var Search = function Search(_ref) {
|
|
|
209
247
|
}, [activeIndex, items]);
|
|
210
248
|
|
|
211
249
|
var highlightString = function highlightString(title) {
|
|
212
|
-
var query = searchQuery.replace(
|
|
250
|
+
var query = searchQuery.replace(SEARCH_QUERY_REGEX, function (w) {
|
|
213
251
|
return "\\".concat(w);
|
|
214
252
|
});
|
|
215
253
|
var stringFragments = title.split(RegExp("(".concat(query, ")"), 'ig'));
|
|
@@ -222,26 +260,67 @@ var Search = function Search(_ref) {
|
|
|
222
260
|
}));
|
|
223
261
|
};
|
|
224
262
|
|
|
263
|
+
var renderSubmitButton = function renderSubmitButton() {
|
|
264
|
+
var Icon = isCompact ? SearchIcon16 : SearchIcon;
|
|
265
|
+
return /*#__PURE__*/_react["default"].createElement("button", (0, _extends2["default"])({}, (0, _uiHelpers.filterDataAttrs)(dataAttrs === null || dataAttrs === void 0 ? void 0 : dataAttrs.submit), {
|
|
266
|
+
className: cn('submit-button'),
|
|
267
|
+
onClick: handleSearchSubmit,
|
|
268
|
+
type: "button"
|
|
269
|
+
}), /*#__PURE__*/_react["default"].createElement(Icon, {
|
|
270
|
+
className: cn('submit-icon', [classes === null || classes === void 0 ? void 0 : classes.icon])
|
|
271
|
+
}));
|
|
272
|
+
};
|
|
273
|
+
|
|
274
|
+
var renderClearButton = function renderClearButton() {
|
|
275
|
+
return /*#__PURE__*/_react["default"].createElement("button", {
|
|
276
|
+
onClick: handleClearClick,
|
|
277
|
+
type: "button",
|
|
278
|
+
className: cn('clear')
|
|
279
|
+
}, /*#__PURE__*/_react["default"].createElement(ClearIcon, {
|
|
280
|
+
className: cn('clear-icon')
|
|
281
|
+
}));
|
|
282
|
+
};
|
|
283
|
+
|
|
284
|
+
var renderList = function renderList() {
|
|
285
|
+
return /*#__PURE__*/_react["default"].createElement("div", {
|
|
286
|
+
className: cn('list')
|
|
287
|
+
}, /*#__PURE__*/_react["default"].createElement("div", {
|
|
288
|
+
className: cn('list-inner')
|
|
289
|
+
}, items.map(function (_ref2, i) {
|
|
290
|
+
var itemValue = _ref2.value,
|
|
291
|
+
searchView = _ref2.searchView,
|
|
292
|
+
_ref2$paddings = _ref2.paddings,
|
|
293
|
+
paddings = _ref2$paddings === void 0 ? SearchItemsPaddings.LARGE : _ref2$paddings;
|
|
294
|
+
return /*#__PURE__*/_react["default"].createElement("div", (0, _extends2["default"])({}, (0, _uiHelpers.filterDataAttrs)(dataAttrs === null || dataAttrs === void 0 ? void 0 : dataAttrs.item, i + 1), {
|
|
295
|
+
ref: activeIndex === i ? highlightedItem : null,
|
|
296
|
+
className: cn('list-item', {
|
|
297
|
+
active: activeIndex === i,
|
|
298
|
+
paddings: paddings
|
|
299
|
+
}),
|
|
300
|
+
onMouseDown: handleSelectSubmit(i),
|
|
301
|
+
onMouseEnter: handleHoverItem(i),
|
|
302
|
+
key: i
|
|
303
|
+
}), /*#__PURE__*/_react["default"].createElement("div", (0, _extends2["default"])({}, (0, _uiHelpers.filterDataAttrs)(dataAttrs === null || dataAttrs === void 0 ? void 0 : dataAttrs.itemTitle, i + 1), {
|
|
304
|
+
className: cn('item-title', [classes === null || classes === void 0 ? void 0 : classes.listItemTitle])
|
|
305
|
+
}), searchView || highlightString(itemValue)));
|
|
306
|
+
})));
|
|
307
|
+
};
|
|
308
|
+
|
|
225
309
|
return /*#__PURE__*/_react["default"].createElement("div", (0, _extends2["default"])({}, (0, _uiHelpers.filterDataAttrs)(dataAttrs === null || dataAttrs === void 0 ? void 0 : dataAttrs.root), {
|
|
226
310
|
className: cn({
|
|
227
311
|
open: isFocused,
|
|
228
|
-
disabled: disabled
|
|
229
|
-
|
|
230
|
-
}), /*#__PURE__*/_react["default"].createElement("div", (0, _extends2["default"])({}, (0, _uiHelpers.filterDataAttrs)(dataAttrs === null || dataAttrs === void 0 ? void 0 : dataAttrs.control), {
|
|
231
|
-
className: cn('control', {
|
|
312
|
+
disabled: disabled,
|
|
313
|
+
type: type,
|
|
232
314
|
error: verification === Verification.ERROR,
|
|
233
315
|
success: verification === Verification.VALID
|
|
234
|
-
}, [
|
|
235
|
-
}), /*#__PURE__*/_react["default"].createElement("
|
|
236
|
-
className: cn('
|
|
237
|
-
|
|
238
|
-
'no-label': !label
|
|
239
|
-
}),
|
|
240
|
-
htmlFor: searchId
|
|
241
|
-
}, /*#__PURE__*/_react["default"].createElement("input", (0, _extends2["default"])({}, (0, _uiHelpers.filterDataAttrs)(dataAttrs === null || dataAttrs === void 0 ? void 0 : dataAttrs.searchField), {
|
|
316
|
+
}, [className])
|
|
317
|
+
}), /*#__PURE__*/_react["default"].createElement("div", (0, _extends2["default"])({}, (0, _uiHelpers.filterDataAttrs)(dataAttrs === null || dataAttrs === void 0 ? void 0 : dataAttrs.control), {
|
|
318
|
+
className: cn('control', [classes === null || classes === void 0 ? void 0 : classes.control])
|
|
319
|
+
}), isCompact && renderSubmitButton(), /*#__PURE__*/_react["default"].createElement("input", (0, _extends2["default"])({}, (0, _uiHelpers.filterDataAttrs)(dataAttrs === null || dataAttrs === void 0 ? void 0 : dataAttrs.searchField), {
|
|
242
320
|
id: searchId,
|
|
243
|
-
className: cn('
|
|
244
|
-
filled: !!searchQuery
|
|
321
|
+
className: cn('field', {
|
|
322
|
+
filled: !!searchQuery,
|
|
323
|
+
labeled: !!label
|
|
245
324
|
}, [classes === null || classes === void 0 ? void 0 : classes.input]),
|
|
246
325
|
placeholder: placeholder,
|
|
247
326
|
value: searchQuery,
|
|
@@ -252,38 +331,20 @@ var Search = function Search(_ref) {
|
|
|
252
331
|
onClick: handleClick,
|
|
253
332
|
disabled: disabled,
|
|
254
333
|
type: "text",
|
|
255
|
-
autoComplete: "off"
|
|
256
|
-
|
|
257
|
-
|
|
334
|
+
autoComplete: "off",
|
|
335
|
+
ref: fieldNode
|
|
336
|
+
})), label && /*#__PURE__*/_react["default"].createElement("label", {
|
|
337
|
+
className: cn('label', [classes === null || classes === void 0 ? void 0 : classes.label]),
|
|
338
|
+
htmlFor: searchId
|
|
258
339
|
}, label, required && /*#__PURE__*/_react["default"].createElement("span", {
|
|
259
340
|
className: cn('require-mark')
|
|
260
|
-
}, "*"))
|
|
261
|
-
className: cn('
|
|
262
|
-
|
|
263
|
-
|
|
264
|
-
className: cn('
|
|
265
|
-
|
|
266
|
-
|
|
267
|
-
}, /*#__PURE__*/_react["default"].createElement("div", {
|
|
268
|
-
className: cn('list-inner')
|
|
269
|
-
}, items.map(function (_ref2, i) {
|
|
270
|
-
var itemValue = _ref2.value,
|
|
271
|
-
searchView = _ref2.searchView,
|
|
272
|
-
_ref2$paddings = _ref2.paddings,
|
|
273
|
-
paddings = _ref2$paddings === void 0 ? SearchItemsPaddings.LARGE : _ref2$paddings;
|
|
274
|
-
return /*#__PURE__*/_react["default"].createElement("div", (0, _extends2["default"])({}, (0, _uiHelpers.filterDataAttrs)(dataAttrs === null || dataAttrs === void 0 ? void 0 : dataAttrs.item, i + 1), {
|
|
275
|
-
ref: activeIndex === i ? highlightedItem : null,
|
|
276
|
-
className: cn('list-item', {
|
|
277
|
-
active: activeIndex === i,
|
|
278
|
-
paddings: paddings
|
|
279
|
-
}),
|
|
280
|
-
onMouseDown: handleSelectSubmit(i),
|
|
281
|
-
onMouseEnter: handleHoverItem(i),
|
|
282
|
-
key: i
|
|
283
|
-
}), /*#__PURE__*/_react["default"].createElement("div", (0, _extends2["default"])({}, (0, _uiHelpers.filterDataAttrs)(dataAttrs === null || dataAttrs === void 0 ? void 0 : dataAttrs.itemTitle, i + 1), {
|
|
284
|
-
className: cn('item-title', [classes === null || classes === void 0 ? void 0 : classes.listItemTitle])
|
|
285
|
-
}), searchView || highlightString(itemValue)));
|
|
286
|
-
})))), noticeText && /*#__PURE__*/_react["default"].createElement("div", (0, _extends2["default"])({}, (0, _uiHelpers.filterDataAttrs)(dataAttrs === null || dataAttrs === void 0 ? void 0 : dataAttrs.notice), {
|
|
341
|
+
}, "*")), showAdditionalElement && /*#__PURE__*/_react["default"].createElement("div", {
|
|
342
|
+
className: cn('icons')
|
|
343
|
+
}, showTextFieldSubmit && renderSubmitButton(), showLoader && /*#__PURE__*/_react["default"].createElement(_Preloader["default"], {
|
|
344
|
+
delay: false,
|
|
345
|
+
className: cn('loader'),
|
|
346
|
+
sizeAll: "small"
|
|
347
|
+
}), showClearIcon && renderClearButton()), !!items.length && renderList()), noticeText && /*#__PURE__*/_react["default"].createElement("div", (0, _extends2["default"])({}, (0, _uiHelpers.filterDataAttrs)(dataAttrs === null || dataAttrs === void 0 ? void 0 : dataAttrs.notice), {
|
|
287
348
|
className: cn('notice', {
|
|
288
349
|
error: verification === Verification.ERROR,
|
|
289
350
|
success: verification === Verification.VALID
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@megafon/ui-core",
|
|
3
|
-
"version": "4.14.
|
|
3
|
+
"version": "4.14.2",
|
|
4
4
|
"files": [
|
|
5
5
|
"dist",
|
|
6
6
|
"styles"
|
|
@@ -54,7 +54,7 @@
|
|
|
54
54
|
"@babel/preset-env": "^7.8.6",
|
|
55
55
|
"@babel/preset-react": "^7.8.3",
|
|
56
56
|
"@babel/preset-typescript": "^7.8.3",
|
|
57
|
-
"@megafon/ui-icons": "^2.
|
|
57
|
+
"@megafon/ui-icons": "^2.8.0",
|
|
58
58
|
"@svgr/core": "^2.4.1",
|
|
59
59
|
"@testing-library/jest-dom": "5.16.2",
|
|
60
60
|
"@testing-library/react": "12.1.2",
|
|
@@ -100,5 +100,5 @@
|
|
|
100
100
|
"react-popper": "^2.2.3",
|
|
101
101
|
"swiper": "^6.5.6"
|
|
102
102
|
},
|
|
103
|
-
"gitHead": "
|
|
103
|
+
"gitHead": "43725eddf6f23f91c95f9f7c932e9b9589a4af04"
|
|
104
104
|
}
|