@salutejs/plasma-new-hope 0.174.0-canary.1505.11503860288.0 → 0.174.0-canary.1505.11515852860.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (59) hide show
  1. package/cjs/components/Combobox/ComboboxNew/Combobox.js +15 -21
  2. package/cjs/components/Combobox/ComboboxNew/Combobox.js.map +1 -1
  3. package/cjs/components/Combobox/ComboboxNew/utils/getInitialValue.js +1 -7
  4. package/cjs/components/Combobox/ComboboxNew/utils/getInitialValue.js.map +1 -1
  5. package/cjs/components/Select/Select.js +2 -10
  6. package/cjs/components/Select/Select.js.map +1 -1
  7. package/cjs/components/Select/utils/getButtonLabel.js +2 -2
  8. package/cjs/components/Select/utils/getButtonLabel.js.map +1 -1
  9. package/cjs/components/Select/utils/getInitialValue.js +1 -7
  10. package/cjs/components/Select/utils/getInitialValue.js.map +1 -1
  11. package/emotion/cjs/components/Combobox/ComboboxNew/Combobox.js +14 -20
  12. package/emotion/cjs/components/Combobox/ComboboxNew/utils/getInitialValue.js +1 -7
  13. package/emotion/cjs/components/Select/Select.js +2 -10
  14. package/emotion/cjs/components/Select/utils/getButtonLabel.js +2 -2
  15. package/emotion/cjs/components/Select/utils/getInitialValue.js +1 -7
  16. package/emotion/cjs/examples/plasma_b2c/components/Combobox/Combobox.stories.tsx +6 -0
  17. package/emotion/cjs/examples/plasma_web/components/Combobox/Combobox.stories.tsx +6 -0
  18. package/emotion/es/components/Combobox/ComboboxNew/Combobox.js +14 -20
  19. package/emotion/es/components/Combobox/ComboboxNew/utils/getInitialValue.js +1 -7
  20. package/emotion/es/components/Select/Select.js +2 -10
  21. package/emotion/es/components/Select/utils/getButtonLabel.js +2 -2
  22. package/emotion/es/components/Select/utils/getInitialValue.js +1 -7
  23. package/emotion/es/examples/plasma_b2c/components/Combobox/Combobox.stories.tsx +6 -0
  24. package/emotion/es/examples/plasma_web/components/Combobox/Combobox.stories.tsx +6 -0
  25. package/es/components/Combobox/ComboboxNew/Combobox.js +15 -21
  26. package/es/components/Combobox/ComboboxNew/Combobox.js.map +1 -1
  27. package/es/components/Combobox/ComboboxNew/utils/getInitialValue.js +1 -7
  28. package/es/components/Combobox/ComboboxNew/utils/getInitialValue.js.map +1 -1
  29. package/es/components/Select/Select.js +2 -10
  30. package/es/components/Select/Select.js.map +1 -1
  31. package/es/components/Select/utils/getButtonLabel.js +2 -2
  32. package/es/components/Select/utils/getButtonLabel.js.map +1 -1
  33. package/es/components/Select/utils/getInitialValue.js +1 -7
  34. package/es/components/Select/utils/getInitialValue.js.map +1 -1
  35. package/package.json +2 -2
  36. package/styled-components/cjs/components/Combobox/ComboboxNew/Combobox.js +14 -20
  37. package/styled-components/cjs/components/Combobox/ComboboxNew/utils/getInitialValue.js +1 -7
  38. package/styled-components/cjs/components/Select/Select.js +2 -10
  39. package/styled-components/cjs/components/Select/utils/getButtonLabel.js +2 -2
  40. package/styled-components/cjs/components/Select/utils/getInitialValue.js +1 -7
  41. package/styled-components/cjs/examples/plasma_b2c/components/Combobox/Combobox.stories.tsx +6 -0
  42. package/styled-components/cjs/examples/plasma_web/components/Combobox/Combobox.stories.tsx +6 -0
  43. package/styled-components/es/components/Combobox/ComboboxNew/Combobox.js +14 -20
  44. package/styled-components/es/components/Combobox/ComboboxNew/utils/getInitialValue.js +1 -7
  45. package/styled-components/es/components/Select/Select.js +2 -10
  46. package/styled-components/es/components/Select/utils/getButtonLabel.js +2 -2
  47. package/styled-components/es/components/Select/utils/getInitialValue.js +1 -7
  48. package/styled-components/es/examples/plasma_b2c/components/Combobox/Combobox.stories.tsx +6 -0
  49. package/styled-components/es/examples/plasma_web/components/Combobox/Combobox.stories.tsx +6 -0
  50. package/types/components/Combobox/ComboboxNew/Combobox.d.ts.map +1 -1
  51. package/types/components/Combobox/ComboboxNew/Combobox.types.d.ts +7 -1
  52. package/types/components/Combobox/ComboboxNew/Combobox.types.d.ts.map +1 -1
  53. package/types/components/Combobox/ComboboxNew/utils/getInitialValue.d.ts.map +1 -1
  54. package/types/components/Select/Select.d.ts.map +1 -1
  55. package/types/components/Select/utils/getInitialValue.d.ts.map +1 -1
  56. package/types/examples/plasma_b2c/components/Combobox/Combobox.d.ts +18 -6
  57. package/types/examples/plasma_b2c/components/Combobox/Combobox.d.ts.map +1 -1
  58. package/types/examples/plasma_web/components/Combobox/Combobox.d.ts +18 -6
  59. package/types/examples/plasma_web/components/Combobox/Combobox.d.ts.map +1 -1
@@ -20,7 +20,7 @@ var _getPathMaps = /*#__PURE__*/require("./hooks/getPathMaps");
20
20
  var _Combobox2 = /*#__PURE__*/require("./Combobox.styles");
21
21
  var _base = /*#__PURE__*/require("./variations/_view/base");
22
22
  var _base2 = /*#__PURE__*/require("./variations/_size/base");
23
- var _excluded = ["multiple", "value", "onChange", "isTargetAmount", "items", "placement", "label", "placeholder", "helperText", "contentLeft", "textBefore", "textAfter", "variant", "listOverflow", "listHeight", "listWidth", "portal", "renderItem", "view", "size", "labelPlacement", "readOnly", "disabled", "alwaysOpened", "filter", "closeAfterSelect", "renderValue"];
23
+ var _excluded = ["multiple", "value", "onChange", "isTargetAmount", "targetAmount", "items", "placement", "label", "placeholder", "helperText", "contentLeft", "textBefore", "textAfter", "variant", "listOverflow", "listHeight", "listWidth", "portal", "renderItem", "view", "size", "labelPlacement", "readOnly", "disabled", "alwaysOpened", "filter", "closeAfterSelect", "renderValue"];
24
24
  function _getRequireWildcardCache(e) { if ("function" != typeof WeakMap) return null; var r = new WeakMap(), t = new WeakMap(); return (_getRequireWildcardCache = function _getRequireWildcardCache(e) { return e ? t : r; })(e); }
25
25
  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 && {}.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; }
26
26
  function _extends() { _extends = Object.assign ? Object.assign.bind() : function (target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]; for (var key in source) { if (Object.prototype.hasOwnProperty.call(source, key)) { target[key] = source[key]; } } } return target; }; return _extends.apply(this, arguments); }
@@ -44,6 +44,7 @@ var comboboxRoot = exports.comboboxRoot = function comboboxRoot(Root) {
44
44
  outerValue = props.value,
45
45
  outerOnChange = props.onChange,
46
46
  isTargetAmount = props.isTargetAmount,
47
+ targetAmount = props.targetAmount,
47
48
  items = props.items,
48
49
  _props$placement = props.placement,
49
50
  placement = _props$placement === void 0 ? 'bottom-start' : _props$placement,
@@ -73,9 +74,13 @@ var comboboxRoot = exports.comboboxRoot = function comboboxRoot(Root) {
73
74
  outerCloseAfterSelect = props.closeAfterSelect,
74
75
  renderValue = props.renderValue,
75
76
  rest = _objectWithoutProperties(props, _excluded);
77
+ var transformedItems = (0, _react.useMemo)(function () {
78
+ return (0, _utils3.initialItemsTransform)(items || []);
79
+ }, [items]);
80
+
76
81
  // Создаем структуры для быстрой работы с деревом
77
82
  var _useMemo = (0, _react.useMemo)(function () {
78
- return (0, _getPathMaps.getTreeMaps)(items);
83
+ return (0, _getPathMaps.getTreeMaps)(transformedItems);
79
84
  }, [items]),
80
85
  _useMemo2 = _slicedToArray(_useMemo, 3),
81
86
  valueToCheckedMap = _useMemo2[0],
@@ -94,9 +99,6 @@ var comboboxRoot = exports.comboboxRoot = function comboboxRoot(Root) {
94
99
  var floatingPopoverRef = (0, _react.useRef)(null);
95
100
  var inputForkRef = (0, _plasmaCore.useForkRef)(inputRef, ref);
96
101
  var treeId = (0, _plasmaCore.safeUseId)();
97
- var transformedItems = (0, _react.useMemo)(function () {
98
- return (0, _utils3.initialItemsTransform)(items || []);
99
- }, [items]);
100
102
  var filteredItems = (0, _utils3.filterItems)(transformedItems, textValue, (_valueToItemMap$get2 = valueToItemMap.get(value)) === null || _valueToItemMap$get2 === void 0 ? void 0 : _valueToItemMap$get2.label, filter);
101
103
  var _useMemo3 = (0, _react.useMemo)(function () {
102
104
  return (0, _getPathMaps.getPathMap)(filteredItems);
@@ -263,16 +265,7 @@ var comboboxRoot = exports.comboboxRoot = function comboboxRoot(Root) {
263
265
  if (e) {
264
266
  e.stopPropagation();
265
267
  }
266
- var checkedCopy = new Map(checked);
267
- var isCurrentChecked = checkedCopy.get(item.value);
268
- checkedCopy.forEach(function (_, key) {
269
- checkedCopy.set(key, false);
270
- });
271
- if (!isCurrentChecked) {
272
- checkedCopy.set(item.value, 'done');
273
- (0, _utils3.updateSingleAncestors)(item, checkedCopy, 'dot');
274
- }
275
- setTextValue(isCurrentChecked ? '' : item.label);
268
+ var isCurrentChecked = checked.get(item.value);
276
269
  if (!alwaysOpened && closeAfterSelect) {
277
270
  dispatchPath({
278
271
  type: 'reset'
@@ -289,14 +282,15 @@ var comboboxRoot = exports.comboboxRoot = function comboboxRoot(Root) {
289
282
  if (multiple && Array.isArray(value)) {
290
283
  if (value.length === 0) return [];
291
284
  if (isTargetAmount) {
292
- return ["\u0412\u044B\u0431\u0440\u0430\u043D\u043E ".concat(value.length)];
285
+ return ["\u0412\u044B\u0431\u0440\u0430\u043D\u043E ".concat(targetAmount || value.length)];
293
286
  }
294
- var mapper = renderValue && function (stringValue) {
287
+ var renderValueMapper = renderValue && function (stringValue) {
295
288
  return renderValue(valueToItemMap.get(stringValue));
296
- } || function (stringValue) {
289
+ };
290
+ var valueToItemMapper = function valueToItemMapper(stringValue) {
297
291
  return valueToItemMap.get(stringValue).label;
298
292
  };
299
- return value.map(mapper);
293
+ return value.map(renderValueMapper || valueToItemMapper);
300
294
  }
301
295
  return [];
302
296
  };
@@ -347,7 +341,7 @@ var comboboxRoot = exports.comboboxRoot = function comboboxRoot(Root) {
347
341
  // В deps мы кладем именно outerValue и internalValue, а не просто value.
348
342
  // Т.к. вначале нужно отфильтровать и провалидировать outerValue и результат положить в переменную.
349
343
  // А переменную, содержащую сложные типы данных, нельзя помещать в deps.
350
- }, [outerValue, internalValue]);
344
+ }, [outerValue, internalValue, items]);
351
345
  return /*#__PURE__*/_react["default"].createElement(Root, {
352
346
  size: size,
353
347
  view: view,
@@ -11,13 +11,7 @@ var getInitialValue = exports.getInitialValue = function getInitialValue(outerVa
11
11
  if (outerValue.length === 0) {
12
12
  return [];
13
13
  }
14
- var updatedValue = [];
15
- outerValue.forEach(function (value) {
16
- if (valueToItemMap.has(value)) {
17
- updatedValue.push(value);
18
- }
19
- });
20
- return updatedValue;
14
+ return outerValue.filter(valueToItemMap.has.bind(valueToItemMap));
21
15
  }
22
16
  if (valueToItemMap.has(outerValue)) {
23
17
  return outerValue;
@@ -163,15 +163,7 @@ var selectRoot = exports.selectRoot = function selectRoot(Root) {
163
163
  if (e) {
164
164
  e.stopPropagation();
165
165
  }
166
- var checkedCopy = new Map(checked);
167
- var isCurrentChecked = checkedCopy.get(item.value);
168
- checkedCopy.forEach(function (_, key) {
169
- checkedCopy.set(key, false);
170
- });
171
- if (!isCurrentChecked) {
172
- checkedCopy.set(item.value, 'done');
173
- (0, _utils2.updateSingleAncestors)(item, checkedCopy, 'dot');
174
- }
166
+ var isCurrentChecked = checked.get(item.value);
175
167
  if (closeAfterSelect) {
176
168
  dispatchPath({
177
169
  type: 'reset'
@@ -243,7 +235,7 @@ var selectRoot = exports.selectRoot = function selectRoot(Root) {
243
235
  }
244
236
  }
245
237
  setChecked(checkedCopy);
246
- }, [outerValue]);
238
+ }, [outerValue, items]);
247
239
  return /*#__PURE__*/_react["default"].createElement(Root, _extends({
248
240
  ref: ref,
249
241
  size: size,
@@ -22,8 +22,8 @@ var getButtonLabel = exports.getButtonLabel = function getButtonLabel(_ref3) {
22
22
  if ((0, _utils.isEmpty)(value) && typeof value !== 'number') {
23
23
  return label || '';
24
24
  }
25
- if (selectProps.multiselect && selectProps.isTargetAmount) {
26
- return "\u0412\u044B\u0431\u0440\u0430\u043D\u043E: ".concat(value.toString().length);
25
+ if (selectProps.multiselect && Array.isArray(value) && selectProps.isTargetAmount) {
26
+ return "\u0412\u044B\u0431\u0440\u0430\u043D\u043E: ".concat(value.length);
27
27
  }
28
28
  if (selectProps.multiselect && Array.isArray(value)) {
29
29
  return value === null || value === void 0 ? void 0 : value.map(function (itemValue) {
@@ -11,13 +11,7 @@ var getInitialValue = exports.getInitialValue = function getInitialValue(outerVa
11
11
  if (outerValue.length === 0) {
12
12
  return [];
13
13
  }
14
- var updatedValue = [];
15
- outerValue.forEach(function (value) {
16
- if (valueToItemMap.has(value)) {
17
- updatedValue.push(value);
18
- }
19
- });
20
- return updatedValue;
14
+ return outerValue.filter(valueToItemMap.has.bind(valueToItemMap));
21
15
  }
22
16
  if (valueToItemMap.has(outerValue)) {
23
17
  return outerValue;
@@ -68,6 +68,10 @@ const meta: Meta<StorySelectProps> = {
68
68
  control: { type: 'boolean' },
69
69
  if: { arg: 'alwaysOpened', truthy: false },
70
70
  },
71
+ targetAmount: {
72
+ control: { type: 'number' },
73
+ if: { arg: 'isTargetAmount', truthy: true },
74
+ },
71
75
  },
72
76
  args: {
73
77
  label: 'Label',
@@ -78,6 +82,7 @@ const meta: Meta<StorySelectProps> = {
78
82
  view: 'default',
79
83
  enableContentLeft: false,
80
84
  isTargetAmount: false,
85
+ targetAmount: undefined,
81
86
  variant: 'normal',
82
87
  alwaysOpened: false,
83
88
  disabled: false,
@@ -94,6 +99,7 @@ const meta: Meta<StorySelectProps> = {
94
99
  'placeholder',
95
100
  'helperText',
96
101
  'isTargetAmount',
102
+ 'targetAmount',
97
103
  'closeAfterSelect',
98
104
  'alwaysOpened',
99
105
  'variant',
@@ -68,6 +68,10 @@ const meta: Meta<StorySelectProps> = {
68
68
  control: { type: 'boolean' },
69
69
  if: { arg: 'alwaysOpened', truthy: false },
70
70
  },
71
+ targetAmount: {
72
+ control: { type: 'number' },
73
+ if: { arg: 'isTargetAmount', truthy: true },
74
+ },
71
75
  },
72
76
  args: {
73
77
  label: 'Label',
@@ -78,6 +82,7 @@ const meta: Meta<StorySelectProps> = {
78
82
  view: 'default',
79
83
  enableContentLeft: false,
80
84
  isTargetAmount: false,
85
+ targetAmount: undefined,
81
86
  variant: 'normal',
82
87
  alwaysOpened: false,
83
88
  disabled: false,
@@ -94,6 +99,7 @@ const meta: Meta<StorySelectProps> = {
94
99
  'placeholder',
95
100
  'helperText',
96
101
  'isTargetAmount',
102
+ 'targetAmount',
97
103
  'closeAfterSelect',
98
104
  'alwaysOpened',
99
105
  'variant',
@@ -1,4 +1,4 @@
1
- var _excluded = ["multiple", "value", "onChange", "isTargetAmount", "items", "placement", "label", "placeholder", "helperText", "contentLeft", "textBefore", "textAfter", "variant", "listOverflow", "listHeight", "listWidth", "portal", "renderItem", "view", "size", "labelPlacement", "readOnly", "disabled", "alwaysOpened", "filter", "closeAfterSelect", "renderValue"];
1
+ var _excluded = ["multiple", "value", "onChange", "isTargetAmount", "targetAmount", "items", "placement", "label", "placeholder", "helperText", "contentLeft", "textBefore", "textAfter", "variant", "listOverflow", "listHeight", "listWidth", "portal", "renderItem", "view", "size", "labelPlacement", "readOnly", "disabled", "alwaysOpened", "filter", "closeAfterSelect", "renderValue"];
2
2
  function _extends() { _extends = Object.assign ? Object.assign.bind() : function (target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]; for (var key in source) { if (Object.prototype.hasOwnProperty.call(source, key)) { target[key] = source[key]; } } } return target; }; return _extends.apply(this, arguments); }
3
3
  function _slicedToArray(arr, i) { return _arrayWithHoles(arr) || _iterableToArrayLimit(arr, i) || _unsupportedIterableToArray(arr, i) || _nonIterableRest(); }
4
4
  function _nonIterableRest() { throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); }
@@ -35,6 +35,7 @@ export var comboboxRoot = function comboboxRoot(Root) {
35
35
  outerValue = props.value,
36
36
  outerOnChange = props.onChange,
37
37
  isTargetAmount = props.isTargetAmount,
38
+ targetAmount = props.targetAmount,
38
39
  items = props.items,
39
40
  _props$placement = props.placement,
40
41
  placement = _props$placement === void 0 ? 'bottom-start' : _props$placement,
@@ -64,9 +65,13 @@ export var comboboxRoot = function comboboxRoot(Root) {
64
65
  outerCloseAfterSelect = props.closeAfterSelect,
65
66
  renderValue = props.renderValue,
66
67
  rest = _objectWithoutProperties(props, _excluded);
68
+ var transformedItems = useMemo(function () {
69
+ return initialItemsTransform(items || []);
70
+ }, [items]);
71
+
67
72
  // Создаем структуры для быстрой работы с деревом
68
73
  var _useMemo = useMemo(function () {
69
- return getTreeMaps(items);
74
+ return getTreeMaps(transformedItems);
70
75
  }, [items]),
71
76
  _useMemo2 = _slicedToArray(_useMemo, 3),
72
77
  valueToCheckedMap = _useMemo2[0],
@@ -85,9 +90,6 @@ export var comboboxRoot = function comboboxRoot(Root) {
85
90
  var floatingPopoverRef = useRef(null);
86
91
  var inputForkRef = useForkRef(inputRef, ref);
87
92
  var treeId = safeUseId();
88
- var transformedItems = useMemo(function () {
89
- return initialItemsTransform(items || []);
90
- }, [items]);
91
93
  var filteredItems = filterItems(transformedItems, textValue, (_valueToItemMap$get2 = valueToItemMap.get(value)) === null || _valueToItemMap$get2 === void 0 ? void 0 : _valueToItemMap$get2.label, filter);
92
94
  var _useMemo3 = useMemo(function () {
93
95
  return getPathMap(filteredItems);
@@ -254,16 +256,7 @@ export var comboboxRoot = function comboboxRoot(Root) {
254
256
  if (e) {
255
257
  e.stopPropagation();
256
258
  }
257
- var checkedCopy = new Map(checked);
258
- var isCurrentChecked = checkedCopy.get(item.value);
259
- checkedCopy.forEach(function (_, key) {
260
- checkedCopy.set(key, false);
261
- });
262
- if (!isCurrentChecked) {
263
- checkedCopy.set(item.value, 'done');
264
- updateSingleAncestors(item, checkedCopy, 'dot');
265
- }
266
- setTextValue(isCurrentChecked ? '' : item.label);
259
+ var isCurrentChecked = checked.get(item.value);
267
260
  if (!alwaysOpened && closeAfterSelect) {
268
261
  dispatchPath({
269
262
  type: 'reset'
@@ -280,14 +273,15 @@ export var comboboxRoot = function comboboxRoot(Root) {
280
273
  if (multiple && Array.isArray(value)) {
281
274
  if (value.length === 0) return [];
282
275
  if (isTargetAmount) {
283
- return ["\u0412\u044B\u0431\u0440\u0430\u043D\u043E ".concat(value.length)];
276
+ return ["\u0412\u044B\u0431\u0440\u0430\u043D\u043E ".concat(targetAmount || value.length)];
284
277
  }
285
- var mapper = renderValue && function (stringValue) {
278
+ var renderValueMapper = renderValue && function (stringValue) {
286
279
  return renderValue(valueToItemMap.get(stringValue));
287
- } || function (stringValue) {
280
+ };
281
+ var valueToItemMapper = function valueToItemMapper(stringValue) {
288
282
  return valueToItemMap.get(stringValue).label;
289
283
  };
290
- return value.map(mapper);
284
+ return value.map(renderValueMapper || valueToItemMapper);
291
285
  }
292
286
  return [];
293
287
  };
@@ -338,7 +332,7 @@ export var comboboxRoot = function comboboxRoot(Root) {
338
332
  // В deps мы кладем именно outerValue и internalValue, а не просто value.
339
333
  // Т.к. вначале нужно отфильтровать и провалидировать outerValue и результат положить в переменную.
340
334
  // А переменную, содержащую сложные типы данных, нельзя помещать в deps.
341
- }, [outerValue, internalValue]);
335
+ }, [outerValue, internalValue, items]);
342
336
  return /*#__PURE__*/React.createElement(Root, {
343
337
  size: size,
344
338
  view: view,
@@ -5,13 +5,7 @@ export var getInitialValue = function getInitialValue(outerValue, valueToItemMap
5
5
  if (outerValue.length === 0) {
6
6
  return [];
7
7
  }
8
- var updatedValue = [];
9
- outerValue.forEach(function (value) {
10
- if (valueToItemMap.has(value)) {
11
- updatedValue.push(value);
12
- }
13
- });
14
- return updatedValue;
8
+ return outerValue.filter(valueToItemMap.has.bind(valueToItemMap));
15
9
  }
16
10
  if (valueToItemMap.has(outerValue)) {
17
11
  return outerValue;
@@ -154,15 +154,7 @@ export var selectRoot = function selectRoot(Root) {
154
154
  if (e) {
155
155
  e.stopPropagation();
156
156
  }
157
- var checkedCopy = new Map(checked);
158
- var isCurrentChecked = checkedCopy.get(item.value);
159
- checkedCopy.forEach(function (_, key) {
160
- checkedCopy.set(key, false);
161
- });
162
- if (!isCurrentChecked) {
163
- checkedCopy.set(item.value, 'done');
164
- updateSingleAncestors(item, checkedCopy, 'dot');
165
- }
157
+ var isCurrentChecked = checked.get(item.value);
166
158
  if (closeAfterSelect) {
167
159
  dispatchPath({
168
160
  type: 'reset'
@@ -234,7 +226,7 @@ export var selectRoot = function selectRoot(Root) {
234
226
  }
235
227
  }
236
228
  setChecked(checkedCopy);
237
- }, [outerValue]);
229
+ }, [outerValue, items]);
238
230
  return /*#__PURE__*/React.createElement(Root, _extends({
239
231
  ref: ref,
240
232
  size: size,
@@ -16,8 +16,8 @@ export var getButtonLabel = function getButtonLabel(_ref3) {
16
16
  if (isEmpty(value) && typeof value !== 'number') {
17
17
  return label || '';
18
18
  }
19
- if (selectProps.multiselect && selectProps.isTargetAmount) {
20
- return "\u0412\u044B\u0431\u0440\u0430\u043D\u043E: ".concat(value.toString().length);
19
+ if (selectProps.multiselect && Array.isArray(value) && selectProps.isTargetAmount) {
20
+ return "\u0412\u044B\u0431\u0440\u0430\u043D\u043E: ".concat(value.length);
21
21
  }
22
22
  if (selectProps.multiselect && Array.isArray(value)) {
23
23
  return value === null || value === void 0 ? void 0 : value.map(function (itemValue) {
@@ -5,13 +5,7 @@ export var getInitialValue = function getInitialValue(outerValue, valueToItemMap
5
5
  if (outerValue.length === 0) {
6
6
  return [];
7
7
  }
8
- var updatedValue = [];
9
- outerValue.forEach(function (value) {
10
- if (valueToItemMap.has(value)) {
11
- updatedValue.push(value);
12
- }
13
- });
14
- return updatedValue;
8
+ return outerValue.filter(valueToItemMap.has.bind(valueToItemMap));
15
9
  }
16
10
  if (valueToItemMap.has(outerValue)) {
17
11
  return outerValue;
@@ -68,6 +68,10 @@ const meta: Meta<StorySelectProps> = {
68
68
  control: { type: 'boolean' },
69
69
  if: { arg: 'alwaysOpened', truthy: false },
70
70
  },
71
+ targetAmount: {
72
+ control: { type: 'number' },
73
+ if: { arg: 'isTargetAmount', truthy: true },
74
+ },
71
75
  },
72
76
  args: {
73
77
  label: 'Label',
@@ -78,6 +82,7 @@ const meta: Meta<StorySelectProps> = {
78
82
  view: 'default',
79
83
  enableContentLeft: false,
80
84
  isTargetAmount: false,
85
+ targetAmount: undefined,
81
86
  variant: 'normal',
82
87
  alwaysOpened: false,
83
88
  disabled: false,
@@ -94,6 +99,7 @@ const meta: Meta<StorySelectProps> = {
94
99
  'placeholder',
95
100
  'helperText',
96
101
  'isTargetAmount',
102
+ 'targetAmount',
97
103
  'closeAfterSelect',
98
104
  'alwaysOpened',
99
105
  'variant',
@@ -68,6 +68,10 @@ const meta: Meta<StorySelectProps> = {
68
68
  control: { type: 'boolean' },
69
69
  if: { arg: 'alwaysOpened', truthy: false },
70
70
  },
71
+ targetAmount: {
72
+ control: { type: 'number' },
73
+ if: { arg: 'isTargetAmount', truthy: true },
74
+ },
71
75
  },
72
76
  args: {
73
77
  label: 'Label',
@@ -78,6 +82,7 @@ const meta: Meta<StorySelectProps> = {
78
82
  view: 'default',
79
83
  enableContentLeft: false,
80
84
  isTargetAmount: false,
85
+ targetAmount: undefined,
81
86
  variant: 'normal',
82
87
  alwaysOpened: false,
83
88
  disabled: false,
@@ -94,6 +99,7 @@ const meta: Meta<StorySelectProps> = {
94
99
  'placeholder',
95
100
  'helperText',
96
101
  'isTargetAmount',
102
+ 'targetAmount',
97
103
  'closeAfterSelect',
98
104
  'alwaysOpened',
99
105
  'variant',
@@ -8,8 +8,8 @@ import { getTreeMaps, getPathMap } from './hooks/getPathMaps.js';
8
8
  import { IconArrowWrapper, StyledArrow, Ul, StyledEmptyState, base } from './Combobox.styles.js';
9
9
  import { base as base$1 } from './variations/_view/base.js';
10
10
  import { base as base$2 } from './variations/_size/base.js';
11
- import { getInitialValue } from './utils/getInitialValue.js';
12
11
  import { initialItemsTransform } from './utils/initialItemsTransform.js';
12
+ import { getInitialValue } from './utils/getInitialValue.js';
13
13
  import { filterItems } from './utils/filterItems.js';
14
14
  import { pathReducer } from './reducers/pathReducer.js';
15
15
  import { focusedPathReducer } from './reducers/focusedPathReducer.js';
@@ -23,7 +23,7 @@ import { sizeToIconSize } from '../../Select/utils/sizeToIconSize.js';
23
23
  import { getItemId } from './utils/getItemId.js';
24
24
  import { Inner } from './ui/Inner/Inner.js';
25
25
 
26
- var _excluded = ["multiple", "value", "onChange", "isTargetAmount", "items", "placement", "label", "placeholder", "helperText", "contentLeft", "textBefore", "textAfter", "variant", "listOverflow", "listHeight", "listWidth", "portal", "renderItem", "view", "size", "labelPlacement", "readOnly", "disabled", "alwaysOpened", "filter", "closeAfterSelect", "renderValue"];
26
+ var _excluded = ["multiple", "value", "onChange", "isTargetAmount", "targetAmount", "items", "placement", "label", "placeholder", "helperText", "contentLeft", "textBefore", "textAfter", "variant", "listOverflow", "listHeight", "listWidth", "portal", "renderItem", "view", "size", "labelPlacement", "readOnly", "disabled", "alwaysOpened", "filter", "closeAfterSelect", "renderValue"];
27
27
  var Context = /*#__PURE__*/createContext({});
28
28
 
29
29
  /**
@@ -36,6 +36,7 @@ var comboboxRoot = function comboboxRoot(Root) {
36
36
  outerValue = props.value,
37
37
  outerOnChange = props.onChange,
38
38
  isTargetAmount = props.isTargetAmount,
39
+ targetAmount = props.targetAmount,
39
40
  items = props.items,
40
41
  _props$placement = props.placement,
41
42
  placement = _props$placement === void 0 ? 'bottom-start' : _props$placement,
@@ -65,9 +66,13 @@ var comboboxRoot = function comboboxRoot(Root) {
65
66
  outerCloseAfterSelect = props.closeAfterSelect,
66
67
  renderValue = props.renderValue,
67
68
  rest = _objectWithoutProperties(props, _excluded);
69
+ var transformedItems = useMemo(function () {
70
+ return initialItemsTransform(items || []);
71
+ }, [items]);
72
+
68
73
  // Создаем структуры для быстрой работы с деревом
69
74
  var _useMemo = useMemo(function () {
70
- return getTreeMaps(items);
75
+ return getTreeMaps(transformedItems);
71
76
  }, [items]),
72
77
  _useMemo2 = _slicedToArray(_useMemo, 3),
73
78
  valueToCheckedMap = _useMemo2[0],
@@ -86,9 +91,6 @@ var comboboxRoot = function comboboxRoot(Root) {
86
91
  var floatingPopoverRef = useRef(null);
87
92
  var inputForkRef = useForkRef(inputRef, ref);
88
93
  var treeId = safeUseId();
89
- var transformedItems = useMemo(function () {
90
- return initialItemsTransform(items || []);
91
- }, [items]);
92
94
  var filteredItems = filterItems(transformedItems, textValue, (_valueToItemMap$get2 = valueToItemMap.get(value)) === null || _valueToItemMap$get2 === void 0 ? void 0 : _valueToItemMap$get2.label, filter);
93
95
  var _useMemo3 = useMemo(function () {
94
96
  return getPathMap(filteredItems);
@@ -255,16 +257,7 @@ var comboboxRoot = function comboboxRoot(Root) {
255
257
  if (e) {
256
258
  e.stopPropagation();
257
259
  }
258
- var checkedCopy = new Map(checked);
259
- var isCurrentChecked = checkedCopy.get(item.value);
260
- checkedCopy.forEach(function (_, key) {
261
- checkedCopy.set(key, false);
262
- });
263
- if (!isCurrentChecked) {
264
- checkedCopy.set(item.value, 'done');
265
- updateSingleAncestors(item, checkedCopy, 'dot');
266
- }
267
- setTextValue(isCurrentChecked ? '' : item.label);
260
+ var isCurrentChecked = checked.get(item.value);
268
261
  if (!alwaysOpened && closeAfterSelect) {
269
262
  dispatchPath({
270
263
  type: 'reset'
@@ -281,14 +274,15 @@ var comboboxRoot = function comboboxRoot(Root) {
281
274
  if (multiple && Array.isArray(value)) {
282
275
  if (value.length === 0) return [];
283
276
  if (isTargetAmount) {
284
- return ["\u0412\u044B\u0431\u0440\u0430\u043D\u043E ".concat(value.length)];
277
+ return ["\u0412\u044B\u0431\u0440\u0430\u043D\u043E ".concat(targetAmount || value.length)];
285
278
  }
286
- var mapper = renderValue && function (stringValue) {
279
+ var renderValueMapper = renderValue && function (stringValue) {
287
280
  return renderValue(valueToItemMap.get(stringValue));
288
- } || function (stringValue) {
281
+ };
282
+ var valueToItemMapper = function valueToItemMapper(stringValue) {
289
283
  return valueToItemMap.get(stringValue).label;
290
284
  };
291
- return value.map(mapper);
285
+ return value.map(renderValueMapper || valueToItemMapper);
292
286
  }
293
287
  return [];
294
288
  };
@@ -339,7 +333,7 @@ var comboboxRoot = function comboboxRoot(Root) {
339
333
  // В deps мы кладем именно outerValue и internalValue, а не просто value.
340
334
  // Т.к. вначале нужно отфильтровать и провалидировать outerValue и результат положить в переменную.
341
335
  // А переменную, содержащую сложные типы данных, нельзя помещать в deps.
342
- }, [outerValue, internalValue]);
336
+ }, [outerValue, internalValue, items]);
343
337
  return /*#__PURE__*/React.createElement(Root, {
344
338
  size: size,
345
339
  view: view,