@salutejs/plasma-new-hope 0.175.1-dev.0 → 0.175.2-dev.0
Sign up to get free protection for your applications and to get access to all the features.
- package/cjs/components/Combobox/ComboboxNew/Combobox.js +27 -22
- package/cjs/components/Combobox/ComboboxNew/Combobox.js.map +1 -1
- package/cjs/components/Combobox/ComboboxNew/utils/getInitialValue.js +21 -0
- package/cjs/components/Combobox/ComboboxNew/utils/getInitialValue.js.map +1 -0
- package/cjs/components/Combobox/ComboboxNew/utils/initialItemsTransform.js +9 -5
- package/cjs/components/Combobox/ComboboxNew/utils/initialItemsTransform.js.map +1 -1
- package/cjs/components/Pagination/ui/PaginationSelectPerPage/PaginationSelectPerPage.js +2 -2
- package/cjs/components/Pagination/ui/PaginationSelectPerPage/PaginationSelectPerPage.js.map +1 -1
- package/cjs/components/Select/Select.js +13 -25
- package/cjs/components/Select/Select.js.map +1 -1
- package/cjs/components/Select/hooks/useKeyboardNavigation.js +1 -1
- package/cjs/components/Select/hooks/useKeyboardNavigation.js.map +1 -1
- package/cjs/components/Select/ui/Target/ui/Textfield/Textfield.js +1 -1
- package/cjs/components/Select/ui/Target/ui/Textfield/Textfield.js.map +1 -1
- package/cjs/components/Select/ui/Target/ui/Textfield/Textfield.styles.js +1 -1
- package/cjs/components/Select/ui/Target/ui/Textfield/Textfield.styles.js.map +1 -1
- package/cjs/components/Select/utils/getButtonLabel.js +1 -1
- package/cjs/components/Select/utils/getButtonLabel.js.map +1 -1
- package/cjs/components/Select/utils/getInitialValue.js +21 -0
- package/cjs/components/Select/utils/getInitialValue.js.map +1 -0
- package/cjs/components/Select/utils/initialItemsTransform.js +9 -6
- package/cjs/components/Select/utils/initialItemsTransform.js.map +1 -1
- package/emotion/cjs/components/Combobox/ComboboxNew/Combobox.js +26 -22
- package/emotion/cjs/components/Combobox/ComboboxNew/utils/getInitialValue.js +20 -0
- package/emotion/cjs/components/Combobox/ComboboxNew/utils/index.js +8 -1
- package/emotion/cjs/components/Combobox/ComboboxNew/utils/initialItemsTransform.js +19 -5
- package/emotion/cjs/components/Pagination/ui/PaginationSelectPerPage/PaginationSelectPerPage.js +2 -2
- package/emotion/cjs/components/Select/Select.js +12 -25
- package/emotion/cjs/components/Select/hooks/useKeyboardNavigation.js +1 -1
- package/emotion/cjs/components/Select/ui/Target/ui/Textfield/Textfield.js +1 -1
- package/emotion/cjs/components/Select/ui/Target/ui/Textfield/Textfield.styles.js +13 -13
- package/emotion/cjs/components/Select/utils/getButtonLabel.js +1 -1
- package/emotion/cjs/components/Select/utils/getInitialValue.js +20 -0
- package/emotion/cjs/components/Select/utils/index.js +8 -1
- package/emotion/cjs/components/Select/utils/initialItemsTransform.js +19 -6
- package/emotion/cjs/examples/plasma_b2c/components/Combobox/Combobox.stories.tsx +6 -0
- package/emotion/cjs/examples/plasma_web/components/Combobox/Combobox.stories.tsx +6 -0
- package/emotion/es/components/Combobox/ComboboxNew/Combobox.js +27 -23
- package/emotion/es/components/Combobox/ComboboxNew/utils/getInitialValue.js +14 -0
- package/emotion/es/components/Combobox/ComboboxNew/utils/index.js +2 -1
- package/emotion/es/components/Combobox/ComboboxNew/utils/initialItemsTransform.js +19 -5
- package/emotion/es/components/Pagination/ui/PaginationSelectPerPage/PaginationSelectPerPage.js +2 -2
- package/emotion/es/components/Select/Select.js +13 -26
- package/emotion/es/components/Select/hooks/useKeyboardNavigation.js +1 -1
- package/emotion/es/components/Select/ui/Target/ui/Textfield/Textfield.js +1 -1
- package/emotion/es/components/Select/ui/Target/ui/Textfield/Textfield.styles.js +13 -13
- package/emotion/es/components/Select/utils/getButtonLabel.js +1 -1
- package/emotion/es/components/Select/utils/getInitialValue.js +14 -0
- package/emotion/es/components/Select/utils/index.js +2 -1
- package/emotion/es/components/Select/utils/initialItemsTransform.js +19 -6
- package/emotion/es/examples/plasma_b2c/components/Combobox/Combobox.stories.tsx +6 -0
- package/emotion/es/examples/plasma_web/components/Combobox/Combobox.stories.tsx +6 -0
- package/es/components/Combobox/ComboboxNew/Combobox.js +27 -22
- package/es/components/Combobox/ComboboxNew/Combobox.js.map +1 -1
- package/es/components/Combobox/ComboboxNew/utils/getInitialValue.js +17 -0
- package/es/components/Combobox/ComboboxNew/utils/getInitialValue.js.map +1 -0
- package/es/components/Combobox/ComboboxNew/utils/initialItemsTransform.js +9 -5
- package/es/components/Combobox/ComboboxNew/utils/initialItemsTransform.js.map +1 -1
- package/es/components/Pagination/ui/PaginationSelectPerPage/PaginationSelectPerPage.js +2 -2
- package/es/components/Pagination/ui/PaginationSelectPerPage/PaginationSelectPerPage.js.map +1 -1
- package/es/components/Select/Select.js +14 -26
- package/es/components/Select/Select.js.map +1 -1
- package/es/components/Select/hooks/useKeyboardNavigation.js +1 -1
- package/es/components/Select/hooks/useKeyboardNavigation.js.map +1 -1
- package/es/components/Select/ui/Target/ui/Textfield/Textfield.js +1 -1
- package/es/components/Select/ui/Target/ui/Textfield/Textfield.js.map +1 -1
- package/es/components/Select/ui/Target/ui/Textfield/Textfield.styles.js +1 -1
- package/es/components/Select/ui/Target/ui/Textfield/Textfield.styles.js.map +1 -1
- package/es/components/Select/utils/getButtonLabel.js +1 -1
- package/es/components/Select/utils/getButtonLabel.js.map +1 -1
- package/es/components/Select/utils/getInitialValue.js +17 -0
- package/es/components/Select/utils/getInitialValue.js.map +1 -0
- package/es/components/Select/utils/initialItemsTransform.js +9 -6
- package/es/components/Select/utils/initialItemsTransform.js.map +1 -1
- package/package.json +2 -2
- package/styled-components/cjs/components/Combobox/ComboboxNew/Combobox.js +26 -22
- package/styled-components/cjs/components/Combobox/ComboboxNew/utils/getInitialValue.js +20 -0
- package/styled-components/cjs/components/Combobox/ComboboxNew/utils/index.js +8 -1
- package/styled-components/cjs/components/Combobox/ComboboxNew/utils/initialItemsTransform.js +19 -5
- package/styled-components/cjs/components/Pagination/ui/PaginationSelectPerPage/PaginationSelectPerPage.js +2 -2
- package/styled-components/cjs/components/Select/Select.js +12 -25
- package/styled-components/cjs/components/Select/hooks/useKeyboardNavigation.js +1 -1
- package/styled-components/cjs/components/Select/ui/Target/ui/Textfield/Textfield.js +1 -1
- package/styled-components/cjs/components/Select/ui/Target/ui/Textfield/Textfield.styles.js +1 -1
- package/styled-components/cjs/components/Select/utils/getButtonLabel.js +1 -1
- package/styled-components/cjs/components/Select/utils/getInitialValue.js +20 -0
- package/styled-components/cjs/components/Select/utils/index.js +8 -1
- package/styled-components/cjs/components/Select/utils/initialItemsTransform.js +19 -6
- package/styled-components/cjs/examples/plasma_b2c/components/Combobox/Combobox.stories.tsx +6 -0
- package/styled-components/cjs/examples/plasma_web/components/Combobox/Combobox.stories.tsx +6 -0
- package/styled-components/es/components/Combobox/ComboboxNew/Combobox.js +27 -23
- package/styled-components/es/components/Combobox/ComboboxNew/utils/getInitialValue.js +14 -0
- package/styled-components/es/components/Combobox/ComboboxNew/utils/index.js +2 -1
- package/styled-components/es/components/Combobox/ComboboxNew/utils/initialItemsTransform.js +19 -5
- package/styled-components/es/components/Pagination/ui/PaginationSelectPerPage/PaginationSelectPerPage.js +2 -2
- package/styled-components/es/components/Select/Select.js +13 -26
- package/styled-components/es/components/Select/hooks/useKeyboardNavigation.js +1 -1
- package/styled-components/es/components/Select/ui/Target/ui/Textfield/Textfield.js +1 -1
- package/styled-components/es/components/Select/ui/Target/ui/Textfield/Textfield.styles.js +1 -1
- package/styled-components/es/components/Select/utils/getButtonLabel.js +1 -1
- package/styled-components/es/components/Select/utils/getInitialValue.js +14 -0
- package/styled-components/es/components/Select/utils/index.js +2 -1
- package/styled-components/es/components/Select/utils/initialItemsTransform.js +19 -6
- package/styled-components/es/examples/plasma_b2c/components/Combobox/Combobox.stories.tsx +6 -0
- package/styled-components/es/examples/plasma_web/components/Combobox/Combobox.stories.tsx +6 -0
- package/types/components/Combobox/ComboboxNew/Combobox.d.ts.map +1 -1
- package/types/components/Combobox/ComboboxNew/Combobox.types.d.ts +14 -3
- package/types/components/Combobox/ComboboxNew/Combobox.types.d.ts.map +1 -1
- package/types/components/Combobox/ComboboxNew/utils/getInitialValue.d.ts +4 -0
- package/types/components/Combobox/ComboboxNew/utils/getInitialValue.d.ts.map +1 -0
- package/types/components/Combobox/ComboboxNew/utils/index.d.ts +1 -0
- package/types/components/Combobox/ComboboxNew/utils/index.d.ts.map +1 -1
- package/types/components/Combobox/ComboboxNew/utils/initialItemsTransform.d.ts.map +1 -1
- package/types/components/Select/Select.d.ts.map +1 -1
- package/types/components/Select/Select.types.d.ts +1 -0
- package/types/components/Select/Select.types.d.ts.map +1 -1
- package/types/components/Select/hooks/useKeyboardNavigation.d.ts +2 -2
- package/types/components/Select/hooks/useKeyboardNavigation.d.ts.map +1 -1
- package/types/components/Select/ui/Target/Target.types.d.ts +2 -2
- package/types/components/Select/ui/Target/Target.types.d.ts.map +1 -1
- package/types/components/Select/ui/Target/ui/Textfield/Textfield.styles.d.ts +4 -4
- package/types/components/Select/ui/Target/ui/Textfield/Textfield.styles.d.ts.map +1 -1
- package/types/components/Select/utils/getInitialValue.d.ts +4 -0
- package/types/components/Select/utils/getInitialValue.d.ts.map +1 -0
- package/types/components/Select/utils/index.d.ts +1 -0
- package/types/components/Select/utils/index.d.ts.map +1 -1
- package/types/components/Select/utils/initialItemsTransform.d.ts.map +1 -1
- package/types/examples/plasma_b2c/components/Combobox/Combobox.d.ts +30 -6
- package/types/examples/plasma_b2c/components/Combobox/Combobox.d.ts.map +1 -1
- package/types/examples/plasma_web/components/Combobox/Combobox.d.ts +30 -6
- 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"];
|
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,
|
@@ -71,10 +72,15 @@ var comboboxRoot = exports.comboboxRoot = function comboboxRoot(Root) {
|
|
71
72
|
alwaysOpened = _props$alwaysOpened === void 0 ? false : _props$alwaysOpened,
|
72
73
|
filter = props.filter,
|
73
74
|
outerCloseAfterSelect = props.closeAfterSelect,
|
75
|
+
renderValue = props.renderValue,
|
74
76
|
rest = _objectWithoutProperties(props, _excluded);
|
77
|
+
var transformedItems = (0, _react.useMemo)(function () {
|
78
|
+
return (0, _utils3.initialItemsTransform)(items || []);
|
79
|
+
}, [items]);
|
80
|
+
|
75
81
|
// Создаем структуры для быстрой работы с деревом
|
76
82
|
var _useMemo = (0, _react.useMemo)(function () {
|
77
|
-
return (0, _getPathMaps.getTreeMaps)(
|
83
|
+
return (0, _getPathMaps.getTreeMaps)(transformedItems);
|
78
84
|
}, [items]),
|
79
85
|
_useMemo2 = _slicedToArray(_useMemo, 3),
|
80
86
|
valueToCheckedMap = _useMemo2[0],
|
@@ -88,14 +94,11 @@ var comboboxRoot = exports.comboboxRoot = function comboboxRoot(Root) {
|
|
88
94
|
_useState4 = _slicedToArray(_useState3, 2),
|
89
95
|
internalValue = _useState4[0],
|
90
96
|
setInternalValue = _useState4[1];
|
91
|
-
var value = outerValue
|
97
|
+
var value = outerValue !== null && outerValue !== undefined ? (0, _utils3.getInitialValue)(outerValue, valueToItemMap) : internalValue;
|
92
98
|
var inputRef = (0, _react.useRef)(null);
|
93
99
|
var floatingPopoverRef = (0, _react.useRef)(null);
|
94
100
|
var inputForkRef = (0, _plasmaCore.useForkRef)(inputRef, ref);
|
95
101
|
var treeId = (0, _plasmaCore.safeUseId)();
|
96
|
-
var transformedItems = (0, _react.useMemo)(function () {
|
97
|
-
return (0, _utils3.initialItemsTransform)(items || []);
|
98
|
-
}, [items]);
|
99
102
|
var filteredItems = (0, _utils3.filterItems)(transformedItems, textValue, (_valueToItemMap$get2 = valueToItemMap.get(value)) === null || _valueToItemMap$get2 === void 0 ? void 0 : _valueToItemMap$get2.label, filter);
|
100
103
|
var _useMemo3 = (0, _react.useMemo)(function () {
|
101
104
|
return (0, _getPathMaps.getPathMap)(filteredItems);
|
@@ -262,16 +265,7 @@ var comboboxRoot = exports.comboboxRoot = function comboboxRoot(Root) {
|
|
262
265
|
if (e) {
|
263
266
|
e.stopPropagation();
|
264
267
|
}
|
265
|
-
var
|
266
|
-
var isCurrentChecked = checkedCopy.get(item.value);
|
267
|
-
checkedCopy.forEach(function (_, key) {
|
268
|
-
checkedCopy.set(key, false);
|
269
|
-
});
|
270
|
-
if (!isCurrentChecked) {
|
271
|
-
checkedCopy.set(item.value, 'done');
|
272
|
-
(0, _utils3.updateSingleAncestors)(item, checkedCopy, 'dot');
|
273
|
-
}
|
274
|
-
setTextValue(isCurrentChecked ? '' : item.label);
|
268
|
+
var isCurrentChecked = checked.get(item.value);
|
275
269
|
if (!alwaysOpened && closeAfterSelect) {
|
276
270
|
dispatchPath({
|
277
271
|
type: 'reset'
|
@@ -285,14 +279,18 @@ var comboboxRoot = exports.comboboxRoot = function comboboxRoot(Root) {
|
|
285
279
|
}
|
286
280
|
};
|
287
281
|
var getChips = function getChips() {
|
288
|
-
if (multiple) {
|
282
|
+
if (multiple && Array.isArray(value)) {
|
289
283
|
if (value.length === 0) return [];
|
290
284
|
if (isTargetAmount) {
|
291
|
-
return ["\u0412\u044B\u0431\u0440\u0430\u043D\u043E ".concat(value.length)];
|
285
|
+
return ["\u0412\u044B\u0431\u0440\u0430\u043D\u043E ".concat(targetAmount || value.length)];
|
292
286
|
}
|
293
|
-
|
294
|
-
return valueToItemMap.get(
|
295
|
-
}
|
287
|
+
var renderValueMapper = renderValue && function (stringValue) {
|
288
|
+
return renderValue(valueToItemMap.get(stringValue));
|
289
|
+
};
|
290
|
+
var valueToItemMapper = function valueToItemMapper(stringValue) {
|
291
|
+
return valueToItemMap.get(stringValue).label;
|
292
|
+
};
|
293
|
+
return value.map(renderValueMapper || valueToItemMapper);
|
296
294
|
}
|
297
295
|
return [];
|
298
296
|
};
|
@@ -320,6 +318,7 @@ var comboboxRoot = exports.comboboxRoot = function comboboxRoot(Root) {
|
|
320
318
|
// В данном эффекте мы следим за изменениями value снаружи и вносим коррективы в дерево чекбоксов.
|
321
319
|
// Пример: когда юзер очистил value извне, тогда нужно пройтись по элементам и выключить все чекбоксы.
|
322
320
|
(0, _react.useLayoutEffect)(function () {
|
321
|
+
var _valueToItemMap$get4;
|
323
322
|
var checkedCopy = new Map(checked);
|
324
323
|
checkedCopy.forEach(function (_, key) {
|
325
324
|
checkedCopy.set(key, false);
|
@@ -337,7 +336,12 @@ var comboboxRoot = exports.comboboxRoot = function comboboxRoot(Root) {
|
|
337
336
|
}
|
338
337
|
}
|
339
338
|
setChecked(checkedCopy);
|
340
|
-
|
339
|
+
setTextValue(((_valueToItemMap$get4 = valueToItemMap.get(outerValue)) === null || _valueToItemMap$get4 === void 0 ? void 0 : _valueToItemMap$get4.label) || '');
|
340
|
+
|
341
|
+
// В deps мы кладем именно outerValue и internalValue, а не просто value.
|
342
|
+
// Т.к. вначале нужно отфильтровать и провалидировать outerValue и результат положить в переменную.
|
343
|
+
// А переменную, содержащую сложные типы данных, нельзя помещать в deps.
|
344
|
+
}, [outerValue, internalValue, items]);
|
341
345
|
return /*#__PURE__*/_react["default"].createElement(Root, {
|
342
346
|
size: size,
|
343
347
|
view: view,
|
@@ -0,0 +1,20 @@
|
|
1
|
+
"use strict";
|
2
|
+
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
4
|
+
value: true
|
5
|
+
});
|
6
|
+
exports.getInitialValue = void 0;
|
7
|
+
// Утилита предназначена для фильтрации элементов в value, которые отсутствуют в items.
|
8
|
+
// Эти элементы игнорируются и не участвуют в дальнейшей работе компонента.
|
9
|
+
var getInitialValue = exports.getInitialValue = function getInitialValue(outerValue, valueToItemMap) {
|
10
|
+
if (Array.isArray(outerValue)) {
|
11
|
+
if (outerValue.length === 0) {
|
12
|
+
return [];
|
13
|
+
}
|
14
|
+
return outerValue.filter(valueToItemMap.has.bind(valueToItemMap));
|
15
|
+
}
|
16
|
+
if (valueToItemMap.has(outerValue)) {
|
17
|
+
return outerValue;
|
18
|
+
}
|
19
|
+
return '';
|
20
|
+
};
|
@@ -9,6 +9,12 @@ Object.defineProperty(exports, "filterItems", {
|
|
9
9
|
return _filterItems.filterItems;
|
10
10
|
}
|
11
11
|
});
|
12
|
+
Object.defineProperty(exports, "getInitialValue", {
|
13
|
+
enumerable: true,
|
14
|
+
get: function get() {
|
15
|
+
return _getInitialValue.getInitialValue;
|
16
|
+
}
|
17
|
+
});
|
12
18
|
Object.defineProperty(exports, "getItemId", {
|
13
19
|
enumerable: true,
|
14
20
|
get: function get() {
|
@@ -51,4 +57,5 @@ var _updateAncestors = /*#__PURE__*/require("./updateAncestors");
|
|
51
57
|
var _updateSingleAncestors = /*#__PURE__*/require("./updateSingleAncestors");
|
52
58
|
var _sizeToIconSize = /*#__PURE__*/require("./sizeToIconSize");
|
53
59
|
var _filterItems = /*#__PURE__*/require("./filterItems");
|
54
|
-
var _getItemId = /*#__PURE__*/require("./getItemId");
|
60
|
+
var _getItemId = /*#__PURE__*/require("./getItemId");
|
61
|
+
var _getInitialValue = /*#__PURE__*/require("./getInitialValue");
|
@@ -1,17 +1,31 @@
|
|
1
1
|
"use strict";
|
2
2
|
|
3
|
+
function _typeof(o) { "@babel/helpers - typeof"; return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function (o) { return typeof o; } : function (o) { return o && "function" == typeof Symbol && o.constructor === Symbol && o !== Symbol.prototype ? "symbol" : typeof o; }, _typeof(o); }
|
3
4
|
Object.defineProperty(exports, "__esModule", {
|
4
5
|
value: true
|
5
6
|
});
|
6
7
|
exports.initialItemsTransform = void 0;
|
8
|
+
function ownKeys(e, r) { var t = Object.keys(e); if (Object.getOwnPropertySymbols) { var o = Object.getOwnPropertySymbols(e); r && (o = o.filter(function (r) { return Object.getOwnPropertyDescriptor(e, r).enumerable; })), t.push.apply(t, o); } return t; }
|
9
|
+
function _objectSpread(e) { for (var r = 1; r < arguments.length; r++) { var t = null != arguments[r] ? arguments[r] : {}; r % 2 ? ownKeys(Object(t), !0).forEach(function (r) { _defineProperty(e, r, t[r]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys(Object(t)).forEach(function (r) { Object.defineProperty(e, r, Object.getOwnPropertyDescriptor(t, r)); }); } return e; }
|
10
|
+
function _defineProperty(obj, key, value) { key = _toPropertyKey(key); if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }
|
11
|
+
function _toPropertyKey(t) { var i = _toPrimitive(t, "string"); return "symbol" == _typeof(i) ? i : i + ""; }
|
12
|
+
function _toPrimitive(t, r) { if ("object" != _typeof(t) || !t) return t; var e = t[Symbol.toPrimitive]; if (void 0 !== e) { var i = e.call(t, r || "default"); if ("object" != _typeof(i)) return i; throw new TypeError("@@toPrimitive must return a primitive value."); } return ("string" === r ? String : Number)(t); }
|
13
|
+
function _toConsumableArray(arr) { return _arrayWithoutHoles(arr) || _iterableToArray(arr) || _unsupportedIterableToArray(arr) || _nonIterableSpread(); }
|
14
|
+
function _nonIterableSpread() { throw new TypeError("Invalid attempt to spread non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); }
|
15
|
+
function _unsupportedIterableToArray(o, minLen) { if (!o) return; if (typeof o === "string") return _arrayLikeToArray(o, minLen); var n = Object.prototype.toString.call(o).slice(8, -1); if (n === "Object" && o.constructor) n = o.constructor.name; if (n === "Map" || n === "Set") return Array.from(o); if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _arrayLikeToArray(o, minLen); }
|
16
|
+
function _iterableToArray(iter) { if (typeof Symbol !== "undefined" && iter[Symbol.iterator] != null || iter["@@iterator"] != null) return Array.from(iter); }
|
17
|
+
function _arrayWithoutHoles(arr) { if (Array.isArray(arr)) return _arrayLikeToArray(arr); }
|
18
|
+
function _arrayLikeToArray(arr, len) { if (len == null || len > arr.length) len = arr.length; for (var i = 0, arr2 = new Array(len); i < len; i++) arr2[i] = arr[i]; return arr2; }
|
7
19
|
// Проходимся по массиву items и добавляем в каждый item ключ parent, который ссылается на item родителя.
|
8
20
|
// Дает возможность прохода к корневому элементу (снизу вверх).
|
21
|
+
// На выходе получаем глубокую копию исходного массива items.
|
9
22
|
var initialItemsTransform = exports.initialItemsTransform = function initialItemsTransform(items, parent) {
|
10
|
-
items.
|
11
|
-
|
12
|
-
|
13
|
-
|
23
|
+
return _toConsumableArray(items).map(function (item) {
|
24
|
+
var itemCopy = _objectSpread({}, item);
|
25
|
+
itemCopy.parent = parent;
|
26
|
+
if (itemCopy.items) {
|
27
|
+
itemCopy.items = initialItemsTransform(itemCopy.items, itemCopy);
|
14
28
|
}
|
29
|
+
return itemCopy;
|
15
30
|
});
|
16
|
-
return items;
|
17
31
|
};
|
package/emotion/cjs/components/Pagination/ui/PaginationSelectPerPage/PaginationSelectPerPage.js
CHANGED
@@ -24,8 +24,8 @@ var PaginationSelectPerPage = exports.PaginationSelectPerPage = function Paginat
|
|
24
24
|
listWidth = _ref.listWidth,
|
25
25
|
rest = _objectWithoutProperties(_ref, _excluded);
|
26
26
|
var handleSelectChange = function handleSelectChange(newValue) {
|
27
|
-
if (newValue) {
|
28
|
-
onChangeValue
|
27
|
+
if (newValue && !Array.isArray(newValue) && onChangeValue) {
|
28
|
+
onChangeValue(Number(newValue));
|
29
29
|
}
|
30
30
|
};
|
31
31
|
var transformedList = perPageList.map(function (num) {
|
@@ -67,17 +67,6 @@ var selectRoot = exports.selectRoot = function selectRoot(Root) {
|
|
67
67
|
separator = props.separator,
|
68
68
|
outerCloseAfterSelect = props.closeAfterSelect,
|
69
69
|
rest = _objectWithoutProperties(props, _excluded);
|
70
|
-
var _useState = (0, _react.useState)(outerValue || props.multiselect ? [] : ''),
|
71
|
-
_useState2 = _slicedToArray(_useState, 2),
|
72
|
-
internalValue = _useState2[0],
|
73
|
-
setInternalValue = _useState2[1];
|
74
|
-
var value = outerValue || internalValue;
|
75
|
-
var onChange = function onChange(e) {
|
76
|
-
if (outerOnChange) {
|
77
|
-
outerOnChange(e);
|
78
|
-
}
|
79
|
-
setInternalValue(e);
|
80
|
-
};
|
81
70
|
var transformedItems = (0, _react.useMemo)(function () {
|
82
71
|
return (0, _utils2.initialItemsTransform)(items || []);
|
83
72
|
}, [items]);
|
@@ -87,6 +76,12 @@ var selectRoot = exports.selectRoot = function selectRoot(Root) {
|
|
87
76
|
focusedToValueMap = _usePathMaps2[1],
|
88
77
|
valueToCheckedMap = _usePathMaps2[2],
|
89
78
|
valueToItemMap = _usePathMaps2[3];
|
79
|
+
var value = (0, _utils2.getInitialValue)(outerValue, valueToItemMap);
|
80
|
+
var onChange = function onChange(e) {
|
81
|
+
if (outerOnChange) {
|
82
|
+
outerOnChange(e);
|
83
|
+
}
|
84
|
+
};
|
90
85
|
var _useReducer = (0, _react.useReducer)(_reducers.pathReducer, []),
|
91
86
|
_useReducer2 = _slicedToArray(_useReducer, 2),
|
92
87
|
path = _useReducer2[0],
|
@@ -99,10 +94,10 @@ var selectRoot = exports.selectRoot = function selectRoot(Root) {
|
|
99
94
|
_useReducer6 = _slicedToArray(_useReducer5, 2),
|
100
95
|
focusedChipIndex = _useReducer6[0],
|
101
96
|
dispatchFocusedChipIndex = _useReducer6[1];
|
102
|
-
var
|
103
|
-
|
104
|
-
checked =
|
105
|
-
setChecked =
|
97
|
+
var _useState = (0, _react.useState)(valueToCheckedMap),
|
98
|
+
_useState2 = _slicedToArray(_useState, 2),
|
99
|
+
checked = _useState2[0],
|
100
|
+
setChecked = _useState2[1];
|
106
101
|
var closeAfterSelect = outerCloseAfterSelect !== null && outerCloseAfterSelect !== void 0 ? outerCloseAfterSelect : !props.multiselect;
|
107
102
|
var targetRef = (0, _hooks.useOutsideClick)(function () {
|
108
103
|
if (focusedChipIndex != null) {
|
@@ -168,15 +163,7 @@ var selectRoot = exports.selectRoot = function selectRoot(Root) {
|
|
168
163
|
if (e) {
|
169
164
|
e.stopPropagation();
|
170
165
|
}
|
171
|
-
var
|
172
|
-
var isCurrentChecked = checkedCopy.get(item.value);
|
173
|
-
checkedCopy.forEach(function (_, key) {
|
174
|
-
checkedCopy.set(key, false);
|
175
|
-
});
|
176
|
-
if (!isCurrentChecked) {
|
177
|
-
checkedCopy.set(item.value, 'done');
|
178
|
-
(0, _utils2.updateSingleAncestors)(item, checkedCopy, 'dot');
|
179
|
-
}
|
166
|
+
var isCurrentChecked = checked.get(item.value);
|
180
167
|
if (closeAfterSelect) {
|
181
168
|
dispatchPath({
|
182
169
|
type: 'reset'
|
@@ -248,7 +235,7 @@ var selectRoot = exports.selectRoot = function selectRoot(Root) {
|
|
248
235
|
}
|
249
236
|
}
|
250
237
|
setChecked(checkedCopy);
|
251
|
-
}, [
|
238
|
+
}, [outerValue, items]);
|
252
239
|
return /*#__PURE__*/_react["default"].createElement(Root, _extends({
|
253
240
|
ref: ref,
|
254
241
|
size: size,
|
@@ -159,7 +159,7 @@ var useKeyNavigation = exports.useKeyNavigation = function useKeyNavigation(_ref
|
|
159
159
|
}
|
160
160
|
case keys.Backspace:
|
161
161
|
{
|
162
|
-
if (!multiselect) break;
|
162
|
+
if (!multiselect || !Array.isArray(value)) break;
|
163
163
|
if (focusedChipIndex !== null) {
|
164
164
|
var _currentItem = valueToItemMap.get(value[focusedChipIndex]);
|
165
165
|
handlePressDown(_currentItem);
|
@@ -41,7 +41,7 @@ var getLabel = function getLabel(_ref) {
|
|
41
41
|
text: renderValue ? renderValue(valueToItemMap.get(currentValue)) : itemLabel,
|
42
42
|
onClick: function onClick(e) {
|
43
43
|
e.stopPropagation();
|
44
|
-
onChipClick(currentValue);
|
44
|
+
onChipClick(currentValue.toString());
|
45
45
|
},
|
46
46
|
focused: focusedChipIndex === index
|
47
47
|
});
|