@true-engineering/true-react-common-ui-kit 1.9.0 → 1.10.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (31) hide show
  1. package/dist/components/Input/Input.styles.d.ts +1 -0
  2. package/dist/components/Select/Select.d.ts +12 -3
  3. package/dist/components/Select/Select.styles.d.ts +10 -0
  4. package/dist/components/Select/SelectList/SelectList.d.ts +6 -4
  5. package/dist/components/Select/SelectList/SelectList.styles.d.ts +5 -0
  6. package/dist/components/Select/SelectListItem/SelectListItem.d.ts +14 -0
  7. package/dist/components/Select/SelectListItem/SelectListItem.styles.d.ts +2 -0
  8. package/dist/components/Select/constants.d.ts +2 -0
  9. package/dist/components/Select/helpers.d.ts +4 -1
  10. package/dist/components/Select/index.d.ts +1 -0
  11. package/dist/components/Select/types.d.ts +1 -0
  12. package/dist/helpers/utils.d.ts +2 -0
  13. package/dist/true-react-common-ui-kit.js +340 -163
  14. package/dist/true-react-common-ui-kit.js.map +1 -1
  15. package/dist/true-react-common-ui-kit.umd.cjs +340 -163
  16. package/dist/true-react-common-ui-kit.umd.cjs.map +1 -1
  17. package/package.json +1 -1
  18. package/src/components/Input/Input.styles.ts +2 -0
  19. package/src/components/Input/Input.tsx +4 -1
  20. package/src/components/Select/MultiSelect.stories.tsx +262 -0
  21. package/src/components/Select/Select.styles.ts +13 -0
  22. package/src/components/Select/Select.tsx +215 -114
  23. package/src/components/Select/SelectList/SelectList.styles.ts +6 -2
  24. package/src/components/Select/SelectList/SelectList.tsx +64 -39
  25. package/src/components/Select/SelectListItem/SelectListItem.styles.ts +14 -0
  26. package/src/components/Select/SelectListItem/SelectListItem.tsx +73 -0
  27. package/src/components/Select/constants.ts +2 -0
  28. package/src/components/Select/helpers.ts +16 -8
  29. package/src/components/Select/index.ts +1 -0
  30. package/src/components/Select/types.ts +1 -0
  31. package/src/helpers/utils.ts +29 -0
@@ -1111,11 +1111,11 @@
1111
1111
  if (Array.isArray(arr))
1112
1112
  return arr;
1113
1113
  }
1114
- function _array_without_holes$6(arr) {
1114
+ function _array_without_holes$7(arr) {
1115
1115
  if (Array.isArray(arr))
1116
1116
  return _array_like_to_array$q(arr);
1117
1117
  }
1118
- function _iterable_to_array$6(iter) {
1118
+ function _iterable_to_array$7(iter) {
1119
1119
  if (typeof Symbol !== "undefined" && iter[Symbol.iterator] != null || iter["@@iterator"] != null)
1120
1120
  return Array.from(iter);
1121
1121
  }
@@ -1150,14 +1150,14 @@
1150
1150
  function _non_iterable_rest$o() {
1151
1151
  throw new TypeError("Invalid attempt to destructure non-iterable instance.\\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.");
1152
1152
  }
1153
- function _non_iterable_spread$6() {
1153
+ function _non_iterable_spread$7() {
1154
1154
  throw new TypeError("Invalid attempt to spread non-iterable instance.\\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.");
1155
1155
  }
1156
1156
  function _sliced_to_array$o(arr, i) {
1157
1157
  return _array_with_holes$o(arr) || _iterable_to_array_limit$o(arr, i) || _unsupported_iterable_to_array$q(arr, i) || _non_iterable_rest$o();
1158
1158
  }
1159
- function _to_consumable_array$6(arr) {
1160
- return _array_without_holes$6(arr) || _iterable_to_array$6(arr) || _unsupported_iterable_to_array$q(arr) || _non_iterable_spread$6();
1159
+ function _to_consumable_array$7(arr) {
1160
+ return _array_without_holes$7(arr) || _iterable_to_array$7(arr) || _unsupported_iterable_to_array$q(arr) || _non_iterable_spread$7();
1161
1161
  }
1162
1162
  function _unsupported_iterable_to_array$q(o, minLen) {
1163
1163
  if (!o)
@@ -1292,6 +1292,9 @@
1292
1292
  var isNotEmpty = function(val) {
1293
1293
  return typeof val === "string" ? val.trim() !== "" : val !== null && val !== void 0;
1294
1294
  };
1295
+ var isStringNotEmpty = function(value) {
1296
+ return (value !== null && value !== void 0 ? value : "").trim() !== "";
1297
+ };
1295
1298
  var trimStringToMaxLength = function(val, maxLength) {
1296
1299
  return val.length > maxLength ? val.slice(0, maxLength) : val;
1297
1300
  };
@@ -1309,7 +1312,7 @@
1309
1312
  for (var _len = arguments.length, args = new Array(_len), _key = 0; _key < _len; _key++) {
1310
1313
  args[_key] = arguments[_key];
1311
1314
  }
1312
- var testId = getTestId.apply(void 0, _to_consumable_array$6(args));
1315
+ var testId = getTestId.apply(void 0, _to_consumable_array$7(args));
1313
1316
  return isNotEmpty(testId) ? {
1314
1317
  "data-testid": testId
1315
1318
  } : void 0;
@@ -1337,6 +1340,21 @@
1337
1340
  tabIndex: -1
1338
1341
  };
1339
1342
  };
1343
+ var createFilter = function(getter) {
1344
+ return function(items, query) {
1345
+ return items.filter(function(item) {
1346
+ var possibleValues = getter(item).reduce(function(acc, cur) {
1347
+ return _to_consumable_array$7(acc).concat(_to_consumable_array$7(isStringNotEmpty(cur) ? [
1348
+ cur === null || cur === void 0 ? void 0 : cur.toLowerCase()
1349
+ ] : []));
1350
+ }, []);
1351
+ var queryString = query.toLowerCase().trim();
1352
+ return possibleValues.some(function(v) {
1353
+ return v === null || v === void 0 ? void 0 : v.includes(queryString);
1354
+ });
1355
+ });
1356
+ };
1357
+ };
1340
1358
  var minWidthModifier = {
1341
1359
  name: "minWidth",
1342
1360
  enabled: true,
@@ -1360,19 +1378,19 @@
1360
1378
  arr2[i] = arr[i];
1361
1379
  return arr2;
1362
1380
  }
1363
- function _array_without_holes$5(arr) {
1381
+ function _array_without_holes$6(arr) {
1364
1382
  if (Array.isArray(arr))
1365
1383
  return _array_like_to_array$p(arr);
1366
1384
  }
1367
- function _iterable_to_array$5(iter) {
1385
+ function _iterable_to_array$6(iter) {
1368
1386
  if (typeof Symbol !== "undefined" && iter[Symbol.iterator] != null || iter["@@iterator"] != null)
1369
1387
  return Array.from(iter);
1370
1388
  }
1371
- function _non_iterable_spread$5() {
1389
+ function _non_iterable_spread$6() {
1372
1390
  throw new TypeError("Invalid attempt to spread non-iterable instance.\\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.");
1373
1391
  }
1374
- function _to_consumable_array$5(arr) {
1375
- return _array_without_holes$5(arr) || _iterable_to_array$5(arr) || _unsupported_iterable_to_array$p(arr) || _non_iterable_spread$5();
1392
+ function _to_consumable_array$6(arr) {
1393
+ return _array_without_holes$6(arr) || _iterable_to_array$6(arr) || _unsupported_iterable_to_array$p(arr) || _non_iterable_spread$6();
1376
1394
  }
1377
1395
  function _unsupported_iterable_to_array$p(o, minLen) {
1378
1396
  if (!o)
@@ -1412,7 +1430,7 @@
1412
1430
  var possibleValues = [
1413
1431
  country.countryRu,
1414
1432
  country.countryEn
1415
- ].concat(_to_consumable_array$5(country.countryRu.split(" ")), _to_consumable_array$5(country.countryEn.split(" ")), [
1433
+ ].concat(_to_consumable_array$6(country.countryRu.split(" ")), _to_consumable_array$6(country.countryEn.split(" ")), [
1416
1434
  country.dialCode
1417
1435
  ]).map(function(part) {
1418
1436
  return part.toLowerCase();
@@ -3892,11 +3910,11 @@
3892
3910
  arr2[i] = arr[i];
3893
3911
  return arr2;
3894
3912
  }
3895
- function _array_without_holes$4(arr) {
3913
+ function _array_without_holes$5(arr) {
3896
3914
  if (Array.isArray(arr))
3897
3915
  return _array_like_to_array$o(arr);
3898
3916
  }
3899
- function _define_property$O(obj, key, value) {
3917
+ function _define_property$P(obj, key, value) {
3900
3918
  if (key in obj) {
3901
3919
  Object.defineProperty(obj, key, {
3902
3920
  value,
@@ -3909,11 +3927,11 @@
3909
3927
  }
3910
3928
  return obj;
3911
3929
  }
3912
- function _iterable_to_array$4(iter) {
3930
+ function _iterable_to_array$5(iter) {
3913
3931
  if (typeof Symbol !== "undefined" && iter[Symbol.iterator] != null || iter["@@iterator"] != null)
3914
3932
  return Array.from(iter);
3915
3933
  }
3916
- function _non_iterable_spread$4() {
3934
+ function _non_iterable_spread$5() {
3917
3935
  throw new TypeError("Invalid attempt to spread non-iterable instance.\\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.");
3918
3936
  }
3919
3937
  function _object_spread$N(target) {
@@ -3926,13 +3944,13 @@
3926
3944
  }));
3927
3945
  }
3928
3946
  ownKeys2.forEach(function(key) {
3929
- _define_property$O(target, key, source[key]);
3947
+ _define_property$P(target, key, source[key]);
3930
3948
  });
3931
3949
  }
3932
3950
  return target;
3933
3951
  }
3934
- function _to_consumable_array$4(arr) {
3935
- return _array_without_holes$4(arr) || _iterable_to_array$4(arr) || _unsupported_iterable_to_array$o(arr) || _non_iterable_spread$4();
3952
+ function _to_consumable_array$5(arr) {
3953
+ return _array_without_holes$5(arr) || _iterable_to_array$5(arr) || _unsupported_iterable_to_array$o(arr) || _non_iterable_spread$5();
3936
3954
  }
3937
3955
  function _unsupported_iterable_to_array$o(o, minLen) {
3938
3956
  if (!o)
@@ -3968,7 +3986,7 @@
3968
3986
  popperData = usePopper(referenceElement, dropdownElement, {
3969
3987
  enabled: isOpen,
3970
3988
  placement,
3971
- modifiers: _to_consumable_array$4(shouldRenderInBody ? [
3989
+ modifiers: _to_consumable_array$5(shouldRenderInBody ? [
3972
3990
  minWidthModifier
3973
3991
  ] : []).concat([
3974
3992
  {
@@ -3991,7 +4009,7 @@
3991
4009
  ]
3992
4010
  }, flipOptions)
3993
4011
  }
3994
- ], _to_consumable_array$4(modifiers))
4012
+ ], _to_consumable_array$5(modifiers))
3995
4013
  });
3996
4014
  }
3997
4015
  React.useEffect(function() {
@@ -4851,7 +4869,7 @@
4851
4869
  ]
4852
4870
  }
4853
4871
  });
4854
- function _define_property$N(obj, key, value) {
4872
+ function _define_property$O(obj, key, value) {
4855
4873
  if (key in obj) {
4856
4874
  Object.defineProperty(obj, key, {
4857
4875
  value,
@@ -4874,7 +4892,7 @@
4874
4892
  }));
4875
4893
  }
4876
4894
  ownKeys2.forEach(function(key) {
4877
- _define_property$N(target, key, source[key]);
4895
+ _define_property$O(target, key, source[key]);
4878
4896
  });
4879
4897
  }
4880
4898
  return target;
@@ -5001,7 +5019,7 @@
5001
5019
  var complexIcons = {
5002
5020
  avatar: avatarGreen
5003
5021
  };
5004
- function _define_property$M(obj, key, value) {
5022
+ function _define_property$N(obj, key, value) {
5005
5023
  if (key in obj) {
5006
5024
  Object.defineProperty(obj, key, {
5007
5025
  value,
@@ -5024,7 +5042,7 @@
5024
5042
  }));
5025
5043
  }
5026
5044
  ownKeys2.forEach(function(key) {
5027
- _define_property$M(target, key, source[key]);
5045
+ _define_property$N(target, key, source[key]);
5028
5046
  });
5029
5047
  }
5030
5048
  return target;
@@ -5048,7 +5066,7 @@
5048
5066
  alignItems: "center"
5049
5067
  }
5050
5068
  };
5051
- function _define_property$L(obj, key, value) {
5069
+ function _define_property$M(obj, key, value) {
5052
5070
  if (key in obj) {
5053
5071
  Object.defineProperty(obj, key, {
5054
5072
  value,
@@ -5071,7 +5089,7 @@
5071
5089
  }));
5072
5090
  }
5073
5091
  ownKeys2.forEach(function(key) {
5074
- _define_property$L(target, key, source[key]);
5092
+ _define_property$M(target, key, source[key]);
5075
5093
  });
5076
5094
  }
5077
5095
  return target;
@@ -5162,7 +5180,7 @@
5162
5180
  },
5163
5181
  content: {}
5164
5182
  };
5165
- function _define_property$K(obj, key, value) {
5183
+ function _define_property$L(obj, key, value) {
5166
5184
  if (key in obj) {
5167
5185
  Object.defineProperty(obj, key, {
5168
5186
  value,
@@ -5185,7 +5203,7 @@
5185
5203
  }));
5186
5204
  }
5187
5205
  ownKeys2.forEach(function(key) {
5188
- _define_property$K(target, key, source[key]);
5206
+ _define_property$L(target, key, source[key]);
5189
5207
  });
5190
5208
  }
5191
5209
  return target;
@@ -5233,7 +5251,7 @@
5233
5251
  className: classes.spacer
5234
5252
  }),
5235
5253
  /* @__PURE__ */ jsxs("div", _object_spread_props$A(_object_spread$J({
5236
- className: clsx(classes.item, (_obj = {}, _define_property$K(_obj, classes.disabledItem, item.disabled), _define_property$K(_obj, classes.withIconGap, item.withIconGap), _obj))
5254
+ className: clsx(classes.item, (_obj = {}, _define_property$L(_obj, classes.disabledItem, item.disabled), _define_property$L(_obj, classes.withIconGap, item.withIconGap), _obj))
5237
5255
  }, addDataTestId((_item_testId = item.testId) !== null && _item_testId !== void 0 ? _item_testId : getTestId(testId, "item-".concat(idx))), item.disabled && addDataAttributes({
5238
5256
  disabled: item.disabled
5239
5257
  })), {
@@ -5261,7 +5279,7 @@
5261
5279
  })
5262
5280
  }));
5263
5281
  };
5264
- function _define_property$J(obj, key, value) {
5282
+ function _define_property$K(obj, key, value) {
5265
5283
  if (key in obj) {
5266
5284
  Object.defineProperty(obj, key, {
5267
5285
  value,
@@ -5284,7 +5302,7 @@
5284
5302
  }));
5285
5303
  }
5286
5304
  ownKeys2.forEach(function(key) {
5287
- _define_property$J(target, key, source[key]);
5305
+ _define_property$K(target, key, source[key]);
5288
5306
  });
5289
5307
  }
5290
5308
  return target;
@@ -5368,7 +5386,7 @@
5368
5386
  if (Array.isArray(arr))
5369
5387
  return arr;
5370
5388
  }
5371
- function _define_property$I(obj, key, value) {
5389
+ function _define_property$J(obj, key, value) {
5372
5390
  if (key in obj) {
5373
5391
  Object.defineProperty(obj, key, {
5374
5392
  value,
@@ -5422,7 +5440,7 @@
5422
5440
  }));
5423
5441
  }
5424
5442
  ownKeys2.forEach(function(key) {
5425
- _define_property$I(target, key, source[key]);
5443
+ _define_property$J(target, key, source[key]);
5426
5444
  });
5427
5445
  }
5428
5446
  return target;
@@ -5563,7 +5581,7 @@
5563
5581
  width: "100%"
5564
5582
  }
5565
5583
  };
5566
- function _define_property$H(obj, key, value) {
5584
+ function _define_property$I(obj, key, value) {
5567
5585
  if (key in obj) {
5568
5586
  Object.defineProperty(obj, key, {
5569
5587
  value,
@@ -5586,7 +5604,7 @@
5586
5604
  }));
5587
5605
  }
5588
5606
  ownKeys2.forEach(function(key) {
5589
- _define_property$H(target, key, source[key]);
5607
+ _define_property$I(target, key, source[key]);
5590
5608
  });
5591
5609
  }
5592
5610
  return target;
@@ -5780,7 +5798,7 @@
5780
5798
  },
5781
5799
  tweakPreloaderComponent: {}
5782
5800
  };
5783
- function _define_property$G(obj, key, value) {
5801
+ function _define_property$H(obj, key, value) {
5784
5802
  if (key in obj) {
5785
5803
  Object.defineProperty(obj, key, {
5786
5804
  value,
@@ -5803,7 +5821,7 @@
5803
5821
  }));
5804
5822
  }
5805
5823
  ownKeys2.forEach(function(key) {
5806
- _define_property$G(target, key, source[key]);
5824
+ _define_property$H(target, key, source[key]);
5807
5825
  });
5808
5826
  }
5809
5827
  return target;
@@ -5837,7 +5855,7 @@
5837
5855
  var _useTheme = useTheme("ThemedPreloader", styles$E, tweakStyles), classes = _useTheme.classes, componentStyles = _useTheme.componentStyles;
5838
5856
  var preloaderComponentStyles = useTweakStyles(componentStyles, tweakStyles, "tweakPreloaderComponent");
5839
5857
  return /* @__PURE__ */ jsx("div", _object_spread_props$w(_object_spread$F({
5840
- className: clsx(classes.root, classes[type], _define_property$G({}, classes.currentColor, useCurrentColor))
5858
+ className: clsx(classes.root, classes[type], _define_property$H({}, classes.currentColor, useCurrentColor))
5841
5859
  }, addDataAttributes(data)), {
5842
5860
  children: type === "dots" ? /* @__PURE__ */ jsx(DotsPreloader, {
5843
5861
  tweakStyles: preloaderComponentStyles
@@ -6017,7 +6035,7 @@
6017
6035
  }
6018
6036
  }
6019
6037
  };
6020
- function _define_property$F(obj, key, value) {
6038
+ function _define_property$G(obj, key, value) {
6021
6039
  if (key in obj) {
6022
6040
  Object.defineProperty(obj, key, {
6023
6041
  value,
@@ -6040,7 +6058,7 @@
6040
6058
  }));
6041
6059
  }
6042
6060
  ownKeys2.forEach(function(key) {
6043
- _define_property$F(target, key, source[key]);
6061
+ _define_property$G(target, key, source[key]);
6044
6062
  });
6045
6063
  }
6046
6064
  return target;
@@ -6093,7 +6111,7 @@
6093
6111
  var _obj, _obj1;
6094
6112
  return /* @__PURE__ */ jsxs("button", _object_spread_props$v(_object_spread$E({
6095
6113
  type,
6096
- className: clsx(classes.root, classes[size], classes[view], (_obj = {}, _define_property$F(_obj, classes.disabled, isDisabled), _define_property$F(_obj, classes.fullWidth, isFullWidth), _define_property$F(_obj, classes.inline, isInline), _define_property$F(_obj, classes.active, isActive), _define_property$F(_obj, classes.loading, isLoading), _define_property$F(_obj, classes.onlyIcon, hasIcon && !hasChildren), _obj)),
6114
+ className: clsx(classes.root, classes[size], classes[view], (_obj = {}, _define_property$G(_obj, classes.disabled, isDisabled), _define_property$G(_obj, classes.fullWidth, isFullWidth), _define_property$G(_obj, classes.inline, isInline), _define_property$G(_obj, classes.active, isActive), _define_property$G(_obj, classes.loading, isLoading), _define_property$G(_obj, classes.onlyIcon, hasIcon && !hasChildren), _obj)),
6097
6115
  tabIndex: shouldSkipTabNavigation ? -1 : void 0,
6098
6116
  disabled: hasNoAction,
6099
6117
  onClick: !hasNoAction ? onClick : void 0,
@@ -6101,7 +6119,7 @@
6101
6119
  }, addDataTestId(testId), addDataAttributes(data)), {
6102
6120
  children: [
6103
6121
  /* @__PURE__ */ jsxs("span", {
6104
- className: clsx(classes.content, (_obj1 = {}, _define_property$F(_obj1, classes.iconFromRight, hasChildren && hasIcon && iconPosition === "right"), _define_property$F(_obj1, classes.iconFromLeft, hasChildren && hasIcon && iconPosition === "left"), _obj1)),
6122
+ className: clsx(classes.content, (_obj1 = {}, _define_property$G(_obj1, classes.iconFromRight, hasChildren && hasIcon && iconPosition === "right"), _define_property$G(_obj1, classes.iconFromLeft, hasChildren && hasIcon && iconPosition === "left"), _obj1)),
6105
6123
  children: [
6106
6124
  hasIcon && /* @__PURE__ */ jsx("span", {
6107
6125
  className: classes.icon,
@@ -6193,7 +6211,7 @@
6193
6211
  if (Array.isArray(arr))
6194
6212
  return arr;
6195
6213
  }
6196
- function _define_property$E(obj, key, value) {
6214
+ function _define_property$F(obj, key, value) {
6197
6215
  if (key in obj) {
6198
6216
  Object.defineProperty(obj, key, {
6199
6217
  value,
@@ -6247,7 +6265,7 @@
6247
6265
  }));
6248
6266
  }
6249
6267
  ownKeys2.forEach(function(key) {
6250
- _define_property$E(target, key, source[key]);
6268
+ _define_property$F(target, key, source[key]);
6251
6269
  });
6252
6270
  }
6253
6271
  return target;
@@ -6316,7 +6334,7 @@
6316
6334
  ]);
6317
6335
  var _obj;
6318
6336
  return /* @__PURE__ */ jsxs("label", _object_spread_props$u(_object_spread$D({
6319
- className: clsx(classes.root, (_obj = {}, _define_property$E(_obj, classes.disabled, isDisabled), _define_property$E(_obj, classes.labelPositionLeft, labelPosition === "left"), _obj))
6337
+ className: clsx(classes.root, (_obj = {}, _define_property$F(_obj, classes.disabled, isDisabled), _define_property$F(_obj, classes.labelPositionLeft, labelPosition === "left"), _obj))
6320
6338
  }, addDataTestId(testId), addDataAttributes(data)), {
6321
6339
  children: [
6322
6340
  /* @__PURE__ */ jsx("input", _object_spread$D({
@@ -6367,7 +6385,7 @@
6367
6385
  }
6368
6386
  }
6369
6387
  };
6370
- function _define_property$D(obj, key, value) {
6388
+ function _define_property$E(obj, key, value) {
6371
6389
  if (key in obj) {
6372
6390
  Object.defineProperty(obj, key, {
6373
6391
  value,
@@ -6390,7 +6408,7 @@
6390
6408
  }));
6391
6409
  }
6392
6410
  ownKeys2.forEach(function(key) {
6393
- _define_property$D(target, key, source[key]);
6411
+ _define_property$E(target, key, source[key]);
6394
6412
  });
6395
6413
  }
6396
6414
  return target;
@@ -6565,7 +6583,7 @@
6565
6583
  },
6566
6584
  root: {}
6567
6585
  };
6568
- function _define_property$C(obj, key, value) {
6586
+ function _define_property$D(obj, key, value) {
6569
6587
  if (key in obj) {
6570
6588
  Object.defineProperty(obj, key, {
6571
6589
  value,
@@ -6588,7 +6606,7 @@
6588
6606
  }));
6589
6607
  }
6590
6608
  ownKeys2.forEach(function(key) {
6591
- _define_property$C(target, key, source[key]);
6609
+ _define_property$D(target, key, source[key]);
6592
6610
  });
6593
6611
  }
6594
6612
  return target;
@@ -6873,6 +6891,7 @@
6873
6891
  paddingLeft: 13
6874
6892
  },
6875
6893
  loading: {},
6894
+ withUnits: {},
6876
6895
  tweakPreloader: {}
6877
6896
  };
6878
6897
  var renderIcon = function(icon) {
@@ -6920,7 +6939,7 @@
6920
6939
  });
6921
6940
  };
6922
6941
  }
6923
- function _define_property$B(obj, key, value) {
6942
+ function _define_property$C(obj, key, value) {
6924
6943
  if (key in obj) {
6925
6944
  Object.defineProperty(obj, key, {
6926
6945
  value,
@@ -6974,7 +6993,7 @@
6974
6993
  }));
6975
6994
  }
6976
6995
  ownKeys2.forEach(function(key) {
6977
- _define_property$B(target, key, source[key]);
6996
+ _define_property$C(target, key, source[key]);
6978
6997
  });
6979
6998
  }
6980
6999
  return target;
@@ -7169,9 +7188,10 @@
7169
7188
  var hasUnits = units !== void 0 && units !== "";
7170
7189
  var hasLabel = isNotEmpty(label);
7171
7190
  var hasPlaceholder = (!hasLabel || hasFocus && !isReadonly) && isNotEmpty(placeholder);
7191
+ var shouldShowUnits = (hasValue || isFocused && !hasPlaceholder) && hasUnits;
7172
7192
  var _obj;
7173
7193
  var props = _object_spread$A({
7174
- className: clsx(classes.input, (_obj = {}, _define_property$B(_obj, classes.withFloatingLabel, hasFloatingLabel && hasLabel), _define_property$B(_obj, classes.withIcons, hasControls), _define_property$B(_obj, classes.withControls, hasControls), _define_property$B(_obj, classes.floatingLabelWithoutPadding, hasFloatingLabel && hasLabel && border === "bottom"), _obj)),
7194
+ className: clsx(classes.input, (_obj = {}, _define_property$C(_obj, classes.withFloatingLabel, hasFloatingLabel && hasLabel), _define_property$C(_obj, classes.withIcons, hasControls), _define_property$C(_obj, classes.withControls, hasControls), _define_property$C(_obj, classes.withUnits, shouldShowUnits), _define_property$C(_obj, classes.floatingLabelWithoutPadding, hasFloatingLabel && hasLabel && border === "bottom"), _obj)),
7175
7195
  onFocus: handleFocus,
7176
7196
  onBlur: handleBlur,
7177
7197
  onChange: handleChange,
@@ -7194,7 +7214,7 @@
7194
7214
  className: classes.root,
7195
7215
  children: [
7196
7216
  /* @__PURE__ */ jsxs("div", _object_spread_props$s(_object_spread$A({
7197
- className: clsx(classes.inputWrapper, (_obj1 = {}, _define_property$B(_obj1, classes.required, isRequired && !hasRequiredLabel), _define_property$B(_obj1, classes.invalid, isInvalid), _define_property$B(_obj1, classes.focused, hasFocus), _define_property$B(_obj1, classes.disabled, isDisabled), _define_property$B(_obj1, classes.autosize, isAutoSizeable), _obj1), inlineStyle !== void 0 && classes[inlineStyle], border !== void 0 && classes["border-".concat(border)]),
7217
+ className: clsx(classes.inputWrapper, (_obj1 = {}, _define_property$C(_obj1, classes.required, isRequired && !hasRequiredLabel), _define_property$C(_obj1, classes.invalid, isInvalid), _define_property$C(_obj1, classes.focused, hasFocus), _define_property$C(_obj1, classes.disabled, isDisabled), _define_property$C(_obj1, classes.autosize, isAutoSizeable), _obj1), inlineStyle !== void 0 && classes[inlineStyle], border !== void 0 && classes["border-".concat(border)]),
7198
7218
  "data-value": isAutoSizeable ? value : void 0
7199
7219
  }, addDataAttributes(data)), {
7200
7220
  children: [
@@ -7208,12 +7228,12 @@
7208
7228
  beforeMaskedStateChange
7209
7229
  }, props)),
7210
7230
  hasLabel && /* @__PURE__ */ jsx("span", {
7211
- className: clsx(classes.label, (_obj2 = {}, _define_property$B(_obj2, classes.invalidLabel, isInvalid), _define_property$B(_obj2, classes.requiredLabel, hasRequiredLabel && !isRequired), _define_property$B(_obj2, classes.activeLabel, hasFocus && !isReadonly || hasValue), _define_property$B(_obj2, classes.floating, hasFloatingLabel), // Обсуждаемо, сделал так, потому что не хочется создавать новую пропсу, на каждый чих в стилях
7212
- _define_property$B(_obj2, classes.floatingWithoutPadding, hasFloatingLabel && border === "bottom"), _obj2)),
7231
+ className: clsx(classes.label, (_obj2 = {}, _define_property$C(_obj2, classes.invalidLabel, isInvalid), _define_property$C(_obj2, classes.requiredLabel, hasRequiredLabel && !isRequired), _define_property$C(_obj2, classes.activeLabel, hasFocus && !isReadonly || hasValue), _define_property$C(_obj2, classes.floating, hasFloatingLabel), // Обсуждаемо, сделал так, потому что не хочется создавать новую пропсу, на каждый чих в стилях
7232
+ _define_property$C(_obj2, classes.floatingWithoutPadding, hasFloatingLabel && border === "bottom"), _obj2)),
7213
7233
  children: label
7214
7234
  }),
7215
- (hasValue || isFocused && !hasPlaceholder) && hasUnits && /* @__PURE__ */ jsxs("div", {
7216
- className: clsx(classes.unitsWrapper, _define_property$B({}, classes.withFloatingLabel, hasFloatingLabel && hasLabel)),
7235
+ shouldShowUnits && /* @__PURE__ */ jsxs("div", {
7236
+ className: clsx(classes.unitsWrapper, _define_property$C({}, classes.withFloatingLabel, hasFloatingLabel && hasLabel)),
7217
7237
  children: [
7218
7238
  /* @__PURE__ */ jsx("span", {
7219
7239
  className: classes.fakeValue,
@@ -7245,7 +7265,7 @@
7245
7265
  })
7246
7266
  }),
7247
7267
  iconType !== void 0 && /* @__PURE__ */ jsx("div", {
7248
- className: clsx(classes.inputIcon, _define_property$B({}, classes.activeIcon, !isDisabled && onIconClick !== void 0)),
7268
+ className: clsx(classes.inputIcon, _define_property$C({}, classes.activeIcon, !isDisabled && onIconClick !== void 0)),
7249
7269
  onClick: !isDisabled ? onIconClick : void 0,
7250
7270
  children: renderIcon(iconType)
7251
7271
  })
@@ -7273,7 +7293,7 @@
7273
7293
  },
7274
7294
  tweakInput: {}
7275
7295
  };
7276
- function _define_property$A(obj, key, value) {
7296
+ function _define_property$B(obj, key, value) {
7277
7297
  if (key in obj) {
7278
7298
  Object.defineProperty(obj, key, {
7279
7299
  value,
@@ -7296,7 +7316,7 @@
7296
7316
  }));
7297
7317
  }
7298
7318
  ownKeys2.forEach(function(key) {
7299
- _define_property$A(target, key, source[key]);
7319
+ _define_property$B(target, key, source[key]);
7300
7320
  });
7301
7321
  }
7302
7322
  return target;
@@ -7450,7 +7470,7 @@
7450
7470
  _defineProperties(Constructor, staticProps);
7451
7471
  return Constructor;
7452
7472
  }
7453
- function _define_property$z(obj, key, value) {
7473
+ function _define_property$A(obj, key, value) {
7454
7474
  if (key in obj) {
7455
7475
  Object.defineProperty(obj, key, {
7456
7476
  value,
@@ -7493,7 +7513,7 @@
7493
7513
  }));
7494
7514
  }
7495
7515
  ownKeys2.forEach(function(key) {
7496
- _define_property$z(target, key, source[key]);
7516
+ _define_property$A(target, key, source[key]);
7497
7517
  });
7498
7518
  }
7499
7519
  return target;
@@ -7591,8 +7611,8 @@
7591
7611
  _class_call_check(this, ScrollIntoViewIfNeeded2);
7592
7612
  var _this;
7593
7613
  _this = _super.apply(this, arguments);
7594
- _define_property$z(_assert_this_initialized(_this), "node", React.createRef());
7595
- _define_property$z(_assert_this_initialized(_this), "handleScrollIntoViewIfNeeded", function() {
7614
+ _define_property$A(_assert_this_initialized(_this), "node", React.createRef());
7615
+ _define_property$A(_assert_this_initialized(_this), "handleScrollIntoViewIfNeeded", function() {
7596
7616
  var options = _this.props.options;
7597
7617
  var _this_node = _this.node, node = _this_node.current;
7598
7618
  if (node) {
@@ -7642,8 +7662,8 @@
7642
7662
  ]);
7643
7663
  return ScrollIntoViewIfNeeded2;
7644
7664
  }(React.PureComponent);
7645
- _define_property$z(ScrollIntoViewIfNeeded, "defaultProps", ScrollIntoViewIfNeededDefaultProps);
7646
- function _define_property$y(obj, key, value) {
7665
+ _define_property$A(ScrollIntoViewIfNeeded, "defaultProps", ScrollIntoViewIfNeededDefaultProps);
7666
+ function _define_property$z(obj, key, value) {
7647
7667
  if (key in obj) {
7648
7668
  Object.defineProperty(obj, key, {
7649
7669
  value,
@@ -7666,7 +7686,7 @@
7666
7686
  }));
7667
7687
  }
7668
7688
  ownKeys2.forEach(function(key) {
7669
- _define_property$y(target, key, source[key]);
7689
+ _define_property$z(target, key, source[key]);
7670
7690
  });
7671
7691
  }
7672
7692
  return target;
@@ -7717,6 +7737,9 @@
7717
7737
  boxSizing: "border-box",
7718
7738
  fontSize: 14
7719
7739
  },
7740
+ cellWithCheckbox: {
7741
+ padding: 0
7742
+ },
7720
7743
  noMatchesLabel: {
7721
7744
  pointerEvents: "none"
7722
7745
  },
@@ -7731,7 +7754,17 @@
7731
7754
  },
7732
7755
  defaultCell: {}
7733
7756
  };
7734
- function _define_property$x(obj, key, value) {
7757
+ var checkboxStyles = {
7758
+ root: {
7759
+ padding: CELL_PADDING,
7760
+ width: "100%"
7761
+ },
7762
+ input: {
7763
+ // иначе будет фокуситься и энтер будет вызывать изменение нескольких опций
7764
+ display: "none"
7765
+ }
7766
+ };
7767
+ function _define_property$y(obj, key, value) {
7735
7768
  if (key in obj) {
7736
7769
  Object.defineProperty(obj, key, {
7737
7770
  value,
@@ -7754,7 +7787,7 @@
7754
7787
  }));
7755
7788
  }
7756
7789
  ownKeys2.forEach(function(key) {
7757
- _define_property$x(target, key, source[key]);
7790
+ _define_property$y(target, key, source[key]);
7758
7791
  });
7759
7792
  }
7760
7793
  return target;
@@ -7783,15 +7816,67 @@
7783
7816
  }
7784
7817
  return target;
7785
7818
  }
7786
- var DEFAULT_OPTION_INDEX = -1;
7819
+ var SelectListItem = function(param) {
7820
+ var classes = param.classes, index = param.index, isSemiChecked = param.isSemiChecked, isDisabled = param.isDisabled, isActive = param.isActive, children = param.children, isFocused = param.isFocused, onOptionSelect = param.onOptionSelect, onToggleCheckbox = param.onToggleCheckbox;
7821
+ var isMultiSelect = isNotEmpty(onToggleCheckbox);
7822
+ var _obj;
7823
+ return /* @__PURE__ */ jsx(ScrollIntoViewIfNeeded, _object_spread_props$q(_object_spread$w({
7824
+ active: isFocused,
7825
+ options: {
7826
+ block: "nearest"
7827
+ },
7828
+ className: clsx(classes.cell, (_obj = {}, _define_property$y(_obj, classes.cellWithCheckbox, isMultiSelect), _define_property$y(_obj, classes.focused, isFocused), _define_property$y(_obj, classes.active, isActive && !isMultiSelect), _define_property$y(_obj, classes.disabled, isDisabled), _obj))
7829
+ }, addDataAttributes({
7830
+ disabled: isDisabled,
7831
+ active: isActive,
7832
+ focused: isFocused
7833
+ })), {
7834
+ onClick: !isDisabled && !isMultiSelect ? function(event) {
7835
+ return onOptionSelect(index, event);
7836
+ } : void 0,
7837
+ children: isMultiSelect ? /* @__PURE__ */ jsx(Checkbox, {
7838
+ value: index,
7839
+ isChecked: isActive || isSemiChecked,
7840
+ isSemiChecked,
7841
+ isDisabled,
7842
+ tweakStyles: checkboxStyles,
7843
+ onSelect: function(v) {
7844
+ return onToggleCheckbox(index, v.isSelected);
7845
+ },
7846
+ children
7847
+ }) : children
7848
+ }));
7849
+ };
7850
+ var DEFAULT_OPTION_INDEX = -2;
7851
+ var ALL_OPTION_INDEX = -1;
7852
+ function _define_property$x(obj, key, value) {
7853
+ if (key in obj) {
7854
+ Object.defineProperty(obj, key, {
7855
+ value,
7856
+ enumerable: true,
7857
+ configurable: true,
7858
+ writable: true
7859
+ });
7860
+ } else {
7861
+ obj[key] = value;
7862
+ }
7863
+ return obj;
7864
+ }
7787
7865
  function SelectList(param) {
7788
- var options = param.options, focusedIndex = param.focusedIndex, activeValue = param.activeValue, defaultOptionLabel = param.defaultOptionLabel, _param_noMatchesLabel = param.noMatchesLabel, noMatchesLabel = _param_noMatchesLabel === void 0 ? "Совпадений не найдено" : _param_noMatchesLabel, isLoading = param.isLoading, _param_loadingLabel = param.loadingLabel, loadingLabel = _param_loadingLabel === void 0 ? "Загрузка..." : _param_loadingLabel, tweakStyles = param.tweakStyles, testId = param.testId, _param_shouldScrollToList = param.shouldScrollToList, shouldScrollToList = _param_shouldScrollToList === void 0 ? true : _param_shouldScrollToList, customListHeader = param.customListHeader, isOptionDisabled = param.isOptionDisabled, onOptionClick = param.onOptionClick, convertValueToString = param.convertValueToString, convertValueToReactNode = param.convertValueToReactNode, _param_convertValueToId = param.convertValueToId, convertValueToId = _param_convertValueToId === void 0 ? convertValueToString : _param_convertValueToId;
7866
+ var options = param.options, focusedIndex = param.focusedIndex, activeValue = param.activeValue, defaultOptionLabel = param.defaultOptionLabel, _param_noMatchesLabel = param.noMatchesLabel, noMatchesLabel = _param_noMatchesLabel === void 0 ? "Совпадений не найдено" : _param_noMatchesLabel, isLoading = param.isLoading, _param_loadingLabel = param.loadingLabel, loadingLabel = _param_loadingLabel === void 0 ? "Загрузка..." : _param_loadingLabel, tweakStyles = param.tweakStyles, testId = param.testId, _param_shouldScrollToList = param.shouldScrollToList, shouldScrollToList = _param_shouldScrollToList === void 0 ? true : _param_shouldScrollToList, customListHeader = param.customListHeader, isOptionDisabled = param.isOptionDisabled, allOptionsLabel = param.allOptionsLabel, onOptionSelect = param.onOptionSelect, onToggleCheckbox = param.onToggleCheckbox, convertValueToString = param.convertValueToString, _param_convertValueToReactNode = param.convertValueToReactNode, convertValueToReactNode = _param_convertValueToReactNode === void 0 ? convertValueToString : _param_convertValueToReactNode, convertValueToId = param.convertValueToId;
7789
7867
  var classes = useTheme("SelectList", styles$v, tweakStyles).classes;
7790
- var activeValueId = isNotEmpty(activeValue) ? convertValueToId(activeValue) : void 0;
7791
- var isActiveOption = function(item) {
7792
- return convertValueToId(item) === activeValueId;
7793
- };
7794
- var convertFunction = convertValueToReactNode !== null && convertValueToReactNode !== void 0 ? convertValueToReactNode : convertValueToString;
7868
+ var isMultiSelect = isNotEmpty(onToggleCheckbox);
7869
+ var multiSelectValue = activeValue;
7870
+ var _multiSelectValue_length;
7871
+ var selectedOptionsCount = (_multiSelectValue_length = multiSelectValue === null || multiSelectValue === void 0 ? void 0 : multiSelectValue.length) !== null && _multiSelectValue_length !== void 0 ? _multiSelectValue_length : 0;
7872
+ var _multiSelectValue_map;
7873
+ var activeOptionsIdMap = React.useMemo(function() {
7874
+ return isMultiSelect ? (_multiSelectValue_map = multiSelectValue === null || multiSelectValue === void 0 ? void 0 : multiSelectValue.map(convertValueToId)) !== null && _multiSelectValue_map !== void 0 ? _multiSelectValue_map : [] : [];
7875
+ }, [
7876
+ isMultiSelect,
7877
+ multiSelectValue,
7878
+ convertValueToId
7879
+ ]);
7795
7880
  var optionsDisableMap = React.useMemo(function() {
7796
7881
  return options.map(function(o) {
7797
7882
  return isOptionDisabled(o);
@@ -7802,15 +7887,18 @@
7802
7887
  ]);
7803
7888
  var listOptions = React.useMemo(function() {
7804
7889
  return options.map(function(opt, i) {
7805
- return convertFunction(opt, optionsDisableMap[i]);
7890
+ return convertValueToReactNode(opt, optionsDisableMap[i]);
7806
7891
  });
7807
7892
  }, [
7808
7893
  options,
7809
- convertFunction,
7894
+ convertValueToReactNode,
7810
7895
  optionsDisableMap
7811
7896
  ]);
7897
+ var isActiveOption = function(item) {
7898
+ return isMultiSelect ? activeOptionsIdMap.includes(convertValueToId(item)) : isNotEmpty(activeValue) && convertValueToId(activeValue) === convertValueToId(item);
7899
+ };
7812
7900
  return /* @__PURE__ */ jsxs(ScrollIntoViewIfNeeded, {
7813
- active: shouldScrollToList,
7901
+ active: shouldScrollToList && !isMultiSelect,
7814
7902
  className: clsx(classes.root, _define_property$x({}, classes.withListHeader, isNotEmpty(customListHeader))),
7815
7903
  children: [
7816
7904
  isNotEmpty(customListHeader) && /* @__PURE__ */ jsx("div", {
@@ -7825,39 +7913,42 @@
7825
7913
  children: loadingLabel
7826
7914
  }) : /* @__PURE__ */ jsxs(Fragment, {
7827
7915
  children: [
7828
- defaultOptionLabel !== void 0 && /* @__PURE__ */ jsx(ScrollIntoViewIfNeeded, {
7916
+ isNotEmpty(defaultOptionLabel) && /* @__PURE__ */ jsx(ScrollIntoViewIfNeeded, {
7829
7917
  active: focusedIndex === DEFAULT_OPTION_INDEX,
7830
7918
  options: {
7831
7919
  block: "nearest"
7832
7920
  },
7833
7921
  className: clsx(classes.cell, classes.defaultCell, focusedIndex === DEFAULT_OPTION_INDEX && classes.focused),
7834
7922
  onClick: function(event) {
7835
- return onOptionClick(DEFAULT_OPTION_INDEX, event);
7923
+ return onOptionSelect(DEFAULT_OPTION_INDEX, event);
7836
7924
  },
7837
7925
  children: defaultOptionLabel
7838
7926
  }),
7927
+ isNotEmpty(allOptionsLabel) && /* @__PURE__ */ jsx(SelectListItem, {
7928
+ classes,
7929
+ index: ALL_OPTION_INDEX,
7930
+ isSemiChecked: selectedOptionsCount > 0 && selectedOptionsCount < options.length,
7931
+ isActive: selectedOptionsCount === options.length,
7932
+ isFocused: focusedIndex === ALL_OPTION_INDEX,
7933
+ onOptionSelect,
7934
+ onToggleCheckbox,
7935
+ children: allOptionsLabel
7936
+ }),
7839
7937
  listOptions.map(function(opt, i) {
7840
7938
  var optionValue = options[i];
7841
- var isFocused = i === focusedIndex;
7939
+ var isFocused = focusedIndex === i;
7842
7940
  var isActive = isActiveOption(optionValue);
7843
7941
  var isDisabled = optionsDisableMap[i];
7844
- var _obj;
7845
- return /* @__PURE__ */ jsx(ScrollIntoViewIfNeeded, _object_spread_props$q(_object_spread$w({
7846
- active: isFocused,
7847
- options: {
7848
- block: "nearest"
7849
- },
7850
- className: clsx(classes.cell, (_obj = {}, _define_property$x(_obj, classes.focused, isFocused), _define_property$x(_obj, classes.active, isActive), _define_property$x(_obj, classes.disabled, isDisabled), _obj))
7851
- }, addDataAttributes({
7852
- disabled: isDisabled,
7853
- active: isActive,
7854
- focused: isFocused
7855
- })), {
7856
- onClick: !isDisabled ? function(event) {
7857
- return onOptionClick(i, event);
7858
- } : void 0,
7942
+ return /* @__PURE__ */ jsx(SelectListItem, {
7943
+ classes,
7944
+ index: i,
7945
+ isDisabled,
7946
+ isActive,
7947
+ isFocused,
7948
+ onOptionSelect,
7949
+ onToggleCheckbox,
7859
7950
  children: opt
7860
- }), i);
7951
+ }, i);
7861
7952
  }),
7862
7953
  listOptions.length === 0 && /* @__PURE__ */ jsx("div", {
7863
7954
  className: clsx(classes.cell, classes.noMatchesLabel),
@@ -7879,10 +7970,13 @@
7879
7970
  var defaultCompareFunction = function(v1, v2) {
7880
7971
  return v1 === v2;
7881
7972
  };
7882
- var getActiveValueIndex = function(options, value, convertFunc) {
7883
- return isNotEmpty(value) ? options.findIndex(function(o) {
7884
- return convertFunc(o) === convertFunc(value);
7885
- }) : -1;
7973
+ var getDefaultConvertToIdFunction = function(convertValueToString) {
7974
+ return function(value) {
7975
+ return isNotEmpty(value === null || value === void 0 ? void 0 : value.id) ? String(value.id) : convertValueToString(value);
7976
+ };
7977
+ };
7978
+ var isMultiSelectValue = function(props, _value) {
7979
+ return props.isMultiSelect === true;
7886
7980
  };
7887
7981
  var styles$u = {
7888
7982
  root: {
@@ -7932,6 +8026,21 @@
7932
8026
  input: {
7933
8027
  paddingRight: 32
7934
8028
  },
8029
+ withUnits: {
8030
+ paddingRight: 8
8031
+ },
8032
+ unitsWrapper: {
8033
+ position: "unset",
8034
+ padding: [
8035
+ 0,
8036
+ 32,
8037
+ 0,
8038
+ 0
8039
+ ]
8040
+ },
8041
+ fakeValue: {
8042
+ display: "none"
8043
+ },
7935
8044
  disabled: {
7936
8045
  "& $input": {
7937
8046
  cursor: "default"
@@ -8116,6 +8225,10 @@
8116
8225
  if (Array.isArray(arr))
8117
8226
  return arr;
8118
8227
  }
8228
+ function _array_without_holes$4(arr) {
8229
+ if (Array.isArray(arr))
8230
+ return _array_like_to_array$j(arr);
8231
+ }
8119
8232
  function asyncGeneratorStep$4(gen, resolve, reject, _next, _throw, key, arg) {
8120
8233
  try {
8121
8234
  var info = gen[key](arg);
@@ -8158,6 +8271,10 @@
8158
8271
  }
8159
8272
  return obj;
8160
8273
  }
8274
+ function _iterable_to_array$4(iter) {
8275
+ if (typeof Symbol !== "undefined" && iter[Symbol.iterator] != null || iter["@@iterator"] != null)
8276
+ return Array.from(iter);
8277
+ }
8161
8278
  function _iterable_to_array_limit$j(arr, i) {
8162
8279
  var _i = arr == null ? null : typeof Symbol !== "undefined" && arr[Symbol.iterator] || arr["@@iterator"];
8163
8280
  if (_i == null)
@@ -8189,6 +8306,9 @@
8189
8306
  function _non_iterable_rest$j() {
8190
8307
  throw new TypeError("Invalid attempt to destructure non-iterable instance.\\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.");
8191
8308
  }
8309
+ function _non_iterable_spread$4() {
8310
+ throw new TypeError("Invalid attempt to spread non-iterable instance.\\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.");
8311
+ }
8192
8312
  function _object_spread$u(target) {
8193
8313
  for (var i = 1; i < arguments.length; i++) {
8194
8314
  var source = arguments[i] != null ? arguments[i] : {};
@@ -8263,6 +8383,9 @@
8263
8383
  function _sliced_to_array$j(arr, i) {
8264
8384
  return _array_with_holes$j(arr) || _iterable_to_array_limit$j(arr, i) || _unsupported_iterable_to_array$j(arr, i) || _non_iterable_rest$j();
8265
8385
  }
8386
+ function _to_consumable_array$4(arr) {
8387
+ return _array_without_holes$4(arr) || _iterable_to_array$4(arr) || _unsupported_iterable_to_array$j(arr) || _non_iterable_spread$4();
8388
+ }
8266
8389
  function _unsupported_iterable_to_array$j(o, minLen) {
8267
8390
  if (!o)
8268
8391
  return;
@@ -8378,11 +8501,12 @@
8378
8501
  };
8379
8502
  }
8380
8503
  };
8381
- function Select(_param) {
8382
- var options = _param.options, value = _param.value, defaultOptionLabel = _param.defaultOptionLabel, _param_debounceTime = _param.debounceTime, debounceTime = _param_debounceTime === void 0 ? 400 : _param_debounceTime, _param_optionsMode = _param.optionsMode, optionsMode = _param_optionsMode === void 0 ? "normal" : _param_optionsMode, noMatchesLabel = _param.noMatchesLabel, loadingLabel = _param.loadingLabel, tweakStyles = _param.tweakStyles, testId = _param.testId, isReadonly = _param.isReadonly, isDisabled = _param.isDisabled, dropdownOptions = _param.dropdownOptions, _param_minSymbolsCountToOpenList = _param.minSymbolsCountToOpenList, minSymbolsCountToOpenList = _param_minSymbolsCountToOpenList === void 0 ? 0 : _param_minSymbolsCountToOpenList, _param_dropdownIcon = _param.dropdownIcon, dropdownIcon = _param_dropdownIcon === void 0 ? "chevron-down" : _param_dropdownIcon, _param_shouldScrollToList = _param.shouldScrollToList, shouldScrollToList = _param_shouldScrollToList === void 0 ? true : _param_shouldScrollToList, searchInput = _param.searchInput, onChange = _param.onChange, onFocus = _param.onFocus, onBlur = _param.onBlur, onType = _param.onType, onOpen = _param.onOpen, _param_isOptionDisabled = _param.isOptionDisabled, isOptionDisabled = _param_isOptionDisabled === void 0 ? defaultIsOptionDisabled : _param_isOptionDisabled, _param_compareValuesOnChange = _param.compareValuesOnChange, compareValuesOnChange = _param_compareValuesOnChange === void 0 ? defaultCompareFunction : _param_compareValuesOnChange, _param_convertValueToString = _param.convertValueToString, convertValueToString = _param_convertValueToString === void 0 ? defaultConvertFunction$2 : _param_convertValueToString, convertValueToId = _param.convertValueToId, convertValueToReactNode = _param.convertValueToReactNode, optionsFilter = _param.optionsFilter, inputProps = _object_without_properties$5(_param, [
8504
+ function Select(props) {
8505
+ var options = props.options, value = props.value, defaultOptionLabel = props.defaultOptionLabel, allOptionsLabel = props.allOptionsLabel, _props_debounceTime = props.debounceTime, debounceTime = _props_debounceTime === void 0 ? 400 : _props_debounceTime, _props_optionsMode = props.optionsMode, optionsMode = _props_optionsMode === void 0 ? "normal" : _props_optionsMode, noMatchesLabel = props.noMatchesLabel, loadingLabel = props.loadingLabel, tweakStyles = props.tweakStyles, testId = props.testId, isReadonly = props.isReadonly, isDisabled = props.isDisabled, dropdownOptions = props.dropdownOptions, _props_minSymbolsCountToOpenList = props.minSymbolsCountToOpenList, minSymbolsCountToOpenList = _props_minSymbolsCountToOpenList === void 0 ? 0 : _props_minSymbolsCountToOpenList, _props_dropdownIcon = props.dropdownIcon, dropdownIcon = _props_dropdownIcon === void 0 ? "chevron-down" : _props_dropdownIcon, _props_shouldScrollToList = props.shouldScrollToList, shouldScrollToList = _props_shouldScrollToList === void 0 ? true : _props_shouldScrollToList, searchInput = props.searchInput, units = props.units, onChange = props.onChange, onFocus = props.onFocus, onBlur = props.onBlur, onType = props.onType, onOpen = props.onOpen, _props_isOptionDisabled = props.isOptionDisabled, isOptionDisabled = _props_isOptionDisabled === void 0 ? defaultIsOptionDisabled : _props_isOptionDisabled, _props_compareValuesOnChange = props.compareValuesOnChange, compareValuesOnChange = _props_compareValuesOnChange === void 0 ? defaultCompareFunction : _props_compareValuesOnChange, _props_convertValueToString = props.convertValueToString, convertValueToString = _props_convertValueToString === void 0 ? defaultConvertFunction$2 : _props_convertValueToString, convertValueToId = props.convertValueToId, convertValueToReactNode = props.convertValueToReactNode, optionsFilter = props.optionsFilter, inputProps = _object_without_properties$5(props, [
8383
8506
  "options",
8384
8507
  "value",
8385
8508
  "defaultOptionLabel",
8509
+ "allOptionsLabel",
8386
8510
  "debounceTime",
8387
8511
  "optionsMode",
8388
8512
  "noMatchesLabel",
@@ -8396,6 +8520,7 @@
8396
8520
  "dropdownIcon",
8397
8521
  "shouldScrollToList",
8398
8522
  "searchInput",
8523
+ "units",
8399
8524
  "onChange",
8400
8525
  "onFocus",
8401
8526
  "onBlur",
@@ -8412,8 +8537,8 @@
8412
8537
  var isMounted = useIsMounted();
8413
8538
  var _useState = _sliced_to_array$j(React.useState(false), 2), isListOpen = _useState[0], setIsListOpen = _useState[1];
8414
8539
  var _useState1 = _sliced_to_array$j(React.useState(false), 2), areOptionsLoading = _useState1[0], setAreOptionsLoading = _useState1[1];
8415
- var hasDefaultOption = defaultOptionLabel !== void 0;
8416
- var _useState2 = _sliced_to_array$j(React.useState(-1), 2), focusedListCellIndex = _useState2[0], setFocusedListCellIndex = _useState2[1];
8540
+ var hasDefaultOption = isStringNotEmpty(defaultOptionLabel);
8541
+ var _useState2 = _sliced_to_array$j(React.useState(DEFAULT_OPTION_INDEX), 2), focusedListCellIndex = _useState2[0], setFocusedListCellIndex = _useState2[1];
8417
8542
  var _useState3 = _sliced_to_array$j(React.useState(""), 2), searchValue = _useState3[0], setSearchValue = _useState3[1];
8418
8543
  var _useState4 = _sliced_to_array$j(React.useState(true), 2), shouldShowDefaultOption = _useState4[0], setShouldShowDefaultOption = _useState4[1];
8419
8544
  var inputWrapper = React.useRef(null);
@@ -8421,31 +8546,50 @@
8421
8546
  var input = React.useRef(null);
8422
8547
  var shouldRenderSearchInputInList = (searchInput === null || searchInput === void 0 ? void 0 : searchInput.shouldRenderInList) === true;
8423
8548
  var hasSearchInputInList = optionsMode !== "normal" && shouldRenderSearchInputInList;
8424
- var stringValue = isNotEmpty(value) ? convertValueToString(value) : void 0;
8549
+ var isMultiSelect = isMultiSelectValue(props);
8550
+ var strValue = isMultiSelect ? value === null || value === void 0 ? void 0 : value[0] : value;
8551
+ var shouldShowAllOption = isMultiSelect && isNotEmpty(allOptionsLabel) && searchValue === "";
8425
8552
  var filteredOptions = React.useMemo(function() {
8426
8553
  if (optionsMode !== "search") {
8427
8554
  return options;
8428
8555
  }
8429
- if (isNotEmpty(optionsFilter)) {
8430
- return optionsFilter(options, searchValue);
8431
- }
8432
- var lowerCaseValue = searchValue === null || searchValue === void 0 ? void 0 : searchValue.toLowerCase();
8433
- return options.filter(function(option) {
8434
- var convertedOption = convertValueToString(option);
8435
- return convertedOption !== void 0 && convertedOption.toLowerCase().includes(lowerCaseValue);
8556
+ var _convertValueToString;
8557
+ var filter = optionsFilter !== null && optionsFilter !== void 0 ? optionsFilter : createFilter(function(option) {
8558
+ return [
8559
+ (_convertValueToString = convertValueToString(option)) !== null && _convertValueToString !== void 0 ? _convertValueToString : ""
8560
+ ];
8436
8561
  });
8562
+ return filter(options, searchValue);
8437
8563
  }, [
8438
- optionsMode,
8439
8564
  optionsFilter,
8440
8565
  options,
8441
8566
  convertValueToString,
8442
- searchValue
8567
+ searchValue,
8568
+ optionsMode
8443
8569
  ]);
8444
- React.useEffect(function() {
8445
- setFocusedListCellIndex(getActiveValueIndex(filteredOptions, value, convertValueToString));
8570
+ var optionsIndexesForNavigation = React.useMemo(function() {
8571
+ var result = [];
8572
+ if (shouldShowDefaultOption && hasDefaultOption) {
8573
+ result.push(DEFAULT_OPTION_INDEX);
8574
+ }
8575
+ if (shouldShowAllOption) {
8576
+ result.push(ALL_OPTION_INDEX);
8577
+ }
8578
+ return result.concat(filteredOptions.reduce(function(acc, cur, i) {
8579
+ if (!isOptionDisabled(cur)) {
8580
+ acc.push(i);
8581
+ }
8582
+ return acc;
8583
+ }, []));
8446
8584
  }, [
8447
- filteredOptions,
8448
- value,
8585
+ filteredOptions
8586
+ ]);
8587
+ var stringValue = isNotEmpty(strValue) ? convertValueToString(strValue) : void 0;
8588
+ var showedStringValue = isMultiSelect && (value === null || value === void 0 ? void 0 : value.length) === filteredOptions.length && isNotEmpty(allOptionsLabel) ? allOptionsLabel : stringValue;
8589
+ var convertToId = React.useCallback(function(v) {
8590
+ return (convertValueToId !== null && convertValueToId !== void 0 ? convertValueToId : getDefaultConvertToIdFunction(convertValueToString))(v);
8591
+ }, [
8592
+ convertValueToId,
8449
8593
  convertValueToString
8450
8594
  ]);
8451
8595
  var handleListClose = React.useCallback(function(event) {
@@ -8482,11 +8626,9 @@
8482
8626
  }
8483
8627
  };
8484
8628
  var handleOnChange = React.useCallback(function(newValue) {
8485
- var areValuesEqual = compareValuesOnChange(value, newValue);
8486
- if (areValuesEqual) {
8487
- return;
8629
+ if (!compareValuesOnChange(value, newValue)) {
8630
+ onChange(newValue);
8488
8631
  }
8489
- onChange(newValue);
8490
8632
  }, [
8491
8633
  value,
8492
8634
  compareValuesOnChange,
@@ -8494,7 +8636,7 @@
8494
8636
  ]);
8495
8637
  var handleOptionSelect = React.useCallback(function(index, event) {
8496
8638
  var _input_current;
8497
- handleOnChange(index === -1 ? void 0 : filteredOptions[index]);
8639
+ handleOnChange(index === DEFAULT_OPTION_INDEX ? void 0 : filteredOptions[index]);
8498
8640
  handleListClose(event);
8499
8641
  (_input_current = input.current) === null || _input_current === void 0 ? void 0 : _input_current.blur();
8500
8642
  }, [
@@ -8502,6 +8644,36 @@
8502
8644
  handleListClose,
8503
8645
  filteredOptions
8504
8646
  ]);
8647
+ var handleToggleOptionCheckbox = React.useCallback(function(index, isSelected) {
8648
+ if (!isMultiSelect) {
8649
+ return;
8650
+ }
8651
+ if (index === DEFAULT_OPTION_INDEX || index === ALL_OPTION_INDEX && !isSelected) {
8652
+ handleOnChange(void 0);
8653
+ return;
8654
+ }
8655
+ if (index === ALL_OPTION_INDEX && isSelected) {
8656
+ handleOnChange(options);
8657
+ return;
8658
+ }
8659
+ var option = filteredOptions[index];
8660
+ handleOnChange(isSelected ? (
8661
+ // Добавляем
8662
+ _to_consumable_array$4(value !== null && value !== void 0 ? value : []).concat([
8663
+ option
8664
+ ])
8665
+ ) : (
8666
+ // Убираем
8667
+ value === null || value === void 0 ? void 0 : value.filter(function(o) {
8668
+ return convertToId(o) !== convertToId(option);
8669
+ })
8670
+ ));
8671
+ }, [
8672
+ handleOnChange,
8673
+ filteredOptions,
8674
+ isMultiSelect,
8675
+ value
8676
+ ]);
8505
8677
  var handleOnType = React.useCallback(function() {
8506
8678
  var _ref2 = _async_to_generator$4(function(v) {
8507
8679
  return __generator$4(this, function(_state) {
@@ -8561,47 +8733,43 @@
8561
8733
  return;
8562
8734
  }
8563
8735
  event.stopPropagation();
8736
+ var curIndexInNavigation = optionsIndexesForNavigation.findIndex(function(index) {
8737
+ return index === focusedListCellIndex;
8738
+ });
8564
8739
  switch (event.code) {
8565
8740
  case "Enter":
8566
8741
  case "NumpadEnter": {
8567
- var indexToClick = focusedListCellIndex;
8568
- if (indexToClick === -1 && filteredOptions.length === 1) {
8569
- indexToClick = 0;
8742
+ var indexToSelect = focusedListCellIndex;
8743
+ if (indexToSelect === DEFAULT_OPTION_INDEX && filteredOptions.length === 1) {
8744
+ indexToSelect = 0;
8745
+ }
8746
+ if (isMultiSelect) {
8747
+ var isThisValueAlreadySelected;
8748
+ if (indexToSelect === ALL_OPTION_INDEX) {
8749
+ isThisValueAlreadySelected = (value === null || value === void 0 ? void 0 : value.length) === options.length;
8750
+ } else {
8751
+ var valueIdToSelect = convertToId(filteredOptions[indexToSelect]);
8752
+ var _value_some;
8753
+ isThisValueAlreadySelected = (_value_some = value === null || value === void 0 ? void 0 : value.some(function(opt) {
8754
+ return convertToId(opt) === valueIdToSelect;
8755
+ })) !== null && _value_some !== void 0 ? _value_some : false;
8756
+ }
8757
+ handleToggleOptionCheckbox(indexToSelect, !isThisValueAlreadySelected);
8758
+ } else {
8759
+ handleOptionSelect(indexToSelect, event);
8570
8760
  }
8571
- handleOptionSelect(indexToClick, event);
8572
8761
  break;
8573
8762
  }
8574
8763
  case "ArrowDown": {
8575
8764
  event.preventDefault();
8576
- var newIndex = focusedListCellIndex !== null && focusedListCellIndex !== void 0 ? focusedListCellIndex : -1;
8577
- for (var i = newIndex; i < newIndex + filteredOptions.length; i++) {
8578
- var targetIndex = (i + 1) % filteredOptions.length;
8579
- if (shouldShowDefaultOption && hasDefaultOption && newIndex > -1 && targetIndex === 0) {
8580
- newIndex = -1;
8581
- break;
8582
- }
8583
- if (!isOptionDisabled(filteredOptions[targetIndex])) {
8584
- newIndex = targetIndex;
8585
- break;
8586
- }
8587
- }
8588
- setFocusedListCellIndex(newIndex);
8765
+ var targetIndexInNavigation = (curIndexInNavigation + 1) % optionsIndexesForNavigation.length;
8766
+ setFocusedListCellIndex(optionsIndexesForNavigation[targetIndexInNavigation]);
8589
8767
  break;
8590
8768
  }
8591
8769
  case "ArrowUp": {
8592
8770
  event.preventDefault();
8593
- var newIndex1 = (focusedListCellIndex !== null && focusedListCellIndex !== void 0 ? focusedListCellIndex : -1) === -1 ? 0 : focusedListCellIndex;
8594
- for (var i1 = newIndex1; i1 > newIndex1 - filteredOptions.length; i1--) {
8595
- var targetIndex1 = (i1 > 0 ? i1 : filteredOptions.length + i1) - 1;
8596
- if (shouldShowDefaultOption && hasDefaultOption && focusedListCellIndex !== -1 && targetIndex1 === filteredOptions.length - 1) {
8597
- setFocusedListCellIndex(-1);
8598
- break;
8599
- }
8600
- if (!isOptionDisabled(filteredOptions[targetIndex1])) {
8601
- setFocusedListCellIndex(targetIndex1);
8602
- break;
8603
- }
8604
- }
8771
+ var targetIndexInNavigation1 = (curIndexInNavigation - 1 + optionsIndexesForNavigation.length) % optionsIndexesForNavigation.length;
8772
+ setFocusedListCellIndex(optionsIndexesForNavigation[targetIndexInNavigation1]);
8605
8773
  break;
8606
8774
  }
8607
8775
  }
@@ -8653,12 +8821,16 @@
8653
8821
  ]
8654
8822
  });
8655
8823
  React.useEffect(function() {
8656
- if (isOpen && onOpen !== void 0) {
8657
- onOpen();
8824
+ var val = isMultiSelect ? value === null || value === void 0 ? void 0 : value[0] : value;
8825
+ var _optionsIndexesForNavigation_find;
8826
+ setFocusedListCellIndex((_optionsIndexesForNavigation_find = optionsIndexesForNavigation.find(function(index) {
8827
+ return filteredOptions[index] === val;
8828
+ })) !== null && _optionsIndexesForNavigation_find !== void 0 ? _optionsIndexesForNavigation_find : optionsIndexesForNavigation[0]);
8829
+ if (isOpen) {
8830
+ onOpen === null || onOpen === void 0 ? void 0 : onOpen();
8658
8831
  }
8659
8832
  }, [
8660
- isOpen,
8661
- onOpen
8833
+ isOpen
8662
8834
  ]);
8663
8835
  var _obj;
8664
8836
  var listEl = /* @__PURE__ */ jsx("div", _object_spread_props$o(_object_spread$u({
@@ -8670,6 +8842,7 @@
8670
8842
  children: isOpen && /* @__PURE__ */ jsx(SelectList, {
8671
8843
  options: filteredOptions,
8672
8844
  defaultOptionLabel: hasDefaultOption && shouldShowDefaultOption ? defaultOptionLabel : void 0,
8845
+ allOptionsLabel: shouldShowAllOption ? allOptionsLabel : void 0,
8673
8846
  customListHeader: hasSearchInputInList ? /* @__PURE__ */ jsx(SearchInput, _object_spread$u({
8674
8847
  value: searchValue,
8675
8848
  onChange: handleInputChange,
@@ -8687,8 +8860,9 @@
8687
8860
  isOptionDisabled,
8688
8861
  convertValueToString,
8689
8862
  convertValueToReactNode,
8690
- convertValueToId,
8691
- onOptionClick: handleOptionSelect
8863
+ convertValueToId: convertToId,
8864
+ onOptionSelect: handleOptionSelect,
8865
+ onToggleCheckbox: isMultiSelect ? handleToggleOptionCheckbox : void 0
8692
8866
  })
8693
8867
  }));
8694
8868
  return /* @__PURE__ */ jsxs("div", {
@@ -8701,7 +8875,7 @@
8701
8875
  ref: inputWrapper,
8702
8876
  children: [
8703
8877
  /* @__PURE__ */ jsx(Input, _object_spread$u({
8704
- value: searchValue !== "" && !shouldRenderSearchInputInList ? searchValue : stringValue,
8878
+ value: searchValue !== "" && !shouldRenderSearchInputInList ? searchValue : showedStringValue,
8705
8879
  onChange: handleInputChange,
8706
8880
  isActive: isListOpen,
8707
8881
  isReadonly: hasReadonlyInput,
@@ -8711,7 +8885,8 @@
8711
8885
  ref: input,
8712
8886
  isLoading: areOptionsLoading,
8713
8887
  tweakStyles: tweakInputStyles,
8714
- testId
8888
+ testId,
8889
+ units: isMultiSelect && isNotEmpty(value) && value.length > 1 && value.length !== options.length ? "(+".concat(value.length - 1, ")") : units
8715
8890
  }, inputProps)),
8716
8891
  /* @__PURE__ */ jsx("div", {
8717
8892
  onMouseDown: function(event) {
@@ -27889,6 +28064,7 @@
27889
28064
  exports2.checkElementParentsClassNames = checkElementParentsClassNames;
27890
28065
  exports2.checkSearchStringInCountry = checkSearchStringInCountry;
27891
28066
  exports2.commonTheme = commonTheme;
28067
+ exports2.createFilter = createFilter;
27892
28068
  exports2.defaultConvertFunction = defaultConvertFunction$1;
27893
28069
  exports2.findCountryByCode = findCountryByCode;
27894
28070
  exports2.findCountryIndexByCode = findCountryIndexByCode;
@@ -27913,6 +28089,7 @@
27913
28089
  exports2.isInt = isInt;
27914
28090
  exports2.isNotEmpty = isNotEmpty;
27915
28091
  exports2.isSpaceChar = isSpaceChar;
28092
+ exports2.isStringNotEmpty = isStringNotEmpty;
27916
28093
  exports2.minWidthModifier = minWidthModifier;
27917
28094
  exports2.phoneInfo = phoneInfo;
27918
28095
  exports2.removeStringFormat = removeStringFormat;