@itcase/ui 1.0.53 → 1.0.55
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/_commonjsHelpers-facfc6d6.js +7 -0
- package/dist/components/Avatar.js +1 -1
- package/dist/components/Choice.js +2 -2
- package/dist/components/DadataHintField.js +1141 -0
- package/dist/components/DatePicker.js +8 -10
- package/dist/components/Image.js +2 -2
- package/dist/css/components/DadataHintField/DadataHintField.css +43 -0
- package/package.json +2 -1
|
@@ -92,8 +92,8 @@ const Choice = /*#__PURE__*/React__default.default.forwardRef((props, ref) => {
|
|
|
92
92
|
className: clsx__default.default('choice__item-label'),
|
|
93
93
|
htmlFor: item.label
|
|
94
94
|
}, /*#__PURE__*/React__default.default.createElement(index.Text, {
|
|
95
|
-
|
|
96
|
-
|
|
95
|
+
size: labelTextSize,
|
|
96
|
+
textColor: item.value === active.value ? labelTextActiveColor : labelTextColor
|
|
97
97
|
}, item.label))))));
|
|
98
98
|
});
|
|
99
99
|
Choice.displayName = 'Choice';
|
|
@@ -0,0 +1,1141 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
var React = require('react');
|
|
4
|
+
var PropTypes = require('prop-types');
|
|
5
|
+
var clsx = require('clsx');
|
|
6
|
+
var _commonjsHelpers = require('../_commonjsHelpers-facfc6d6.js');
|
|
7
|
+
var crypto = require('crypto');
|
|
8
|
+
var index = require('./Input.js');
|
|
9
|
+
require('../hooks/useDeviceTargetClass.js');
|
|
10
|
+
require('lodash/castArray');
|
|
11
|
+
require('lodash/camelCase');
|
|
12
|
+
require('../context/UIContext.js');
|
|
13
|
+
require('../hooks/useMediaQueries.js');
|
|
14
|
+
require('react-responsive');
|
|
15
|
+
|
|
16
|
+
function _interopDefault (e) { return e && e.__esModule ? e : { default: e }; }
|
|
17
|
+
|
|
18
|
+
var React__default = /*#__PURE__*/_interopDefault(React);
|
|
19
|
+
var PropTypes__default = /*#__PURE__*/_interopDefault(PropTypes);
|
|
20
|
+
var clsx__default = /*#__PURE__*/_interopDefault(clsx);
|
|
21
|
+
var crypto__default = /*#__PURE__*/_interopDefault(crypto);
|
|
22
|
+
|
|
23
|
+
//
|
|
24
|
+
|
|
25
|
+
var shallowequal = function shallowEqual(objA, objB, compare, compareContext) {
|
|
26
|
+
var ret = compare ? compare.call(compareContext, objA, objB) : void 0;
|
|
27
|
+
|
|
28
|
+
if (ret !== void 0) {
|
|
29
|
+
return !!ret;
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
if (objA === objB) {
|
|
33
|
+
return true;
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
if (typeof objA !== "object" || !objA || typeof objB !== "object" || !objB) {
|
|
37
|
+
return false;
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
var keysA = Object.keys(objA);
|
|
41
|
+
var keysB = Object.keys(objB);
|
|
42
|
+
|
|
43
|
+
if (keysA.length !== keysB.length) {
|
|
44
|
+
return false;
|
|
45
|
+
}
|
|
46
|
+
|
|
47
|
+
var bHasOwnProperty = Object.prototype.hasOwnProperty.bind(objB);
|
|
48
|
+
|
|
49
|
+
// Test for A's keys different from B.
|
|
50
|
+
for (var idx = 0; idx < keysA.length; idx++) {
|
|
51
|
+
var key = keysA[idx];
|
|
52
|
+
|
|
53
|
+
if (!bHasOwnProperty(key)) {
|
|
54
|
+
return false;
|
|
55
|
+
}
|
|
56
|
+
|
|
57
|
+
var valueA = objA[key];
|
|
58
|
+
var valueB = objB[key];
|
|
59
|
+
|
|
60
|
+
ret = compare ? compare.call(compareContext, valueA, valueB, key) : void 0;
|
|
61
|
+
|
|
62
|
+
if (ret === false || (ret === void 0 && valueA !== valueB)) {
|
|
63
|
+
return false;
|
|
64
|
+
}
|
|
65
|
+
}
|
|
66
|
+
|
|
67
|
+
return true;
|
|
68
|
+
};
|
|
69
|
+
|
|
70
|
+
var shallowEqual = /*@__PURE__*/_commonjsHelpers.getDefaultExportFromCjs(shallowequal);
|
|
71
|
+
|
|
72
|
+
/**
|
|
73
|
+
* Returns a function, that, as long as it continues to be invoked, will not
|
|
74
|
+
* be triggered. The function will be called after it stops being called for
|
|
75
|
+
* N milliseconds. If `immediate` is passed, trigger the function on the
|
|
76
|
+
* leading edge, instead of the trailing. The function also has a property 'clear'
|
|
77
|
+
* that is a function which will clear the timer to prevent previously scheduled executions.
|
|
78
|
+
*
|
|
79
|
+
* @source underscore.js
|
|
80
|
+
* @see http://unscriptable.com/2009/03/20/debouncing-javascript-methods/
|
|
81
|
+
* @param {Function} function to wrap
|
|
82
|
+
* @param {Number} timeout in ms (`100`)
|
|
83
|
+
* @param {Boolean} whether to execute at the beginning (`false`)
|
|
84
|
+
* @api public
|
|
85
|
+
*/
|
|
86
|
+
|
|
87
|
+
function debounce(func, wait, immediate){
|
|
88
|
+
var timeout, args, context, timestamp, result;
|
|
89
|
+
if (null == wait) wait = 100;
|
|
90
|
+
|
|
91
|
+
function later() {
|
|
92
|
+
var last = Date.now() - timestamp;
|
|
93
|
+
|
|
94
|
+
if (last < wait && last >= 0) {
|
|
95
|
+
timeout = setTimeout(later, wait - last);
|
|
96
|
+
} else {
|
|
97
|
+
timeout = null;
|
|
98
|
+
if (!immediate) {
|
|
99
|
+
result = func.apply(context, args);
|
|
100
|
+
context = args = null;
|
|
101
|
+
}
|
|
102
|
+
}
|
|
103
|
+
}
|
|
104
|
+
var debounced = function(){
|
|
105
|
+
context = this;
|
|
106
|
+
args = arguments;
|
|
107
|
+
timestamp = Date.now();
|
|
108
|
+
var callNow = immediate && !timeout;
|
|
109
|
+
if (!timeout) timeout = setTimeout(later, wait);
|
|
110
|
+
if (callNow) {
|
|
111
|
+
result = func.apply(context, args);
|
|
112
|
+
context = args = null;
|
|
113
|
+
}
|
|
114
|
+
|
|
115
|
+
return result;
|
|
116
|
+
};
|
|
117
|
+
|
|
118
|
+
debounced.clear = function() {
|
|
119
|
+
if (timeout) {
|
|
120
|
+
clearTimeout(timeout);
|
|
121
|
+
timeout = null;
|
|
122
|
+
}
|
|
123
|
+
};
|
|
124
|
+
|
|
125
|
+
debounced.flush = function() {
|
|
126
|
+
if (timeout) {
|
|
127
|
+
result = func.apply(context, args);
|
|
128
|
+
context = args = null;
|
|
129
|
+
|
|
130
|
+
clearTimeout(timeout);
|
|
131
|
+
timeout = null;
|
|
132
|
+
}
|
|
133
|
+
};
|
|
134
|
+
|
|
135
|
+
return debounced;
|
|
136
|
+
}
|
|
137
|
+
// Adds compatibility for ES modules
|
|
138
|
+
debounce.debounce = debounce;
|
|
139
|
+
|
|
140
|
+
var debounce_1 = debounce;
|
|
141
|
+
|
|
142
|
+
let urlAlphabet =
|
|
143
|
+
'useandom-26T198340PX75pxJACKVERYMINDBUSHWOLF_GQZbfghjklqvwyzrict';
|
|
144
|
+
|
|
145
|
+
const POOL_SIZE_MULTIPLIER = 128;
|
|
146
|
+
let pool, poolOffset;
|
|
147
|
+
let fillPool = bytes => {
|
|
148
|
+
if (!pool || pool.length < bytes) {
|
|
149
|
+
pool = Buffer.allocUnsafe(bytes * POOL_SIZE_MULTIPLIER);
|
|
150
|
+
crypto__default.default.randomFillSync(pool);
|
|
151
|
+
poolOffset = 0;
|
|
152
|
+
} else if (poolOffset + bytes > pool.length) {
|
|
153
|
+
crypto__default.default.randomFillSync(pool);
|
|
154
|
+
poolOffset = 0;
|
|
155
|
+
}
|
|
156
|
+
poolOffset += bytes;
|
|
157
|
+
};
|
|
158
|
+
let nanoid = (size = 21) => {
|
|
159
|
+
fillPool((size -= 0));
|
|
160
|
+
let id = '';
|
|
161
|
+
for (let i = poolOffset - size; i < poolOffset; i++) {
|
|
162
|
+
id += urlAlphabet[pool[i] & 63];
|
|
163
|
+
}
|
|
164
|
+
return id
|
|
165
|
+
};
|
|
166
|
+
|
|
167
|
+
var xhr;
|
|
168
|
+
var makeRequest = function (method, endpoint, data, cache, onReceiveData) {
|
|
169
|
+
if (xhr) {
|
|
170
|
+
xhr.abort();
|
|
171
|
+
}
|
|
172
|
+
var cacheKey;
|
|
173
|
+
if (cache) {
|
|
174
|
+
cacheKey = cache.serializeCacheKey({
|
|
175
|
+
headers: data.headers,
|
|
176
|
+
body: data.json,
|
|
177
|
+
url: endpoint,
|
|
178
|
+
method: method,
|
|
179
|
+
});
|
|
180
|
+
var cachedData = cache.get(cacheKey);
|
|
181
|
+
if (cachedData) {
|
|
182
|
+
onReceiveData(cachedData);
|
|
183
|
+
return;
|
|
184
|
+
}
|
|
185
|
+
}
|
|
186
|
+
xhr = new XMLHttpRequest();
|
|
187
|
+
xhr.open(method, endpoint);
|
|
188
|
+
if (data.headers) {
|
|
189
|
+
Object.entries(data.headers).forEach(function (_a) {
|
|
190
|
+
var header = _a[0], headerValue = _a[1];
|
|
191
|
+
xhr.setRequestHeader(header, headerValue);
|
|
192
|
+
});
|
|
193
|
+
}
|
|
194
|
+
xhr.send(JSON.stringify(data.json));
|
|
195
|
+
xhr.onreadystatechange = function () {
|
|
196
|
+
var _a;
|
|
197
|
+
if (!xhr || xhr.readyState !== 4) {
|
|
198
|
+
return;
|
|
199
|
+
}
|
|
200
|
+
if (xhr.status === 200) {
|
|
201
|
+
var payload = (_a = JSON.parse(xhr.response)) === null || _a === void 0 ? void 0 : _a.suggestions;
|
|
202
|
+
if (payload) {
|
|
203
|
+
cache === null || cache === void 0 ? void 0 : cache.set(cacheKey, payload);
|
|
204
|
+
onReceiveData(payload);
|
|
205
|
+
}
|
|
206
|
+
}
|
|
207
|
+
};
|
|
208
|
+
};
|
|
209
|
+
|
|
210
|
+
var HttpCache = /** @class */ (function () {
|
|
211
|
+
function HttpCache() {
|
|
212
|
+
}
|
|
213
|
+
/**
|
|
214
|
+
* Сгенерировать уникальный ключ кеша из параметров http-запроса
|
|
215
|
+
* @example
|
|
216
|
+
* ```ts
|
|
217
|
+
* cache.serializeCacheKey({
|
|
218
|
+
* url: 'https://example.com',
|
|
219
|
+
* body: { key: "value" },
|
|
220
|
+
* method: "POST"
|
|
221
|
+
* })
|
|
222
|
+
* ```
|
|
223
|
+
*/
|
|
224
|
+
HttpCache.prototype.serializeCacheKey = function (payload) {
|
|
225
|
+
try {
|
|
226
|
+
return JSON.stringify(payload);
|
|
227
|
+
}
|
|
228
|
+
catch (_e) {
|
|
229
|
+
// на случай попытки сериализации объекта с циклическими зависимостями внутри
|
|
230
|
+
return payload.url + String(Math.random());
|
|
231
|
+
}
|
|
232
|
+
};
|
|
233
|
+
return HttpCache;
|
|
234
|
+
}());
|
|
235
|
+
|
|
236
|
+
var __extends$7 = (undefined && undefined.__extends) || (function () {
|
|
237
|
+
var extendStatics = function (d, b) {
|
|
238
|
+
extendStatics = Object.setPrototypeOf ||
|
|
239
|
+
({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
|
|
240
|
+
function (d, b) { for (var p in b) if (Object.prototype.hasOwnProperty.call(b, p)) d[p] = b[p]; };
|
|
241
|
+
return extendStatics(d, b);
|
|
242
|
+
};
|
|
243
|
+
return function (d, b) {
|
|
244
|
+
if (typeof b !== "function" && b !== null)
|
|
245
|
+
throw new TypeError("Class extends value " + String(b) + " is not a constructor or null");
|
|
246
|
+
extendStatics(d, b);
|
|
247
|
+
function __() { this.constructor = d; }
|
|
248
|
+
d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
|
|
249
|
+
};
|
|
250
|
+
})();
|
|
251
|
+
var minute = 60000;
|
|
252
|
+
var DefaultHttpCache = /** @class */ (function (_super) {
|
|
253
|
+
__extends$7(DefaultHttpCache, _super);
|
|
254
|
+
function DefaultHttpCache() {
|
|
255
|
+
var _this = _super !== null && _super.apply(this, arguments) || this;
|
|
256
|
+
_this._map = new Map();
|
|
257
|
+
_this._ttl = 10 * minute;
|
|
258
|
+
return _this;
|
|
259
|
+
}
|
|
260
|
+
Object.defineProperty(DefaultHttpCache, "shared", {
|
|
261
|
+
/**
|
|
262
|
+
* Синглтон
|
|
263
|
+
* @example
|
|
264
|
+
* ```ts
|
|
265
|
+
* cache.shared.get('key');
|
|
266
|
+
* ```
|
|
267
|
+
*/
|
|
268
|
+
get: function () {
|
|
269
|
+
if (!DefaultHttpCache.sharedInstance) {
|
|
270
|
+
DefaultHttpCache.sharedInstance = new DefaultHttpCache();
|
|
271
|
+
}
|
|
272
|
+
return DefaultHttpCache.sharedInstance;
|
|
273
|
+
},
|
|
274
|
+
enumerable: false,
|
|
275
|
+
configurable: true
|
|
276
|
+
});
|
|
277
|
+
Object.defineProperty(DefaultHttpCache.prototype, "ttl", {
|
|
278
|
+
/**
|
|
279
|
+
* Время жизни кеша в миллисекундах
|
|
280
|
+
* @example
|
|
281
|
+
* ```ts
|
|
282
|
+
* cache.ttl = 60000;
|
|
283
|
+
* cache.ttl = Infinity;
|
|
284
|
+
* cache.tll = 0;
|
|
285
|
+
*
|
|
286
|
+
* // негативные значения игнорируются
|
|
287
|
+
* cache.ttl = -1;
|
|
288
|
+
* cache.ttl = Number.NEGATIVE_INFINITY;
|
|
289
|
+
* ```
|
|
290
|
+
*/
|
|
291
|
+
get: function () {
|
|
292
|
+
return this._ttl;
|
|
293
|
+
},
|
|
294
|
+
set: function (ttl) {
|
|
295
|
+
if (typeof ttl === 'number' && ttl >= 0) {
|
|
296
|
+
this._ttl = ttl;
|
|
297
|
+
}
|
|
298
|
+
},
|
|
299
|
+
enumerable: false,
|
|
300
|
+
configurable: true
|
|
301
|
+
});
|
|
302
|
+
Object.defineProperty(DefaultHttpCache.prototype, "size", {
|
|
303
|
+
/**
|
|
304
|
+
* Количество элементов в кеше
|
|
305
|
+
*/
|
|
306
|
+
get: function () {
|
|
307
|
+
return this._map.size;
|
|
308
|
+
},
|
|
309
|
+
enumerable: false,
|
|
310
|
+
configurable: true
|
|
311
|
+
});
|
|
312
|
+
DefaultHttpCache.prototype.get = function (key) {
|
|
313
|
+
var data = this._map.get(key);
|
|
314
|
+
if (!data)
|
|
315
|
+
return null;
|
|
316
|
+
if (data.expires <= Date.now()) {
|
|
317
|
+
this.delete(key);
|
|
318
|
+
return null;
|
|
319
|
+
}
|
|
320
|
+
return data.data;
|
|
321
|
+
};
|
|
322
|
+
DefaultHttpCache.prototype.set = function (key, data) {
|
|
323
|
+
this._map.set(key, {
|
|
324
|
+
data: data,
|
|
325
|
+
expires: Date.now() + this.ttl,
|
|
326
|
+
});
|
|
327
|
+
return this;
|
|
328
|
+
};
|
|
329
|
+
DefaultHttpCache.prototype.delete = function (key) {
|
|
330
|
+
this._map.delete(key);
|
|
331
|
+
return this;
|
|
332
|
+
};
|
|
333
|
+
DefaultHttpCache.prototype.reset = function () {
|
|
334
|
+
this._map.clear();
|
|
335
|
+
return this;
|
|
336
|
+
};
|
|
337
|
+
return DefaultHttpCache;
|
|
338
|
+
}(HttpCache));
|
|
339
|
+
|
|
340
|
+
var __extends$6 = (undefined && undefined.__extends) || (function () {
|
|
341
|
+
var extendStatics = function (d, b) {
|
|
342
|
+
extendStatics = Object.setPrototypeOf ||
|
|
343
|
+
({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
|
|
344
|
+
function (d, b) { for (var p in b) if (Object.prototype.hasOwnProperty.call(b, p)) d[p] = b[p]; };
|
|
345
|
+
return extendStatics(d, b);
|
|
346
|
+
};
|
|
347
|
+
return function (d, b) {
|
|
348
|
+
if (typeof b !== "function" && b !== null)
|
|
349
|
+
throw new TypeError("Class extends value " + String(b) + " is not a constructor or null");
|
|
350
|
+
extendStatics(d, b);
|
|
351
|
+
function __() { this.constructor = d; }
|
|
352
|
+
d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
|
|
353
|
+
};
|
|
354
|
+
})();
|
|
355
|
+
var __assign = (undefined && undefined.__assign) || function () {
|
|
356
|
+
__assign = Object.assign || function(t) {
|
|
357
|
+
for (var s, i = 1, n = arguments.length; i < n; i++) {
|
|
358
|
+
s = arguments[i];
|
|
359
|
+
for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p))
|
|
360
|
+
t[p] = s[p];
|
|
361
|
+
}
|
|
362
|
+
return t;
|
|
363
|
+
};
|
|
364
|
+
return __assign.apply(this, arguments);
|
|
365
|
+
};
|
|
366
|
+
var BaseSuggestions = /** @class */ (function (_super) {
|
|
367
|
+
__extends$6(BaseSuggestions, _super);
|
|
368
|
+
function BaseSuggestions(props) {
|
|
369
|
+
var _this = _super.call(this, props) || this;
|
|
370
|
+
/**
|
|
371
|
+
* URL для загрузки подсказок, переопределяется в конкретном компоненте
|
|
372
|
+
*/
|
|
373
|
+
_this.loadSuggestionsUrl = '';
|
|
374
|
+
_this.dontPerformBlurHandler = false;
|
|
375
|
+
_this.getSuggestionsUrl = function () {
|
|
376
|
+
var url = _this.props.url;
|
|
377
|
+
return url || _this.loadSuggestionsUrl;
|
|
378
|
+
};
|
|
379
|
+
_this.setupDebounce = function (delay) {
|
|
380
|
+
if (typeof delay === 'number' && delay > 0) {
|
|
381
|
+
_this.fetchSuggestions = debounce_1.debounce(_this.performFetchSuggestions, delay);
|
|
382
|
+
}
|
|
383
|
+
else {
|
|
384
|
+
_this.fetchSuggestions = _this.performFetchSuggestions;
|
|
385
|
+
}
|
|
386
|
+
};
|
|
387
|
+
_this.fetchSuggestions = function () {
|
|
388
|
+
//
|
|
389
|
+
};
|
|
390
|
+
_this.handleInputFocus = function (event) {
|
|
391
|
+
_this.setState({ isFocused: true });
|
|
392
|
+
var suggestions = _this.state.suggestions;
|
|
393
|
+
if (suggestions.length === 0) {
|
|
394
|
+
_this.fetchSuggestions();
|
|
395
|
+
}
|
|
396
|
+
var inputProps = _this.props.inputProps;
|
|
397
|
+
if (inputProps && inputProps.onFocus) {
|
|
398
|
+
inputProps.onFocus(event);
|
|
399
|
+
}
|
|
400
|
+
};
|
|
401
|
+
_this.handleInputBlur = function (event) {
|
|
402
|
+
var _a = _this.state, suggestions = _a.suggestions, suggestionIndex = _a.suggestionIndex;
|
|
403
|
+
var _b = _this.props, selectOnBlur = _b.selectOnBlur, inputProps = _b.inputProps;
|
|
404
|
+
_this.setState({ isFocused: false });
|
|
405
|
+
if (suggestions.length === 0) {
|
|
406
|
+
_this.fetchSuggestions();
|
|
407
|
+
}
|
|
408
|
+
if (selectOnBlur && !_this.dontPerformBlurHandler) {
|
|
409
|
+
if (suggestions.length > 0) {
|
|
410
|
+
var suggestionIndexToSelect = suggestionIndex >= 0 && suggestionIndex < suggestions.length ? suggestionIndex : 0;
|
|
411
|
+
_this.selectSuggestion(suggestionIndexToSelect, true);
|
|
412
|
+
}
|
|
413
|
+
}
|
|
414
|
+
_this.dontPerformBlurHandler = false;
|
|
415
|
+
if (inputProps && inputProps.onBlur) {
|
|
416
|
+
inputProps.onBlur(event);
|
|
417
|
+
}
|
|
418
|
+
};
|
|
419
|
+
_this.handleInputChange = function (event) {
|
|
420
|
+
var value = event.target.value;
|
|
421
|
+
var inputProps = _this.props.inputProps;
|
|
422
|
+
if (_this.didMount) {
|
|
423
|
+
_this.setState({ query: value, inputQuery: value, displaySuggestions: !!value }, function () {
|
|
424
|
+
_this.fetchSuggestions();
|
|
425
|
+
});
|
|
426
|
+
}
|
|
427
|
+
if (inputProps && inputProps.onChange) {
|
|
428
|
+
inputProps.onChange(event);
|
|
429
|
+
}
|
|
430
|
+
};
|
|
431
|
+
_this.handleInputKeyDown = function (event) {
|
|
432
|
+
_this.handleKeyboard(event);
|
|
433
|
+
var inputProps = _this.props.inputProps;
|
|
434
|
+
if (inputProps && inputProps.onKeyDown) {
|
|
435
|
+
inputProps.onKeyDown(event);
|
|
436
|
+
}
|
|
437
|
+
};
|
|
438
|
+
_this.handleInputKeyPress = function (event) {
|
|
439
|
+
_this.handleKeyboard(event);
|
|
440
|
+
var inputProps = _this.props.inputProps;
|
|
441
|
+
if (inputProps && inputProps.onKeyPress) {
|
|
442
|
+
inputProps.onKeyPress(event);
|
|
443
|
+
}
|
|
444
|
+
};
|
|
445
|
+
_this.handleKeyboard = function (event) {
|
|
446
|
+
var _a = _this.state, suggestions = _a.suggestions, suggestionIndex = _a.suggestionIndex, inputQuery = _a.inputQuery;
|
|
447
|
+
if (event.which === 40) {
|
|
448
|
+
// Arrow down
|
|
449
|
+
event.preventDefault();
|
|
450
|
+
if (suggestionIndex < suggestions.length - 1) {
|
|
451
|
+
var newSuggestionIndex = suggestionIndex + 1;
|
|
452
|
+
var newInputQuery = suggestions[newSuggestionIndex].value;
|
|
453
|
+
if (_this.didMount) {
|
|
454
|
+
_this.setState({ suggestionIndex: newSuggestionIndex, query: newInputQuery });
|
|
455
|
+
}
|
|
456
|
+
}
|
|
457
|
+
}
|
|
458
|
+
else if (event.which === 38) {
|
|
459
|
+
// Arrow up
|
|
460
|
+
event.preventDefault();
|
|
461
|
+
if (suggestionIndex >= 0) {
|
|
462
|
+
var newSuggestionIndex = suggestionIndex - 1;
|
|
463
|
+
var newInputQuery = newSuggestionIndex === -1 ? inputQuery : suggestions[newSuggestionIndex].value;
|
|
464
|
+
if (_this.didMount) {
|
|
465
|
+
_this.setState({ suggestionIndex: newSuggestionIndex, query: newInputQuery });
|
|
466
|
+
}
|
|
467
|
+
}
|
|
468
|
+
}
|
|
469
|
+
else if (event.which === 13) {
|
|
470
|
+
// Enter
|
|
471
|
+
event.preventDefault();
|
|
472
|
+
if (suggestionIndex >= 0) {
|
|
473
|
+
_this.selectSuggestion(suggestionIndex);
|
|
474
|
+
}
|
|
475
|
+
}
|
|
476
|
+
};
|
|
477
|
+
_this.performFetchSuggestions = function () {
|
|
478
|
+
var _a = _this.props, minChars = _a.minChars, token = _a.token;
|
|
479
|
+
var query = _this.state.query;
|
|
480
|
+
// Проверяем на минимальное количество символов для отправки
|
|
481
|
+
if (typeof minChars === 'number' && minChars > 0 && query.length < minChars) {
|
|
482
|
+
_this.setState({ suggestions: [], suggestionIndex: -1 });
|
|
483
|
+
return;
|
|
484
|
+
}
|
|
485
|
+
makeRequest('POST', _this.getSuggestionsUrl(), {
|
|
486
|
+
headers: {
|
|
487
|
+
Accept: 'application/json',
|
|
488
|
+
Authorization: "Token ".concat(token),
|
|
489
|
+
'Content-Type': 'application/json',
|
|
490
|
+
},
|
|
491
|
+
json: _this.getLoadSuggestionsData(),
|
|
492
|
+
}, _this.httpCache, function (suggestions) {
|
|
493
|
+
if (_this.didMount) {
|
|
494
|
+
_this.setState({ suggestions: suggestions, suggestionIndex: -1 });
|
|
495
|
+
}
|
|
496
|
+
});
|
|
497
|
+
};
|
|
498
|
+
_this.onSuggestionClick = function (index, event) {
|
|
499
|
+
event.stopPropagation();
|
|
500
|
+
_this.selectSuggestion(index);
|
|
501
|
+
};
|
|
502
|
+
_this.selectSuggestion = function (index, isSilent) {
|
|
503
|
+
if (isSilent === void 0) { isSilent = false; }
|
|
504
|
+
var suggestions = _this.state.suggestions;
|
|
505
|
+
var _a = _this.props, selectOnBlur = _a.selectOnBlur, onChange = _a.onChange;
|
|
506
|
+
if (suggestions.length >= index - 1) {
|
|
507
|
+
var suggestion = suggestions[index];
|
|
508
|
+
if (selectOnBlur) {
|
|
509
|
+
_this.dontPerformBlurHandler = true;
|
|
510
|
+
}
|
|
511
|
+
_this.setState({ query: suggestion.value, inputQuery: suggestion.value, displaySuggestions: false }, function () {
|
|
512
|
+
if (!isSilent) {
|
|
513
|
+
_this.fetchSuggestions();
|
|
514
|
+
setTimeout(function () { return _this.setCursorToEnd(_this.textInput); });
|
|
515
|
+
}
|
|
516
|
+
});
|
|
517
|
+
if (onChange) {
|
|
518
|
+
onChange(suggestion);
|
|
519
|
+
}
|
|
520
|
+
}
|
|
521
|
+
};
|
|
522
|
+
_this.setCursorToEnd = function (element) {
|
|
523
|
+
if (element) {
|
|
524
|
+
var valueLength = element.value.length;
|
|
525
|
+
if (element.selectionStart || element.selectionStart === 0) {
|
|
526
|
+
// eslint-disable-next-line no-param-reassign
|
|
527
|
+
element.selectionStart = valueLength;
|
|
528
|
+
// eslint-disable-next-line no-param-reassign
|
|
529
|
+
element.selectionEnd = valueLength;
|
|
530
|
+
element.focus();
|
|
531
|
+
}
|
|
532
|
+
}
|
|
533
|
+
};
|
|
534
|
+
_this.getHighlightWords = function () {
|
|
535
|
+
var inputQuery = _this.state.inputQuery;
|
|
536
|
+
var wordsToPass = ['г', 'респ', 'ул', 'р-н', 'село', 'деревня', 'поселок', 'пр-д', 'пл', 'к', 'кв', 'обл', 'д'];
|
|
537
|
+
var words = inputQuery.replace(',', '').split(' ');
|
|
538
|
+
words = words.filter(function (word) {
|
|
539
|
+
return wordsToPass.indexOf(word) < 0;
|
|
540
|
+
});
|
|
541
|
+
return words;
|
|
542
|
+
};
|
|
543
|
+
/**
|
|
544
|
+
* Функция, которая вернет уникальный key для списка React
|
|
545
|
+
* @param suggestion
|
|
546
|
+
*/
|
|
547
|
+
_this.getSuggestionKey = function (suggestion) { return suggestion.value; };
|
|
548
|
+
_this.focus = function () {
|
|
549
|
+
if (_this.textInput) {
|
|
550
|
+
_this.textInput.focus();
|
|
551
|
+
}
|
|
552
|
+
};
|
|
553
|
+
_this.setInputValue = function (value) {
|
|
554
|
+
_this.setState({ query: value || '', inputQuery: value || '' });
|
|
555
|
+
};
|
|
556
|
+
_this.didMount = false;
|
|
557
|
+
var _a = _this.props, defaultQuery = _a.defaultQuery, value = _a.value, delay = _a.delay;
|
|
558
|
+
var valueQuery = value ? value.value : undefined;
|
|
559
|
+
_this.setupDebounce(delay);
|
|
560
|
+
_this.state = {
|
|
561
|
+
query: defaultQuery || valueQuery || '',
|
|
562
|
+
inputQuery: defaultQuery || valueQuery || '',
|
|
563
|
+
isFocused: false,
|
|
564
|
+
displaySuggestions: true,
|
|
565
|
+
suggestions: [],
|
|
566
|
+
suggestionIndex: -1,
|
|
567
|
+
};
|
|
568
|
+
return _this;
|
|
569
|
+
}
|
|
570
|
+
BaseSuggestions.prototype.componentDidMount = function () {
|
|
571
|
+
this.didMount = true;
|
|
572
|
+
};
|
|
573
|
+
BaseSuggestions.prototype.componentDidUpdate = function (prevProps) {
|
|
574
|
+
var _a = this.props, value = _a.value, delay = _a.delay;
|
|
575
|
+
var _b = this.state, query = _b.query, inputQuery = _b.inputQuery;
|
|
576
|
+
if (!shallowEqual(prevProps.value, value)) {
|
|
577
|
+
var newQuery = value ? value.value : '';
|
|
578
|
+
if (query !== newQuery || inputQuery !== newQuery) {
|
|
579
|
+
this.setState({ query: newQuery, inputQuery: newQuery });
|
|
580
|
+
}
|
|
581
|
+
}
|
|
582
|
+
if (delay !== prevProps.delay) {
|
|
583
|
+
this.setupDebounce(delay);
|
|
584
|
+
}
|
|
585
|
+
};
|
|
586
|
+
BaseSuggestions.prototype.componentWillUnmount = function () {
|
|
587
|
+
this.didMount = false;
|
|
588
|
+
};
|
|
589
|
+
Object.defineProperty(BaseSuggestions.prototype, "uid", {
|
|
590
|
+
get: function () {
|
|
591
|
+
if (this.props.uid) {
|
|
592
|
+
return this.props.uid;
|
|
593
|
+
}
|
|
594
|
+
if (!this._uid) {
|
|
595
|
+
this._uid = nanoid();
|
|
596
|
+
}
|
|
597
|
+
return this._uid;
|
|
598
|
+
},
|
|
599
|
+
enumerable: false,
|
|
600
|
+
configurable: true
|
|
601
|
+
});
|
|
602
|
+
Object.defineProperty(BaseSuggestions.prototype, "httpCache", {
|
|
603
|
+
get: function () {
|
|
604
|
+
var _a = this.props, cacheProp = _a.httpCache, ttl = _a.httpCacheTtl;
|
|
605
|
+
if (!cacheProp) {
|
|
606
|
+
return null;
|
|
607
|
+
}
|
|
608
|
+
if (cacheProp instanceof HttpCache) {
|
|
609
|
+
return cacheProp;
|
|
610
|
+
}
|
|
611
|
+
var cache = DefaultHttpCache.shared;
|
|
612
|
+
if (typeof ttl === 'number') {
|
|
613
|
+
cache.ttl = ttl;
|
|
614
|
+
}
|
|
615
|
+
return cache;
|
|
616
|
+
},
|
|
617
|
+
enumerable: false,
|
|
618
|
+
configurable: true
|
|
619
|
+
});
|
|
620
|
+
BaseSuggestions.prototype.render = function () {
|
|
621
|
+
var _this = this;
|
|
622
|
+
var _a = this.props, inputProps = _a.inputProps, hintText = _a.hintText, containerClassName = _a.containerClassName, hintClassName = _a.hintClassName, suggestionsClassName = _a.suggestionsClassName, suggestionClassName = _a.suggestionClassName, currentSuggestionClassName = _a.currentSuggestionClassName, customInput = _a.customInput, children = _a.children;
|
|
623
|
+
var _b = this.state, query = _b.query, isFocused = _b.isFocused, suggestions = _b.suggestions, suggestionIndex = _b.suggestionIndex, displaySuggestions = _b.displaySuggestions;
|
|
624
|
+
var Component = typeof customInput !== 'undefined' ? customInput : 'input';
|
|
625
|
+
var optionsExpanded = isFocused && suggestions && displaySuggestions && suggestions.length > 0;
|
|
626
|
+
return (React__default.default.createElement("div", { role: "combobox", "aria-expanded": optionsExpanded ? 'true' : 'false', "aria-owns": this.uid, "aria-controls": this.uid, "aria-haspopup": "listbox", className: containerClassName || 'react-dadata react-dadata__container' },
|
|
627
|
+
React__default.default.createElement("div", null,
|
|
628
|
+
React__default.default.createElement(Component, __assign({ autoComplete: "off", className: "react-dadata__input" }, inputProps, { value: query, ref: function (input) {
|
|
629
|
+
_this.textInput = input;
|
|
630
|
+
}, onChange: this.handleInputChange, onKeyPress: this.handleInputKeyPress, onKeyDown: this.handleInputKeyDown, onFocus: this.handleInputFocus, onBlur: this.handleInputBlur }))),
|
|
631
|
+
optionsExpanded && (React__default.default.createElement("ul", { id: this.uid, "aria-expanded": true, role: "listbox", className: suggestionsClassName || 'react-dadata__suggestions' },
|
|
632
|
+
typeof hintText !== 'undefined' && (React__default.default.createElement("div", { className: hintClassName || 'react-dadata__suggestion-note' }, hintText)),
|
|
633
|
+
suggestions.map(function (suggestion, index) {
|
|
634
|
+
var suggestionClass = suggestionClassName || 'react-dadata__suggestion';
|
|
635
|
+
if (index === suggestionIndex) {
|
|
636
|
+
suggestionClass += " ".concat(currentSuggestionClassName || 'react-dadata__suggestion--current');
|
|
637
|
+
}
|
|
638
|
+
return (React__default.default.createElement("button", { role: "option", "aria-selected": index === suggestionIndex ? 'true' : 'false', key: _this.getSuggestionKey(suggestion), onMouseDown: _this.onSuggestionClick.bind(_this, index), className: suggestionClass }, _this.renderOption(suggestion)));
|
|
639
|
+
}))),
|
|
640
|
+
children));
|
|
641
|
+
};
|
|
642
|
+
return BaseSuggestions;
|
|
643
|
+
}(React__default.default.PureComponent));
|
|
644
|
+
|
|
645
|
+
let IDX = 36;
|
|
646
|
+
let HEX = "";
|
|
647
|
+
while (IDX--) {
|
|
648
|
+
HEX += IDX.toString(36);
|
|
649
|
+
}
|
|
650
|
+
function uid(len = 11) {
|
|
651
|
+
let str = "";
|
|
652
|
+
let num = len;
|
|
653
|
+
while (num--) {
|
|
654
|
+
str += HEX[Math.random() * 36 | 0];
|
|
655
|
+
}
|
|
656
|
+
return str;
|
|
657
|
+
}
|
|
658
|
+
|
|
659
|
+
const escapeRegexp = (term) => term.replace(/[|\\{}()[\]^$+*?.-]/g, (char) => `\\${char}`);
|
|
660
|
+
const termsToRegExpString = (terms) => terms.replace(/\s{2,}/g, " ").split(" ").join("|");
|
|
661
|
+
const regexpQuery = ({
|
|
662
|
+
terms,
|
|
663
|
+
matchExactly = false
|
|
664
|
+
}) => {
|
|
665
|
+
if (typeof terms !== "string") {
|
|
666
|
+
throw new TypeError("Expected a string");
|
|
667
|
+
}
|
|
668
|
+
const escapedTerms = escapeRegexp(terms.trim());
|
|
669
|
+
return `(${matchExactly ? escapedTerms : termsToRegExpString(escapedTerms)})`;
|
|
670
|
+
};
|
|
671
|
+
const buildRegexp = ({
|
|
672
|
+
terms,
|
|
673
|
+
matchExactly = false
|
|
674
|
+
}) => {
|
|
675
|
+
try {
|
|
676
|
+
const fromString = /^([/~@;%#'])(.*?)\1([gimsuy]*)$/.exec(terms);
|
|
677
|
+
if (fromString) {
|
|
678
|
+
return new RegExp(fromString[2], fromString[3]);
|
|
679
|
+
}
|
|
680
|
+
return new RegExp(regexpQuery({ terms, matchExactly }), "ig");
|
|
681
|
+
} catch (e) {
|
|
682
|
+
throw new TypeError("Expected terms to be either a string or a RegExp!");
|
|
683
|
+
}
|
|
684
|
+
};
|
|
685
|
+
|
|
686
|
+
const hasProp = (prop) => (obj) => obj !== null && typeof obj === "object" && prop in obj;
|
|
687
|
+
const hasMatch = hasProp("match");
|
|
688
|
+
const chunkExists = (chunk) => typeof chunk !== "undefined";
|
|
689
|
+
function clip({
|
|
690
|
+
curr,
|
|
691
|
+
next,
|
|
692
|
+
prev,
|
|
693
|
+
clipBy = 3
|
|
694
|
+
}) {
|
|
695
|
+
const words = curr.text.split(" ");
|
|
696
|
+
const len = words.length;
|
|
697
|
+
if (curr.match || clipBy >= len) {
|
|
698
|
+
return curr.text;
|
|
699
|
+
}
|
|
700
|
+
const ellipsis = "...";
|
|
701
|
+
if (chunkExists(next) && chunkExists(prev) && hasMatch(prev) && hasMatch(next)) {
|
|
702
|
+
if (len > clipBy * 2) {
|
|
703
|
+
return [
|
|
704
|
+
...words.slice(0, clipBy),
|
|
705
|
+
ellipsis,
|
|
706
|
+
...words.slice(-clipBy)
|
|
707
|
+
].join(" ");
|
|
708
|
+
}
|
|
709
|
+
return curr.text;
|
|
710
|
+
}
|
|
711
|
+
if (chunkExists(next) && hasMatch(next)) {
|
|
712
|
+
return [ellipsis, ...words.slice(-clipBy)].join(" ");
|
|
713
|
+
}
|
|
714
|
+
if (chunkExists(prev) && hasMatch(prev)) {
|
|
715
|
+
return [...words.slice(0, clipBy), ellipsis].join(" ");
|
|
716
|
+
}
|
|
717
|
+
return curr.text;
|
|
718
|
+
}
|
|
719
|
+
|
|
720
|
+
var __defProp = Object.defineProperty;
|
|
721
|
+
var __defProps = Object.defineProperties;
|
|
722
|
+
var __getOwnPropDescs = Object.getOwnPropertyDescriptors;
|
|
723
|
+
var __getOwnPropSymbols = Object.getOwnPropertySymbols;
|
|
724
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
725
|
+
var __propIsEnum = Object.prototype.propertyIsEnumerable;
|
|
726
|
+
var __defNormalProp = (obj, key, value) => key in obj ? __defProp(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
|
|
727
|
+
var __spreadValues = (a, b) => {
|
|
728
|
+
for (var prop in b || (b = {}))
|
|
729
|
+
if (__hasOwnProp.call(b, prop))
|
|
730
|
+
__defNormalProp(a, prop, b[prop]);
|
|
731
|
+
if (__getOwnPropSymbols)
|
|
732
|
+
for (var prop of __getOwnPropSymbols(b)) {
|
|
733
|
+
if (__propIsEnum.call(b, prop))
|
|
734
|
+
__defNormalProp(a, prop, b[prop]);
|
|
735
|
+
}
|
|
736
|
+
return a;
|
|
737
|
+
};
|
|
738
|
+
var __spreadProps = (a, b) => __defProps(a, __getOwnPropDescs(b));
|
|
739
|
+
const hasLength = (str) => str.length > 0;
|
|
740
|
+
const highlightWords = ({
|
|
741
|
+
text,
|
|
742
|
+
query,
|
|
743
|
+
clipBy,
|
|
744
|
+
matchExactly = false
|
|
745
|
+
}) => {
|
|
746
|
+
const safeQuery = typeof query === "string" ? query.trim() : query;
|
|
747
|
+
if (safeQuery === "") {
|
|
748
|
+
return [
|
|
749
|
+
{
|
|
750
|
+
key: uid(),
|
|
751
|
+
text,
|
|
752
|
+
match: false
|
|
753
|
+
}
|
|
754
|
+
];
|
|
755
|
+
}
|
|
756
|
+
const searchRegexp = buildRegexp({ terms: query, matchExactly });
|
|
757
|
+
return text.split(searchRegexp).filter(hasLength).map((str) => ({
|
|
758
|
+
// Compose the object for a match
|
|
759
|
+
key: uid(),
|
|
760
|
+
text: str,
|
|
761
|
+
match: matchExactly ? str.toLowerCase() === safeQuery.toLowerCase() : searchRegexp.test(str)
|
|
762
|
+
})).map((chunk, index, chunks) => __spreadValues(__spreadValues({}, chunk), typeof clipBy === "number" && {
|
|
763
|
+
// We only overwrite the text if there is a clip
|
|
764
|
+
text: clip(__spreadProps(__spreadValues(__spreadValues({
|
|
765
|
+
curr: chunk
|
|
766
|
+
}, index < chunks.length - 1 && { next: chunks[index + 1] }), index > 0 && { prev: chunks[index - 1] }), {
|
|
767
|
+
// If this wasn't the first chunk, set the previous chunk
|
|
768
|
+
clipBy
|
|
769
|
+
}))
|
|
770
|
+
}));
|
|
771
|
+
};
|
|
772
|
+
|
|
773
|
+
var __extends$5 = (undefined && undefined.__extends) || (function () {
|
|
774
|
+
var extendStatics = function (d, b) {
|
|
775
|
+
extendStatics = Object.setPrototypeOf ||
|
|
776
|
+
({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
|
|
777
|
+
function (d, b) { for (var p in b) if (Object.prototype.hasOwnProperty.call(b, p)) d[p] = b[p]; };
|
|
778
|
+
return extendStatics(d, b);
|
|
779
|
+
};
|
|
780
|
+
return function (d, b) {
|
|
781
|
+
if (typeof b !== "function" && b !== null)
|
|
782
|
+
throw new TypeError("Class extends value " + String(b) + " is not a constructor or null");
|
|
783
|
+
extendStatics(d, b);
|
|
784
|
+
function __() { this.constructor = d; }
|
|
785
|
+
d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
|
|
786
|
+
};
|
|
787
|
+
})();
|
|
788
|
+
var HighlightWords = /** @class */ (function (_super) {
|
|
789
|
+
__extends$5(HighlightWords, _super);
|
|
790
|
+
function HighlightWords() {
|
|
791
|
+
return _super !== null && _super.apply(this, arguments) || this;
|
|
792
|
+
}
|
|
793
|
+
HighlightWords.prototype.render = function () {
|
|
794
|
+
var _a = this.props, text = _a.text, words = _a.words, highlightClassName = _a.highlightClassName, _b = _a.tagName, tagName = _b === void 0 ? 'span' : _b;
|
|
795
|
+
var query = typeof words === 'string' ? words : words.join(' ');
|
|
796
|
+
var chunks = highlightWords({ text: text, query: query });
|
|
797
|
+
return (React__default.default.createElement("span", { "aria-label": text }, chunks.map(function (chunk) {
|
|
798
|
+
if (!chunk.match) {
|
|
799
|
+
return React__default.default.createElement("span", { key: chunk.key, "aria-hidden": true }, chunk.text);
|
|
800
|
+
}
|
|
801
|
+
var Component = tagName;
|
|
802
|
+
return (React__default.default.createElement(Component, { key: chunk.key, className: highlightClassName, "aria-hidden": true }, chunk.text));
|
|
803
|
+
})));
|
|
804
|
+
};
|
|
805
|
+
return HighlightWords;
|
|
806
|
+
}(React.PureComponent));
|
|
807
|
+
|
|
808
|
+
var __extends$4 = (undefined && undefined.__extends) || (function () {
|
|
809
|
+
var extendStatics = function (d, b) {
|
|
810
|
+
extendStatics = Object.setPrototypeOf ||
|
|
811
|
+
({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
|
|
812
|
+
function (d, b) { for (var p in b) if (Object.prototype.hasOwnProperty.call(b, p)) d[p] = b[p]; };
|
|
813
|
+
return extendStatics(d, b);
|
|
814
|
+
};
|
|
815
|
+
return function (d, b) {
|
|
816
|
+
if (typeof b !== "function" && b !== null)
|
|
817
|
+
throw new TypeError("Class extends value " + String(b) + " is not a constructor or null");
|
|
818
|
+
extendStatics(d, b);
|
|
819
|
+
function __() { this.constructor = d; }
|
|
820
|
+
d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
|
|
821
|
+
};
|
|
822
|
+
})();
|
|
823
|
+
/** @class */ ((function (_super) {
|
|
824
|
+
__extends$4(AddressSuggestions, _super);
|
|
825
|
+
function AddressSuggestions() {
|
|
826
|
+
var _this = _super !== null && _super.apply(this, arguments) || this;
|
|
827
|
+
_this.loadSuggestionsUrl = 'https://suggestions.dadata.ru/suggestions/api/4_1/rs/suggest/address';
|
|
828
|
+
_this.getLoadSuggestionsData = function () {
|
|
829
|
+
var _a = _this.props, count = _a.count, filterFromBound = _a.filterFromBound, filterToBound = _a.filterToBound, filterLocations = _a.filterLocations, filterLocationsBoost = _a.filterLocationsBoost, filterLanguage = _a.filterLanguage, filterRestrictValue = _a.filterRestrictValue;
|
|
830
|
+
var query = _this.state.query;
|
|
831
|
+
// TODO: Type this params
|
|
832
|
+
var requestPayload = {
|
|
833
|
+
query: query,
|
|
834
|
+
count: count || 10,
|
|
835
|
+
};
|
|
836
|
+
// Ограничение поиска по типу
|
|
837
|
+
if (filterFromBound && filterToBound) {
|
|
838
|
+
requestPayload.from_bound = { value: filterFromBound };
|
|
839
|
+
requestPayload.to_bound = { value: filterToBound };
|
|
840
|
+
}
|
|
841
|
+
// Язык подсказок
|
|
842
|
+
if (filterLanguage) {
|
|
843
|
+
requestPayload.language = filterLanguage;
|
|
844
|
+
}
|
|
845
|
+
// Сужение области поиска
|
|
846
|
+
if (filterLocations) {
|
|
847
|
+
requestPayload.locations = filterLocations;
|
|
848
|
+
}
|
|
849
|
+
// Приоритет города при ранжировании
|
|
850
|
+
if (filterLocationsBoost) {
|
|
851
|
+
requestPayload.locations_boost = filterLocationsBoost;
|
|
852
|
+
}
|
|
853
|
+
// @see https://confluence.hflabs.ru/pages/viewpage.action?pageId=1023737934
|
|
854
|
+
if (filterRestrictValue) {
|
|
855
|
+
requestPayload.restrict_value = true;
|
|
856
|
+
}
|
|
857
|
+
return requestPayload;
|
|
858
|
+
};
|
|
859
|
+
_this.renderOption = function (suggestion) {
|
|
860
|
+
var _a = _this.props, renderOption = _a.renderOption, highlightClassName = _a.highlightClassName;
|
|
861
|
+
var query = _this.state.query;
|
|
862
|
+
return renderOption ? (renderOption(suggestion, query)) : (React__default.default.createElement(HighlightWords, { highlightClassName: highlightClassName || 'react-dadata--highlighted', words: _this.getHighlightWords(), tagName: "mark", text: suggestion.value }));
|
|
863
|
+
};
|
|
864
|
+
return _this;
|
|
865
|
+
}
|
|
866
|
+
return AddressSuggestions;
|
|
867
|
+
})(BaseSuggestions));
|
|
868
|
+
|
|
869
|
+
var __extends$3 = (undefined && undefined.__extends) || (function () {
|
|
870
|
+
var extendStatics = function (d, b) {
|
|
871
|
+
extendStatics = Object.setPrototypeOf ||
|
|
872
|
+
({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
|
|
873
|
+
function (d, b) { for (var p in b) if (Object.prototype.hasOwnProperty.call(b, p)) d[p] = b[p]; };
|
|
874
|
+
return extendStatics(d, b);
|
|
875
|
+
};
|
|
876
|
+
return function (d, b) {
|
|
877
|
+
if (typeof b !== "function" && b !== null)
|
|
878
|
+
throw new TypeError("Class extends value " + String(b) + " is not a constructor or null");
|
|
879
|
+
extendStatics(d, b);
|
|
880
|
+
function __() { this.constructor = d; }
|
|
881
|
+
d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
|
|
882
|
+
};
|
|
883
|
+
})();
|
|
884
|
+
var PartySuggestions = /** @class */ (function (_super) {
|
|
885
|
+
__extends$3(PartySuggestions, _super);
|
|
886
|
+
function PartySuggestions() {
|
|
887
|
+
var _this = _super !== null && _super.apply(this, arguments) || this;
|
|
888
|
+
_this.loadSuggestionsUrl = 'https://suggestions.dadata.ru/suggestions/api/4_1/rs/suggest/party';
|
|
889
|
+
_this.getLoadSuggestionsData = function () {
|
|
890
|
+
var _a = _this.props, count = _a.count, filterStatus = _a.filterStatus, filterType = _a.filterType, filterOkved = _a.filterOkved, filterLocations = _a.filterLocations, filterLocationsBoost = _a.filterLocationsBoost;
|
|
891
|
+
var query = _this.state.query;
|
|
892
|
+
var requestPayload = {
|
|
893
|
+
query: query,
|
|
894
|
+
count: count || 10,
|
|
895
|
+
};
|
|
896
|
+
// Ограничение по статусу организации
|
|
897
|
+
if (filterStatus) {
|
|
898
|
+
requestPayload.status = filterStatus;
|
|
899
|
+
}
|
|
900
|
+
// Ограничение по ОКВЭД
|
|
901
|
+
// @see https://confluence.hflabs.ru/pages/viewpage.action?pageId=1093075333
|
|
902
|
+
if (filterOkved) {
|
|
903
|
+
requestPayload.okved = filterOkved;
|
|
904
|
+
}
|
|
905
|
+
// Ограничение по типу организации
|
|
906
|
+
if (filterType) {
|
|
907
|
+
requestPayload.type = filterType;
|
|
908
|
+
}
|
|
909
|
+
// Сужение области поиска
|
|
910
|
+
if (filterLocations) {
|
|
911
|
+
requestPayload.locations = filterLocations;
|
|
912
|
+
}
|
|
913
|
+
// Приоритет города при ранжировании
|
|
914
|
+
if (filterLocationsBoost) {
|
|
915
|
+
requestPayload.locations_boost = filterLocationsBoost;
|
|
916
|
+
}
|
|
917
|
+
return requestPayload;
|
|
918
|
+
};
|
|
919
|
+
_this.getSuggestionKey = function (suggestion) { return suggestion.data.hid; };
|
|
920
|
+
_this.renderOption = function (suggestion) {
|
|
921
|
+
var _a = _this.props, renderOption = _a.renderOption, highlightClassName = _a.highlightClassName;
|
|
922
|
+
var query = _this.state.query;
|
|
923
|
+
return renderOption ? (renderOption(suggestion, query)) : (React__default.default.createElement("div", null,
|
|
924
|
+
React__default.default.createElement("div", { className: suggestion.data.state.status === 'LIQUIDATED' ? 'react-dadata__suggestion--line-through' : undefined },
|
|
925
|
+
React__default.default.createElement(HighlightWords, { highlightClassName: highlightClassName || 'react-dadata--highlighted', words: _this.getHighlightWords(), text: suggestion.value })),
|
|
926
|
+
React__default.default.createElement("div", { className: "react-dadata__suggestion-subtitle" },
|
|
927
|
+
suggestion.data.inn && React__default.default.createElement("div", { className: "react-dadata__suggestion-subtitle-item" }, suggestion.data.inn),
|
|
928
|
+
suggestion.data.address && suggestion.data.address.value && (React__default.default.createElement("div", { className: "react-dadata__suggestion-subtitle-item" },
|
|
929
|
+
React__default.default.createElement(HighlightWords, { highlightClassName: highlightClassName || 'react-dadata--highlighted', words: _this.getHighlightWords(), text: suggestion.data.address.value }))))));
|
|
930
|
+
};
|
|
931
|
+
return _this;
|
|
932
|
+
}
|
|
933
|
+
return PartySuggestions;
|
|
934
|
+
}(BaseSuggestions));
|
|
935
|
+
|
|
936
|
+
var __extends$2 = (undefined && undefined.__extends) || (function () {
|
|
937
|
+
var extendStatics = function (d, b) {
|
|
938
|
+
extendStatics = Object.setPrototypeOf ||
|
|
939
|
+
({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
|
|
940
|
+
function (d, b) { for (var p in b) if (Object.prototype.hasOwnProperty.call(b, p)) d[p] = b[p]; };
|
|
941
|
+
return extendStatics(d, b);
|
|
942
|
+
};
|
|
943
|
+
return function (d, b) {
|
|
944
|
+
if (typeof b !== "function" && b !== null)
|
|
945
|
+
throw new TypeError("Class extends value " + String(b) + " is not a constructor or null");
|
|
946
|
+
extendStatics(d, b);
|
|
947
|
+
function __() { this.constructor = d; }
|
|
948
|
+
d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
|
|
949
|
+
};
|
|
950
|
+
})();
|
|
951
|
+
/** @class */ ((function (_super) {
|
|
952
|
+
__extends$2(BankSuggestions, _super);
|
|
953
|
+
function BankSuggestions() {
|
|
954
|
+
var _this = _super !== null && _super.apply(this, arguments) || this;
|
|
955
|
+
_this.loadSuggestionsUrl = 'https://suggestions.dadata.ru/suggestions/api/4_1/rs/suggest/bank';
|
|
956
|
+
_this.getLoadSuggestionsData = function () {
|
|
957
|
+
var _a = _this.props, count = _a.count, filterStatus = _a.filterStatus, filterType = _a.filterType, filterLocations = _a.filterLocations, filterLocationsBoost = _a.filterLocationsBoost;
|
|
958
|
+
var query = _this.state.query;
|
|
959
|
+
var requestPayload = {
|
|
960
|
+
query: query,
|
|
961
|
+
count: count || 10,
|
|
962
|
+
};
|
|
963
|
+
// Ограничение по статусу организации
|
|
964
|
+
if (filterStatus) {
|
|
965
|
+
requestPayload.status = filterStatus;
|
|
966
|
+
}
|
|
967
|
+
// Ограничение по типу организации
|
|
968
|
+
if (filterType) {
|
|
969
|
+
requestPayload.type = filterType;
|
|
970
|
+
}
|
|
971
|
+
// Сужение области поиска
|
|
972
|
+
if (filterLocations) {
|
|
973
|
+
requestPayload.locations = filterLocations;
|
|
974
|
+
}
|
|
975
|
+
// Приоритет города при ранжировании
|
|
976
|
+
if (filterLocationsBoost) {
|
|
977
|
+
requestPayload.locations_boost = filterLocationsBoost;
|
|
978
|
+
}
|
|
979
|
+
return requestPayload;
|
|
980
|
+
};
|
|
981
|
+
_this.getSuggestionKey = function (suggestion) { return "".concat(suggestion.data.bic); };
|
|
982
|
+
_this.renderOption = function (suggestion) {
|
|
983
|
+
var _a = _this.props, renderOption = _a.renderOption, highlightClassName = _a.highlightClassName;
|
|
984
|
+
var query = _this.state.query;
|
|
985
|
+
return renderOption ? (renderOption(suggestion, query)) : (React__default.default.createElement("div", null,
|
|
986
|
+
React__default.default.createElement("div", { className: suggestion.data.state.status === 'LIQUIDATED' ? 'react-dadata__suggestion--line-through' : undefined },
|
|
987
|
+
React__default.default.createElement(HighlightWords, { highlightClassName: highlightClassName || 'react-dadata--highlighted', words: _this.getHighlightWords(), text: suggestion.value })),
|
|
988
|
+
React__default.default.createElement("div", { className: "react-dadata__suggestion-subtitle" },
|
|
989
|
+
suggestion.data.bic && React__default.default.createElement("div", { className: "react-dadata__suggestion-subtitle-item" }, suggestion.data.bic),
|
|
990
|
+
suggestion.data.address && suggestion.data.address.value && (React__default.default.createElement("div", { className: "react-dadata__suggestion-subtitle-item" },
|
|
991
|
+
React__default.default.createElement(HighlightWords, { highlightClassName: highlightClassName || 'react-dadata--highlighted', words: _this.getHighlightWords(), text: suggestion.data.address.value }))))));
|
|
992
|
+
};
|
|
993
|
+
return _this;
|
|
994
|
+
}
|
|
995
|
+
return BankSuggestions;
|
|
996
|
+
})(BaseSuggestions));
|
|
997
|
+
|
|
998
|
+
var __extends$1 = (undefined && undefined.__extends) || (function () {
|
|
999
|
+
var extendStatics = function (d, b) {
|
|
1000
|
+
extendStatics = Object.setPrototypeOf ||
|
|
1001
|
+
({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
|
|
1002
|
+
function (d, b) { for (var p in b) if (Object.prototype.hasOwnProperty.call(b, p)) d[p] = b[p]; };
|
|
1003
|
+
return extendStatics(d, b);
|
|
1004
|
+
};
|
|
1005
|
+
return function (d, b) {
|
|
1006
|
+
if (typeof b !== "function" && b !== null)
|
|
1007
|
+
throw new TypeError("Class extends value " + String(b) + " is not a constructor or null");
|
|
1008
|
+
extendStatics(d, b);
|
|
1009
|
+
function __() { this.constructor = d; }
|
|
1010
|
+
d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
|
|
1011
|
+
};
|
|
1012
|
+
})();
|
|
1013
|
+
/** @class */ ((function (_super) {
|
|
1014
|
+
__extends$1(FioSuggestions, _super);
|
|
1015
|
+
function FioSuggestions() {
|
|
1016
|
+
var _this = _super !== null && _super.apply(this, arguments) || this;
|
|
1017
|
+
_this.loadSuggestionsUrl = 'https://suggestions.dadata.ru/suggestions/api/4_1/rs/suggest/fio';
|
|
1018
|
+
_this.getLoadSuggestionsData = function () {
|
|
1019
|
+
var _a = _this.props, count = _a.count, filterGender = _a.filterGender, filterParts = _a.filterParts;
|
|
1020
|
+
var query = _this.state.query;
|
|
1021
|
+
var requestPayload = {
|
|
1022
|
+
query: query,
|
|
1023
|
+
count: count || 10,
|
|
1024
|
+
};
|
|
1025
|
+
// Ограничение по полу
|
|
1026
|
+
if (filterGender) {
|
|
1027
|
+
requestPayload.gender = filterGender;
|
|
1028
|
+
}
|
|
1029
|
+
// Ограничение по части ФИО
|
|
1030
|
+
if (filterParts) {
|
|
1031
|
+
requestPayload.parts = filterParts;
|
|
1032
|
+
}
|
|
1033
|
+
return requestPayload;
|
|
1034
|
+
};
|
|
1035
|
+
_this.getSuggestionKey = function (suggestion) {
|
|
1036
|
+
return "name:".concat(suggestion.data.name || '', "surname:").concat(suggestion.data.surname || '', "patronymic:").concat(suggestion.data.patronymic || '');
|
|
1037
|
+
};
|
|
1038
|
+
_this.renderOption = function (suggestion) {
|
|
1039
|
+
var _a = _this.props, renderOption = _a.renderOption, highlightClassName = _a.highlightClassName;
|
|
1040
|
+
var query = _this.state.query;
|
|
1041
|
+
return renderOption ? (renderOption(suggestion, query)) : (React__default.default.createElement("div", null,
|
|
1042
|
+
React__default.default.createElement(HighlightWords, { highlightClassName: highlightClassName || 'react-dadata--highlighted', words: _this.getHighlightWords(), text: suggestion.value })));
|
|
1043
|
+
};
|
|
1044
|
+
return _this;
|
|
1045
|
+
}
|
|
1046
|
+
return FioSuggestions;
|
|
1047
|
+
})(BaseSuggestions));
|
|
1048
|
+
|
|
1049
|
+
var __extends = (undefined && undefined.__extends) || (function () {
|
|
1050
|
+
var extendStatics = function (d, b) {
|
|
1051
|
+
extendStatics = Object.setPrototypeOf ||
|
|
1052
|
+
({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
|
|
1053
|
+
function (d, b) { for (var p in b) if (Object.prototype.hasOwnProperty.call(b, p)) d[p] = b[p]; };
|
|
1054
|
+
return extendStatics(d, b);
|
|
1055
|
+
};
|
|
1056
|
+
return function (d, b) {
|
|
1057
|
+
if (typeof b !== "function" && b !== null)
|
|
1058
|
+
throw new TypeError("Class extends value " + String(b) + " is not a constructor or null");
|
|
1059
|
+
extendStatics(d, b);
|
|
1060
|
+
function __() { this.constructor = d; }
|
|
1061
|
+
d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
|
|
1062
|
+
};
|
|
1063
|
+
})();
|
|
1064
|
+
/** @class */ ((function (_super) {
|
|
1065
|
+
__extends(EmailSuggestions, _super);
|
|
1066
|
+
function EmailSuggestions() {
|
|
1067
|
+
var _this = _super !== null && _super.apply(this, arguments) || this;
|
|
1068
|
+
_this.loadSuggestionsUrl = 'https://suggestions.dadata.ru/suggestions/api/4_1/rs/suggest/email';
|
|
1069
|
+
_this.getLoadSuggestionsData = function () {
|
|
1070
|
+
var count = _this.props.count;
|
|
1071
|
+
var query = _this.state.query;
|
|
1072
|
+
return {
|
|
1073
|
+
query: query,
|
|
1074
|
+
count: count || 10,
|
|
1075
|
+
};
|
|
1076
|
+
};
|
|
1077
|
+
_this.getSuggestionKey = function (suggestion) { return suggestion.value; };
|
|
1078
|
+
_this.renderOption = function (suggestion) {
|
|
1079
|
+
var _a = _this.props, renderOption = _a.renderOption, highlightClassName = _a.highlightClassName;
|
|
1080
|
+
var query = _this.state.query;
|
|
1081
|
+
return renderOption ? (renderOption(suggestion, query)) : (React__default.default.createElement("div", null,
|
|
1082
|
+
React__default.default.createElement(HighlightWords, { highlightClassName: highlightClassName || 'react-dadata--highlighted', words: _this.getHighlightWords(), text: suggestion.value })));
|
|
1083
|
+
};
|
|
1084
|
+
return _this;
|
|
1085
|
+
}
|
|
1086
|
+
return EmailSuggestions;
|
|
1087
|
+
})(BaseSuggestions));
|
|
1088
|
+
|
|
1089
|
+
function DadataHintField(props) {
|
|
1090
|
+
const {
|
|
1091
|
+
delay,
|
|
1092
|
+
inputProps,
|
|
1093
|
+
setValue,
|
|
1094
|
+
input,
|
|
1095
|
+
meta,
|
|
1096
|
+
token
|
|
1097
|
+
} = props;
|
|
1098
|
+
const dadataInputProps = React.useMemo(() => {
|
|
1099
|
+
return {
|
|
1100
|
+
...inputProps,
|
|
1101
|
+
className: clsx__default.default('react-dadata__input', meta.active && 'input_state_focus', meta.error && meta.touched && 'input_state_error'),
|
|
1102
|
+
// https://www.npmjs.com/package/react-dadata
|
|
1103
|
+
// "Свойство value игнорируется."
|
|
1104
|
+
// value: input.value,
|
|
1105
|
+
inputValue: input.value,
|
|
1106
|
+
onFocus: input.onFocus,
|
|
1107
|
+
onBlur: input.onBlur,
|
|
1108
|
+
onChange: input.onChange
|
|
1109
|
+
};
|
|
1110
|
+
}, [inputProps, meta.active, meta.error, meta.touched, input.value, input.onFocus, input.onBlur, input.onChange]);
|
|
1111
|
+
return /*#__PURE__*/React__default.default.createElement(PartySuggestions, {
|
|
1112
|
+
customInput: DadataСustomInput,
|
|
1113
|
+
delay: delay || 750,
|
|
1114
|
+
inputProps: dadataInputProps,
|
|
1115
|
+
minChars: 3,
|
|
1116
|
+
token: token,
|
|
1117
|
+
onChange: setValue
|
|
1118
|
+
});
|
|
1119
|
+
}
|
|
1120
|
+
DadataHintField.propTypes = {
|
|
1121
|
+
delay: PropTypes__default.default.number,
|
|
1122
|
+
input: PropTypes__default.default.object,
|
|
1123
|
+
inputProps: PropTypes__default.default.object,
|
|
1124
|
+
meta: PropTypes__default.default.object,
|
|
1125
|
+
setValue: PropTypes__default.default.func,
|
|
1126
|
+
token: PropTypes__default.default.string
|
|
1127
|
+
};
|
|
1128
|
+
function DadataСustomInput(props) {
|
|
1129
|
+
const {
|
|
1130
|
+
inputValue,
|
|
1131
|
+
...otherProps
|
|
1132
|
+
} = props;
|
|
1133
|
+
return /*#__PURE__*/React__default.default.createElement(index.Input, Object.assign({}, otherProps, {
|
|
1134
|
+
value: inputValue
|
|
1135
|
+
}));
|
|
1136
|
+
}
|
|
1137
|
+
DadataСustomInput.propTypes = {
|
|
1138
|
+
inputValue: PropTypes__default.default.object
|
|
1139
|
+
};
|
|
1140
|
+
|
|
1141
|
+
exports.DadataHintField = DadataHintField;
|
|
@@ -3,6 +3,7 @@
|
|
|
3
3
|
var React = require('react');
|
|
4
4
|
var PropTypes = require('prop-types');
|
|
5
5
|
var clsx = require('clsx');
|
|
6
|
+
var _commonjsHelpers = require('../_commonjsHelpers-facfc6d6.js');
|
|
6
7
|
var defineProperty = require('../defineProperty-f9e5e1f3.js');
|
|
7
8
|
var ReactDOM = require('react-dom');
|
|
8
9
|
var index = require('./Input.js');
|
|
@@ -64,10 +65,6 @@ var PropTypes__default = /*#__PURE__*/_interopDefault(PropTypes);
|
|
|
64
65
|
var clsx__default = /*#__PURE__*/_interopDefault(clsx);
|
|
65
66
|
var ReactDOM__namespace = /*#__PURE__*/_interopNamespace(ReactDOM);
|
|
66
67
|
|
|
67
|
-
function getDefaultExportFromCjs (x) {
|
|
68
|
-
return x && x.__esModule && Object.prototype.hasOwnProperty.call(x, 'default') ? x['default'] : x;
|
|
69
|
-
}
|
|
70
|
-
|
|
71
68
|
var classnames = {exports: {}};
|
|
72
69
|
|
|
73
70
|
/*!
|
|
@@ -128,7 +125,7 @@ var classnames = {exports: {}};
|
|
|
128
125
|
} (classnames));
|
|
129
126
|
|
|
130
127
|
var classnamesExports = classnames.exports;
|
|
131
|
-
var r = /*@__PURE__*/getDefaultExportFromCjs(classnamesExports);
|
|
128
|
+
var r = /*@__PURE__*/_commonjsHelpers.getDefaultExportFromCjs(classnamesExports);
|
|
132
129
|
|
|
133
130
|
function requiredArgs(required, args) {
|
|
134
131
|
if (args.length < required) {
|
|
@@ -9175,7 +9172,7 @@ var reactFastCompare = function isEqual(a, b) {
|
|
|
9175
9172
|
}
|
|
9176
9173
|
};
|
|
9177
9174
|
|
|
9178
|
-
var isEqual = /*@__PURE__*/getDefaultExportFromCjs(reactFastCompare);
|
|
9175
|
+
var isEqual = /*@__PURE__*/_commonjsHelpers.getDefaultExportFromCjs(reactFastCompare);
|
|
9179
9176
|
|
|
9180
9177
|
var EMPTY_MODIFIERS$1 = [];
|
|
9181
9178
|
var usePopper = function usePopper(referenceElement, popperElement, options) {
|
|
@@ -9408,7 +9405,7 @@ if (__DEV__) {
|
|
|
9408
9405
|
|
|
9409
9406
|
var warning_1 = warning;
|
|
9410
9407
|
|
|
9411
|
-
var warning$1 = /*@__PURE__*/getDefaultExportFromCjs(warning_1);
|
|
9408
|
+
var warning$1 = /*@__PURE__*/_commonjsHelpers.getDefaultExportFromCjs(warning_1);
|
|
9412
9409
|
|
|
9413
9410
|
function Reference(_ref) {
|
|
9414
9411
|
var children = _ref.children,
|
|
@@ -10113,7 +10110,7 @@ function DatePickerInput(props) {
|
|
|
10113
10110
|
// datePickerProps.isStartDefaultNull ? null : new Date(),
|
|
10114
10111
|
// )
|
|
10115
10112
|
|
|
10116
|
-
const
|
|
10113
|
+
const start = React.useMemo(() => {
|
|
10117
10114
|
if (value) {
|
|
10118
10115
|
if (typeof value === 'string') {
|
|
10119
10116
|
return new Date(value);
|
|
@@ -10125,6 +10122,7 @@ function DatePickerInput(props) {
|
|
|
10125
10122
|
}
|
|
10126
10123
|
return new Date();
|
|
10127
10124
|
}, [value, datePickerProps.isStartDefaultNull]);
|
|
10125
|
+
const [startDate, setStartDate] = React.useState(start);
|
|
10128
10126
|
const [endDate, setEndDate] = React.useState(null);
|
|
10129
10127
|
|
|
10130
10128
|
// const onChangeDate = useCallback(
|
|
@@ -10136,8 +10134,8 @@ function DatePickerInput(props) {
|
|
|
10136
10134
|
// )
|
|
10137
10135
|
|
|
10138
10136
|
const handleChange = ([newStartDate, newEndDate]) => {
|
|
10139
|
-
onChange && onChange(newStartDate);
|
|
10140
|
-
|
|
10137
|
+
onChange && onChange(newStartDate, newEndDate);
|
|
10138
|
+
setStartDate(newStartDate);
|
|
10141
10139
|
setEndDate(newEndDate);
|
|
10142
10140
|
};
|
|
10143
10141
|
const renderDayContents = (day, date) => {
|
package/dist/components/Image.js
CHANGED
|
@@ -101,10 +101,10 @@ function Image(props) {
|
|
|
101
101
|
className: clsx__default.default('image__wrapper', imageWrapperClassName),
|
|
102
102
|
style: wrapperStyles
|
|
103
103
|
}, /*#__PURE__*/React__default.default.createElement("img", {
|
|
104
|
-
src: src,
|
|
105
104
|
alt: alt,
|
|
106
|
-
|
|
105
|
+
src: src,
|
|
107
106
|
style: imageStyles,
|
|
107
|
+
title: title,
|
|
108
108
|
className: clsx__default.default('image__item', imageWidthClass, imageHeightClass, imageClassName, borderClass, borderColorImageClass),
|
|
109
109
|
onError: onError
|
|
110
110
|
}), overlay, caption, children), after);
|
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
.react-dadata__container{position:relative}.react-dadata__input{border:1px solid #ccc;border-radius:4px;box-sizing:border-box;display:block;font-size:16px;height:38px;outline:none;padding:0 10px;width:100%}.react-dadata__input:focus{border-color:#007cd6;box-shadow:inset 0 1px 1px rgba(0,0,0,.075),0 0 0 3px rgba(0,124,214,.3)}.react-dadata__suggestions{background-color:#fff;border-radius:4px;box-shadow:0 1px 6px 3px rgba(0,0,0,.1);left:0;list-style:none;margin:0;overflow:hidden;padding:0;position:absolute;right:0;text-align:left;top:calc(100% + 8px);z-index:10}.react-dadata__suggestion-note{color:#828282;font-size:14px;padding:10px 10px 5px}.react-dadata__suggestion{background:none;border:none;box-sizing:border-box;cursor:pointer;display:block;font-size:15px;padding:7px 10px;text-align:left;width:100%}.react-dadata__suggestion--line-through{text-decoration:line-through}.react-dadata__suggestion-subtitle{color:#777;font-size:14px;margin-top:4px}.react-dadata__suggestion-subtitle-item{display:inline-block;margin-bottom:4px;margin-right:16px}.react-dadata__suggestion-subtitle-item:last-child{margin-right:0}.react-dadata__suggestion--current{background-color:rgba(0,124,214,.15)}.react-dadata__suggestion:hover{background-color:rgba(0,124,214,.1)}.react-dadata mark{background:none}.react-dadata--highlighted{color:#0094ff}.react-dadata {
|
|
2
|
+
&__container {
|
|
3
|
+
width: 100%;
|
|
4
|
+
^&__input {
|
|
5
|
+
color: var(--react-dadata-color);
|
|
6
|
+
padding: var(--react-dadata-padding);
|
|
7
|
+
border: 1px solid var(--react-dadata-border);
|
|
8
|
+
border-radius: var(--react-dadata-border-radius);
|
|
9
|
+
box-shadow: none;
|
|
10
|
+
&:hover {
|
|
11
|
+
border: solid 1px var(--react-dadata-hover-border);
|
|
12
|
+
}
|
|
13
|
+
}
|
|
14
|
+
}
|
|
15
|
+
&__suggestion {
|
|
16
|
+
position: relative !important;
|
|
17
|
+
&:hover {
|
|
18
|
+
background: var(--color-accent-tertiary);
|
|
19
|
+
}
|
|
20
|
+
}
|
|
21
|
+
&--highlighted {
|
|
22
|
+
color: var(--color-accent-primary);
|
|
23
|
+
}
|
|
24
|
+
& .input_state {
|
|
25
|
+
&_error {
|
|
26
|
+
border: solid 1px var(--react-dadata-error-border);
|
|
27
|
+
&:hover {
|
|
28
|
+
border: solid 1px var(--react-dadata-error-border);
|
|
29
|
+
}
|
|
30
|
+
}
|
|
31
|
+
&_focus {
|
|
32
|
+
border: solid 1px var(--react-dadata-focus-border);
|
|
33
|
+
}
|
|
34
|
+
}
|
|
35
|
+
}:root {
|
|
36
|
+
--react-dadata-padding: 8px 12px;
|
|
37
|
+
--react-dadata-border-radius: 6px;
|
|
38
|
+
--react-dadata-color: var(--color-surface-text-primary);
|
|
39
|
+
--react-dadata-border: var(--color-surface-border-tertiary);
|
|
40
|
+
--react-dadata-hover-border: var(--color-surface-border-quaternary);
|
|
41
|
+
--react-dadata-focus-border: var(--color-surface-border-quaternary);
|
|
42
|
+
--react-dadata-error-border: var(--color-error-border-primary);
|
|
43
|
+
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@itcase/ui",
|
|
3
|
-
"version": "1.0.
|
|
3
|
+
"version": "1.0.55",
|
|
4
4
|
"description": "UI components (Modal, Loader, Popup, etc)",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"Modal",
|
|
@@ -49,6 +49,7 @@
|
|
|
49
49
|
"prop-types": "^15.8.1",
|
|
50
50
|
"rc-slider": "^10.2.1",
|
|
51
51
|
"react": "^18.2.0",
|
|
52
|
+
"react-dadata": "^2.23.1",
|
|
52
53
|
"react-date-range": "^1.4.0",
|
|
53
54
|
"react-dom": "^18.2.0",
|
|
54
55
|
"react-inlinesvg": "^4.0.3",
|