@gravity-ui/dashkit 8.12.1 → 8.13.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.
@@ -54,7 +54,11 @@ export declare class DashKit extends React.PureComponent<DashKitInnerProps> {
54
54
  config: Config;
55
55
  itemsStateAndParams: ItemsStateAndParams;
56
56
  };
57
- static reflowLayout(newLayoutItem: ConfigLayout, layout: ConfigLayout[], groups?: DashKitGroup[]): ConfigLayout[];
57
+ static reflowLayout({ newLayoutItem, layout, groups, }: {
58
+ newLayoutItem?: ConfigLayout;
59
+ layout: ConfigLayout[];
60
+ groups?: DashKitGroup[];
61
+ }): ConfigLayout[];
58
62
  metaRef: React.RefObject<GridLayout>;
59
63
  render(): JSX.Element;
60
64
  getItemsMeta(): any;
@@ -66,8 +66,12 @@ class DashKit extends react_1.default.PureComponent {
66
66
  static removeItem({ id, config, itemsStateAndParams, }) {
67
67
  return utils_1.UpdateManager.removeItem({ id, config, itemsStateAndParams });
68
68
  }
69
- static reflowLayout(newLayoutItem, layout, groups) {
70
- return (0, utils_1.reflowLayout)(newLayoutItem, layout, getReflowGroupsConfig(groups));
69
+ static reflowLayout({ newLayoutItem, layout, groups, }) {
70
+ return (0, utils_1.reflowLayout)({
71
+ newLayoutItem,
72
+ layout,
73
+ reflowLayoutOptions: getReflowGroupsConfig(groups),
74
+ });
71
75
  }
72
76
  render() {
73
77
  return react_1.default.createElement(DashKitView_1.default, Object.assign({ registerManager: registerManager, ref: this.metaRef }, this.props));
@@ -21,7 +21,11 @@ export declare const getChangedParams: ({ initiatorItem, stateAndParams, itemsSt
21
21
  }) => {
22
22
  [x: string]: string | string[];
23
23
  };
24
- export declare function reflowLayout(newLayoutItem: ConfigLayout, layout: ConfigLayout[], reflowLayoutOptions: ReflowLayoutOptions): ConfigLayout[];
24
+ export declare function reflowLayout({ newLayoutItem, layout, reflowLayoutOptions, }: {
25
+ newLayoutItem?: ConfigLayout;
26
+ layout: ConfigLayout[];
27
+ reflowLayoutOptions: ReflowLayoutOptions;
28
+ }): ConfigLayout[];
25
29
  export declare class UpdateManager {
26
30
  static addItem({ item, namespace, layout, config, options, }: {
27
31
  item: AddConfigItem;
@@ -227,7 +227,7 @@ function changeGroupParams({ groupItemIds, initiatorId, initiatorItem, itemsStat
227
227
  };
228
228
  return (0, immutability_helper_1.default)(itemsStateAndParams, obj);
229
229
  }
230
- function reflowLayout(newLayoutItem, layout, reflowLayoutOptions) {
230
+ function reflowLayout({ newLayoutItem, layout, reflowLayoutOptions, }) {
231
231
  const byGroup = {};
232
232
  const reducer = (memo, item, i, _items, isNewItem) => {
233
233
  memo[item.i] = i;
@@ -246,7 +246,9 @@ function reflowLayout(newLayoutItem, layout, reflowLayoutOptions) {
246
246
  return memo;
247
247
  };
248
248
  const orderById = layout.reduce(reducer, {});
249
- reducer(orderById, newLayoutItem, layout.length, layout, true);
249
+ if (newLayoutItem) {
250
+ reducer(orderById, newLayoutItem, layout.length, layout, true);
251
+ }
250
252
  const { defaultProps } = reflowLayoutOptions;
251
253
  return Object.entries(byGroup)
252
254
  .reduce((memo, [groupId, layoutItems]) => {
@@ -287,7 +289,11 @@ class UpdateManager {
287
289
  let newLayout;
288
290
  const newLayoutItem = Object.assign(Object.assign({}, saveDefaultLayout), { i: newItem.id });
289
291
  if (options.reflowLayoutOptions) {
290
- newLayout = reflowLayout(newLayoutItem, config.layout.map((t) => (Object.assign(Object.assign({}, t), (byId[t.i] || {})))), options.reflowLayoutOptions);
292
+ newLayout = reflowLayout({
293
+ newLayoutItem,
294
+ layout: config.layout.map((t) => (Object.assign(Object.assign({}, t), (byId[t.i] || {})))),
295
+ reflowLayoutOptions: options.reflowLayoutOptions,
296
+ });
291
297
  }
292
298
  else {
293
299
  newLayout = [
@@ -305,7 +311,11 @@ class UpdateManager {
305
311
  let newLayout;
306
312
  const newLayoutItem = Object.assign(Object.assign({}, saveDefaultLayout), { i: newItem.id });
307
313
  if (options.reflowLayoutOptions) {
308
- newLayout = reflowLayout(newLayoutItem, config.layout, options.reflowLayoutOptions);
314
+ newLayout = reflowLayout({
315
+ newLayoutItem,
316
+ layout: config.layout,
317
+ reflowLayoutOptions: options.reflowLayoutOptions,
318
+ });
309
319
  }
310
320
  else {
311
321
  newLayout = [...config.layout, newLayoutItem];
@@ -54,7 +54,11 @@ export declare class DashKit extends React.PureComponent<DashKitInnerProps> {
54
54
  config: Config;
55
55
  itemsStateAndParams: ItemsStateAndParams;
56
56
  };
57
- static reflowLayout(newLayoutItem: ConfigLayout, layout: ConfigLayout[], groups?: DashKitGroup[]): ConfigLayout[];
57
+ static reflowLayout({ newLayoutItem, layout, groups, }: {
58
+ newLayoutItem?: ConfigLayout;
59
+ layout: ConfigLayout[];
60
+ groups?: DashKitGroup[];
61
+ }): ConfigLayout[];
58
62
  metaRef: React.RefObject<GridLayout>;
59
63
  render(): JSX.Element;
60
64
  getItemsMeta(): any;
@@ -62,8 +62,12 @@ export class DashKit extends React.PureComponent {
62
62
  static removeItem({ id, config, itemsStateAndParams, }) {
63
63
  return UpdateManager.removeItem({ id, config, itemsStateAndParams });
64
64
  }
65
- static reflowLayout(newLayoutItem, layout, groups) {
66
- return reflowLayout(newLayoutItem, layout, getReflowGroupsConfig(groups));
65
+ static reflowLayout({ newLayoutItem, layout, groups, }) {
66
+ return reflowLayout({
67
+ newLayoutItem,
68
+ layout,
69
+ reflowLayoutOptions: getReflowGroupsConfig(groups),
70
+ });
67
71
  }
68
72
  render() {
69
73
  return React.createElement(DashKitView, Object.assign({ registerManager: registerManager, ref: this.metaRef }, this.props));
@@ -21,7 +21,11 @@ export declare const getChangedParams: ({ initiatorItem, stateAndParams, itemsSt
21
21
  }) => {
22
22
  [x: string]: string | string[];
23
23
  };
24
- export declare function reflowLayout(newLayoutItem: ConfigLayout, layout: ConfigLayout[], reflowLayoutOptions: ReflowLayoutOptions): ConfigLayout[];
24
+ export declare function reflowLayout({ newLayoutItem, layout, reflowLayoutOptions, }: {
25
+ newLayoutItem?: ConfigLayout;
26
+ layout: ConfigLayout[];
27
+ reflowLayoutOptions: ReflowLayoutOptions;
28
+ }): ConfigLayout[];
25
29
  export declare class UpdateManager {
26
30
  static addItem({ item, namespace, layout, config, options, }: {
27
31
  item: AddConfigItem;
@@ -222,7 +222,7 @@ function changeGroupParams({ groupItemIds, initiatorId, initiatorItem, itemsStat
222
222
  };
223
223
  return update(itemsStateAndParams, obj);
224
224
  }
225
- export function reflowLayout(newLayoutItem, layout, reflowLayoutOptions) {
225
+ export function reflowLayout({ newLayoutItem, layout, reflowLayoutOptions, }) {
226
226
  const byGroup = {};
227
227
  const reducer = (memo, item, i, _items, isNewItem) => {
228
228
  memo[item.i] = i;
@@ -241,7 +241,9 @@ export function reflowLayout(newLayoutItem, layout, reflowLayoutOptions) {
241
241
  return memo;
242
242
  };
243
243
  const orderById = layout.reduce(reducer, {});
244
- reducer(orderById, newLayoutItem, layout.length, layout, true);
244
+ if (newLayoutItem) {
245
+ reducer(orderById, newLayoutItem, layout.length, layout, true);
246
+ }
245
247
  const { defaultProps } = reflowLayoutOptions;
246
248
  return Object.entries(byGroup)
247
249
  .reduce((memo, [groupId, layoutItems]) => {
@@ -281,7 +283,11 @@ export class UpdateManager {
281
283
  let newLayout;
282
284
  const newLayoutItem = Object.assign(Object.assign({}, saveDefaultLayout), { i: newItem.id });
283
285
  if (options.reflowLayoutOptions) {
284
- newLayout = reflowLayout(newLayoutItem, config.layout.map((t) => (Object.assign(Object.assign({}, t), (byId[t.i] || {})))), options.reflowLayoutOptions);
286
+ newLayout = reflowLayout({
287
+ newLayoutItem,
288
+ layout: config.layout.map((t) => (Object.assign(Object.assign({}, t), (byId[t.i] || {})))),
289
+ reflowLayoutOptions: options.reflowLayoutOptions,
290
+ });
285
291
  }
286
292
  else {
287
293
  newLayout = [
@@ -299,7 +305,11 @@ export class UpdateManager {
299
305
  let newLayout;
300
306
  const newLayoutItem = Object.assign(Object.assign({}, saveDefaultLayout), { i: newItem.id });
301
307
  if (options.reflowLayoutOptions) {
302
- newLayout = reflowLayout(newLayoutItem, config.layout, options.reflowLayoutOptions);
308
+ newLayout = reflowLayout({
309
+ newLayoutItem,
310
+ layout: config.layout,
311
+ reflowLayoutOptions: options.reflowLayoutOptions,
312
+ });
303
313
  }
304
314
  else {
305
315
  newLayout = [...config.layout, newLayoutItem];
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@gravity-ui/dashkit",
3
- "version": "8.12.1",
3
+ "version": "8.13.0",
4
4
  "description": "Library for rendering dashboard grid layout",
5
5
  "license": "MIT",
6
6
  "repository": {