@gravity-ui/dashkit 8.5.0-beta.4 → 8.5.0-beta.5
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/build/cjs/hocs/withContext.js +23 -34
- package/build/esm/hocs/withContext.js +23 -34
- package/package.json +1 -1
|
@@ -114,7 +114,9 @@ function useMemoStateContext(props) {
|
|
|
114
114
|
forceUpdateLayout((prev) => prev + 1);
|
|
115
115
|
}
|
|
116
116
|
}, []);
|
|
117
|
-
|
|
117
|
+
react_1.default.useMemo(() => {
|
|
118
|
+
const groups = props.groups;
|
|
119
|
+
const layout = props.layout;
|
|
118
120
|
const defaultProps = props.registerManager._gridLayout || {};
|
|
119
121
|
const nowrapGroups = {};
|
|
120
122
|
let hasNowrapGroups = false;
|
|
@@ -143,46 +145,23 @@ function useMemoStateContext(props) {
|
|
|
143
145
|
const widgetId = item.i;
|
|
144
146
|
const parentId = item.parent || common_1.DEFAULT_GROUP;
|
|
145
147
|
if (nowrapGroups[parentId]) {
|
|
148
|
+
// Collecting nowrap elements
|
|
146
149
|
nowrapGroups[parentId].items.push(item);
|
|
147
150
|
nowrapGroups[parentId].leftSpace -= item.w;
|
|
148
151
|
}
|
|
149
|
-
else if (nowrapAdjustedLayouts.current[
|
|
150
|
-
|
|
151
|
-
const adjustedItem = adjustedLayouts.current[widgetId];
|
|
152
|
-
if (originalMaxW) {
|
|
153
|
-
adjustedLayouts.current[widgetId] = Object.assign(Object.assign({}, adjustedItem), { maxW: originalMaxW });
|
|
154
|
-
originalLayouts.current[widgetId] = item;
|
|
155
|
-
}
|
|
156
|
-
else {
|
|
157
|
-
adjustedLayouts.current[widgetId] = Object.assign({}, adjustedItem);
|
|
158
|
-
}
|
|
152
|
+
else if (nowrapAdjustedLayouts.current[widgetId]) {
|
|
153
|
+
// If element is not in horizontal-nowrap cleaning up and reverting adjustLayout values
|
|
159
154
|
delete nowrapAdjustedLayouts.current[widgetId];
|
|
160
155
|
}
|
|
161
|
-
originalLayouts.current[widgetId] = item;
|
|
162
156
|
});
|
|
163
157
|
Object.entries(nowrapGroups).forEach(([, { items, leftSpace }]) => {
|
|
164
158
|
items.forEach((item) => {
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
originalLayouts.current[item.i] = item;
|
|
168
|
-
adjustedLayouts.current[item.i] = Object.assign(Object.assign({}, item), { maxW });
|
|
169
|
-
nowrapAdjustedLayouts.current[item.i] = item.maxW
|
|
170
|
-
? { maxW, originalMaxW: item.maxW }
|
|
171
|
-
: { maxW };
|
|
172
|
-
}
|
|
159
|
+
// setting maxW with adjustLayout fields and saving previous
|
|
160
|
+
nowrapAdjustedLayouts.current[item.i] = item.w + leftSpace;
|
|
173
161
|
});
|
|
174
162
|
});
|
|
175
163
|
}
|
|
176
|
-
|
|
177
|
-
layout.forEach((item) => {
|
|
178
|
-
const widgetId = item.i;
|
|
179
|
-
if (adjustedLayouts.current[widgetId]) {
|
|
180
|
-
originalLayouts.current[widgetId] = item;
|
|
181
|
-
}
|
|
182
|
-
});
|
|
183
|
-
}
|
|
184
|
-
return adjustedLayouts.current;
|
|
185
|
-
}, [props.registerManager]);
|
|
164
|
+
}, [props.registerManager, props.groups, props.layout]);
|
|
186
165
|
const itemsParams = (0, useDeepEqualMemo_1.useDeepEqualMemo)(() => (0, shared_1.getItemsParams)({
|
|
187
166
|
defaultGlobalParams: props.defaultGlobalParams,
|
|
188
167
|
globalParams: props.globalParams,
|
|
@@ -211,24 +190,34 @@ function useMemoStateContext(props) {
|
|
|
211
190
|
.filter(Boolean);
|
|
212
191
|
}, []);
|
|
213
192
|
const resultLayout = react_1.default.useMemo(() => {
|
|
214
|
-
const adjusted =
|
|
193
|
+
const adjusted = adjustedLayouts.current;
|
|
194
|
+
const original = originalLayouts.current;
|
|
195
|
+
const nowrapAdjust = nowrapAdjustedLayouts.current;
|
|
215
196
|
return props.layout.map((item) => {
|
|
216
|
-
|
|
197
|
+
const widgetId = item.i;
|
|
198
|
+
if (adjusted[widgetId] || nowrapAdjust[widgetId]) {
|
|
199
|
+
original[widgetId] = item;
|
|
217
200
|
// eslint-disable-next-line no-unused-vars
|
|
218
|
-
const _a = adjusted[
|
|
201
|
+
const _a = adjusted[widgetId] || item, { parent } = _a, adjustedItem = tslib_1.__rest(_a, ["parent"]);
|
|
219
202
|
adjustedItem.w = item.w;
|
|
220
203
|
adjustedItem.x = item.x;
|
|
221
204
|
adjustedItem.y = item.y;
|
|
222
205
|
if (item.parent) {
|
|
223
206
|
adjustedItem.parent = item.parent;
|
|
224
207
|
}
|
|
208
|
+
if (nowrapAdjust[widgetId]) {
|
|
209
|
+
adjustedItem.maxW = nowrapAdjust[widgetId];
|
|
210
|
+
}
|
|
225
211
|
return adjustedItem;
|
|
226
212
|
}
|
|
227
213
|
else {
|
|
214
|
+
if (original[widgetId]) {
|
|
215
|
+
delete original[widgetId];
|
|
216
|
+
}
|
|
228
217
|
return item;
|
|
229
218
|
}
|
|
230
219
|
});
|
|
231
|
-
}, [props.layout,
|
|
220
|
+
}, [props.layout, layoutUpdateCounter]);
|
|
232
221
|
const reloadItems = react_1.default.useCallback((pluginsRefs, data) => {
|
|
233
222
|
pluginsRefs.forEach((ref) => ref && ref.reload && ref.reload(data));
|
|
234
223
|
}, []);
|
|
@@ -111,7 +111,9 @@ function useMemoStateContext(props) {
|
|
|
111
111
|
forceUpdateLayout((prev) => prev + 1);
|
|
112
112
|
}
|
|
113
113
|
}, []);
|
|
114
|
-
|
|
114
|
+
React.useMemo(() => {
|
|
115
|
+
const groups = props.groups;
|
|
116
|
+
const layout = props.layout;
|
|
115
117
|
const defaultProps = props.registerManager._gridLayout || {};
|
|
116
118
|
const nowrapGroups = {};
|
|
117
119
|
let hasNowrapGroups = false;
|
|
@@ -140,46 +142,23 @@ function useMemoStateContext(props) {
|
|
|
140
142
|
const widgetId = item.i;
|
|
141
143
|
const parentId = item.parent || DEFAULT_GROUP;
|
|
142
144
|
if (nowrapGroups[parentId]) {
|
|
145
|
+
// Collecting nowrap elements
|
|
143
146
|
nowrapGroups[parentId].items.push(item);
|
|
144
147
|
nowrapGroups[parentId].leftSpace -= item.w;
|
|
145
148
|
}
|
|
146
|
-
else if (nowrapAdjustedLayouts.current[
|
|
147
|
-
|
|
148
|
-
const adjustedItem = adjustedLayouts.current[widgetId];
|
|
149
|
-
if (originalMaxW) {
|
|
150
|
-
adjustedLayouts.current[widgetId] = Object.assign(Object.assign({}, adjustedItem), { maxW: originalMaxW });
|
|
151
|
-
originalLayouts.current[widgetId] = item;
|
|
152
|
-
}
|
|
153
|
-
else {
|
|
154
|
-
adjustedLayouts.current[widgetId] = Object.assign({}, adjustedItem);
|
|
155
|
-
}
|
|
149
|
+
else if (nowrapAdjustedLayouts.current[widgetId]) {
|
|
150
|
+
// If element is not in horizontal-nowrap cleaning up and reverting adjustLayout values
|
|
156
151
|
delete nowrapAdjustedLayouts.current[widgetId];
|
|
157
152
|
}
|
|
158
|
-
originalLayouts.current[widgetId] = item;
|
|
159
153
|
});
|
|
160
154
|
Object.entries(nowrapGroups).forEach(([, { items, leftSpace }]) => {
|
|
161
155
|
items.forEach((item) => {
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
originalLayouts.current[item.i] = item;
|
|
165
|
-
adjustedLayouts.current[item.i] = Object.assign(Object.assign({}, item), { maxW });
|
|
166
|
-
nowrapAdjustedLayouts.current[item.i] = item.maxW
|
|
167
|
-
? { maxW, originalMaxW: item.maxW }
|
|
168
|
-
: { maxW };
|
|
169
|
-
}
|
|
156
|
+
// setting maxW with adjustLayout fields and saving previous
|
|
157
|
+
nowrapAdjustedLayouts.current[item.i] = item.w + leftSpace;
|
|
170
158
|
});
|
|
171
159
|
});
|
|
172
160
|
}
|
|
173
|
-
|
|
174
|
-
layout.forEach((item) => {
|
|
175
|
-
const widgetId = item.i;
|
|
176
|
-
if (adjustedLayouts.current[widgetId]) {
|
|
177
|
-
originalLayouts.current[widgetId] = item;
|
|
178
|
-
}
|
|
179
|
-
});
|
|
180
|
-
}
|
|
181
|
-
return adjustedLayouts.current;
|
|
182
|
-
}, [props.registerManager]);
|
|
161
|
+
}, [props.registerManager, props.groups, props.layout]);
|
|
183
162
|
const itemsParams = useDeepEqualMemo(() => getItemsParams({
|
|
184
163
|
defaultGlobalParams: props.defaultGlobalParams,
|
|
185
164
|
globalParams: props.globalParams,
|
|
@@ -208,24 +187,34 @@ function useMemoStateContext(props) {
|
|
|
208
187
|
.filter(Boolean);
|
|
209
188
|
}, []);
|
|
210
189
|
const resultLayout = React.useMemo(() => {
|
|
211
|
-
const adjusted =
|
|
190
|
+
const adjusted = adjustedLayouts.current;
|
|
191
|
+
const original = originalLayouts.current;
|
|
192
|
+
const nowrapAdjust = nowrapAdjustedLayouts.current;
|
|
212
193
|
return props.layout.map((item) => {
|
|
213
|
-
|
|
194
|
+
const widgetId = item.i;
|
|
195
|
+
if (adjusted[widgetId] || nowrapAdjust[widgetId]) {
|
|
196
|
+
original[widgetId] = item;
|
|
214
197
|
// eslint-disable-next-line no-unused-vars
|
|
215
|
-
const _a = adjusted[
|
|
198
|
+
const _a = adjusted[widgetId] || item, { parent } = _a, adjustedItem = __rest(_a, ["parent"]);
|
|
216
199
|
adjustedItem.w = item.w;
|
|
217
200
|
adjustedItem.x = item.x;
|
|
218
201
|
adjustedItem.y = item.y;
|
|
219
202
|
if (item.parent) {
|
|
220
203
|
adjustedItem.parent = item.parent;
|
|
221
204
|
}
|
|
205
|
+
if (nowrapAdjust[widgetId]) {
|
|
206
|
+
adjustedItem.maxW = nowrapAdjust[widgetId];
|
|
207
|
+
}
|
|
222
208
|
return adjustedItem;
|
|
223
209
|
}
|
|
224
210
|
else {
|
|
211
|
+
if (original[widgetId]) {
|
|
212
|
+
delete original[widgetId];
|
|
213
|
+
}
|
|
225
214
|
return item;
|
|
226
215
|
}
|
|
227
216
|
});
|
|
228
|
-
}, [props.layout,
|
|
217
|
+
}, [props.layout, layoutUpdateCounter]);
|
|
229
218
|
const reloadItems = React.useCallback((pluginsRefs, data) => {
|
|
230
219
|
pluginsRefs.forEach((ref) => ref && ref.reload && ref.reload(data));
|
|
231
220
|
}, []);
|