@gravity-ui/dashkit 6.6.1 → 6.7.1

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 (33) hide show
  1. package/build/cjs/components/Item/Item.d.ts +2 -2
  2. package/build/cjs/hocs/prepareItem.d.ts +2 -2
  3. package/build/cjs/hocs/prepareItem.js +2 -2
  4. package/build/cjs/hocs/withContext.js +2 -1
  5. package/build/cjs/shared/modules/helpers.d.ts +0 -9
  6. package/build/cjs/shared/modules/helpers.js +1 -22
  7. package/build/cjs/shared/modules/state-and-params.js +3 -21
  8. package/build/cjs/shared/types/state-and-params.d.ts +3 -0
  9. package/build/cjs/shared/units/__tests__/state-and-params.test.js +71 -0
  10. package/build/cjs/typings/plugin.d.ts +2 -2
  11. package/build/cjs/utils/__tests__/update-manager.test.d.ts +1 -0
  12. package/build/cjs/utils/__tests__/update-manager.test.js +476 -0
  13. package/build/cjs/utils/update-manager.d.ts +3 -2
  14. package/build/cjs/utils/update-manager.js +24 -10
  15. package/build/esm/components/Item/Item.d.ts +2 -2
  16. package/build/esm/hocs/prepareItem.d.ts +2 -2
  17. package/build/esm/hocs/prepareItem.js +2 -2
  18. package/build/esm/hocs/withContext.js +2 -1
  19. package/build/esm/shared/modules/helpers.d.ts +0 -9
  20. package/build/esm/shared/modules/helpers.js +0 -20
  21. package/build/esm/shared/modules/state-and-params.js +4 -22
  22. package/build/esm/shared/types/state-and-params.d.ts +3 -0
  23. package/build/esm/shared/units/__tests__/state-and-params.test.js +71 -0
  24. package/build/esm/typings/plugin.d.ts +2 -2
  25. package/build/esm/utils/__tests__/update-manager.test.d.ts +1 -0
  26. package/build/esm/utils/__tests__/update-manager.test.js +474 -0
  27. package/build/esm/utils/update-manager.d.ts +3 -2
  28. package/build/esm/utils/update-manager.js +24 -10
  29. package/package.json +1 -1
  30. package/build/cjs/utils/__tests__/mock.test.d.ts +0 -1
  31. package/build/cjs/utils/__tests__/mock.test.js +0 -8
  32. package/build/esm/utils/__tests__/mock.test.d.ts +0 -1
  33. package/build/esm/utils/__tests__/mock.test.js +0 -8
@@ -0,0 +1,476 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ const update_manager_1 = require("../update-manager");
4
+ const config = {
5
+ salt: '0.09852189776033704',
6
+ counter: 14,
7
+ items: [
8
+ {
9
+ id: 'al',
10
+ data: {
11
+ tabs: [
12
+ {
13
+ id: 'Jn',
14
+ title: 'tab 1',
15
+ params: {
16
+ Country: 'Germany',
17
+ },
18
+ chartId: 'h8hfbffyo3dg8',
19
+ isDefault: true,
20
+ autoHeight: false,
21
+ },
22
+ {
23
+ id: 'Pf',
24
+ title: 'tab 2',
25
+ params: {},
26
+ chartId: 'f5hfbl3yo3dh7',
27
+ isDefault: false,
28
+ autoHeight: false,
29
+ },
30
+ ],
31
+ hideTitle: true,
32
+ },
33
+ type: 'widget',
34
+ namespace: 'default',
35
+ },
36
+ {
37
+ id: 'Q8',
38
+ data: {
39
+ tabs: [
40
+ {
41
+ id: 'K0',
42
+ title: 'filtering_charts_table (charteditor)',
43
+ params: {
44
+ Year: '',
45
+ Country: '',
46
+ _ap_Country: 'Belgium',
47
+ },
48
+ chartId: '245z37u4ylvet',
49
+ isDefault: true,
50
+ autoHeight: false,
51
+ },
52
+ ],
53
+ hideTitle: false,
54
+ },
55
+ type: 'widget',
56
+ namespace: 'default',
57
+ },
58
+ {
59
+ id: 'L5',
60
+ data: {
61
+ title: 'Country',
62
+ source: {
63
+ datasetId: 'gyrnhj945gum9',
64
+ fieldType: 'string',
65
+ showTitle: true,
66
+ innerTitle: 'Inner title',
67
+ elementType: 'select',
68
+ datasetFieldId: 'd079',
69
+ showInnerTitle: false,
70
+ datasetFieldType: 'DIMENSION',
71
+ },
72
+ sourceType: 'dataset',
73
+ },
74
+ type: 'control',
75
+ defaults: {
76
+ d079: ['Italy', 'France'],
77
+ },
78
+ namespace: 'default',
79
+ },
80
+ {
81
+ id: 'C8',
82
+ data: {
83
+ title: 'Client',
84
+ source: {
85
+ datasetId: 'rfvnhj345gugf',
86
+ fieldType: 'string',
87
+ showTitle: true,
88
+ innerTitle: 'Inner title',
89
+ elementType: 'select',
90
+ datasetFieldId: 'g129',
91
+ showInnerTitle: false,
92
+ datasetFieldType: 'DIMENSION',
93
+ },
94
+ sourceType: 'dataset',
95
+ },
96
+ type: 'control',
97
+ defaults: {
98
+ g129: ['Alex'],
99
+ },
100
+ namespace: 'default',
101
+ },
102
+ {
103
+ id: 'lko',
104
+ data: {
105
+ title: 'External control',
106
+ source: {
107
+ chartId: 'deuaclrdakbc4',
108
+ },
109
+ autoHeight: true,
110
+ sourceType: 'external',
111
+ },
112
+ type: 'control',
113
+ defaults: {
114
+ Name: '',
115
+ Brand: '',
116
+ Label: '',
117
+ },
118
+ namespace: 'default',
119
+ },
120
+ ],
121
+ layout: [
122
+ { h: 4, i: 'al', w: 4, x: 8, y: 0 },
123
+ { h: 16, i: 'Q8', w: 12, x: 12, y: 0 },
124
+ { h: 2, i: 'L5', w: 8, x: 0, y: 2 },
125
+ { h: 2, i: 'C8', w: 8, x: 10, y: 30 },
126
+ { h: 2, i: 'lko', w: 8, x: 0, y: 12 },
127
+ ],
128
+ aliases: {},
129
+ connections: [],
130
+ };
131
+ beforeEach(() => {
132
+ jest.spyOn(console, 'warn').mockImplementation(jest.fn());
133
+ });
134
+ describe('UpdateManager', () => {
135
+ describe('changeStateAndParams', () => {
136
+ it('control adds params to empty itemsStateAndParams', () => {
137
+ expect(update_manager_1.UpdateManager.changeStateAndParams({
138
+ id: 'L5',
139
+ config,
140
+ itemsStateAndParams: {},
141
+ stateAndParams: {
142
+ params: {
143
+ d079: ['Russia'],
144
+ },
145
+ },
146
+ })).toEqual({
147
+ L5: {
148
+ params: {
149
+ d079: ['Russia'],
150
+ },
151
+ },
152
+ __meta__: { queue: [{ id: 'L5' }], version: 2 },
153
+ });
154
+ });
155
+ it('state changes only do not push into the queue', () => {
156
+ expect(update_manager_1.UpdateManager.changeStateAndParams({
157
+ id: 'al',
158
+ config,
159
+ itemsStateAndParams: {
160
+ L5: {
161
+ params: {
162
+ d079: ['Russia'],
163
+ },
164
+ },
165
+ __meta__: { queue: [{ id: 'L5' }, { id: 'Unk' }], version: 2 },
166
+ },
167
+ stateAndParams: {
168
+ state: { tabId: 'Pf' },
169
+ },
170
+ })).toEqual({
171
+ L5: {
172
+ params: {
173
+ d079: ['Russia'],
174
+ },
175
+ },
176
+ al: {
177
+ state: {
178
+ tabId: 'Pf',
179
+ },
180
+ },
181
+ __meta__: { queue: [{ id: 'L5' }], version: 2 },
182
+ });
183
+ });
184
+ it('tab changes clear previous tab params', () => {
185
+ expect(update_manager_1.UpdateManager.changeStateAndParams({
186
+ id: 'al',
187
+ config,
188
+ itemsStateAndParams: {
189
+ al: {
190
+ state: {
191
+ tabId: 'Jn',
192
+ },
193
+ params: {
194
+ Country: 'USA',
195
+ },
196
+ },
197
+ __meta__: { queue: [{ id: 'al', tabId: 'Jn' }], version: 2 },
198
+ },
199
+ stateAndParams: {
200
+ state: { tabId: 'Pf' },
201
+ },
202
+ })).toEqual({
203
+ al: {
204
+ state: {
205
+ tabId: 'Pf',
206
+ },
207
+ },
208
+ __meta__: { queue: [], version: 2 },
209
+ });
210
+ });
211
+ it('control changes rearrange position in the queue', () => {
212
+ expect(update_manager_1.UpdateManager.changeStateAndParams({
213
+ id: 'L5',
214
+ config,
215
+ itemsStateAndParams: {
216
+ al: {
217
+ state: {
218
+ tabId: 'Jn',
219
+ },
220
+ params: {
221
+ Country: 'USA',
222
+ },
223
+ },
224
+ L5: {
225
+ params: {
226
+ d079: ['Russia'],
227
+ },
228
+ },
229
+ C8: {
230
+ params: {
231
+ g129: ['Anton'],
232
+ },
233
+ },
234
+ __meta__: {
235
+ queue: [{ id: 'L5' }, { id: 'C8' }, { id: 'al', tabId: 'Jn' }, { id: 'Unk' }],
236
+ version: 2,
237
+ },
238
+ },
239
+ stateAndParams: {
240
+ params: {
241
+ d079: ['Oman'],
242
+ },
243
+ },
244
+ })).toEqual({
245
+ al: {
246
+ state: {
247
+ tabId: 'Jn',
248
+ },
249
+ params: {
250
+ Country: 'USA',
251
+ },
252
+ },
253
+ L5: {
254
+ params: {
255
+ d079: ['Oman'],
256
+ },
257
+ },
258
+ C8: {
259
+ params: {
260
+ g129: ['Anton'],
261
+ },
262
+ },
263
+ __meta__: {
264
+ queue: [{ id: 'C8' }, { id: 'al', tabId: 'Jn' }, { id: 'L5' }],
265
+ version: 2,
266
+ },
267
+ });
268
+ });
269
+ it('control params should merge', () => {
270
+ expect(update_manager_1.UpdateManager.changeStateAndParams({
271
+ id: 'lko',
272
+ config,
273
+ itemsStateAndParams: {
274
+ L5: {
275
+ params: {
276
+ d079: ['Russia'],
277
+ },
278
+ },
279
+ lko: {
280
+ params: {
281
+ Brand: ['Nuke'],
282
+ Label: ['pin'],
283
+ },
284
+ },
285
+ __meta__: {
286
+ queue: [{ id: 'lko' }, { id: 'L5' }],
287
+ version: 2,
288
+ },
289
+ },
290
+ stateAndParams: {
291
+ params: {
292
+ Name: ['Jack'],
293
+ Label: ['clone'],
294
+ },
295
+ },
296
+ })).toEqual({
297
+ L5: {
298
+ params: {
299
+ d079: ['Russia'],
300
+ },
301
+ },
302
+ lko: {
303
+ params: {
304
+ Brand: ['Nuke'],
305
+ Name: ['Jack'],
306
+ Label: ['clone'],
307
+ },
308
+ },
309
+ __meta__: { queue: [{ id: 'L5' }, { id: 'lko' }], version: 2 },
310
+ });
311
+ });
312
+ it('control cannot set params not from defaults', () => {
313
+ expect(update_manager_1.UpdateManager.changeStateAndParams({
314
+ id: 'lko',
315
+ config,
316
+ itemsStateAndParams: {},
317
+ stateAndParams: {
318
+ params: {
319
+ Brand: ['Nuke'],
320
+ UnknownParam: ['Value'],
321
+ },
322
+ },
323
+ })).toEqual({
324
+ lko: {
325
+ params: {
326
+ Brand: ['Nuke'],
327
+ },
328
+ },
329
+ __meta__: { queue: [{ id: 'lko' }], version: 2 },
330
+ });
331
+ });
332
+ it('filtering_charts_table can set action params not from defaults', () => {
333
+ expect(update_manager_1.UpdateManager.changeStateAndParams({
334
+ id: 'Q8',
335
+ config,
336
+ itemsStateAndParams: {},
337
+ stateAndParams: {
338
+ params: {
339
+ _ap_Country: 'Germany',
340
+ _ap_Brand: 'Pule',
341
+ _ap_Year: '2020',
342
+ },
343
+ state: {
344
+ tabId: 'K0',
345
+ },
346
+ },
347
+ })).toEqual({
348
+ Q8: {
349
+ state: {
350
+ tabId: 'K0',
351
+ },
352
+ params: {
353
+ _ap_Country: 'Germany',
354
+ _ap_Brand: 'Pule',
355
+ _ap_Year: '2020',
356
+ },
357
+ },
358
+ __meta__: { queue: [{ id: 'Q8', tabId: 'K0' }], version: 2 },
359
+ });
360
+ });
361
+ it('the item is correctly removed from the queue', () => {
362
+ expect(update_manager_1.UpdateManager.changeStateAndParams({
363
+ id: 'Q8',
364
+ config,
365
+ itemsStateAndParams: {
366
+ L5: {
367
+ params: {
368
+ d079: ['Russia'],
369
+ },
370
+ },
371
+ Q8: {
372
+ state: {
373
+ tabId: 'K0',
374
+ },
375
+ params: {
376
+ _ap_Country: 'Germany',
377
+ _ap_Year: '2020',
378
+ },
379
+ },
380
+ Unk: {
381
+ params: {
382
+ Country: 'Unknown',
383
+ },
384
+ },
385
+ __meta__: {
386
+ queue: [{ id: 'Q8', tabId: 'K0' }, { id: 'Unk' }, { id: 'L5' }],
387
+ version: 2,
388
+ },
389
+ },
390
+ stateAndParams: {},
391
+ options: { action: 'removeItem' },
392
+ })).toEqual({
393
+ L5: {
394
+ params: {
395
+ d079: ['Russia'],
396
+ },
397
+ },
398
+ __meta__: { queue: [{ id: 'L5' }], version: 2 },
399
+ });
400
+ expect(update_manager_1.UpdateManager.changeStateAndParams({
401
+ id: 'Q8',
402
+ config,
403
+ itemsStateAndParams: {
404
+ L5: {
405
+ params: {
406
+ d079: ['Russia'],
407
+ },
408
+ },
409
+ __meta__: {
410
+ queue: [{ id: 'L5' }],
411
+ version: 2,
412
+ },
413
+ },
414
+ stateAndParams: {},
415
+ options: { action: 'removeItem' },
416
+ })).toEqual({
417
+ L5: {
418
+ params: {
419
+ d079: ['Russia'],
420
+ },
421
+ },
422
+ __meta__: { queue: [{ id: 'L5' }], version: 2 },
423
+ });
424
+ });
425
+ it('the item is correctly setParams using additional options', () => {
426
+ expect(update_manager_1.UpdateManager.changeStateAndParams({
427
+ id: 'Q8',
428
+ config,
429
+ itemsStateAndParams: {
430
+ L5: {
431
+ params: {
432
+ d079: ['Russia'],
433
+ },
434
+ },
435
+ Q8: {
436
+ state: {
437
+ tabId: 'K0',
438
+ },
439
+ params: {
440
+ _ap_Country: 'Germany',
441
+ _ap_Year: '2020',
442
+ },
443
+ },
444
+ __meta__: {
445
+ queue: [{ id: 'Q8', tabId: 'K0' }, { id: 'L5' }],
446
+ version: 2,
447
+ },
448
+ },
449
+ stateAndParams: {
450
+ state: {
451
+ tabId: 'K0',
452
+ },
453
+ params: {
454
+ _ap_Country: 'Russia',
455
+ },
456
+ },
457
+ options: { action: 'setParams' },
458
+ })).toEqual({
459
+ L5: {
460
+ params: {
461
+ d079: ['Russia'],
462
+ },
463
+ },
464
+ Q8: {
465
+ state: {
466
+ tabId: 'K0',
467
+ },
468
+ params: {
469
+ _ap_Country: 'Russia',
470
+ },
471
+ },
472
+ __meta__: { queue: [{ id: 'L5' }, { id: 'Q8', tabId: 'K0' }], version: 2 },
473
+ });
474
+ });
475
+ });
476
+ });
@@ -1,4 +1,4 @@
1
- import { Config, ConfigItem, ItemsStateAndParams, ItemStateAndParams } from '../shared';
1
+ import { Config, ConfigItem, ItemsStateAndParams, ItemStateAndParams, ItemStateAndParamsChangeOptions } from '../shared';
2
2
  import { AddConfigItem, WidgetLayout, SetItemOptions } from '../typings';
3
3
  import { RegisterManagerPluginLayout } from './register-manager';
4
4
  interface RemoveItemArg {
@@ -11,6 +11,7 @@ interface ChangeStateAndParamsArg {
11
11
  config: Config;
12
12
  itemsStateAndParams: ItemsStateAndParams;
13
13
  stateAndParams: ItemStateAndParams;
14
+ options?: ItemStateAndParamsChangeOptions;
14
15
  }
15
16
  export declare class UpdateManager {
16
17
  static addItem({ item, namespace, layout, config, options, }: {
@@ -34,6 +35,6 @@ export declare class UpdateManager {
34
35
  layout: WidgetLayout[];
35
36
  config: Config;
36
37
  }): Config;
37
- static changeStateAndParams({ id: initiatorId, config, stateAndParams, itemsStateAndParams, }: ChangeStateAndParamsArg): ItemsStateAndParams;
38
+ static changeStateAndParams({ id: initiatorId, config, stateAndParams, itemsStateAndParams, options, }: ChangeStateAndParamsArg): ItemsStateAndParams;
38
39
  }
39
40
  export {};
@@ -69,9 +69,13 @@ function getAllowableChangedParams(item, stateAndParams, itemsStateAndParams, pa
69
69
  const paramsTypeName = (paramsSettings === null || paramsSettings === void 0 ? void 0 : paramsSettings.type) || 'params';
70
70
  const isActionParamsMode = paramsTypeName === 'actionParams';
71
71
  let allowedParams = {};
72
- const stateParamsConf = isActionParamsMode
73
- ? (0, shared_1.pickActionParamsFromParams)(stateAndParams.params, false)
74
- : stateAndParams.params;
72
+ if (isActionParamsMode) {
73
+ allowedParams = (0, shared_1.pickActionParamsFromParams)(stateAndParams.params, false);
74
+ return (paramsSettings === null || paramsSettings === void 0 ? void 0 : paramsSettings.returnPrefix)
75
+ ? (0, shared_1.transformParamsToActionParams)(allowedParams)
76
+ : allowedParams;
77
+ }
78
+ const stateParamsConf = stateAndParams.params;
75
79
  if ((0, shared_1.isItemWithTabs)(item)) {
76
80
  let tab;
77
81
  if ('state' in stateAndParams && ((_a = stateAndParams.state) === null || _a === void 0 ? void 0 : _a.tabId)) {
@@ -89,11 +93,6 @@ function getAllowableChangedParams(item, stateAndParams, itemsStateAndParams, pa
89
93
  if (Object.keys(allowedParams || {}).length !== Object.keys(stateParamsConf || {}).length) {
90
94
  console.warn('Параметры, которых нет в defaults, будут проигнорированы!');
91
95
  }
92
- if (isActionParamsMode) {
93
- return (paramsSettings === null || paramsSettings === void 0 ? void 0 : paramsSettings.returnPrefix)
94
- ? (0, shared_1.transformParamsToActionParams)(allowedParams)
95
- : allowedParams;
96
- }
97
96
  return allowedParams;
98
97
  }
99
98
  function changeStateAndParamsVersion1({ id: initiatorId, config, stateAndParams, itemsStateAndParams, }) {
@@ -233,7 +232,7 @@ class UpdateManager {
233
232
  },
234
233
  });
235
234
  }
236
- static changeStateAndParams({ id: initiatorId, config, stateAndParams, itemsStateAndParams, }) {
235
+ static changeStateAndParams({ id: initiatorId, config, stateAndParams, itemsStateAndParams, options, }) {
237
236
  var _a, _b;
238
237
  if ((0, shared_1.getCurrentVersion)(itemsStateAndParams) === 1) {
239
238
  return changeStateAndParamsVersion1({
@@ -243,6 +242,7 @@ class UpdateManager {
243
242
  itemsStateAndParams,
244
243
  });
245
244
  }
245
+ const action = options === null || options === void 0 ? void 0 : options.action;
246
246
  const hasState = 'state' in stateAndParams;
247
247
  const { items } = config;
248
248
  const itemsIds = items.map(({ id: itemId }) => itemId);
@@ -252,6 +252,20 @@ class UpdateManager {
252
252
  const newTabId = (_a = stateAndParams.state) === null || _a === void 0 ? void 0 : _a.tabId;
253
253
  const isTabSwitched = (0, shared_1.isItemWithTabs)(initiatorItem) && Boolean(newTabId);
254
254
  const currentMeta = (0, shared_1.getItemsStateAndParamsMeta)(itemsStateAndParams);
255
+ if (action === 'removeItem') {
256
+ return (0, immutability_helper_1.default)(itemsStateAndParams, {
257
+ $unset: [...unusedIds, initiatorId],
258
+ [shared_1.META_KEY]: {
259
+ $set: currentMeta
260
+ ? (0, shared_1.deleteFromQueue)({
261
+ id: initiatorId,
262
+ itemsStateAndParams,
263
+ config,
264
+ })
265
+ : (0, shared_1.getInitialItemsStateAndParamsMeta)(),
266
+ },
267
+ });
268
+ }
255
269
  if ('params' in stateAndParams) {
256
270
  const allowableParams = getAllowableChangedParams(initiatorItem, stateAndParams, itemsStateAndParams);
257
271
  const allowableActionParams = getAllowableChangedParams(initiatorItem, stateAndParams, itemsStateAndParams, { type: 'actionParams', returnPrefix: true });
@@ -262,7 +276,7 @@ class UpdateManager {
262
276
  let commandUpdateParams = ((_b = itemsStateAndParams[initiatorId]) === null || _b === void 0 ? void 0 : _b.params)
263
277
  ? '$merge'
264
278
  : '$set';
265
- if (isTabSwitched) {
279
+ if (isTabSwitched || action === 'setParams') {
266
280
  commandUpdateParams = '$set';
267
281
  }
268
282
  const obj = {
@@ -1,7 +1,7 @@
1
1
  declare const _default: {
2
2
  new (props: any): {
3
3
  shouldComponentUpdate(nextProps: any): boolean;
4
- _onStateAndParamsChange: (stateAndParams: any) => void;
4
+ _onStateAndParamsChange: (stateAndParams: any, options: any) => void;
5
5
  render(): JSX.Element;
6
6
  context: unknown;
7
7
  setState<K extends string | number | symbol>(state: any, callback?: (() => void) | undefined): void;
@@ -25,7 +25,7 @@ declare const _default: {
25
25
  };
26
26
  new (props: any, context: any): {
27
27
  shouldComponentUpdate(nextProps: any): boolean;
28
- _onStateAndParamsChange: (stateAndParams: any) => void;
28
+ _onStateAndParamsChange: (stateAndParams: any, options: any) => void;
29
29
  render(): JSX.Element;
30
30
  context: unknown;
31
31
  setState<K extends string | number | symbol>(state: any, callback?: (() => void) | undefined): void;
@@ -1,7 +1,7 @@
1
1
  export function prepareItem(Component: any): {
2
2
  new (props: any): {
3
3
  shouldComponentUpdate(nextProps: any): boolean;
4
- _onStateAndParamsChange: (stateAndParams: any) => void;
4
+ _onStateAndParamsChange: (stateAndParams: any, options: any) => void;
5
5
  render(): JSX.Element;
6
6
  context: unknown;
7
7
  setState<K extends string | number | symbol>(state: any, callback?: (() => void) | undefined): void;
@@ -25,7 +25,7 @@ export function prepareItem(Component: any): {
25
25
  };
26
26
  new (props: any, context: any): {
27
27
  shouldComponentUpdate(nextProps: any): boolean;
28
- _onStateAndParamsChange: (stateAndParams: any) => void;
28
+ _onStateAndParamsChange: (stateAndParams: any, options: any) => void;
29
29
  render(): JSX.Element;
30
30
  context: unknown;
31
31
  setState<K extends string | number | symbol>(state: any, callback?: (() => void) | undefined): void;
@@ -6,8 +6,8 @@ export function prepareItem(Component) {
6
6
  return _a = class PrepareItem extends React.Component {
7
7
  constructor() {
8
8
  super(...arguments);
9
- this._onStateAndParamsChange = (stateAndParams) => {
10
- this.context.onItemStateAndParamsChange(this.props.id, stateAndParams);
9
+ this._onStateAndParamsChange = (stateAndParams, options) => {
10
+ this.context.onItemStateAndParamsChange(this.props.id, stateAndParams, options);
11
11
  };
12
12
  }
13
13
  shouldComponentUpdate(nextProps) {
@@ -47,13 +47,14 @@ function useMemoStateContext(props) {
47
47
  itemsStateAndParams: props.itemsStateAndParams,
48
48
  }));
49
49
  }, [props.config, props.itemsStateAndParams, onChange]);
50
- const onItemStateAndParamsChange = React.useCallback((id, stateAndParams) => {
50
+ const onItemStateAndParamsChange = React.useCallback((id, stateAndParams, options) => {
51
51
  onChange({
52
52
  itemsStateAndParams: UpdateManager.changeStateAndParams({
53
53
  id,
54
54
  config: props.config,
55
55
  stateAndParams,
56
56
  itemsStateAndParams: props.itemsStateAndParams,
57
+ options,
57
58
  }),
58
59
  });
59
60
  }, [props.config, props.itemsStateAndParams, onChange]);
@@ -69,13 +69,4 @@ export declare function hasActionParam(conf?: StringParams): boolean;
69
69
  * @param stateAndParams
70
70
  */
71
71
  export declare function hasActionParams(stateAndParams: ItemStateAndParams): boolean;
72
- /**
73
- * Collect array of actionParams keys with prefix (_ap_) that must be cleared from widget defaults
74
- * @param defaultWidgetParams
75
- * @param queueWidgetParams
76
- */
77
- export declare function getDefaultsActionParamsToClear({ defaultWidgetParams, queueWidgetParams, }: {
78
- defaultWidgetParams: StringParams;
79
- queueWidgetParams: StringParams;
80
- }): string[];
81
72
  export {};
@@ -3,7 +3,6 @@ import get from 'lodash/get';
3
3
  import invert from 'lodash/invert';
4
4
  import isEmpty from 'lodash/isEmpty';
5
5
  import pick from 'lodash/pick';
6
- import intersection from 'lodash/intersection';
7
6
  import { META_KEY, CURRENT_VERSION, ACTION_PARAM_PREFIX } from '../constants';
8
7
  function getNormalizedPlugins(plugins) {
9
8
  return keyBy(plugins, 'type');
@@ -240,22 +239,3 @@ export function hasActionParams(stateAndParams) {
240
239
  }
241
240
  return hasActionParam(stateAndParams.params);
242
241
  }
243
- /**
244
- * Collect array of actionParams keys with prefix (_ap_) that must be cleared from widget defaults
245
- * @param defaultWidgetParams
246
- * @param queueWidgetParams
247
- */
248
- export function getDefaultsActionParamsToClear({ defaultWidgetParams, queueWidgetParams, }) {
249
- const widgetDefaultsWithActionParams = hasActionParam(defaultWidgetParams)
250
- ? pickActionParamsFromParams(defaultWidgetParams)
251
- : null;
252
- if (!widgetDefaultsWithActionParams) {
253
- return [];
254
- }
255
- // clear default actionParams if some param with the same name without prefix affected on current widget
256
- // ex.: queueWidgetParams contain {Year: 1970} and default actionParams contain {_ap_Year: 2000}
257
- const actionParamKeyToClear = intersection(Object.keys(queueWidgetParams), Object.keys(widgetDefaultsWithActionParams));
258
- return actionParamKeyToClear.length
259
- ? actionParamKeyToClear.map((key) => `${ACTION_PARAM_PREFIX}${key}`)
260
- : [];
261
- }