@snack-uikit/list 0.29.7-preview-644edaa1.0 → 0.30.1-preview-76bcef09.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/CHANGELOG.md CHANGED
@@ -3,6 +3,17 @@
3
3
  All notable changes to this project will be documented in this file.
4
4
  See [Conventional Commits](https://conventionalcommits.org) for commit guidelines.
5
5
 
6
+ # 0.30.0 (2025-06-23)
7
+
8
+
9
+ ### Features
10
+
11
+ * **PDS-2461:** list virtualization scroll to initial value ([9ff5a87](https://github.com/cloud-ru-tech/snack-uikit/commit/9ff5a8781367fd3ea0bdc879fb4f5484228459be))
12
+
13
+
14
+
15
+
16
+
6
17
  ## 0.29.6 (2025-06-19)
7
18
 
8
19
  ### Only dependencies have been changed
@@ -84,7 +84,6 @@ exports.ListPrivate = (0, react_1.forwardRef)((_a, ref) => {
84
84
  browser: null,
85
85
  measured: false
86
86
  });
87
- console.info('[DEBUG] ScrollState', scrollState);
88
87
  const emptyStates = (0, helperComponents_1.useEmptyState)({
89
88
  noDataState,
90
89
  noResultsState,
@@ -137,24 +136,18 @@ exports.ListPrivate = (0, react_1.forwardRef)((_a, ref) => {
137
136
  (0, react_1.useEffect)(() => {
138
137
  var _a;
139
138
  if (isScrollToItemEnabled) {
140
- console.info('[DEBUG] selectedItemIndex', selectedItemIndex);
141
139
  if (!scrollState.measured) {
142
- console.info('[DEBUG] Not measured yet');
143
140
  return; // Not measured yet
144
141
  }
145
142
  if (selectedItemIndex < 0 || !selectedItem) {
146
- console.info('[DEBUG] Cannot scroll to non-existing item');
147
143
  return; // Cannot scroll to non-existing item
148
144
  }
149
145
  if (scrollState.virtualizer === selectedItem.originalId) {
150
- console.info('[DEBUG] No need to re-scroll to the same item during re-renders');
151
146
  return; // No need to re-scroll to the same item during re-renders
152
147
  }
153
148
  if ((selectedItem === null || selectedItem === void 0 ? void 0 : selectedItem.itemRef) && ((_a = innerScrollRef.current) === null || _a === void 0 ? void 0 : _a.contains(selectedItem === null || selectedItem === void 0 ? void 0 : selectedItem.itemRef.current))) {
154
- console.info('[DEBUG] No need to scroll to manually clicked item currently present in DOM');
155
149
  return; // No need to scroll to manually clicked item currently present in DOM
156
150
  }
157
- console.info('[DEBUG] SCROLLING BY VIRTUALIZER');
158
151
  virtualizer.scrollToIndex(selectedItemIndex, {
159
152
  align: 'center'
160
153
  });
@@ -165,7 +158,7 @@ exports.ListPrivate = (0, react_1.forwardRef)((_a, ref) => {
165
158
  }, [isScrollToItemEnabled, scrollState, selectedItem, selectedItemIndex, virtualizer]);
166
159
  const isTargetPresentInDom = Boolean((_b = selectedItem === null || selectedItem === void 0 ? void 0 : selectedItem.itemRef) === null || _b === void 0 ? void 0 : _b.current);
167
160
  (0, react_1.useEffect)(() => {
168
- var _a, _b, _c;
161
+ var _a, _b;
169
162
  if (!selectedItem) {
170
163
  return;
171
164
  }
@@ -178,8 +171,7 @@ exports.ListPrivate = (0, react_1.forwardRef)((_a, ref) => {
178
171
  if (scrollState.virtualizer === scrollState.browser) {
179
172
  return; // Virtualizer scroll has not been executed => no need for additional scroll
180
173
  }
181
- console.info('[DEBUG] SCROLLING BY BROWSER', (_a = selectedItem.itemRef) === null || _a === void 0 ? void 0 : _a.current);
182
- (_c = (_b = selectedItem.itemRef) === null || _b === void 0 ? void 0 : _b.current) === null || _c === void 0 ? void 0 : _c.scrollIntoView({
174
+ (_b = (_a = selectedItem.itemRef) === null || _a === void 0 ? void 0 : _a.current) === null || _b === void 0 ? void 0 : _b.scrollIntoView({
183
175
  block: 'center'
184
176
  });
185
177
  setScrollState(prevState => Object.assign(Object.assign({}, prevState), {
@@ -34,7 +34,6 @@ export const ListPrivate = forwardRef((_a, ref) => {
34
34
  const itemsPinTopJSX = useRenderItems(pinTop);
35
35
  const itemsPinBottomJSX = useRenderItems(pinBottom);
36
36
  const [scrollState, setScrollState] = useState({ virtualizer: null, browser: null, measured: false });
37
- console.info('[DEBUG] ScrollState', scrollState);
38
37
  const emptyStates = useEmptyState({ noDataState, noResultsState, errorDataState });
39
38
  const hasNoItems = items.length === 0;
40
39
  const { selectedItemIndex, selectedItem } = useMemo(() => {
@@ -78,31 +77,25 @@ export const ListPrivate = forwardRef((_a, ref) => {
78
77
  useEffect(() => {
79
78
  var _a;
80
79
  if (isScrollToItemEnabled) {
81
- console.info('[DEBUG] selectedItemIndex', selectedItemIndex);
82
80
  if (!scrollState.measured) {
83
- console.info('[DEBUG] Not measured yet');
84
81
  return; // Not measured yet
85
82
  }
86
83
  if (selectedItemIndex < 0 || !selectedItem) {
87
- console.info('[DEBUG] Cannot scroll to non-existing item');
88
84
  return; // Cannot scroll to non-existing item
89
85
  }
90
86
  if (scrollState.virtualizer === selectedItem.originalId) {
91
- console.info('[DEBUG] No need to re-scroll to the same item during re-renders');
92
87
  return; // No need to re-scroll to the same item during re-renders
93
88
  }
94
89
  if ((selectedItem === null || selectedItem === void 0 ? void 0 : selectedItem.itemRef) && ((_a = innerScrollRef.current) === null || _a === void 0 ? void 0 : _a.contains(selectedItem === null || selectedItem === void 0 ? void 0 : selectedItem.itemRef.current))) {
95
- console.info('[DEBUG] No need to scroll to manually clicked item currently present in DOM');
96
90
  return; // No need to scroll to manually clicked item currently present in DOM
97
91
  }
98
- console.info('[DEBUG] SCROLLING BY VIRTUALIZER');
99
92
  virtualizer.scrollToIndex(selectedItemIndex, { align: 'center' });
100
93
  setScrollState(prevState => (Object.assign(Object.assign({}, prevState), { virtualizer: selectedItem.originalId })));
101
94
  }
102
95
  }, [isScrollToItemEnabled, scrollState, selectedItem, selectedItemIndex, virtualizer]);
103
96
  const isTargetPresentInDom = Boolean((_b = selectedItem === null || selectedItem === void 0 ? void 0 : selectedItem.itemRef) === null || _b === void 0 ? void 0 : _b.current);
104
97
  useEffect(() => {
105
- var _a, _b, _c;
98
+ var _a, _b;
106
99
  if (!selectedItem) {
107
100
  return;
108
101
  }
@@ -115,8 +108,7 @@ export const ListPrivate = forwardRef((_a, ref) => {
115
108
  if (scrollState.virtualizer === scrollState.browser) {
116
109
  return; // Virtualizer scroll has not been executed => no need for additional scroll
117
110
  }
118
- console.info('[DEBUG] SCROLLING BY BROWSER', (_a = selectedItem.itemRef) === null || _a === void 0 ? void 0 : _a.current);
119
- (_c = (_b = selectedItem.itemRef) === null || _b === void 0 ? void 0 : _b.current) === null || _c === void 0 ? void 0 : _c.scrollIntoView({ block: 'center' });
111
+ (_b = (_a = selectedItem.itemRef) === null || _a === void 0 ? void 0 : _a.current) === null || _b === void 0 ? void 0 : _b.scrollIntoView({ block: 'center' });
120
112
  setScrollState(prevState => (Object.assign(Object.assign({}, prevState), { browser: selectedItem.originalId })));
121
113
  }, [scrollState, selectedItem, isTargetPresentInDom, selectedItemIndex]);
122
114
  const loadingJSX = useMemo(() => loading && (_jsx("div", { role: 'spinbutton', tabIndex: -1, className: styles.loader, "data-size": size, "data-no-items": hasNoItems || undefined, "data-test-id": 'list__loader', children: _jsx(Spinner, { size: size === 'l' ? 's' : 'xs' }) })), [hasNoItems, loading, size]);
package/package.json CHANGED
@@ -4,7 +4,7 @@
4
4
  "access": "public"
5
5
  },
6
6
  "title": "List",
7
- "version": "0.29.7-preview-644edaa1.0",
7
+ "version": "0.30.1-preview-76bcef09.0",
8
8
  "sideEffects": [
9
9
  "*.css",
10
10
  "*.woff",
@@ -39,13 +39,13 @@
39
39
  "@snack-uikit/button": "0.19.11",
40
40
  "@snack-uikit/divider": "3.2.6",
41
41
  "@snack-uikit/dropdown": "0.4.8",
42
- "@snack-uikit/icons": "0.26.4",
43
- "@snack-uikit/info-block": "0.6.25",
42
+ "@snack-uikit/icons": "0.26.5-preview-76bcef09.0",
43
+ "@snack-uikit/info-block": "0.6.26-preview-76bcef09.0",
44
44
  "@snack-uikit/loaders": "0.9.5",
45
45
  "@snack-uikit/scroll": "0.10.1",
46
- "@snack-uikit/search-private": "0.4.21",
47
- "@snack-uikit/toggles": "0.13.15",
48
- "@snack-uikit/truncate-string": "0.6.21",
46
+ "@snack-uikit/search-private": "0.4.22-preview-76bcef09.0",
47
+ "@snack-uikit/toggles": "0.13.16-preview-76bcef09.0",
48
+ "@snack-uikit/truncate-string": "0.6.22-preview-76bcef09.0",
49
49
  "@snack-uikit/utils": "3.8.2",
50
50
  "@tanstack/react-virtual": "3.11.2",
51
51
  "classnames": "2.5.1",
@@ -54,5 +54,5 @@
54
54
  "peerDependencies": {
55
55
  "@snack-uikit/locale": "*"
56
56
  },
57
- "gitHead": "3a8c0893412768a16a57ffad69934ffda7383e83"
57
+ "gitHead": "f319535e21d641f07f7f7f20ae249d94b7586544"
58
58
  }
@@ -67,7 +67,6 @@ export const ListPrivate = forwardRef(
67
67
  const itemsPinBottomJSX = useRenderItems(pinBottom);
68
68
 
69
69
  const [scrollState, setScrollState] = useState<ScrollState>({ virtualizer: null, browser: null, measured: false });
70
- console.info('[DEBUG] ScrollState', scrollState);
71
70
 
72
71
  const emptyStates = useEmptyState({ noDataState, noResultsState, errorDataState });
73
72
  const hasNoItems = items.length === 0;
@@ -125,25 +124,19 @@ export const ListPrivate = forwardRef(
125
124
 
126
125
  useEffect(() => {
127
126
  if (isScrollToItemEnabled) {
128
- console.info('[DEBUG] selectedItemIndex', selectedItemIndex);
129
127
  if (!scrollState.measured) {
130
- console.info('[DEBUG] Not measured yet');
131
128
  return; // Not measured yet
132
129
  }
133
130
  if (selectedItemIndex < 0 || !selectedItem) {
134
- console.info('[DEBUG] Cannot scroll to non-existing item');
135
131
  return; // Cannot scroll to non-existing item
136
132
  }
137
133
  if (scrollState.virtualizer === selectedItem.originalId) {
138
- console.info('[DEBUG] No need to re-scroll to the same item during re-renders');
139
134
  return; // No need to re-scroll to the same item during re-renders
140
135
  }
141
136
  if (selectedItem?.itemRef && innerScrollRef.current?.contains(selectedItem?.itemRef.current)) {
142
- console.info('[DEBUG] No need to scroll to manually clicked item currently present in DOM');
143
137
  return; // No need to scroll to manually clicked item currently present in DOM
144
138
  }
145
139
 
146
- console.info('[DEBUG] SCROLLING BY VIRTUALIZER');
147
140
  virtualizer.scrollToIndex(selectedItemIndex, { align: 'center' });
148
141
 
149
142
  setScrollState(prevState => ({
@@ -169,8 +162,6 @@ export const ListPrivate = forwardRef(
169
162
  return; // Virtualizer scroll has not been executed => no need for additional scroll
170
163
  }
171
164
 
172
- console.info('[DEBUG] SCROLLING BY BROWSER', selectedItem.itemRef?.current);
173
-
174
165
  selectedItem.itemRef?.current?.scrollIntoView({ block: 'center' });
175
166
 
176
167
  setScrollState(prevState => ({