@hh.ru/magritte-ui-tree-selector 5.5.80 → 5.5.81

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 (86) hide show
  1. package/Action.d.ts +1 -1
  2. package/Action.js +15 -12
  3. package/Action.js.map +1 -1
  4. package/Item.d.ts +3 -3
  5. package/Item.js +106 -54
  6. package/Item.js.map +1 -1
  7. package/ItemContent.d.ts +2 -2
  8. package/ItemContent.js +69 -15
  9. package/ItemContent.js.map +1 -1
  10. package/ItemsList.d.ts +3 -3
  11. package/ItemsList.js +243 -159
  12. package/ItemsList.js.map +1 -1
  13. package/MobileDelimiter.js +1 -1
  14. package/MobileDelimiter.js.map +1 -1
  15. package/MobileItem.d.ts +2 -2
  16. package/MobileItem.js +26 -5
  17. package/MobileItem.js.map +1 -1
  18. package/MobileItemsList.d.ts +2 -2
  19. package/MobileItemsList.js +259 -132
  20. package/MobileItemsList.js.map +1 -1
  21. package/MobileParentItem.d.ts +3 -3
  22. package/MobileParentItem.js +33 -14
  23. package/MobileParentItem.js.map +1 -1
  24. package/TreeSelector.d.ts +2 -2
  25. package/TreeSelector.js +49 -20
  26. package/TreeSelector.js.map +1 -1
  27. package/TreeSelectorDummy.d.ts +2 -2
  28. package/TreeSelectorDummy.js +178 -109
  29. package/TreeSelectorDummy.js.map +1 -1
  30. package/TreeSelectorItemBase.d.ts +2 -2
  31. package/TreeSelectorItemBase.js +12 -6
  32. package/TreeSelectorItemBase.js.map +1 -1
  33. package/TreeSelectorWrapper.js +38 -24
  34. package/TreeSelectorWrapper.js.map +1 -1
  35. package/collection/treeCollection.d.ts +1 -1
  36. package/collection/treeCollection.js +178 -184
  37. package/collection/treeCollection.js.map +1 -1
  38. package/collection/treeCollectionHelper.d.ts +9 -3
  39. package/collection/treeCollectionHelper.js +68 -105
  40. package/collection/treeCollectionHelper.js.map +1 -1
  41. package/collection/types.d.ts +1 -1
  42. package/index.css +45 -45
  43. package/index.d.ts +9 -9
  44. package/index.js +1 -1
  45. package/index.mock.d.ts +6 -6
  46. package/index.mock.js +14 -6
  47. package/index.mock.js.map +1 -1
  48. package/package.json +13 -13
  49. package/strategy/createSingleValueToggler.d.ts +1 -1
  50. package/strategy/createSingleValueToggler.js +17 -41
  51. package/strategy/createSingleValueToggler.js.map +1 -1
  52. package/strategy/createTreeCollectionToggler.d.ts +3 -3
  53. package/strategy/createTreeCollectionToggler.js +42 -58
  54. package/strategy/createTreeCollectionToggler.js.map +1 -1
  55. package/strategy/dummyToggle.d.ts +1 -1
  56. package/strategy/dummyToggle.js +10 -13
  57. package/strategy/dummyToggle.js.map +1 -1
  58. package/strategy/immutableSelectionStrategy.d.ts +3 -3
  59. package/strategy/immutableSelectionStrategy.js +27 -26
  60. package/strategy/immutableSelectionStrategy.js.map +1 -1
  61. package/strategy/selectionStrategy.d.ts +3 -3
  62. package/strategy/selectionStrategy.js +47 -56
  63. package/strategy/selectionStrategy.js.map +1 -1
  64. package/strategy/types.d.ts +1 -1
  65. package/tree-selector-item-DiHx85es.js +5 -0
  66. package/tree-selector-item-DiHx85es.js.map +1 -0
  67. package/types.d.ts +2 -2
  68. package/useAnimationTimeout.js +14 -14
  69. package/useAnimationTimeout.js.map +1 -1
  70. package/useDisabled.d.ts +2 -2
  71. package/useDisabled.js +7 -10
  72. package/useDisabled.js.map +1 -1
  73. package/useExpanded.d.ts +2 -2
  74. package/useExpanded.js +65 -54
  75. package/useExpanded.js.map +1 -1
  76. package/useIndeterminate.d.ts +2 -2
  77. package/useIndeterminate.js +17 -18
  78. package/useIndeterminate.js.map +1 -1
  79. package/useRenderInput.d.ts +1 -1
  80. package/useRenderInput.js +44 -32
  81. package/useRenderInput.js.map +1 -1
  82. package/useSelected.d.ts +3 -3
  83. package/useSelected.js +36 -31
  84. package/useSelected.js.map +1 -1
  85. package/tree-selector-item-BOEDcwrO.js +0 -5
  86. package/tree-selector-item-BOEDcwrO.js.map +0 -1
@@ -10,7 +10,7 @@ import { Action } from './Action.js';
10
10
  import { MobileDelimiter } from './MobileDelimiter.js';
11
11
  import { MobileItem } from './MobileItem.js';
12
12
  import { MobileParentItem } from './MobileParentItem.js';
13
- import { s as styles } from './tree-selector-item-BOEDcwrO.js';
13
+ import { s as styles } from './tree-selector-item-DiHx85es.js';
14
14
  import '@hh.ru/magritte-ui-checkbox-radio';
15
15
  import '@hh.ru/magritte-ui-card';
16
16
  import '@hh.ru/magritte-ui-typography';
@@ -19,145 +19,272 @@ import '@hh.ru/magritte-ui-badge';
19
19
 
20
20
  const DEFAULT_ITEM_HEIGHT = 56;
21
21
  const SCROLLEND_HANDLER_DEBOUNCE_MS = 150;
22
- const DELIMITER = ';';
22
+ const DELIMITER = ";";
23
23
  const MobileItemsListComponent = (props, ref) => {
24
- const { collection, selected, disabled, leavesOnly, singleChoice, onChange, checkSelectable, getMobileSearchItemOrder, setInputValue, handleChangeInput, isSearch, renderMobileDelimiter, renderItem, contentFilterQuery, getSelectAllParentTrl, renderContentBefore, renderContentAfter, onMobileNavigationChange, } = props;
25
- const navigationChangeCallback = useRef(onMobileNavigationChange);
26
- navigationChangeCallback.current = onMobileNavigationChange;
27
- const prevParentIds = useRef([]);
28
- const prevQueries = useRef([]);
29
- const currentQuery = useRef(contentFilterQuery);
30
- const [currentParentId, setCurrentParentId] = useState();
31
- const items = useMemo(() => (currentParentId ? collection.getChildren(currentParentId) : collection.getTopLevel()), [currentParentId, collection]);
32
- const orderHashMap = useMemo(() => {
33
- return items.reduce((acc, item) => {
34
- acc[item.id] = isSearch && !currentParentId ? getMobileSearchItemOrder(item) : 0;
35
- return acc;
36
- }, {});
37
- }, [items, isSearch, currentParentId, getMobileSearchItemOrder]);
38
- const sortedItems = useMemo(() => {
39
- return items.sort((itemA, itemB) => {
40
- return orderHashMap[itemA.id] - orderHashMap[itemB.id];
41
- });
42
- }, [items, orderHashMap]);
43
- const isSelectable = currentParentId && !leavesOnly && checkSelectable?.(currentParentId, collection);
44
- const withContentBefore = !!renderContentBefore;
45
- const withContentAfter = !!renderContentAfter;
46
- const count = items.length + (isSelectable ? 1 : 0) + (withContentBefore ? 1 : 0) + (withContentAfter ? 1 : 0);
47
- const parentRef = useRef(null);
48
- const isScrolling = useRef(false);
49
- const getItemKey = (index) => {
50
- if (withContentBefore && index === 0) {
51
- return 'promoTop';
24
+ const {
25
+ collection,
26
+ selected,
27
+ disabled,
28
+ leavesOnly,
29
+ singleChoice,
30
+ onChange,
31
+ checkSelectable,
32
+ getMobileSearchItemOrder,
33
+ setInputValue,
34
+ handleChangeInput,
35
+ isSearch,
36
+ renderMobileDelimiter,
37
+ renderItem,
38
+ contentFilterQuery,
39
+ getSelectAllParentTrl,
40
+ renderContentBefore,
41
+ renderContentAfter,
42
+ onMobileNavigationChange
43
+ } = props;
44
+ const navigationChangeCallback = useRef(onMobileNavigationChange);
45
+ navigationChangeCallback.current = onMobileNavigationChange;
46
+ const prevParentIds = useRef([]);
47
+ const prevQueries = useRef([]);
48
+ const currentQuery = useRef(contentFilterQuery);
49
+ const [currentParentId, setCurrentParentId] = useState();
50
+ const items = useMemo(
51
+ () => currentParentId ? collection.getChildren(currentParentId) : collection.getTopLevel(),
52
+ [currentParentId, collection]
53
+ );
54
+ const orderHashMap = useMemo(() => {
55
+ return items.reduce((acc, item) => {
56
+ acc[item.id] = isSearch && !currentParentId ? getMobileSearchItemOrder(item) : 0;
57
+ return acc;
58
+ }, {});
59
+ }, [items, isSearch, currentParentId, getMobileSearchItemOrder]);
60
+ const sortedItems = useMemo(() => {
61
+ return items.sort((itemA, itemB) => {
62
+ return orderHashMap[itemA.id] - orderHashMap[itemB.id];
63
+ });
64
+ }, [items, orderHashMap]);
65
+ const isSelectable = currentParentId && !leavesOnly && checkSelectable?.(currentParentId, collection);
66
+ const withContentBefore = !!renderContentBefore;
67
+ const withContentAfter = !!renderContentAfter;
68
+ const count = items.length + (isSelectable ? 1 : 0) + (withContentBefore ? 1 : 0) + (withContentAfter ? 1 : 0);
69
+ const parentRef = useRef(null);
70
+ const isScrolling = useRef(false);
71
+ const getItemKey = (index) => {
72
+ if (withContentBefore && index === 0) {
73
+ return "promoTop";
74
+ }
75
+ if (withContentAfter && index === count - 1) {
76
+ return "promoBottom";
77
+ }
78
+ const isSelectAllItem = isSelectable && (index === 0 && !withContentBefore || index === 1 && withContentBefore);
79
+ if (isSelectAllItem) {
80
+ return `current${currentParentId}`;
81
+ }
82
+ const itemIndex = index - (isSelectable ? 1 : 0) - (withContentBefore ? 1 : 0);
83
+ const item = sortedItems[itemIndex];
84
+ return currentParentId ? `${currentParentId}${DELIMITER}${item.id}` : `${item.id}`;
85
+ };
86
+ const virtualizer = useVirtualizer({
87
+ count,
88
+ getScrollElement: () => parentRef.current,
89
+ estimateSize: () => DEFAULT_ITEM_HEIGHT,
90
+ getItemKey
91
+ });
92
+ const itemsVirtualizer = virtualizer.getVirtualItems();
93
+ useEffect(() => {
94
+ setCurrentParentId(void 0);
95
+ prevParentIds.current = [];
96
+ prevQueries.current = [];
97
+ navigationChangeCallback.current?.(void 0);
98
+ currentQuery.current = contentFilterQuery;
99
+ }, [contentFilterQuery]);
100
+ useImperativeHandle(
101
+ ref,
102
+ () => ({
103
+ back: () => {
104
+ if (!isScrolling.current) {
105
+ const prevParentId = prevParentIds.current.pop();
106
+ setCurrentParentId(prevParentId);
107
+ navigationChangeCallback.current?.(prevParentId);
108
+ if (prevQueries.current.length) {
109
+ const prevInputValue = prevQueries.current.pop();
110
+ setInputValue(prevInputValue);
111
+ currentQuery.current = prevInputValue;
112
+ } else {
113
+ handleChangeInput("");
114
+ }
115
+ }
116
+ }
117
+ }),
118
+ [handleChangeInput, setInputValue]
119
+ );
120
+ useEffect(() => {
121
+ const handleScrollEnd = debounce(() => {
122
+ isScrolling.current = false;
123
+ }, SCROLLEND_HANDLER_DEBOUNCE_MS);
124
+ const handleScroll = () => {
125
+ isScrolling.current = true;
126
+ handleScrollEnd();
127
+ };
128
+ parentRef.current?.addEventListener("scroll", handleScroll);
129
+ return () => {
130
+ parentRef.current?.removeEventListener("scroll", handleScroll);
131
+ };
132
+ }, []);
133
+ const refCallback = useCallback((node) => {
134
+ parentRef.current = node ? node.parentElement : null;
135
+ }, []);
136
+ useEffect(() => {
137
+ virtualizer.scrollToIndex(0);
138
+ }, [currentParentId, sortedItems, virtualizer]);
139
+ return /* @__PURE__ */ jsx(
140
+ "div",
141
+ {
142
+ ref: refCallback,
143
+ className: styles.virtualizedList,
144
+ style: {
145
+ height: `${virtualizer.getTotalSize()}px`
146
+ },
147
+ children: itemsVirtualizer.map((virtualItem) => {
148
+ const isContentBeforeItem = withContentBefore && virtualItem.index === 0;
149
+ const isContentAfterItem = withContentAfter && virtualItem.index === count - 1;
150
+ const isSelectAllItem = isSelectable && (virtualItem.index === 0 && !withContentBefore || virtualItem.index === 1 && withContentBefore);
151
+ if (isContentBeforeItem) {
152
+ return /* @__PURE__ */ jsx(
153
+ "div",
154
+ {
155
+ ref: virtualizer.measureElement,
156
+ "data-index": virtualItem.index,
157
+ className: styles.virtualizedItem,
158
+ style: {
159
+ transform: `translateY(${virtualItem.start}px)`
160
+ },
161
+ children: renderContentBefore(isSearch)
162
+ },
163
+ virtualItem.key
164
+ );
52
165
  }
53
- if (withContentAfter && index === count - 1) {
54
- return 'promoBottom';
166
+ if (isContentAfterItem) {
167
+ return /* @__PURE__ */ jsx(
168
+ "div",
169
+ {
170
+ ref: virtualizer.measureElement,
171
+ "data-index": virtualItem.index,
172
+ className: styles.virtualizedItem,
173
+ style: {
174
+ transform: `translateY(${virtualItem.start}px)`
175
+ },
176
+ children: renderContentAfter(isSearch)
177
+ },
178
+ virtualItem.key
179
+ );
55
180
  }
56
- const isSelectAllItem = isSelectable && ((index === 0 && !withContentBefore) || (index === 1 && withContentBefore));
57
181
  if (isSelectAllItem) {
58
- return `current${currentParentId}`;
182
+ return /* @__PURE__ */ jsx(
183
+ "div",
184
+ {
185
+ ref: virtualizer.measureElement,
186
+ "data-index": virtualItem.index,
187
+ className: styles.virtualizedItem,
188
+ style: {
189
+ transform: `translateY(${virtualItem.start}px)`
190
+ },
191
+ children: /* @__PURE__ */ jsx("div", { className: styles.mobileItem, children: /* @__PURE__ */ jsx(
192
+ CheckableCardElement,
193
+ {
194
+ padding: 16,
195
+ flexible: true,
196
+ borderRadius: 12,
197
+ Element: "label",
198
+ checked: selected.includes(currentParentId),
199
+ "data-qa": `tree-selector-select-all-${currentParentId}`,
200
+ children: /* @__PURE__ */ jsx(
201
+ Cell,
202
+ {
203
+ Element: "div",
204
+ disabled: disabled.includes(currentParentId),
205
+ right: /* @__PURE__ */ jsx(
206
+ Action,
207
+ {
208
+ selected: selected.includes(currentParentId),
209
+ onChange,
210
+ id: currentParentId,
211
+ singleChoice
212
+ }
213
+ ),
214
+ children: /* @__PURE__ */ jsx(CellText, { children: getSelectAllParentTrl(currentParentId) })
215
+ }
216
+ )
217
+ }
218
+ ) })
219
+ },
220
+ virtualItem.key
221
+ );
59
222
  }
60
- const itemIndex = index - (isSelectable ? 1 : 0) - (withContentBefore ? 1 : 0);
223
+ const itemIndex = virtualItem.index - (isSelectable ? 1 : 0) - (withContentBefore ? 1 : 0);
61
224
  const item = sortedItems[itemIndex];
62
- return currentParentId ? `${currentParentId}${DELIMITER}${item.id}` : `${item.id}`;
63
- };
64
- const virtualizer = useVirtualizer({
65
- count,
66
- getScrollElement: () => parentRef.current,
67
- estimateSize: () => DEFAULT_ITEM_HEIGHT,
68
- getItemKey,
69
- });
70
- const itemsVirtualizer = virtualizer.getVirtualItems();
71
- useEffect(() => {
72
- setCurrentParentId(undefined);
73
- prevParentIds.current = [];
74
- prevQueries.current = [];
75
- navigationChangeCallback.current?.(undefined);
76
- currentQuery.current = contentFilterQuery;
77
- }, [contentFilterQuery]);
78
- useImperativeHandle(ref, () => ({
79
- back: () => {
80
- if (!isScrolling.current) {
81
- const prevParentId = prevParentIds.current.pop();
82
- setCurrentParentId(prevParentId);
83
- navigationChangeCallback.current?.(prevParentId);
84
- if (prevQueries.current.length) {
85
- const prevInputValue = prevQueries.current.pop();
86
- setInputValue(prevInputValue);
87
- currentQuery.current = prevInputValue;
225
+ const hasChildren = collection.hasChildren(item.id);
226
+ const hasLetter = item.additional?.char && !isSearch;
227
+ const delimiterContent = renderMobileDelimiter?.({
228
+ item,
229
+ order: orderHashMap[item.id],
230
+ isSearch,
231
+ index: itemIndex,
232
+ isTopLevel: !currentParentId
233
+ });
234
+ const withGap = !!withContentBefore && virtualItem.index !== 1 || !withContentBefore && virtualItem.index !== 0;
235
+ return /* @__PURE__ */ jsx(
236
+ "div",
237
+ {
238
+ ref: virtualizer.measureElement,
239
+ "data-index": virtualItem.index,
240
+ style: {
241
+ transform: `translateY(${virtualItem.start}px)`
242
+ },
243
+ className: classnames(styles.virtualizedItem, {
244
+ [styles.withGap]: withGap
245
+ }),
246
+ children: /* @__PURE__ */ jsxs("div", { className: styles.mobileItem, children: [
247
+ hasLetter && /* @__PURE__ */ jsx(MobileDelimiter, { children: item.additional?.char }),
248
+ delimiterContent && /* @__PURE__ */ jsx(MobileDelimiter, { children: delimiterContent }),
249
+ hasChildren ? /* @__PURE__ */ jsx(
250
+ MobileParentItem,
251
+ {
252
+ collection,
253
+ item,
254
+ selected,
255
+ onClick: () => {
256
+ prevParentIds.current.push(currentParentId);
257
+ prevQueries.current.push(currentQuery.current);
258
+ setCurrentParentId(item.id);
259
+ setInputValue("");
260
+ currentQuery.current = "";
261
+ navigationChangeCallback.current?.(item.id);
262
+ },
263
+ parentId: currentParentId,
264
+ isSearch,
265
+ renderItem
88
266
  }
89
- else {
90
- handleChangeInput('');
267
+ ) : /* @__PURE__ */ jsx(
268
+ MobileItem,
269
+ {
270
+ item,
271
+ singleChoice,
272
+ isSelectable: checkSelectable?.(item.id, collection),
273
+ isSelected: selected.includes(item.id),
274
+ isDisabled: disabled.includes(item.id),
275
+ onChange,
276
+ isSearch,
277
+ renderItem,
278
+ parentId: currentParentId
91
279
  }
92
- }
93
- },
94
- }), [handleChangeInput, setInputValue]);
95
- useEffect(() => {
96
- const handleScrollEnd = debounce(() => {
97
- isScrolling.current = false;
98
- }, SCROLLEND_HANDLER_DEBOUNCE_MS);
99
- const handleScroll = () => {
100
- isScrolling.current = true;
101
- handleScrollEnd();
102
- };
103
- parentRef.current?.addEventListener('scroll', handleScroll);
104
- return () => {
105
- parentRef.current?.removeEventListener('scroll', handleScroll);
106
- };
107
- }, []);
108
- const refCallback = useCallback((node) => {
109
- parentRef.current = node ? node.parentElement : null;
110
- }, []);
111
- useEffect(() => {
112
- virtualizer.scrollToIndex(0);
113
- }, [currentParentId, sortedItems, virtualizer]);
114
- return (jsx("div", { ref: refCallback, className: styles.virtualizedList, style: {
115
- height: `${virtualizer.getTotalSize()}px`,
116
- }, children: itemsVirtualizer.map((virtualItem) => {
117
- const isContentBeforeItem = withContentBefore && virtualItem.index === 0;
118
- const isContentAfterItem = withContentAfter && virtualItem.index === count - 1;
119
- const isSelectAllItem = isSelectable &&
120
- ((virtualItem.index === 0 && !withContentBefore) || (virtualItem.index === 1 && withContentBefore));
121
- if (isContentBeforeItem) {
122
- return (jsx("div", { ref: virtualizer.measureElement, "data-index": virtualItem.index, className: styles.virtualizedItem, style: {
123
- transform: `translateY(${virtualItem.start}px)`,
124
- }, children: renderContentBefore(isSearch) }, virtualItem.key));
125
- }
126
- if (isContentAfterItem) {
127
- return (jsx("div", { ref: virtualizer.measureElement, "data-index": virtualItem.index, className: styles.virtualizedItem, style: {
128
- transform: `translateY(${virtualItem.start}px)`,
129
- }, children: renderContentAfter(isSearch) }, virtualItem.key));
130
- }
131
- if (isSelectAllItem) {
132
- return (jsx("div", { ref: virtualizer.measureElement, "data-index": virtualItem.index, className: styles.virtualizedItem, style: {
133
- transform: `translateY(${virtualItem.start}px)`,
134
- }, children: jsx("div", { className: styles.mobileItem, children: jsx(CheckableCardElement, { padding: 16, flexible: true, borderRadius: 12, Element: "label", checked: selected.includes(currentParentId), "data-qa": `tree-selector-select-all-${currentParentId}`, children: jsx(Cell, { Element: 'div', disabled: disabled.includes(currentParentId), right: jsx(Action, { selected: selected.includes(currentParentId), onChange: onChange, id: currentParentId, singleChoice: singleChoice }), children: jsx(CellText, { children: getSelectAllParentTrl(currentParentId) }) }) }) }) }, virtualItem.key));
135
- }
136
- const itemIndex = virtualItem.index - (isSelectable ? 1 : 0) - (withContentBefore ? 1 : 0);
137
- const item = sortedItems[itemIndex];
138
- const hasChildren = collection.hasChildren(item.id);
139
- const hasLetter = item.additional?.char && !isSearch;
140
- const delimiterContent = renderMobileDelimiter?.({
141
- item,
142
- order: orderHashMap[item.id],
143
- isSearch,
144
- index: itemIndex,
145
- isTopLevel: !currentParentId,
146
- });
147
- const withGap = (!!withContentBefore && virtualItem.index !== 1) || (!withContentBefore && virtualItem.index !== 0);
148
- return (jsx("div", { ref: virtualizer.measureElement, "data-index": virtualItem.index, style: {
149
- transform: `translateY(${virtualItem.start}px)`,
150
- }, className: classnames(styles.virtualizedItem, {
151
- [styles.withGap]: withGap,
152
- }), children: jsxs("div", { className: styles.mobileItem, children: [hasLetter && jsx(MobileDelimiter, { children: item.additional?.char }), delimiterContent && jsx(MobileDelimiter, { children: delimiterContent }), hasChildren ? (jsx(MobileParentItem, { collection: collection, item: item, selected: selected, onClick: () => {
153
- prevParentIds.current.push(currentParentId);
154
- prevQueries.current.push(currentQuery.current);
155
- setCurrentParentId(item.id);
156
- setInputValue('');
157
- currentQuery.current = '';
158
- navigationChangeCallback.current?.(item.id);
159
- }, parentId: currentParentId, isSearch: isSearch, renderItem: renderItem })) : (jsx(MobileItem, { item: item, singleChoice: singleChoice, isSelectable: checkSelectable?.(item.id, collection), isSelected: selected.includes(item.id), isDisabled: disabled.includes(item.id), onChange: onChange, isSearch: isSearch, renderItem: renderItem, parentId: currentParentId }))] }) }, virtualItem.key));
160
- }) }));
280
+ )
281
+ ] })
282
+ },
283
+ virtualItem.key
284
+ );
285
+ })
286
+ }
287
+ );
161
288
  };
162
289
  const MobileItemsList = forwardRef(MobileItemsListComponent);
163
290
 
@@ -1 +1 @@
1
- {"version":3,"file":"MobileItemsList.js","sources":["src/MobileItemsList.tsx"],"sourcesContent":["import {\n ReactElement,\n useMemo,\n useState,\n useImperativeHandle,\n forwardRef,\n ForwardedRef,\n useRef,\n useEffect,\n RefCallback,\n useCallback,\n} from 'react';\nimport { useVirtualizer } from '@tanstack/react-virtual';\nimport classnames from 'classnames';\n\nimport { debounce } from '@hh.ru/magritte-common-func-utils';\nimport { Cell, CellText } from '@hh.ru/magritte-ui-cell';\nimport { CheckableCardElement } from '@hh.ru/magritte-ui-checkable-card/CheckableCardElement';\nimport { Action } from '@hh.ru/magritte-ui-tree-selector/Action';\nimport { MobileDelimiter } from '@hh.ru/magritte-ui-tree-selector/MobileDelimiter';\nimport { MobileItem } from '@hh.ru/magritte-ui-tree-selector/MobileItem';\nimport { MobileParentItem } from '@hh.ru/magritte-ui-tree-selector/MobileParentItem';\nimport { AdditionalDefault, TreeModel } from '@hh.ru/magritte-ui-tree-selector/collection/types';\nimport { ListControls, TreeSelectorDummyProps } from '@hh.ru/magritte-ui-tree-selector/types';\n\nimport styles from './tree-selector-item.less';\n\nconst DEFAULT_ITEM_HEIGHT = 56;\nconst SCROLLEND_HANDLER_DEBOUNCE_MS = 150;\nconst DELIMITER = ';';\n\ntype MobileItemsListProps<Additional extends AdditionalDefault> = {\n selected: string[];\n disabled: string[];\n getMobileSearchItemOrder: (model: TreeModel<Additional>) => number;\n setInputValue: (newValue: string) => void;\n handleChangeInput: (newValue: string) => void;\n contentFilterQuery: string;\n isSearch: boolean;\n} & Pick<\n TreeSelectorDummyProps<Additional>,\n | 'collection'\n | 'leavesOnly'\n | 'singleChoice'\n | 'checkSelectable'\n | 'onChange'\n | 'renderItem'\n | 'renderMobileDelimiter'\n | 'onMobileNavigationChange'\n | 'getSelectAllParentTrl'\n | 'renderContentBefore'\n | 'renderContentAfter'\n>;\n\nconst MobileItemsListComponent = <Additional extends AdditionalDefault>(\n props: MobileItemsListProps<Additional>,\n ref: ForwardedRef<ListControls>\n): ReactElement => {\n const {\n collection,\n selected,\n disabled,\n leavesOnly,\n singleChoice,\n onChange,\n checkSelectable,\n getMobileSearchItemOrder,\n setInputValue,\n handleChangeInput,\n isSearch,\n renderMobileDelimiter,\n renderItem,\n contentFilterQuery,\n getSelectAllParentTrl,\n renderContentBefore,\n renderContentAfter,\n onMobileNavigationChange,\n } = props;\n const navigationChangeCallback = useRef(onMobileNavigationChange);\n navigationChangeCallback.current = onMobileNavigationChange;\n const prevParentIds = useRef<(string | undefined)[]>([]);\n const prevQueries = useRef<string[]>([]);\n const currentQuery = useRef(contentFilterQuery);\n const [currentParentId, setCurrentParentId] = useState<string | undefined>();\n const items = useMemo(\n () => (currentParentId ? collection.getChildren(currentParentId) : collection.getTopLevel()),\n [currentParentId, collection]\n );\n const orderHashMap = useMemo(() => {\n return items.reduce<Record<TreeModel<Additional>['id'], number>>((acc, item) => {\n acc[item.id] = isSearch && !currentParentId ? getMobileSearchItemOrder(item) : 0;\n return acc;\n }, {});\n }, [items, isSearch, currentParentId, getMobileSearchItemOrder]);\n\n const sortedItems = useMemo(() => {\n return items.sort((itemA, itemB) => {\n return orderHashMap[itemA.id] - orderHashMap[itemB.id];\n });\n }, [items, orderHashMap]);\n\n const isSelectable = currentParentId && !leavesOnly && checkSelectable?.(currentParentId, collection);\n const withContentBefore = !!renderContentBefore;\n const withContentAfter = !!renderContentAfter;\n const count = items.length + (isSelectable ? 1 : 0) + (withContentBefore ? 1 : 0) + (withContentAfter ? 1 : 0);\n const parentRef = useRef<HTMLElement | null>(null);\n const isScrolling = useRef(false);\n\n const getItemKey = (index: number) => {\n if (withContentBefore && index === 0) {\n return 'promoTop';\n }\n\n if (withContentAfter && index === count - 1) {\n return 'promoBottom';\n }\n\n const isSelectAllItem =\n isSelectable && ((index === 0 && !withContentBefore) || (index === 1 && withContentBefore));\n\n if (isSelectAllItem) {\n return `current${currentParentId}`;\n }\n\n const itemIndex = index - (isSelectable ? 1 : 0) - (withContentBefore ? 1 : 0);\n const item = sortedItems[itemIndex];\n\n return currentParentId ? `${currentParentId}${DELIMITER}${item.id}` : `${item.id}`;\n };\n\n const virtualizer = useVirtualizer({\n count,\n getScrollElement: () => parentRef.current,\n estimateSize: () => DEFAULT_ITEM_HEIGHT,\n getItemKey,\n });\n\n const itemsVirtualizer = virtualizer.getVirtualItems();\n\n useEffect(() => {\n setCurrentParentId(undefined);\n prevParentIds.current = [];\n prevQueries.current = [];\n navigationChangeCallback.current?.(undefined);\n currentQuery.current = contentFilterQuery;\n }, [contentFilterQuery]);\n\n useImperativeHandle(\n ref,\n () => ({\n back: () => {\n if (!isScrolling.current) {\n const prevParentId = prevParentIds.current.pop();\n setCurrentParentId(prevParentId);\n navigationChangeCallback.current?.(prevParentId);\n if (prevQueries.current.length) {\n const prevInputValue = prevQueries.current.pop() as string;\n setInputValue(prevInputValue);\n currentQuery.current = prevInputValue;\n } else {\n handleChangeInput('');\n }\n }\n },\n }),\n [handleChangeInput, setInputValue]\n );\n\n useEffect(() => {\n const handleScrollEnd = debounce(() => {\n isScrolling.current = false;\n }, SCROLLEND_HANDLER_DEBOUNCE_MS);\n\n const handleScroll = () => {\n isScrolling.current = true;\n handleScrollEnd();\n };\n parentRef.current?.addEventListener('scroll', handleScroll);\n\n return () => {\n parentRef.current?.removeEventListener('scroll', handleScroll);\n };\n }, []);\n\n const refCallback: RefCallback<HTMLDivElement> = useCallback((node) => {\n parentRef.current = node ? node.parentElement : null;\n }, []);\n\n useEffect(() => {\n virtualizer.scrollToIndex(0);\n }, [currentParentId, sortedItems, virtualizer]);\n\n return (\n <div\n ref={refCallback}\n className={styles.virtualizedList}\n style={{\n height: `${virtualizer.getTotalSize()}px`,\n }}\n >\n {itemsVirtualizer.map((virtualItem) => {\n const isContentBeforeItem = withContentBefore && virtualItem.index === 0;\n const isContentAfterItem = withContentAfter && virtualItem.index === count - 1;\n const isSelectAllItem =\n isSelectable &&\n ((virtualItem.index === 0 && !withContentBefore) || (virtualItem.index === 1 && withContentBefore));\n\n if (isContentBeforeItem) {\n return (\n <div\n key={virtualItem.key}\n ref={virtualizer.measureElement}\n data-index={virtualItem.index}\n className={styles.virtualizedItem}\n style={{\n transform: `translateY(${virtualItem.start}px)`,\n }}\n >\n {renderContentBefore(isSearch)}\n </div>\n );\n }\n\n if (isContentAfterItem) {\n return (\n <div\n key={virtualItem.key}\n ref={virtualizer.measureElement}\n data-index={virtualItem.index}\n className={styles.virtualizedItem}\n style={{\n transform: `translateY(${virtualItem.start}px)`,\n }}\n >\n {renderContentAfter(isSearch)}\n </div>\n );\n }\n\n if (isSelectAllItem) {\n return (\n <div\n key={virtualItem.key}\n ref={virtualizer.measureElement}\n data-index={virtualItem.index}\n className={styles.virtualizedItem}\n style={{\n transform: `translateY(${virtualItem.start}px)`,\n }}\n >\n <div className={styles.mobileItem}>\n <CheckableCardElement\n padding={16}\n flexible\n borderRadius={12}\n Element=\"label\"\n checked={selected.includes(currentParentId)}\n data-qa={`tree-selector-select-all-${currentParentId}`}\n >\n <Cell\n Element={'div'}\n disabled={disabled.includes(currentParentId)}\n right={\n <Action\n selected={selected.includes(currentParentId)}\n onChange={onChange}\n id={currentParentId}\n singleChoice={singleChoice}\n />\n }\n >\n <CellText>{getSelectAllParentTrl(currentParentId)}</CellText>\n </Cell>\n </CheckableCardElement>\n </div>\n </div>\n );\n }\n const itemIndex = virtualItem.index - (isSelectable ? 1 : 0) - (withContentBefore ? 1 : 0);\n const item = sortedItems[itemIndex];\n const hasChildren = collection.hasChildren(item.id);\n const hasLetter = item.additional?.char && !isSearch;\n const delimiterContent = renderMobileDelimiter?.({\n item,\n order: orderHashMap[item.id],\n isSearch,\n index: itemIndex,\n isTopLevel: !currentParentId,\n });\n const withGap =\n (!!withContentBefore && virtualItem.index !== 1) || (!withContentBefore && virtualItem.index !== 0);\n return (\n <div\n key={virtualItem.key}\n ref={virtualizer.measureElement}\n data-index={virtualItem.index}\n style={{\n transform: `translateY(${virtualItem.start}px)`,\n }}\n className={classnames(styles.virtualizedItem, {\n [styles.withGap]: withGap,\n })}\n >\n <div className={styles.mobileItem}>\n {hasLetter && <MobileDelimiter>{item.additional?.char}</MobileDelimiter>}\n {delimiterContent && <MobileDelimiter>{delimiterContent}</MobileDelimiter>}\n {hasChildren ? (\n <MobileParentItem\n collection={collection}\n item={item}\n selected={selected}\n onClick={() => {\n prevParentIds.current.push(currentParentId);\n prevQueries.current.push(currentQuery.current);\n setCurrentParentId(item.id);\n setInputValue('');\n currentQuery.current = '';\n navigationChangeCallback.current?.(item.id);\n }}\n parentId={currentParentId}\n isSearch={isSearch}\n renderItem={renderItem}\n />\n ) : (\n <MobileItem\n item={item}\n singleChoice={singleChoice}\n isSelectable={checkSelectable?.(item.id, collection)}\n isSelected={selected.includes(item.id)}\n isDisabled={disabled.includes(item.id)}\n onChange={onChange}\n isSearch={isSearch}\n renderItem={renderItem}\n parentId={currentParentId}\n />\n )}\n </div>\n </div>\n );\n })}\n </div>\n );\n};\n\nexport const MobileItemsList = forwardRef(MobileItemsListComponent) as <Additional extends AdditionalDefault>(\n props: MobileItemsListProps<Additional> & { ref?: ForwardedRef<ListControls> }\n) => ReactElement;\n"],"names":["_jsx","_jsxs"],"mappings":";;;;;;;;;;;;;;;;;;AA2BA,MAAM,mBAAmB,GAAG,EAAE,CAAC;AAC/B,MAAM,6BAA6B,GAAG,GAAG,CAAC;AAC1C,MAAM,SAAS,GAAG,GAAG,CAAC;AAyBtB,MAAM,wBAAwB,GAAG,CAC7B,KAAuC,EACvC,GAA+B,KACjB;AACd,IAAA,MAAM,EACF,UAAU,EACV,QAAQ,EACR,QAAQ,EACR,UAAU,EACV,YAAY,EACZ,QAAQ,EACR,eAAe,EACf,wBAAwB,EACxB,aAAa,EACb,iBAAiB,EACjB,QAAQ,EACR,qBAAqB,EACrB,UAAU,EACV,kBAAkB,EAClB,qBAAqB,EACrB,mBAAmB,EACnB,kBAAkB,EAClB,wBAAwB,GAC3B,GAAG,KAAK,CAAC;AACV,IAAA,MAAM,wBAAwB,GAAG,MAAM,CA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C,CAAC;gCAC5B,aAAa,CAAC,EAAE,CAAC,CAAC;AAClB,gCAAA,YAAY,CAAC,OAAO,GAAG,EAAE,CAAC;gCAC1B,wBAAwB,CAAC,OAAO,GAAG,IAAI,CAAC,EAAE,CAAC,CAAC;AAChD,6BAAC,EACD,QAAQ,EAAE,eAAe,EACzB,QAAQ,EAAE,QAAQ,EAClB,UAAU,EAAE,UAAU,EACxB,CAAA,KAEFA,GAAC,CAAA,UAAU,EACP,EAAA,IAAI,EAAE,IAAI,EACV,YAAY,EAAE,YAAY,EAC1B,YAAY,EAAE,eAAe,GAAG,IAAI,CAAC,EAAE,EAAE,UAAU,CAAC,EACpD,UAAU,EAAE,QAAQ,CAAC,QAAQ,CAAC,IAAI,CAAC,EAAE,CAAC,EACtC,UAAU,EAAE,QAAQ,CAAC,QAAQ,CAAC,IAAI,CAAC,EAAE,CAAC,EACtC,QAAQ,EAAE,QAAQ,EAClB,QAAQ,EAAE,QAAQ,EAClB,UAAU,EAAE,UAAU,EACtB,QAAQ,EAAE,eAAe,EAC3B,CAAA,CACL,IACC,EA3CD,EAAA,WAAW,CAAC,GAAG,CA4ClB,EACR;SACL,CAAC,EACA,CAAA,EACR;AACN,CAAC,CAAC;MAEW,eAAe,GAAG,UAAU,CAAC,wBAAwB;;;;"}
1
+ {"version":3,"file":"MobileItemsList.js","sources":["src/MobileItemsList.tsx"],"sourcesContent":["import {\n ReactElement,\n useMemo,\n useState,\n useImperativeHandle,\n forwardRef,\n ForwardedRef,\n useRef,\n useEffect,\n RefCallback,\n useCallback,\n} from 'react';\nimport { useVirtualizer } from '@tanstack/react-virtual';\nimport classnames from 'classnames';\n\nimport { debounce } from '@hh.ru/magritte-common-func-utils';\nimport { Cell, CellText } from '@hh.ru/magritte-ui-cell';\nimport { CheckableCardElement } from '@hh.ru/magritte-ui-checkable-card/CheckableCardElement';\nimport { Action } from '@hh.ru/magritte-ui-tree-selector/Action';\nimport { MobileDelimiter } from '@hh.ru/magritte-ui-tree-selector/MobileDelimiter';\nimport { MobileItem } from '@hh.ru/magritte-ui-tree-selector/MobileItem';\nimport { MobileParentItem } from '@hh.ru/magritte-ui-tree-selector/MobileParentItem';\nimport { AdditionalDefault, TreeModel } from '@hh.ru/magritte-ui-tree-selector/collection/types';\nimport { ListControls, TreeSelectorDummyProps } from '@hh.ru/magritte-ui-tree-selector/types';\n\nimport styles from './tree-selector-item.less';\n\nconst DEFAULT_ITEM_HEIGHT = 56;\nconst SCROLLEND_HANDLER_DEBOUNCE_MS = 150;\nconst DELIMITER = ';';\n\ntype MobileItemsListProps<Additional extends AdditionalDefault> = {\n selected: string[];\n disabled: string[];\n getMobileSearchItemOrder: (model: TreeModel<Additional>) => number;\n setInputValue: (newValue: string) => void;\n handleChangeInput: (newValue: string) => void;\n contentFilterQuery: string;\n isSearch: boolean;\n} & Pick<\n TreeSelectorDummyProps<Additional>,\n | 'collection'\n | 'leavesOnly'\n | 'singleChoice'\n | 'checkSelectable'\n | 'onChange'\n | 'renderItem'\n | 'renderMobileDelimiter'\n | 'onMobileNavigationChange'\n | 'getSelectAllParentTrl'\n | 'renderContentBefore'\n | 'renderContentAfter'\n>;\n\nconst MobileItemsListComponent = <Additional extends AdditionalDefault>(\n props: MobileItemsListProps<Additional>,\n ref: ForwardedRef<ListControls>\n): ReactElement => {\n const {\n collection,\n selected,\n disabled,\n leavesOnly,\n singleChoice,\n onChange,\n checkSelectable,\n getMobileSearchItemOrder,\n setInputValue,\n handleChangeInput,\n isSearch,\n renderMobileDelimiter,\n renderItem,\n contentFilterQuery,\n getSelectAllParentTrl,\n renderContentBefore,\n renderContentAfter,\n onMobileNavigationChange,\n } = props;\n const navigationChangeCallback = useRef(onMobileNavigationChange);\n navigationChangeCallback.current = onMobileNavigationChange;\n const prevParentIds = useRef<(string | undefined)[]>([]);\n const prevQueries = useRef<string[]>([]);\n const currentQuery = useRef(contentFilterQuery);\n const [currentParentId, setCurrentParentId] = useState<string | undefined>();\n const items = useMemo(\n () => (currentParentId ? collection.getChildren(currentParentId) : collection.getTopLevel()),\n [currentParentId, collection]\n );\n const orderHashMap = useMemo(() => {\n return items.reduce<Record<TreeModel<Additional>['id'], number>>((acc, item) => {\n acc[item.id] = isSearch && !currentParentId ? getMobileSearchItemOrder(item) : 0;\n return acc;\n }, {});\n }, [items, isSearch, currentParentId, getMobileSearchItemOrder]);\n\n const sortedItems = useMemo(() => {\n return items.sort((itemA, itemB) => {\n return orderHashMap[itemA.id] - orderHashMap[itemB.id];\n });\n }, [items, orderHashMap]);\n\n const isSelectable = currentParentId && !leavesOnly && checkSelectable?.(currentParentId, collection);\n const withContentBefore = !!renderContentBefore;\n const withContentAfter = !!renderContentAfter;\n const count = items.length + (isSelectable ? 1 : 0) + (withContentBefore ? 1 : 0) + (withContentAfter ? 1 : 0);\n const parentRef = useRef<HTMLElement | null>(null);\n const isScrolling = useRef(false);\n\n const getItemKey = (index: number) => {\n if (withContentBefore && index === 0) {\n return 'promoTop';\n }\n\n if (withContentAfter && index === count - 1) {\n return 'promoBottom';\n }\n\n const isSelectAllItem =\n isSelectable && ((index === 0 && !withContentBefore) || (index === 1 && withContentBefore));\n\n if (isSelectAllItem) {\n return `current${currentParentId}`;\n }\n\n const itemIndex = index - (isSelectable ? 1 : 0) - (withContentBefore ? 1 : 0);\n const item = sortedItems[itemIndex];\n\n return currentParentId ? `${currentParentId}${DELIMITER}${item.id}` : `${item.id}`;\n };\n\n const virtualizer = useVirtualizer({\n count,\n getScrollElement: () => parentRef.current,\n estimateSize: () => DEFAULT_ITEM_HEIGHT,\n getItemKey,\n });\n\n const itemsVirtualizer = virtualizer.getVirtualItems();\n\n useEffect(() => {\n setCurrentParentId(undefined);\n prevParentIds.current = [];\n prevQueries.current = [];\n navigationChangeCallback.current?.(undefined);\n currentQuery.current = contentFilterQuery;\n }, [contentFilterQuery]);\n\n useImperativeHandle(\n ref,\n () => ({\n back: () => {\n if (!isScrolling.current) {\n const prevParentId = prevParentIds.current.pop();\n setCurrentParentId(prevParentId);\n navigationChangeCallback.current?.(prevParentId);\n if (prevQueries.current.length) {\n const prevInputValue = prevQueries.current.pop() as string;\n setInputValue(prevInputValue);\n currentQuery.current = prevInputValue;\n } else {\n handleChangeInput('');\n }\n }\n },\n }),\n [handleChangeInput, setInputValue]\n );\n\n useEffect(() => {\n const handleScrollEnd = debounce(() => {\n isScrolling.current = false;\n }, SCROLLEND_HANDLER_DEBOUNCE_MS);\n\n const handleScroll = () => {\n isScrolling.current = true;\n handleScrollEnd();\n };\n parentRef.current?.addEventListener('scroll', handleScroll);\n\n return () => {\n parentRef.current?.removeEventListener('scroll', handleScroll);\n };\n }, []);\n\n const refCallback: RefCallback<HTMLDivElement> = useCallback((node) => {\n parentRef.current = node ? node.parentElement : null;\n }, []);\n\n useEffect(() => {\n virtualizer.scrollToIndex(0);\n }, [currentParentId, sortedItems, virtualizer]);\n\n return (\n <div\n ref={refCallback}\n className={styles.virtualizedList}\n style={{\n height: `${virtualizer.getTotalSize()}px`,\n }}\n >\n {itemsVirtualizer.map((virtualItem) => {\n const isContentBeforeItem = withContentBefore && virtualItem.index === 0;\n const isContentAfterItem = withContentAfter && virtualItem.index === count - 1;\n const isSelectAllItem =\n isSelectable &&\n ((virtualItem.index === 0 && !withContentBefore) || (virtualItem.index === 1 && withContentBefore));\n\n if (isContentBeforeItem) {\n return (\n <div\n key={virtualItem.key}\n ref={virtualizer.measureElement}\n data-index={virtualItem.index}\n className={styles.virtualizedItem}\n style={{\n transform: `translateY(${virtualItem.start}px)`,\n }}\n >\n {renderContentBefore(isSearch)}\n </div>\n );\n }\n\n if (isContentAfterItem) {\n return (\n <div\n key={virtualItem.key}\n ref={virtualizer.measureElement}\n data-index={virtualItem.index}\n className={styles.virtualizedItem}\n style={{\n transform: `translateY(${virtualItem.start}px)`,\n }}\n >\n {renderContentAfter(isSearch)}\n </div>\n );\n }\n\n if (isSelectAllItem) {\n return (\n <div\n key={virtualItem.key}\n ref={virtualizer.measureElement}\n data-index={virtualItem.index}\n className={styles.virtualizedItem}\n style={{\n transform: `translateY(${virtualItem.start}px)`,\n }}\n >\n <div className={styles.mobileItem}>\n <CheckableCardElement\n padding={16}\n flexible\n borderRadius={12}\n Element=\"label\"\n checked={selected.includes(currentParentId)}\n data-qa={`tree-selector-select-all-${currentParentId}`}\n >\n <Cell\n Element={'div'}\n disabled={disabled.includes(currentParentId)}\n right={\n <Action\n selected={selected.includes(currentParentId)}\n onChange={onChange}\n id={currentParentId}\n singleChoice={singleChoice}\n />\n }\n >\n <CellText>{getSelectAllParentTrl(currentParentId)}</CellText>\n </Cell>\n </CheckableCardElement>\n </div>\n </div>\n );\n }\n const itemIndex = virtualItem.index - (isSelectable ? 1 : 0) - (withContentBefore ? 1 : 0);\n const item = sortedItems[itemIndex];\n const hasChildren = collection.hasChildren(item.id);\n const hasLetter = item.additional?.char && !isSearch;\n const delimiterContent = renderMobileDelimiter?.({\n item,\n order: orderHashMap[item.id],\n isSearch,\n index: itemIndex,\n isTopLevel: !currentParentId,\n });\n const withGap =\n (!!withContentBefore && virtualItem.index !== 1) || (!withContentBefore && virtualItem.index !== 0);\n return (\n <div\n key={virtualItem.key}\n ref={virtualizer.measureElement}\n data-index={virtualItem.index}\n style={{\n transform: `translateY(${virtualItem.start}px)`,\n }}\n className={classnames(styles.virtualizedItem, {\n [styles.withGap]: withGap,\n })}\n >\n <div className={styles.mobileItem}>\n {hasLetter && <MobileDelimiter>{item.additional?.char}</MobileDelimiter>}\n {delimiterContent && <MobileDelimiter>{delimiterContent}</MobileDelimiter>}\n {hasChildren ? (\n <MobileParentItem\n collection={collection}\n item={item}\n selected={selected}\n onClick={() => {\n prevParentIds.current.push(currentParentId);\n prevQueries.current.push(currentQuery.current);\n setCurrentParentId(item.id);\n setInputValue('');\n currentQuery.current = '';\n navigationChangeCallback.current?.(item.id);\n }}\n parentId={currentParentId}\n isSearch={isSearch}\n renderItem={renderItem}\n />\n ) : (\n <MobileItem\n item={item}\n singleChoice={singleChoice}\n isSelectable={checkSelectable?.(item.id, collection)}\n isSelected={selected.includes(item.id)}\n isDisabled={disabled.includes(item.id)}\n onChange={onChange}\n isSearch={isSearch}\n renderItem={renderItem}\n parentId={currentParentId}\n />\n )}\n </div>\n </div>\n );\n })}\n </div>\n );\n};\n\nexport const MobileItemsList = forwardRef(MobileItemsListComponent) as <Additional extends AdditionalDefault>(\n props: MobileItemsListProps<Additional> & { ref?: ForwardedRef<ListControls> }\n) => ReactElement;\n"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;AA2BA,MAAM,mBAAsB,GAAA,EAAA,CAAA;AAC5B,MAAM,6BAAgC,GAAA,GAAA,CAAA;AACtC,MAAM,SAAY,GAAA,GAAA,CAAA;AAyBlB,MAAM,wBAAA,GAA2B,CAC7B,KAAA,EACA,GACe,KAAA;AACf,EAAM,MAAA;AAAA,IACF,UAAA;AAAA,IACA,QAAA;AAAA,IACA,QAAA;AAAA,IACA,UAAA;AAAA,IACA,YAAA;AAAA,IACA,QAAA;AAAA,IACA,eAAA;AAAA,IACA,wBAAA;AAAA,IACA,aAAA;AAAA,IACA,iBAAA;AAAA,IACA,QAAA;AAAA,IACA,qBAAA;AAAA,IACA,UAAA;AAAA,IACA,kBAAA;AAAA,IACA,qBAAA;AAAA,IACA,mBAAA;AAAA,IACA,kBAAA;AAAA,IACA,wBAAA;AAAA,GACA,GAAA,KAAA,CAAA;AACJ,EAAM,MAAA,wBAAA,GAA2B,OAAO,wBAAwB,CAAA,CAAA;AAChE,EAAA,wBAAA,CAAyB,OAAU,GAAA,wBAAA,CAAA;AACnC,EAAM,MAAA,aAAA,GAAgB,MAA+B,CAAA,EAAE,CAAA,CAAA;AACvD,EAAM,MAAA,WAAA,GAAc,MAAiB,CAAA,EAAE,CAAA,CAAA;AACvC,EAAM,MAAA,YAAA,GAAe,OAAO,kBAAkB,CAAA,CAAA;AAC9C,EAAA,MAAM,CAAC,eAAA,EAAiB,kBAAkB,CAAA,GAAI,QAA6B,EAAA,CAAA;AAC3E,EAAA,MAAM,KAAQ,GA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A,CAAQ,IAAK,CAAA,YAAA,CAAa,OAAO,CAAA,CAAA;AAC7C,oBAAA,kBAAA,CAAmB,KAAK,EAAE,CAAA,CAAA;AAC1B,oBAAA,aAAA,CAAc,EAAE,CAAA,CAAA;AAChB,oBAAA,YAAA,CAAa,OAAU,GAAA,EAAA,CAAA;AACvB,oBAAyB,wBAAA,CAAA,OAAA,GAAU,KAAK,EAAE,CAAA,CAAA;AAAA,mBAC9C;AAAA,kBACA,QAAU,EAAA,eAAA;AAAA,kBACV,QAAA;AAAA,kBACA,UAAA;AAAA,iBAAA;AAAA,eAGJ,mBAAA,GAAA;AAAA,gBAAC,UAAA;AAAA,gBAAA;AAAA,kBACG,IAAA;AAAA,kBACA,YAAA;AAAA,kBACA,YAAc,EAAA,eAAA,GAAkB,IAAK,CAAA,EAAA,EAAI,UAAU,CAAA;AAAA,kBACnD,UAAY,EAAA,QAAA,CAAS,QAAS,CAAA,IAAA,CAAK,EAAE,CAAA;AAAA,kBACrC,UAAY,EAAA,QAAA,CAAS,QAAS,CAAA,IAAA,CAAK,EAAE,CAAA;AAAA,kBACrC,QAAA;AAAA,kBACA,QAAA;AAAA,kBACA,UAAA;AAAA,kBACA,QAAU,EAAA,eAAA;AAAA,iBAAA;AAAA,eACd;AAAA,aAER,EAAA,CAAA;AAAA,WAAA;AAAA,UA3CK,WAAY,CAAA,GAAA;AAAA,SA4CrB,CAAA;AAAA,OAEP,CAAA;AAAA,KAAA;AAAA,GACL,CAAA;AAER,CAAA,CAAA;AAEa,MAAA,eAAA,GAAkB,WAAW,wBAAwB;;;;"}
@@ -1,7 +1,7 @@
1
1
  import { ReactElement } from 'react';
2
- import TreeCollection from '@hh.ru/magritte-ui-tree-selector/collection/treeCollection';
3
- import { AdditionalDefault, TreeModel } from '@hh.ru/magritte-ui-tree-selector/collection/types';
4
- import { RenderItem } from '@hh.ru/magritte-ui-tree-selector/types';
2
+ import TreeCollection from './collection/treeCollection';
3
+ import { AdditionalDefault, TreeModel } from './collection/types';
4
+ import { RenderItem } from './types';
5
5
  interface MobileParentItemProps<Additional extends AdditionalDefault> {
6
6
  collection: TreeCollection<Additional>;
7
7
  item: TreeModel<Additional>;
@@ -7,20 +7,39 @@ import { Card } from '@hh.ru/magritte-ui-card';
7
7
  import { CellRightLabel } from '@hh.ru/magritte-ui-cell';
8
8
  import { TreeSelectorItemBase } from './TreeSelectorItemBase.js';
9
9
 
10
- const MobileParentItem = ({ collection, item, selected, onClick, isSearch, parentId, renderItem = TreeSelectorItemBase, }) => {
11
- const childrenSelectedCount = useMemo(() => {
12
- let count = 0;
13
- collection.walkChildren(item.id, (model) => {
14
- if (selected.includes(model.id)) {
15
- count += 1;
16
- }
17
- });
18
- return count;
19
- }, [collection, selected, item.id]);
20
- const labelRight = (jsx(CellRightLabel, { badge: childrenSelectedCount ? jsx(Badge, { children: childrenSelectedCount.toString() }) : undefined }));
21
- return (jsx(Card, { padding: 16, borderRadius: 12, borderWidth: "default", stretched: true, onClick: onClick, "data-qa": classnames('tree-selector-item', `tree-selector-item-${item.id}`, {
22
- [`tree-selector-child-${parentId}`]: parentId,
23
- }), children: renderItem({ item, labelRight, childrenSelectedCount, isSearch, isXS: true, isParent: true }) }));
10
+ const MobileParentItem = ({
11
+ collection,
12
+ item,
13
+ selected,
14
+ onClick,
15
+ isSearch,
16
+ parentId,
17
+ renderItem = TreeSelectorItemBase
18
+ }) => {
19
+ const childrenSelectedCount = useMemo(() => {
20
+ let count = 0;
21
+ collection.walkChildren(item.id, (model) => {
22
+ if (selected.includes(model.id)) {
23
+ count += 1;
24
+ }
25
+ });
26
+ return count;
27
+ }, [collection, selected, item.id]);
28
+ const labelRight = /* @__PURE__ */ jsx(CellRightLabel, { badge: childrenSelectedCount ? /* @__PURE__ */ jsx(Badge, { children: childrenSelectedCount.toString() }) : void 0 });
29
+ return /* @__PURE__ */ jsx(
30
+ Card,
31
+ {
32
+ padding: 16,
33
+ borderRadius: 12,
34
+ borderWidth: "default",
35
+ stretched: true,
36
+ onClick,
37
+ "data-qa": classnames("tree-selector-item", `tree-selector-item-${item.id}`, {
38
+ [`tree-selector-child-${parentId}`]: parentId
39
+ }),
40
+ children: renderItem({ item, labelRight, childrenSelectedCount, isSearch, isXS: true, isParent: true })
41
+ }
42
+ );
24
43
  };
25
44
 
26
45
  export { MobileParentItem };
@@ -1 +1 @@
1
- {"version":3,"file":"MobileParentItem.js","sources":["src/MobileParentItem.tsx"],"sourcesContent":["import { ReactElement, useMemo } from 'react';\nimport classnames from 'classnames';\n\nimport { Badge } from '@hh.ru/magritte-ui-badge';\nimport { Card } from '@hh.ru/magritte-ui-card';\nimport { CellRightLabel } from '@hh.ru/magritte-ui-cell';\nimport { TreeSelectorItemBase } from '@hh.ru/magritte-ui-tree-selector/TreeSelectorItemBase';\nimport TreeCollection from '@hh.ru/magritte-ui-tree-selector/collection/treeCollection';\nimport { AdditionalDefault, TreeModel } from '@hh.ru/magritte-ui-tree-selector/collection/types';\nimport { RenderItem } from '@hh.ru/magritte-ui-tree-selector/types';\n\ninterface MobileParentItemProps<Additional extends AdditionalDefault> {\n collection: TreeCollection<Additional>;\n item: TreeModel<Additional>;\n selected: string[];\n onClick: () => void;\n renderItem?: RenderItem<Additional>;\n isSearch: boolean;\n parentId?: string;\n}\n\nexport const MobileParentItem = <Additional extends AdditionalDefault>({\n collection,\n item,\n selected,\n onClick,\n isSearch,\n parentId,\n renderItem = TreeSelectorItemBase,\n}: MobileParentItemProps<Additional>): ReactElement => {\n const childrenSelectedCount = useMemo(() => {\n let count = 0;\n collection.walkChildren(item.id, (model) => {\n if (selected.includes(model.id)) {\n count += 1;\n }\n });\n\n return count;\n }, [collection, selected, item.id]);\n\n const labelRight = (\n <CellRightLabel badge={childrenSelectedCount ? <Badge>{childrenSelectedCount.toString()}</Badge> : undefined} />\n );\n\n return (\n <Card\n padding={16}\n borderRadius={12}\n borderWidth=\"default\"\n stretched\n onClick={onClick}\n data-qa={classnames('tree-selector-item', `tree-selector-item-${item.id}`, {\n [`tree-selector-child-${parentId}`]: parentId,\n })}\n >\n {renderItem({ item, labelRight, childrenSelectedCount, isSearch, isXS: true, isParent: true })}\n </Card>\n );\n};\n"],"names":["_jsx"],"mappings":";;;;;;;;MAqBa,gBAAgB,GAAG,CAAuC,EACnE,UAAU,EACV,IAAI,EACJ,QAAQ,EACR,OAAO,EACP,QAAQ,EACR,QAAQ,EACR,UAAU,GAAG,oBAAoB,GACD,KAAkB;AAClD,IAAA,MAAM,qBAAqB,GAAG,OAAO,CAAC,MAAK;QACvC,IAAI,KAAK,GAAG,CAAC,CAAC;QACd,UAAU,CAAC,YAAY,CAAC,IAAI,CAAC,EAAE,EAAE,CAAC,KAAK,KAAI;YACvC,IAAI,QAAQ,CAAC,QAAQ,CAAC,KAAK,CAAC,EAAE,CAAC,EAAE;gBAC7B,KAAK,IAAI,CAAC,CAAC;aACd;AACL,SAAC,CAAC,CAAC;AAEH,QAAA,OAAO,KAAK,CAAC;KAChB,EAAE,CAAC,UAAU,EAAE,QAAQ,EAAE,IAAI,CAAC,EAAE,CAAC,CAAC,CAAC;IAEpC,MAAM,UAAU,IACZA,GAAC,CAAA,cAAc,EAAC,EAAA,KAAK,EAAE,qBAAqB,GAAGA,GAAA,CAAC,KAAK,EAAE,EAAA,QAAA,EAAA,qBAAqB,CAAC,QAAQ,EAAE,EAAA,CAAS,GAAG,SAAS,EAAI,CAAA,CACnH,CAAC;AAEF,IAAA,QACIA,GAAA,CAAC,IAAI,EAAA,EACD,OAAO,EAAE,EAAE,EACX,YAAY,EAAE,EAAE,EAChB,WAAW,EAAC,SAAS,EACrB,SAAS,EACT,IAAA,EAAA,OAAO,EAAE,OAAO,aACP,UAAU,CAAC,oBAAoB,EAAE,CAAsB,mBAAA,EAAA,IAAI,CAAC,EAAE,EAAE,EAAE;AACvE,YAAA,CAAC,CAAuB,oBAAA,EAAA,QAAQ,CAAE,CAAA,GAAG,QAAQ;SAChD,CAAC,EAAA,QAAA,EAED,UAAU,CAAC,EAAE,IAAI,EAAE,UAAU,EAAE,qBAAqB,EAAE,QAAQ,EAAE,IAAI,EAAE,IAAI,EAAE,QAAQ,EAAE,IAAI,EAAE,CAAC,EAC3F,CAAA,EACT;AACN;;;;"}
1
+ {"version":3,"file":"MobileParentItem.js","sources":["src/MobileParentItem.tsx"],"sourcesContent":["import { ReactElement, useMemo } from 'react';\nimport classnames from 'classnames';\n\nimport { Badge } from '@hh.ru/magritte-ui-badge';\nimport { Card } from '@hh.ru/magritte-ui-card';\nimport { CellRightLabel } from '@hh.ru/magritte-ui-cell';\nimport { TreeSelectorItemBase } from '@hh.ru/magritte-ui-tree-selector/TreeSelectorItemBase';\nimport TreeCollection from '@hh.ru/magritte-ui-tree-selector/collection/treeCollection';\nimport { AdditionalDefault, TreeModel } from '@hh.ru/magritte-ui-tree-selector/collection/types';\nimport { RenderItem } from '@hh.ru/magritte-ui-tree-selector/types';\n\ninterface MobileParentItemProps<Additional extends AdditionalDefault> {\n collection: TreeCollection<Additional>;\n item: TreeModel<Additional>;\n selected: string[];\n onClick: () => void;\n renderItem?: RenderItem<Additional>;\n isSearch: boolean;\n parentId?: string;\n}\n\nexport const MobileParentItem = <Additional extends AdditionalDefault>({\n collection,\n item,\n selected,\n onClick,\n isSearch,\n parentId,\n renderItem = TreeSelectorItemBase,\n}: MobileParentItemProps<Additional>): ReactElement => {\n const childrenSelectedCount = useMemo(() => {\n let count = 0;\n collection.walkChildren(item.id, (model) => {\n if (selected.includes(model.id)) {\n count += 1;\n }\n });\n\n return count;\n }, [collection, selected, item.id]);\n\n const labelRight = (\n <CellRightLabel badge={childrenSelectedCount ? <Badge>{childrenSelectedCount.toString()}</Badge> : undefined} />\n );\n\n return (\n <Card\n padding={16}\n borderRadius={12}\n borderWidth=\"default\"\n stretched\n onClick={onClick}\n data-qa={classnames('tree-selector-item', `tree-selector-item-${item.id}`, {\n [`tree-selector-child-${parentId}`]: parentId,\n })}\n >\n {renderItem({ item, labelRight, childrenSelectedCount, isSearch, isXS: true, isParent: true })}\n </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EAAA,UAAA,CAAW,EAAE,IAAA,EAAM,UAAY,EAAA,qBAAA,EAAuB,UAAU,IAAM,EAAA,IAAA,EAAM,QAAU,EAAA,IAAA,EAAM,CAAA;AAAA,KAAA;AAAA,GACjG,CAAA;AAER;;;;"}
package/TreeSelector.d.ts CHANGED
@@ -1,6 +1,6 @@
1
1
  import { ForwardedRef, ReactElement } from 'react';
2
- import { AdditionalDefault } from '@hh.ru/magritte-ui-tree-selector/collection/types';
3
- import { TreeSelectorProps, ListControls } from '@hh.ru/magritte-ui-tree-selector/types';
2
+ import { AdditionalDefault } from './collection/types';
3
+ import { TreeSelectorProps, ListControls } from './types';
4
4
  export declare const TreeSelector: <Additional extends AdditionalDefault>(props: TreeSelectorProps<Additional> & {
5
5
  ref?: ForwardedRef<ListControls>;
6
6
  }) => ReactElement;