intelicoreact 1.3.91 → 1.3.93

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.
@@ -13,13 +13,15 @@ var _fieldValueFormatters = require("../../../Functions/fieldValueFormatters");
13
13
  var _useDebounce = require("../../../Functions/useDebounce");
14
14
  var _useIsMobile = _interopRequireDefault(require("../../../Functions/useIsMobile"));
15
15
  var _Spinner = _interopRequireDefault(require("../../Layout/Spinner/Spinner"));
16
+ var _RadioInput = _interopRequireDefault(require("../RadioInput/RadioInput"));
16
17
  require("./DropdownLiveSearch.scss");
17
18
  function _getRequireWildcardCache(e) { if ("function" != typeof WeakMap) return null; var r = new WeakMap(), t = new WeakMap(); return (_getRequireWildcardCache = function (e) { return e ? t : r; })(e); }
18
19
  function _interopRequireWildcard(e, r) { if (!r && e && e.__esModule) return e; if (null === e || "object" != typeof e && "function" != typeof e) return { default: e }; var t = _getRequireWildcardCache(r); if (t && t.has(e)) return t.get(e); var n = { __proto__: null }, a = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var u in e) if ("default" !== u && Object.prototype.hasOwnProperty.call(e, u)) { var i = a ? Object.getOwnPropertyDescriptor(e, u) : null; i && (i.get || i.set) ? Object.defineProperty(n, u, i) : n[u] = e[u]; } return n.default = e, t && t.set(e, n), n; }
19
20
  const RC = "dropdown-live-search";
20
21
  const DropdownLiveSearch = _ref => {
21
- var _tabIndex$toString;
22
+ var _dropdownListRef$curr5, _dropdownListRef$curr6, _tabIndex$toString;
22
23
  let {
24
+ label,
23
25
  value,
24
26
  error,
25
27
  disabled,
@@ -55,12 +57,26 @@ const DropdownLiveSearch = _ref => {
55
57
  const dropdownLiveSearchRef = (0, _react.useRef)(null);
56
58
  const dropdownListBoxRef = (0, _react.useRef)(null);
57
59
  const dropdownListRef = (0, _react.useRef)(null);
60
+ const dropdownListHeaderRef = (0, _react.useRef)(null);
58
61
  const searchInputRef = (0, _react.useRef)(null);
62
+ const searchInputModalRef = (0, _react.useRef)(null);
59
63
  const searchValueRef = (0, _react.useRef)(labelByValue);
64
+ const wrapperRef = (0, _react.useRef)(null);
65
+ const [isScrollableList, setIsScrollableList] = (0, _react.useState)(null);
66
+ const [isFixedMaxHeight, setIsFixedMaxHeight] = (0, _react.useState)(false);
67
+ const [scrollTop, setScrollTop] = (0, _react.useState)(0);
68
+ const [scrollHeight, setScrollHeight] = (0, _react.useState)(1);
60
69
  const setSearchValue = val => {
61
70
  setSV(val);
62
71
  searchValueRef.current = val;
63
72
  };
73
+ const onWrapperClick = e => {
74
+ if (e.target === (wrapperRef === null || wrapperRef === void 0 ? void 0 : wrapperRef.current)) {
75
+ e.stopPropagation();
76
+ e.preventDefault();
77
+ setIsOpen(false);
78
+ }
79
+ };
64
80
  const [isFocusedByClick, setIsFocusedByClick] = (0, _react.useState)(false);
65
81
  const debouncedSearchTerm = (0, _useDebounce.useDebounce)({
66
82
  searchValue,
@@ -88,7 +104,7 @@ const DropdownLiveSearch = _ref => {
88
104
  }
89
105
  };
90
106
  const getMarkupForElement = (item, index, optTestId) => {
91
- var _item$value, _item$value2;
107
+ var _item$value, _item$value2, _item$customMobileIco;
92
108
  const lowerLabel = item.label.toLowerCase();
93
109
  const lowerSearchValue = searchValue.toLowerCase();
94
110
  return /*#__PURE__*/_react.default.createElement("button", {
@@ -97,13 +113,13 @@ const DropdownLiveSearch = _ref => {
97
113
  onClick: () => {
98
114
  onChange(item.value);
99
115
  setIsOpen(false);
100
- setSearchValue(item.label);
116
+ if (!withMobileLogic) setSearchValue(item.label);
101
117
  },
102
118
  className: (0, _classnames.default)("".concat(RC, "__list-item"), {
103
119
  ["".concat(RC, "__list-item_active")]: item.value === value,
104
120
  ["".concat(RC, "__list-item_disabled")]: item.disabled
105
121
  }, item.className)
106
- }, /*#__PURE__*/_react.default.createElement("span", {
122
+ }, !isMobile || isMobile && !withMobileLogic && /*#__PURE__*/_react.default.createElement("span", {
107
123
  className: (0, _classnames.default)("".concat(RC, "__active-icon"), {
108
124
  ["".concat(RC, "__active-icon_active")]: lowerLabel === lowerSearchValue
109
125
  })
@@ -113,16 +129,52 @@ const DropdownLiveSearch = _ref => {
113
129
  dangerouslySetInnerHTML: {
114
130
  __html: highlightedText(item.label, item.postfix)
115
131
  }
116
- }));
132
+ }), isMobile ? (_item$customMobileIco = item === null || item === void 0 ? void 0 : item.customMobileIcon) !== null && _item$customMobileIco !== void 0 ? _item$customMobileIco : /*#__PURE__*/_react.default.createElement(_RadioInput.default, {
133
+ value: item.value,
134
+ checked: value
135
+ }) : "");
117
136
  };
118
137
  const getListMarkUp = () => {
119
138
  return /*#__PURE__*/_react.default.createElement("div", {
139
+ className: (0, _classnames.default)("".concat(RC, "__container-wrapper")),
140
+ ref: wrapperRef,
141
+ onClick: isMobile ? onWrapperClick : () => {}
142
+ }, /*#__PURE__*/_react.default.createElement("div", {
143
+ className: (0, _classnames.default)("".concat(RC, "__list-wrapper"), {
144
+ ["".concat(RC, "__list-wrapper--fixed-height")]: isFixedMaxHeight,
145
+ ["".concat(RC, "__list-wrapper--with-bottom-shadow")]: isScrollableList && isMobile,
146
+ ["".concat(RC, "__list-wrapper--with-bottom-shadow-hidden")]: scrollTop === scrollHeight
147
+ })
148
+ }, /*#__PURE__*/_react.default.createElement("div", {
120
149
  id: "dropdown-live-search-list",
121
150
  className: (0, _classnames.default)("".concat(RC, "__container"), {
122
151
  ["".concat(RC, "__list-top")]: isListTop
123
152
  }),
124
153
  ref: dropdownListBoxRef
154
+ }, isMobile && /*#__PURE__*/_react.default.createElement("div", {
155
+ ref: dropdownListHeaderRef,
156
+ className: (0, _classnames.default)("".concat(RC, "__list-header"), {
157
+ ["".concat(RC, "__list-header-with-shadow")]: isScrollableList && isMobile,
158
+ ["".concat(RC, "__list-header-with-shadow-hidden")]: scrollTop === 0
159
+ })
125
160
  }, /*#__PURE__*/_react.default.createElement("div", {
161
+ className: (0, _classnames.default)("".concat(RC, "__list-header-row"))
162
+ }, /*#__PURE__*/_react.default.createElement("div", {
163
+ className: (0, _classnames.default)("".concat(RC, "__list-label"))
164
+ }, label), /*#__PURE__*/_react.default.createElement("div", {
165
+ className: (0, _classnames.default)("".concat(RC, "__list-close-icon")),
166
+ onClick: () => setIsOpen(false)
167
+ }, /*#__PURE__*/_react.default.createElement(_reactFeather.X, {
168
+ onClick: () => setIsOpen(false)
169
+ }))), isSearchable && /*#__PURE__*/_react.default.createElement("input", (0, _extends2.default)({
170
+ ref: searchInputModalRef,
171
+ className: "".concat(RC, "__input"),
172
+ value: isOpen ? searchValue : labelByValue,
173
+ onChange: handle.onInputChange,
174
+ placeholder: placeholder,
175
+ onFocus: searchableInputFocus,
176
+ tabIndex: -1
177
+ }, attributesOfNativeInput))), /*#__PURE__*/_react.default.createElement("div", {
126
178
  className: (0, _classnames.default)("".concat(RC, "__list"), {
127
179
  disabled: isLoading
128
180
  }),
@@ -131,11 +183,18 @@ const DropdownLiveSearch = _ref => {
131
183
  className: "".concat(RC, "__list-item ").concat(RC, "__list-item--no-options")
132
184
  }, noOptionsText)), isLoading && isOpen && /*#__PURE__*/_react.default.createElement(_Spinner.default, {
133
185
  size: options.length <= 3 ? "small" : null
134
- }));
186
+ }))));
135
187
  };
136
188
  const getListContainer = () => {
137
189
  return document.getElementById(dropdownId);
138
190
  };
191
+ (0, _react.useEffect)(() => {
192
+ if (isOpen && isMobile && dropdownListRef !== null && dropdownListRef !== void 0 && dropdownListRef.current && !searchValue) {
193
+ var _dropdownListRef$curr, _dropdownListRef$curr2, _dropdownListRef$curr3, _dropdownListRef$curr4;
194
+ setIsScrollableList((dropdownListRef === null || dropdownListRef === void 0 || (_dropdownListRef$curr = dropdownListRef.current) === null || _dropdownListRef$curr === void 0 ? void 0 : _dropdownListRef$curr.scrollHeight) > (dropdownListRef === null || dropdownListRef === void 0 || (_dropdownListRef$curr2 = dropdownListRef.current) === null || _dropdownListRef$curr2 === void 0 ? void 0 : _dropdownListRef$curr2.clientHeight));
195
+ setIsFixedMaxHeight(isScrollableList || (dropdownListRef === null || dropdownListRef === void 0 || (_dropdownListRef$curr3 = dropdownListRef.current) === null || _dropdownListRef$curr3 === void 0 ? void 0 : _dropdownListRef$curr3.scrollHeight) > (dropdownListRef === null || dropdownListRef === void 0 || (_dropdownListRef$curr4 = dropdownListRef.current) === null || _dropdownListRef$curr4 === void 0 ? void 0 : _dropdownListRef$curr4.clientHeight));
196
+ }
197
+ }, [isOpen, isMobile, isScrollableList, dropdownListRef === null || dropdownListRef === void 0 ? void 0 : dropdownListRef.current, dropdownListRef === null || dropdownListRef === void 0 || (_dropdownListRef$curr5 = dropdownListRef.current) === null || _dropdownListRef$curr5 === void 0 ? void 0 : _dropdownListRef$curr5.scrollHeight, dropdownListRef === null || dropdownListRef === void 0 || (_dropdownListRef$curr6 = dropdownListRef.current) === null || _dropdownListRef$curr6 === void 0 ? void 0 : _dropdownListRef$curr6.clientHeight]);
139
198
  (0, _react.useEffect)(() => {
140
199
  if (!value) setSearchValue("");
141
200
  }, [value]);
@@ -158,7 +217,13 @@ const DropdownLiveSearch = _ref => {
158
217
  const handle = {
159
218
  onInputClick: e => {
160
219
  if (!isOpen) setIsOpen(true);
161
- e.target.select();
220
+ if (isMobile && withMobileLogic) {
221
+ e.preventDefault();
222
+ e.stopPropagation();
223
+ e.target.blur();
224
+ } else {
225
+ e.target.select();
226
+ }
162
227
  },
163
228
  onInputChange: e => {
164
229
  let inputValue = e.target.value;
@@ -187,12 +252,12 @@ const DropdownLiveSearch = _ref => {
187
252
  }, [getListContainer]);
188
253
  (0, _react.useLayoutEffect)(() => {
189
254
  const list = document.getElementById("dropdown-live-search-list");
190
- if (list || isOpen) {
255
+ if ((list || isOpen) && !withMobileLogic) {
191
256
  var _dropdownLiveSearchRe;
192
257
  const dropdownWidth = dropdownLiveSearchRef === null || dropdownLiveSearchRef === void 0 || (_dropdownLiveSearchRe = dropdownLiveSearchRef.current) === null || _dropdownLiveSearchRe === void 0 ? void 0 : _dropdownLiveSearchRe.clientWidth;
193
258
  list.style.width = "".concat(dropdownWidth, "px");
194
259
  }
195
- }, [dropdownLiveSearchRef, isOpen]);
260
+ }, [dropdownLiveSearchRef, isOpen, withMobileLogic]);
196
261
  const doScrollCallback = (0, _react.useCallback)(e => {
197
262
  if (doRequest && typeof doRequest === "function") {
198
263
  if (Math.round(e.target.clientHeight + e.target.scrollTop) == e.target.scrollHeight) {
@@ -201,8 +266,17 @@ const DropdownLiveSearch = _ref => {
201
266
  }
202
267
  }, [options]);
203
268
  (0, _react.useEffect)(() => {
204
- if (!isOpen) setIsFocusedByClick(false);
269
+ if (!isOpen) {
270
+ setIsFocusedByClick(false);
271
+ if (withMobileLogic) setSearchValue("");
272
+ }
205
273
  if (isOpen && dropdownListRef && dropdownListRef.current) {
274
+ if (isMobile && withMobileLogic) {
275
+ var _dropdownListBoxRef$c, _dropdownListHeaderRe, _searchInputModalRef$;
276
+ doRequest("");
277
+ dropdownListRef.current.style.maxHeight = "".concat((dropdownListBoxRef === null || dropdownListBoxRef === void 0 || (_dropdownListBoxRef$c = dropdownListBoxRef.current) === null || _dropdownListBoxRef$c === void 0 || (_dropdownListBoxRef$c = _dropdownListBoxRef$c.getBoundingClientRect()) === null || _dropdownListBoxRef$c === void 0 ? void 0 : _dropdownListBoxRef$c.height) - (dropdownListHeaderRef === null || dropdownListHeaderRef === void 0 || (_dropdownListHeaderRe = dropdownListHeaderRef.current) === null || _dropdownListHeaderRe === void 0 || (_dropdownListHeaderRe = _dropdownListHeaderRe.getBoundingClientRect()) === null || _dropdownListHeaderRe === void 0 ? void 0 : _dropdownListHeaderRe.height), "px");
278
+ searchInputModalRef === null || searchInputModalRef === void 0 || (_searchInputModalRef$ = searchInputModalRef.current) === null || _searchInputModalRef$ === void 0 || _searchInputModalRef$.focus();
279
+ }
206
280
  dropdownListRef.current.addEventListener("scroll", doScrollCallback);
207
281
  }
208
282
  return () => {
@@ -232,7 +306,8 @@ const DropdownLiveSearch = _ref => {
232
306
  }, [getListContainer]);
233
307
  return /*#__PURE__*/_react.default.createElement("div", {
234
308
  className: (0, _classnames.default)(RC, className, {
235
- disabled: disabled
309
+ disabled: disabled,
310
+ ["".concat(RC, "-mobile")]: isMobile
236
311
  }),
237
312
  ref: dropdownLiveSearchRef
238
313
  }, /*#__PURE__*/_react.default.createElement("button", {
@@ -245,7 +320,7 @@ const DropdownLiveSearch = _ref => {
245
320
  }, isSearchable ? /*#__PURE__*/_react.default.createElement("input", (0, _extends2.default)({
246
321
  ref: searchInputRef,
247
322
  className: "".concat(RC, "__input"),
248
- value: isOpen ? searchValue : labelByValue,
323
+ value: isOpen ? isMobile && withMobileLogic ? labelByValue : searchValue : labelByValue,
249
324
  onChange: handle.onInputChange,
250
325
  placeholder: placeholder,
251
326
  onFocus: searchableInputFocus,
@@ -258,6 +333,8 @@ const DropdownLiveSearch = _ref => {
258
333
  ["".concat(RC, "__arrow_active")]: isOpen
259
334
  }),
260
335
  onClick: () => setIsOpen(!isOpen)
261
- }, isOpen ? /*#__PURE__*/_react.default.createElement(_reactFeather.ChevronUp, null) : /*#__PURE__*/_react.default.createElement(_reactFeather.ChevronDown, null))), isOpen && getListMarkUp());
336
+ }, isMobile ? /*#__PURE__*/_react.default.createElement(_reactFeather.Code, {
337
+ className: "mobile-icon"
338
+ }) : isOpen ? /*#__PURE__*/_react.default.createElement(_reactFeather.ChevronUp, null) : /*#__PURE__*/_react.default.createElement(_reactFeather.ChevronDown, null))), isOpen && getListMarkUp());
262
339
  };
263
340
  var _default = exports.default = DropdownLiveSearch;
@@ -234,3 +234,287 @@
234
234
  opacity: 0.5;
235
235
  }
236
236
  }
237
+
238
+ .dropdown-live-search-mobile {
239
+ .dropdown-live-search__arrow {
240
+ transform: rotate(90deg) translateX(-50%);
241
+ }
242
+ .dropdown-live-search__container-wrapper {
243
+ overflow: hidden !important;
244
+ position: fixed;
245
+ top: 0 !important;
246
+ left: 0 !important;
247
+
248
+ width: 100dvw;
249
+ height: 100dvh;
250
+ max-height: 100dvh;
251
+
252
+ background: rgba(23, 29, 51, 0.5);
253
+
254
+ animation-name: fadeIn;
255
+ animation-duration: 0.25s;
256
+ animation-timing-function: ease;
257
+ animation-fill-mode: forwards;
258
+ }
259
+
260
+ .dropdown-live-search__list-wrapper {
261
+ position: fixed;
262
+ top: 0 !important;
263
+ left: 0 !important;
264
+
265
+ overflow: hidden !important;
266
+
267
+ box-sizing: border-box;
268
+ width: 100dvw;
269
+ height: 100dvh;
270
+ max-height: 100dvh;
271
+ padding: $spacing-s;
272
+
273
+ animation-name: slideup;
274
+ animation-duration: 0.4s;
275
+ }
276
+
277
+ .dropdown-live-search__container {
278
+ position: absolute;
279
+ bottom: $spacing-s;
280
+ top: auto;
281
+ z-index: auto;
282
+ width: calc(100% - calc(2 * $spacing-s));
283
+ margin: 0;
284
+ box-sizing: border-box;
285
+
286
+ overflow: hidden;
287
+
288
+ box-sizing: border-box;
289
+
290
+ border-radius: $spacing-l !important;
291
+ max-height: 500px;
292
+ // height: 500px !important;
293
+
294
+ &--with-bottom-shadow::after {
295
+ position: absolute;
296
+ z-index: 6;
297
+ bottom: 0;
298
+
299
+ width: 100%;
300
+ height: 15px;
301
+
302
+ content: "";
303
+
304
+ opacity: 1;
305
+ background: linear-gradient(
306
+ 180deg,
307
+ rgba(212, 218, 230, 0.5) 0%,
308
+ rgba(212, 218, 230, 0.3) 21.35%,
309
+ rgba(247, 248, 250, 0) 100%
310
+ );
311
+
312
+ transition: all 0.2s;
313
+ transform: rotate(180deg);
314
+ }
315
+
316
+ &--with-bottom-shadow-hidden::after {
317
+ opacity: 0;
318
+ }
319
+
320
+ &--fixed-height {
321
+ height: 500px !important;
322
+ }
323
+ }
324
+
325
+ .dropdown-live-search__list {
326
+ max-height: 500px;
327
+ box-shadow: none;
328
+ padding: 0 16px 16px !important;
329
+
330
+ &-header {
331
+ position: relative;
332
+
333
+ display: flex;
334
+ flex-direction: column;
335
+ justify-content: space-between;
336
+ gap: $spacing-m;
337
+
338
+ padding: $spacing-m;
339
+
340
+ font-size: 16px;
341
+ font-weight: 600;
342
+ line-height: 24px;
343
+ letter-spacing: 0.1px;
344
+
345
+ color: #3b414b;
346
+
347
+ &-row {
348
+ display: flex;
349
+ flex-direction: row;
350
+ align-items: center;
351
+
352
+ box-sizing: border-box;
353
+ min-height: 24px;
354
+
355
+ &:first-child {
356
+ padding-right: 50px;
357
+ }
358
+
359
+ .input__wrap {
360
+ display: flex;
361
+ align-items: center;
362
+
363
+ width: 100%;
364
+ padding-right: $spacing-s;
365
+
366
+ border: 1px solid var(--form-input-border, #e1e8f1);
367
+ border-radius: 6px;
368
+ background: var(--black-bg-color, #f8fbff) !important;
369
+
370
+ input {
371
+ background: unset !important;
372
+ }
373
+ }
374
+
375
+ .input__close {
376
+ display: flex;
377
+ align-items: center;
378
+
379
+ box-sizing: border-box;
380
+ width: 24px;
381
+ min-width: 24px;
382
+ height: 24px;
383
+ padding: $spacing-xs;
384
+
385
+ border-radius: 2px;
386
+ background: var(--bg-gray-box, #f0f1f4);
387
+
388
+ &::before,
389
+ &::after {
390
+ top: 50%;
391
+
392
+ height: 12px;
393
+
394
+ border-radius: 8px;
395
+ background-color: #171d33;
396
+
397
+ transform: translateY(-50%) rotate(45deg);
398
+ }
399
+ &::after {
400
+ transform: translateY(-50%) rotate(-45deg);
401
+ }
402
+ }
403
+ }
404
+
405
+ &-with-shadow::after {
406
+ position: absolute;
407
+ z-index: 10;
408
+ bottom: -15px;
409
+ left: 0;
410
+
411
+ width: 100%;
412
+ height: 15px;
413
+
414
+ content: "";
415
+
416
+ opacity: 1;
417
+ background: linear-gradient(
418
+ 180deg,
419
+ rgba(212, 218, 230, 0.5) 0%,
420
+ rgba(212, 218, 230, 0.3) 21.35%,
421
+ rgba(247, 248, 250, 0) 100%
422
+ );
423
+
424
+ transition: all 0.2s;
425
+ }
426
+
427
+ &-with-shadow-hidden::after {
428
+ opacity: 0;
429
+ }
430
+ }
431
+
432
+ &-close-icon {
433
+ position: absolute;
434
+ top: 0;
435
+ right: 0;
436
+
437
+ display: flex;
438
+ justify-content: center;
439
+ align-items: center;
440
+
441
+ box-sizing: border-box;
442
+ width: 50px;
443
+ height: 50px;
444
+ padding: $spacing-m;
445
+
446
+ svg {
447
+ width: 16px;
448
+ height: 16px;
449
+
450
+ color: #a0a4b0;
451
+ }
452
+ }
453
+
454
+ &-item {
455
+ display: flex;
456
+ justify-content: space-between;
457
+
458
+ height: auto !important;
459
+ padding: 10px $spacing-s !important;
460
+
461
+ line-height: 24px;
462
+
463
+ p {
464
+ margin: 0;
465
+ }
466
+
467
+ &-label {
468
+ white-space: wrap !important;
469
+
470
+ span.bg--yellow {
471
+ font-weight: 600;
472
+
473
+ background-color: unset !important;
474
+ }
475
+ }
476
+
477
+ &_active {
478
+ border-radius: 6px;
479
+ background: var(--bg-gray-box, #f0f1f4) !important;
480
+ }
481
+ }
482
+ }
483
+
484
+ .dropdown-live-search__input {
485
+ display: flex;
486
+ align-items: center;
487
+
488
+ width: 100%;
489
+ height: 28px;
490
+ padding-right: $spacing-s;
491
+
492
+ border: 1px solid var(--form-input-border, #e1e8f1);
493
+ border-radius: 6px;
494
+ background: var(--black-bg-color, #f8fbff) !important;
495
+
496
+ input {
497
+ background: unset !important;
498
+ }
499
+ }
500
+ }
501
+
502
+ @keyframes slideup {
503
+ from {
504
+ transform: translateY(100%);
505
+ }
506
+
507
+ to {
508
+ transform: translateY(0);
509
+ }
510
+ }
511
+
512
+ @keyframes fadeIn {
513
+ from {
514
+ opacity: 0;
515
+ }
516
+
517
+ to {
518
+ opacity: 1;
519
+ }
520
+ }
@@ -85,9 +85,7 @@
85
85
 
86
86
  &::before {
87
87
  top: -4.25px;
88
- left: calc(50% -
89
-
90
- px);
88
+ left: calc(50% - 8px);
91
89
  }
92
90
  }
93
91
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "intelicoreact",
3
- "version": "1.3.91",
3
+ "version": "1.3.93",
4
4
  "description": "",
5
5
  "main": "dist/index.js",
6
6
  "files": [