@gravity-ui/dashkit 6.8.0 → 6.10.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.
Files changed (29) hide show
  1. package/README.md +1 -1
  2. package/build/cjs/components/OverlayControls/OverlayControls.d.ts +5 -3
  3. package/build/cjs/shared/modules/__tests__/helpers.test.js +212 -2
  4. package/build/cjs/shared/modules/helpers.d.ts +14 -5
  5. package/build/cjs/shared/modules/helpers.js +89 -19
  6. package/build/cjs/shared/modules/state-and-params.d.ts +2 -2
  7. package/build/cjs/shared/modules/state-and-params.js +73 -42
  8. package/build/cjs/shared/modules/uniq-id.js +3 -0
  9. package/build/cjs/shared/types/config.d.ts +13 -0
  10. package/build/cjs/shared/types/state-and-params.d.ts +4 -2
  11. package/build/cjs/typings/plugin.d.ts +4 -4
  12. package/build/cjs/utils/__tests__/update-manager.test.js +193 -5
  13. package/build/cjs/utils/update-manager.d.ts +2 -2
  14. package/build/cjs/utils/update-manager.js +71 -4
  15. package/build/esm/components/OverlayControls/OverlayControls.d.ts +5 -3
  16. package/build/esm/components/OverlayControls/OverlayControls.js +2 -2
  17. package/build/esm/shared/modules/__tests__/helpers.test.js +213 -3
  18. package/build/esm/shared/modules/helpers.d.ts +14 -5
  19. package/build/esm/shared/modules/helpers.js +87 -19
  20. package/build/esm/shared/modules/state-and-params.d.ts +2 -2
  21. package/build/esm/shared/modules/state-and-params.js +74 -43
  22. package/build/esm/shared/modules/uniq-id.js +4 -1
  23. package/build/esm/shared/types/config.d.ts +13 -0
  24. package/build/esm/shared/types/state-and-params.d.ts +4 -2
  25. package/build/esm/typings/plugin.d.ts +4 -4
  26. package/build/esm/utils/__tests__/update-manager.test.js +193 -5
  27. package/build/esm/utils/update-manager.d.ts +2 -2
  28. package/build/esm/utils/update-manager.js +72 -5
  29. package/package.json +1 -1
package/README.md CHANGED
@@ -328,7 +328,7 @@ DashKit.setSettings({menu: [] as Array<MenuItem>});
328
328
  ### CSS API
329
329
 
330
330
  | Name | Description |
331
- |-:----------------------------------------------|-:---------------------|
331
+ |:-----------------------------------------------|:----------------------|
332
332
  | Action panel variables | |
333
333
  | `--dashkit-action-panel-color` | Background color |
334
334
  | `--dashkit-action-panel-border-color` | Border color |
@@ -1,6 +1,6 @@
1
1
  import React from 'react';
2
- import { ButtonView, ButtonSize, IconProps, MenuItemProps } from '@gravity-ui/uikit';
3
- import { ConfigItem, PluginBase, StringParams, Config, ItemState } from '../../shared';
2
+ import { ButtonSize, ButtonView, IconProps, MenuItemProps } from '@gravity-ui/uikit';
3
+ import { Config, ConfigItem, ItemState, PluginBase, StringParams } from '../../shared';
4
4
  import type { RegisterManager } from '../../utils/register-manager';
5
5
  export declare enum OverlayControlsPosition {
6
6
  TopRight = "top_right",
@@ -45,7 +45,9 @@ type PreparedCopyItemOptionsArg = Pick<ConfigItem, 'data' | 'type' | 'defaults'
45
45
  h: number;
46
46
  };
47
47
  };
48
- export type PreparedCopyItemOptions = PreparedCopyItemOptionsArg;
48
+ export type PreparedCopyItemOptions<C extends object = {}> = PreparedCopyItemOptionsArg & {
49
+ copyContext?: C;
50
+ };
49
51
  type DashKitCtx = React.Context<{
50
52
  context: Record<string, any>;
51
53
  registerManager: RegisterManager;
@@ -3,6 +3,9 @@ Object.defineProperty(exports, "__esModule", { value: true });
3
3
  const constants_1 = require("../../constants");
4
4
  const helpers_1 = require("../helpers");
5
5
  const DEFAULT_CONTROL_ID = 'controlId';
6
+ const DEFAULT_CONTROL_ID_2 = 'controlId2';
7
+ const DEFAULT_GROUP_ITEM_ID = 'groupItemId';
8
+ const DEFAULT_GROUP_ITEM_ID_2 = 'groupItemId2';
6
9
  const DEFAULT_WIDGET_ID = 'widgetId';
7
10
  const DEFAULT_WIDGET_TAB_ID = 'widget_tabId';
8
11
  const NAMESPACE = 'default';
@@ -13,6 +16,25 @@ const getMockedControlItem = ({ id = DEFAULT_CONTROL_ID, defaults, }) => ({
13
16
  type: 'control',
14
17
  namespace: NAMESPACE,
15
18
  });
19
+ const getMockedGroupControlItem = ({ id = DEFAULT_CONTROL_ID, groupItemId = DEFAULT_GROUP_ITEM_ID, groupItemId2 = DEFAULT_GROUP_ITEM_ID_2, defaults, }) => ({
20
+ id,
21
+ data: {
22
+ group: [
23
+ { id: groupItemId, namespace: NAMESPACE, defaults },
24
+ { id: groupItemId2, namespace: NAMESPACE, defaults },
25
+ ],
26
+ },
27
+ type: 'group-control',
28
+ namespace: NAMESPACE,
29
+ });
30
+ const getMockedConfig = ({ items }) => ({
31
+ items,
32
+ salt: '0.9021043992843898',
33
+ counter: 124,
34
+ layout: [],
35
+ aliases: {},
36
+ connections: [],
37
+ });
16
38
  const stateAndParamsWithParamsOnly = {
17
39
  params: {
18
40
  paramName: 'param1',
@@ -121,6 +143,58 @@ describe('modules.helpers', () => {
121
143
  },
122
144
  ]).toEqual((0, helpers_1.formQueueData)({ items: [controlItem5], itemsStateAndParams }));
123
145
  });
146
+ it('return correct queue data for control: group control', () => {
147
+ const itemsStateAndParams = {
148
+ [DEFAULT_CONTROL_ID]: {
149
+ params: {
150
+ [DEFAULT_GROUP_ITEM_ID]: {
151
+ scale: 'd',
152
+ view: 'normal',
153
+ },
154
+ },
155
+ },
156
+ [constants_1.META_KEY]: {
157
+ queue: [{ id: DEFAULT_CONTROL_ID, groupItemId: DEFAULT_GROUP_ITEM_ID }],
158
+ version: 2,
159
+ },
160
+ };
161
+ const controlItem1 = getMockedGroupControlItem({
162
+ id: 'control-1',
163
+ groupItemId: 'group-control-1',
164
+ });
165
+ expect([]).toEqual((0, helpers_1.formQueueData)({ items: [controlItem1], itemsStateAndParams }));
166
+ const controlItem2 = getMockedGroupControlItem({ defaults: { number: 'one', size: 's' } });
167
+ expect([
168
+ {
169
+ id: DEFAULT_GROUP_ITEM_ID,
170
+ namespace: NAMESPACE,
171
+ params: {},
172
+ },
173
+ ]).toEqual((0, helpers_1.formQueueData)({ items: [controlItem2], itemsStateAndParams }));
174
+ const controlItem4 = getMockedGroupControlItem({ defaults: { scale: 'm', size: 's' } });
175
+ expect([
176
+ {
177
+ id: DEFAULT_GROUP_ITEM_ID,
178
+ namespace: NAMESPACE,
179
+ params: {
180
+ scale: 'd',
181
+ },
182
+ },
183
+ ]).toEqual((0, helpers_1.formQueueData)({ items: [controlItem4], itemsStateAndParams }));
184
+ const controlItem5 = getMockedGroupControlItem({
185
+ defaults: { scale: 'm', size: 's', view: 'contrast' },
186
+ });
187
+ expect([
188
+ {
189
+ id: DEFAULT_GROUP_ITEM_ID,
190
+ namespace: NAMESPACE,
191
+ params: {
192
+ scale: 'd',
193
+ view: 'normal',
194
+ },
195
+ },
196
+ ]).toEqual((0, helpers_1.formQueueData)({ items: [controlItem5], itemsStateAndParams }));
197
+ });
124
198
  it('return correct queue data for widget: common', () => {
125
199
  const itemsStateAndParams = {
126
200
  [DEFAULT_WIDGET_ID]: {
@@ -232,10 +306,18 @@ describe('modules.helpers', () => {
232
306
  view: 'normal',
233
307
  },
234
308
  },
309
+ [DEFAULT_CONTROL_ID_2]: {
310
+ params: {
311
+ [DEFAULT_GROUP_ITEM_ID]: {
312
+ size: 'm',
313
+ },
314
+ },
315
+ },
235
316
  [constants_1.META_KEY]: {
236
317
  queue: [
237
318
  { id: DEFAULT_CONTROL_ID },
238
319
  { id: DEFAULT_WIDGET_ID, tabId: DEFAULT_WIDGET_TAB_ID },
320
+ { id: DEFAULT_CONTROL_ID_2, groupItemId: DEFAULT_GROUP_ITEM_ID },
239
321
  ],
240
322
  version: 2,
241
323
  },
@@ -250,19 +332,41 @@ describe('modules.helpers', () => {
250
332
  });
251
333
  const control1 = getMockedControlItem({ id: 'control-1' });
252
334
  const control2 = getMockedControlItem({ defaults: { scale: 'm', view: 'contrast' } });
335
+ const groupControl1 = getMockedGroupControlItem({ id: 'group-control-1' });
336
+ const groupControl2 = getMockedGroupControlItem({
337
+ id: DEFAULT_CONTROL_ID_2,
338
+ defaults: { size: 'xl', view: 'normal' },
339
+ });
253
340
  expect([
254
341
  {
255
342
  id: DEFAULT_CONTROL_ID,
256
343
  namespace: NAMESPACE,
257
- params: { scale: 'd' },
344
+ params: {
345
+ scale: 'd',
346
+ },
258
347
  },
259
348
  {
260
349
  id: DEFAULT_WIDGET_ID,
261
350
  namespace: NAMESPACE,
262
351
  params: { view: 'normal' },
263
352
  },
353
+ {
354
+ id: DEFAULT_GROUP_ITEM_ID,
355
+ namespace: NAMESPACE,
356
+ params: {
357
+ size: 'm',
358
+ },
359
+ },
264
360
  ]).toEqual((0, helpers_1.formQueueData)({
265
- items: [widgetItem2, widgetItem3, control1, widgetItem1, control2],
361
+ items: [
362
+ widgetItem2,
363
+ widgetItem3,
364
+ control1,
365
+ widgetItem1,
366
+ control2,
367
+ groupControl1,
368
+ groupControl2,
369
+ ],
266
370
  itemsStateAndParams,
267
371
  }));
268
372
  });
@@ -291,4 +395,110 @@ describe('modules.helpers', () => {
291
395
  expect(exeptActionParam3.out).toEqual((0, helpers_1.pickExceptActionParamsFromParams)(exeptActionParam3.in));
292
396
  });
293
397
  });
398
+ describe('queue helpers', () => {
399
+ it('add common control to the end of queue', () => {
400
+ const itemsStateAndParams = {
401
+ [constants_1.META_KEY]: {
402
+ queue: [
403
+ { id: DEFAULT_CONTROL_ID },
404
+ { id: DEFAULT_CONTROL_ID_2, groupItemId: DEFAULT_GROUP_ITEM_ID },
405
+ ],
406
+ version: 2,
407
+ },
408
+ };
409
+ const config = getMockedConfig({
410
+ items: [
411
+ getMockedControlItem({}),
412
+ getMockedGroupControlItem({ id: DEFAULT_CONTROL_ID_2 }),
413
+ ],
414
+ });
415
+ expect({
416
+ queue: [
417
+ { id: DEFAULT_CONTROL_ID_2, groupItemId: DEFAULT_GROUP_ITEM_ID },
418
+ { id: DEFAULT_CONTROL_ID },
419
+ ],
420
+ version: 2,
421
+ }).toEqual((0, helpers_1.addToQueue)({ id: DEFAULT_CONTROL_ID, config, itemsStateAndParams }));
422
+ });
423
+ it('remove unused items from queue after adding new group item: remove common items and group items', () => {
424
+ const itemsStateAndParams = {
425
+ [constants_1.META_KEY]: {
426
+ queue: [
427
+ { id: 'control1' },
428
+ { id: 'control2', tabId: 'tab' },
429
+ { id: DEFAULT_CONTROL_ID_2, groupItemId: DEFAULT_GROUP_ITEM_ID_2 },
430
+ { id: DEFAULT_CONTROL_ID },
431
+ { id: DEFAULT_CONTROL_ID_2, groupItemId: 'group-item-1' },
432
+ ],
433
+ version: 2,
434
+ },
435
+ };
436
+ const config = getMockedConfig({
437
+ items: [
438
+ getMockedControlItem({}),
439
+ getMockedGroupControlItem({ id: DEFAULT_CONTROL_ID_2 }),
440
+ ],
441
+ });
442
+ expect({
443
+ queue: [
444
+ { id: DEFAULT_CONTROL_ID_2, groupItemId: DEFAULT_GROUP_ITEM_ID_2 },
445
+ { id: DEFAULT_CONTROL_ID },
446
+ { id: DEFAULT_CONTROL_ID_2, groupItemId: DEFAULT_GROUP_ITEM_ID },
447
+ ],
448
+ version: 2,
449
+ }).toEqual((0, helpers_1.addGroupToQueue)({
450
+ id: DEFAULT_CONTROL_ID_2,
451
+ groupItemIds: [DEFAULT_GROUP_ITEM_ID],
452
+ config,
453
+ itemsStateAndParams,
454
+ }));
455
+ });
456
+ it('remove unused items from queue after adding new item: remove common items and item with group', () => {
457
+ const itemsStateAndParams = {
458
+ [constants_1.META_KEY]: {
459
+ queue: [
460
+ { id: 'control1' },
461
+ { id: 'control2', tabId: 'a3' },
462
+ { id: DEFAULT_CONTROL_ID_2, groupItemId: DEFAULT_GROUP_ITEM_ID_2 },
463
+ { id: DEFAULT_CONTROL_ID_2, groupItemId: DEFAULT_GROUP_ITEM_ID },
464
+ ],
465
+ version: 2,
466
+ },
467
+ };
468
+ const config = getMockedConfig({
469
+ items: [getMockedControlItem({})],
470
+ });
471
+ expect({
472
+ queue: [{ id: DEFAULT_CONTROL_ID }],
473
+ version: 2,
474
+ }).toEqual((0, helpers_1.addToQueue)({
475
+ id: DEFAULT_CONTROL_ID,
476
+ config,
477
+ itemsStateAndParams,
478
+ }));
479
+ });
480
+ it('add group control to queue', () => {
481
+ const itemsStateAndParams = {
482
+ [constants_1.META_KEY]: {
483
+ queue: [{ id: DEFAULT_CONTROL_ID_2, groupItemId: DEFAULT_GROUP_ITEM_ID_2 }],
484
+ version: 2,
485
+ },
486
+ };
487
+ const config = getMockedConfig({
488
+ items: [getMockedGroupControlItem({})],
489
+ });
490
+ expect({
491
+ queue: [
492
+ { id: DEFAULT_CONTROL_ID_2, groupItemId: DEFAULT_GROUP_ITEM_ID },
493
+ { id: DEFAULT_CONTROL_ID_2, groupItemId: DEFAULT_GROUP_ITEM_ID_2 },
494
+ ],
495
+ version: 2,
496
+ }).toEqual((0, helpers_1.addGroupToQueue)({
497
+ id: DEFAULT_CONTROL_ID_2,
498
+ groupItemIds: [DEFAULT_GROUP_ITEM_ID, DEFAULT_GROUP_ITEM_ID_2],
499
+ config,
500
+ itemsStateAndParams,
501
+ }));
502
+ });
503
+ });
294
504
  });
@@ -1,11 +1,12 @@
1
- import { PluginBase, ConfigItem, ItemsStateAndParams, StateAndParamsMetaData, StringParams, ConfigConnection, ConfigAliases, ConfigItemWithTabs, Config, ItemStateAndParams } from '../types';
1
+ import { Config, ConfigAliases, ConfigConnection, ConfigItem, ConfigItemGroup, ConfigItemWithGroup, ConfigItemWithTabs, ItemStateAndParams, ItemsStateAndParams, PluginBase, StateAndParamsMetaData, StringParams } from '../types';
2
2
  export declare function prerenderItems({ items, plugins, }: {
3
3
  items: ConfigItem[];
4
4
  plugins: PluginBase[];
5
5
  }): ConfigItem[];
6
6
  export declare function getItemsStateAndParamsMeta(itemsStateAndParams: ItemsStateAndParams): StateAndParamsMetaData | undefined;
7
7
  export declare function getCurrentVersion(itemsStateAndParams: ItemsStateAndParams): number;
8
- export declare function isItemWithTabs(item: Pick<ConfigItem, 'data'>): item is Pick<ConfigItemWithTabs, 'data'>;
8
+ export declare function isItemWithTabs(item: Pick<ConfigItem, 'data'> | ConfigItemGroup): item is Pick<ConfigItemWithTabs, 'data'>;
9
+ export declare function isItemWithGroup(item: Pick<ConfigItem, 'data'>): item is Pick<ConfigItemWithGroup, 'data'>;
9
10
  export type FormedQueueData = {
10
11
  id: string;
11
12
  namespace: string;
@@ -16,11 +17,11 @@ export declare function formQueueData({ items, itemsStateAndParams, }: {
16
17
  itemsStateAndParams: ItemsStateAndParams;
17
18
  }): FormedQueueData[];
18
19
  export declare function resolveItemInnerId({ item, itemsStateAndParams, }: {
19
- item: ConfigItem;
20
+ item: Pick<ConfigItemWithTabs, 'data' | 'id'>;
20
21
  itemsStateAndParams: ItemsStateAndParams;
21
22
  }): string;
22
23
  export declare function getMapItemsIgnores({ items, ignores, itemsStateAndParams, isFirstVersion, }: {
23
- items: ConfigItem[];
24
+ items: (ConfigItem | ConfigItemGroup)[];
24
25
  ignores: ConfigConnection[];
25
26
  itemsStateAndParams: ItemsStateAndParams;
26
27
  isFirstVersion: boolean;
@@ -35,10 +36,18 @@ export declare function getInitialItemsStateAndParamsMeta(): StateAndParamsMetaD
35
36
  interface ChangeQueueArg {
36
37
  id: string;
37
38
  tabId?: string;
39
+ groupItemId?: string;
40
+ config: Config;
41
+ itemsStateAndParams: ItemsStateAndParams;
42
+ }
43
+ interface ChangeQueueGroupArg {
44
+ id: string;
45
+ groupItemIds: string[];
38
46
  config: Config;
39
47
  itemsStateAndParams: ItemsStateAndParams;
40
48
  }
41
49
  export declare function addToQueue({ id, tabId, config, itemsStateAndParams, }: ChangeQueueArg): StateAndParamsMetaData;
50
+ export declare function addGroupToQueue({ id, groupItemIds, config, itemsStateAndParams, }: ChangeQueueGroupArg): StateAndParamsMetaData;
42
51
  export declare function deleteFromQueue(data: ChangeQueueArg): StateAndParamsMetaData;
43
52
  /**
44
53
  * public function for getting only actionParams from object (all fields with keys that contains prefix)
@@ -63,7 +72,7 @@ export declare function transformParamsToActionParams(params: ItemStateAndParams
63
72
  * check if object contains actionParams
64
73
  * @param conf
65
74
  */
66
- export declare function hasActionParam(conf?: StringParams): boolean;
75
+ export declare function hasActionParam(conf?: StringParams | Record<string, StringParams>): boolean;
67
76
  /**
68
77
  * check if ItemStateAndParams object has actionParams in params or state field
69
78
  * @param stateAndParams
@@ -1,6 +1,6 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.hasActionParams = exports.hasActionParam = exports.transformParamsToActionParams = exports.pickExceptActionParamsFromParams = exports.pickActionParamsFromParams = exports.deleteFromQueue = exports.addToQueue = exports.getInitialItemsStateAndParamsMeta = exports.mergeParamsWithAliases = exports.getMapItemsIgnores = exports.resolveItemInnerId = exports.formQueueData = exports.isItemWithTabs = exports.getCurrentVersion = exports.getItemsStateAndParamsMeta = exports.prerenderItems = void 0;
3
+ exports.hasActionParams = exports.hasActionParam = exports.transformParamsToActionParams = exports.pickExceptActionParamsFromParams = exports.pickActionParamsFromParams = exports.deleteFromQueue = exports.addGroupToQueue = exports.addToQueue = exports.getInitialItemsStateAndParamsMeta = exports.mergeParamsWithAliases = exports.getMapItemsIgnores = exports.resolveItemInnerId = exports.formQueueData = exports.isItemWithGroup = exports.isItemWithTabs = exports.getCurrentVersion = exports.getItemsStateAndParamsMeta = exports.prerenderItems = void 0;
4
4
  const tslib_1 = require("tslib");
5
5
  const keyBy_1 = tslib_1.__importDefault(require("lodash/keyBy"));
6
6
  const get_1 = tslib_1.__importDefault(require("lodash/get"));
@@ -44,31 +44,56 @@ function getCurrentVersion(itemsStateAndParams) {
44
44
  return meta.version;
45
45
  }
46
46
  exports.getCurrentVersion = getCurrentVersion;
47
- function nonNullable(value) {
48
- return value !== null && value !== undefined;
47
+ function isConfigData(item) {
48
+ return 'data' in item && 'type' in item;
49
49
  }
50
50
  function isItemWithTabs(item) {
51
51
  var _a;
52
- return Array.isArray((_a = item === null || item === void 0 ? void 0 : item.data) === null || _a === void 0 ? void 0 : _a.tabs);
52
+ return isConfigData(item) && Array.isArray((_a = item === null || item === void 0 ? void 0 : item.data) === null || _a === void 0 ? void 0 : _a.tabs);
53
53
  }
54
54
  exports.isItemWithTabs = isItemWithTabs;
55
+ function isItemWithGroup(item) {
56
+ var _a;
57
+ return Array.isArray((_a = item === null || item === void 0 ? void 0 : item.data) === null || _a === void 0 ? void 0 : _a.group);
58
+ }
59
+ exports.isItemWithGroup = isItemWithGroup;
55
60
  // Array of parameters from widgets according to queue
56
61
  function formQueueData({ items, itemsStateAndParams, }) {
57
62
  var _a;
58
63
  const queue = ((_a = getItemsStateAndParamsMeta(itemsStateAndParams)) === null || _a === void 0 ? void 0 : _a.queue) || [];
59
64
  const keyById = (0, keyBy_1.default)(items, 'id');
60
- return queue
61
- .map((queueItem) => {
65
+ return queue.reduce((queueArray, queueItem) => {
62
66
  var _a;
63
- const { id: queueId, tabId } = queueItem;
67
+ const { id: queueId, tabId, groupItemId } = queueItem;
64
68
  const item = keyById[queueId];
65
- if (!item) {
66
- return null;
69
+ const isGroup = isItemWithGroup(item);
70
+ if (!item || (isGroup && !groupItemId)) {
71
+ return queueArray;
72
+ }
73
+ if (isGroup && groupItemId) {
74
+ const itemQueueParams = (0, get_1.default)(itemsStateAndParams, [item.id, 'params'], {});
75
+ const groupItem = item.data.group.find(({ id }) => id === groupItemId);
76
+ if (!groupItem) {
77
+ return queueArray;
78
+ }
79
+ const groupItemQueueParams = itemQueueParams[groupItemId];
80
+ const filteredParamsByDefaults = (0, pick_1.default)(groupItemQueueParams, Object.keys(groupItem.defaults || {}));
81
+ /**
82
+ * merging filtered params and filtered actionParams with prefixes
83
+ */
84
+ const params = Object.assign(Object.assign({}, filteredParamsByDefaults), (pickActionParamsFromParams(groupItemQueueParams, true) || {}));
85
+ queueArray.push({
86
+ id: groupItem.id,
87
+ namespace: groupItem.namespace,
88
+ params,
89
+ });
90
+ return queueArray;
67
91
  }
92
+ const itemQueueParams = (0, get_1.default)(itemsStateAndParams, [item.id, 'params'], {});
68
93
  let itemDefaultParams;
69
94
  if (isItemWithTabs(item)) {
70
95
  if (!tabId || resolveItemInnerId({ item, itemsStateAndParams }) !== tabId) {
71
- return null;
96
+ return queueArray;
72
97
  }
73
98
  itemDefaultParams =
74
99
  ((_a = item.data.tabs.find((tabData) => tabData.id === tabId)) === null || _a === void 0 ? void 0 : _a.params) || {};
@@ -76,19 +101,18 @@ function formQueueData({ items, itemsStateAndParams, }) {
76
101
  else {
77
102
  itemDefaultParams = item.defaults || {};
78
103
  }
79
- const itemQueueParams = (0, get_1.default)(itemsStateAndParams, [item.id, 'params'], {});
80
104
  const filteredParamsByDefaults = (0, pick_1.default)(itemQueueParams, Object.keys(itemDefaultParams));
81
105
  /**
82
106
  * merging filtered params and filtered actionParams with prefixes
83
107
  */
84
108
  const params = Object.assign(Object.assign({}, filteredParamsByDefaults), (pickActionParamsFromParams(itemQueueParams, true) || {}));
85
- return {
109
+ queueArray.push({
86
110
  id: item.id,
87
111
  namespace: item.namespace,
88
112
  params,
89
- };
90
- })
91
- .filter(nonNullable);
113
+ });
114
+ return queueArray;
115
+ }, []);
92
116
  }
93
117
  exports.formQueueData = formQueueData;
94
118
  function resolveItemInnerId({ item, itemsStateAndParams, }) {
@@ -151,6 +175,17 @@ function getInitialItemsStateAndParamsMeta() {
151
175
  };
152
176
  }
153
177
  exports.getInitialItemsStateAndParamsMeta = getInitialItemsStateAndParamsMeta;
178
+ function getActualItemsIds(items) {
179
+ return items.reduce((ids, item) => {
180
+ if (isItemWithGroup(item)) {
181
+ item.data.group.forEach((groupItem) => {
182
+ ids.push(groupItem.id);
183
+ });
184
+ }
185
+ ids.push(item.id);
186
+ return ids;
187
+ }, []);
188
+ }
154
189
  function addToQueue({ id, tabId, config, itemsStateAndParams, }) {
155
190
  const queueItem = { id };
156
191
  if (tabId) {
@@ -160,17 +195,47 @@ function addToQueue({ id, tabId, config, itemsStateAndParams, }) {
160
195
  if (!meta) {
161
196
  return { queue: [queueItem], version: constants_1.CURRENT_VERSION };
162
197
  }
163
- const { items } = config;
164
- const actualIds = items.map((item) => item.id);
198
+ const actualIds = getActualItemsIds(config.items);
165
199
  const metaQueue = meta.queue || [];
200
+ const notCurrent = (item) => {
201
+ if (item.groupItemId) {
202
+ return actualIds.includes(item.groupItemId);
203
+ }
204
+ return item.id !== id;
205
+ };
166
206
  return {
167
207
  queue: metaQueue
168
- .filter((item) => actualIds.includes(item.id) && item.id !== id)
208
+ .filter((item) => actualIds.includes(item.id) && notCurrent(item))
169
209
  .concat(queueItem),
170
210
  version: meta.version || constants_1.CURRENT_VERSION,
171
211
  };
172
212
  }
173
213
  exports.addToQueue = addToQueue;
214
+ function addGroupToQueue({ id, groupItemIds, config, itemsStateAndParams, }) {
215
+ const queueItems = groupItemIds.map((groupItemId) => ({
216
+ id,
217
+ groupItemId,
218
+ }));
219
+ const meta = getItemsStateAndParamsMeta(itemsStateAndParams);
220
+ if (!meta) {
221
+ return { queue: queueItems, version: constants_1.CURRENT_VERSION };
222
+ }
223
+ const actualIds = getActualItemsIds(config.items);
224
+ const metaQueue = meta.queue || [];
225
+ const notCurrent = (item) => {
226
+ if (item.groupItemId) {
227
+ return actualIds.includes(item.groupItemId) && !groupItemIds.includes(item.groupItemId);
228
+ }
229
+ return true;
230
+ };
231
+ return {
232
+ queue: metaQueue
233
+ .filter((item) => actualIds.includes(item.id) && notCurrent(item))
234
+ .concat(queueItems),
235
+ version: meta.version || constants_1.CURRENT_VERSION,
236
+ };
237
+ }
238
+ exports.addGroupToQueue = addGroupToQueue;
174
239
  function deleteFromQueue(data) {
175
240
  const meta = addToQueue(data);
176
241
  return Object.assign(Object.assign({}, meta), { queue: meta.queue.slice(0, -1) });
@@ -236,7 +301,12 @@ exports.transformParamsToActionParams = transformParamsToActionParams;
236
301
  * @param conf
237
302
  */
238
303
  function hasActionParam(conf) {
239
- return Object.keys(conf || {}).some((key) => key.startsWith(constants_1.ACTION_PARAM_PREFIX));
304
+ return Object.keys(conf || {}).some((key) => {
305
+ if (conf && typeof conf[key] === 'object' && !Array.isArray(conf[key])) {
306
+ return Object.keys(conf[key]).some((subkey) => subkey.startsWith(constants_1.ACTION_PARAM_PREFIX));
307
+ }
308
+ return key.startsWith(constants_1.ACTION_PARAM_PREFIX);
309
+ });
240
310
  }
241
311
  exports.hasActionParam = hasActionParam;
242
312
  /**
@@ -1,4 +1,4 @@
1
- import { GlobalParams, Config, ItemsStateAndParams, PluginBase, StringParams, ItemState } from '../types';
1
+ import { Config, GlobalParams, ItemState, ItemsStateAndParams, PluginBase, StringParams } from '../types';
2
2
  export interface GetItemsParamsArg {
3
3
  defaultGlobalParams: GlobalParams;
4
4
  globalParams: GlobalParams;
@@ -6,7 +6,7 @@ export interface GetItemsParamsArg {
6
6
  itemsStateAndParams: ItemsStateAndParams;
7
7
  plugins: PluginBase[];
8
8
  }
9
- type GetItemsParamsReturn = Record<string, StringParams>;
9
+ type GetItemsParamsReturn = Record<string, StringParams | Record<string, StringParams>>;
10
10
  export declare function getItemsParams({ defaultGlobalParams, globalParams, config, itemsStateAndParams, plugins, }: GetItemsParamsArg): GetItemsParamsReturn;
11
11
  export declare function getItemsState({ config, itemsStateAndParams, }: {
12
12
  config: Config;