@gravity-ui/dashkit 6.7.2 → 6.9.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/README.md +57 -0
- package/build/cjs/components/ActionPanel/ActionPanel.css +48 -6
- package/build/cjs/components/ActionPanel/ActionPanel.d.ts +3 -1
- package/build/cjs/components/ActionPanel/ActionPanel.js +12 -1
- package/build/cjs/components/GridItem/GridItem.css +22 -7
- package/build/cjs/shared/modules/__tests__/helpers.test.js +212 -2
- package/build/cjs/shared/modules/helpers.d.ts +14 -5
- package/build/cjs/shared/modules/helpers.js +89 -19
- package/build/cjs/shared/modules/state-and-params.d.ts +2 -2
- package/build/cjs/shared/modules/state-and-params.js +73 -42
- package/build/cjs/shared/modules/uniq-id.js +3 -0
- package/build/cjs/shared/types/config.d.ts +13 -0
- package/build/cjs/shared/types/state-and-params.d.ts +4 -2
- package/build/cjs/typings/plugin.d.ts +4 -4
- package/build/cjs/utils/__tests__/update-manager.test.js +193 -5
- package/build/cjs/utils/update-manager.d.ts +2 -2
- package/build/cjs/utils/update-manager.js +71 -4
- package/build/esm/components/ActionPanel/ActionPanel.css +48 -6
- package/build/esm/components/ActionPanel/ActionPanel.d.ts +3 -1
- package/build/esm/components/ActionPanel/ActionPanel.js +12 -1
- package/build/esm/components/GridItem/GridItem.css +22 -7
- package/build/esm/shared/modules/__tests__/helpers.test.js +213 -3
- package/build/esm/shared/modules/helpers.d.ts +14 -5
- package/build/esm/shared/modules/helpers.js +87 -19
- package/build/esm/shared/modules/state-and-params.d.ts +2 -2
- package/build/esm/shared/modules/state-and-params.js +74 -43
- package/build/esm/shared/modules/uniq-id.js +4 -1
- package/build/esm/shared/types/config.d.ts +13 -0
- package/build/esm/shared/types/state-and-params.d.ts +4 -2
- package/build/esm/typings/plugin.d.ts +4 -4
- package/build/esm/utils/__tests__/update-manager.test.js +193 -5
- package/build/esm/utils/update-manager.d.ts +2 -2
- package/build/esm/utils/update-manager.js +72 -5
- package/package.json +3 -2
package/README.md
CHANGED
|
@@ -325,6 +325,63 @@ type MenuItem = {
|
|
|
325
325
|
DashKit.setSettings({menu: [] as Array<MenuItem>});
|
|
326
326
|
```
|
|
327
327
|
|
|
328
|
+
### CSS API
|
|
329
|
+
|
|
330
|
+
| Name | Description |
|
|
331
|
+
|:-----------------------------------------------|:----------------------|
|
|
332
|
+
| Action panel variables | |
|
|
333
|
+
| `--dashkit-action-panel-color` | Background color |
|
|
334
|
+
| `--dashkit-action-panel-border-color` | Border color |
|
|
335
|
+
| `--dashkit-action-panel-border-radius` | Border radius |
|
|
336
|
+
| Action panel item variables | |
|
|
337
|
+
| `--dashkit-action-panel-item-color` | Backgroud color |
|
|
338
|
+
| `--dashkit-action-panel-item-text-color` | Text color |
|
|
339
|
+
| `--dashkit-action-panel-item-color-hover` | Hover backgroud color |
|
|
340
|
+
| `--dashkit-action-panel-item-text-color-hover` | Hover text color |
|
|
341
|
+
| Overlay variables | |
|
|
342
|
+
| `--dashkit-overlay-border-color` | Border color |
|
|
343
|
+
| `--dashkit-overlay-color` | Background color |
|
|
344
|
+
| `--dashkit-overlay-opacity` | Opacity |
|
|
345
|
+
| Grid item variables | |
|
|
346
|
+
| `--dashkit-grid-item-edit-opacity` | Opacity |
|
|
347
|
+
| `--dashkit-grid-item-border-radius` | Border radius |
|
|
348
|
+
| Placeholder variables | |
|
|
349
|
+
| `--dashkit-placeholder-color` | Background color |
|
|
350
|
+
| `--dashkit-placeholder-opacity` | Opacity |
|
|
351
|
+
|
|
352
|
+
#### Usage example
|
|
353
|
+
|
|
354
|
+
|
|
355
|
+
```css
|
|
356
|
+
.custom-theme-wrapper {
|
|
357
|
+
--dashkit-grid-item-edit-opacit: 1;
|
|
358
|
+
--dashkit-overlay-color: var(--g-color-base-float);
|
|
359
|
+
--dashkit-overlay-border-color: var(--g-color-base-float);
|
|
360
|
+
--dashkit-overlay-opacity: 0.5;
|
|
361
|
+
|
|
362
|
+
--dashkit-action-panel-border-color: var(--g-color-line-info);
|
|
363
|
+
--dashkit-action-panel-color: var(--g-color-base-float-accent);
|
|
364
|
+
--dashkit-action-panel-border-radius: var(--g-border-radius-xxl);
|
|
365
|
+
}
|
|
366
|
+
```
|
|
367
|
+
|
|
368
|
+
```tsx
|
|
369
|
+
// ....
|
|
370
|
+
|
|
371
|
+
const CustomThemeWrapper = (props: {
|
|
372
|
+
dashkitProps: DashkitProps;
|
|
373
|
+
actionPanelProps: ActionPanelProps;
|
|
374
|
+
}) => {
|
|
375
|
+
return (
|
|
376
|
+
<div className="custom-theme-wrapper">
|
|
377
|
+
<Dashkit {...props.dashkitProps} />
|
|
378
|
+
<ActionPanel {...props.actionPanelProps} />
|
|
379
|
+
</div>
|
|
380
|
+
);
|
|
381
|
+
};
|
|
382
|
+
```
|
|
383
|
+
|
|
384
|
+
|
|
328
385
|
## Development
|
|
329
386
|
|
|
330
387
|
### Build & watch
|
|
@@ -1,33 +1,75 @@
|
|
|
1
1
|
.dashkit-action-panel {
|
|
2
|
-
|
|
3
|
-
|
|
2
|
+
--_--dashkit-action-panel-color: var(--dashkit-action-panel-color, var(--g-color-base-float));
|
|
3
|
+
--_--dashkit-action-panel-border-color: var(
|
|
4
|
+
--dashkit-action-panel-border-color,
|
|
5
|
+
var(--g-color-base-brand)
|
|
6
|
+
);
|
|
7
|
+
--_--dashkit-action-panel-border-radius: var(
|
|
8
|
+
--dashkit-action-panel-border-radius,
|
|
9
|
+
var(--g-border-radius-xl)
|
|
10
|
+
);
|
|
11
|
+
background-color: var(--_--dashkit-action-panel-color);
|
|
4
12
|
position: fixed;
|
|
5
13
|
bottom: 20px;
|
|
6
14
|
display: flex;
|
|
7
|
-
border-radius:
|
|
15
|
+
border-radius: var(--_--dashkit-action-panel-border-radius);
|
|
16
|
+
border: 2px solid var(--_--dashkit-action-panel-border-color);
|
|
8
17
|
padding: 8px;
|
|
9
18
|
gap: 0;
|
|
10
19
|
left: 50%;
|
|
11
|
-
transform: translateX(-50%);
|
|
20
|
+
transform: translateX(-50%) translateY(0);
|
|
12
21
|
z-index: 1;
|
|
13
22
|
}
|
|
23
|
+
.dashkit-action-panel-enter {
|
|
24
|
+
transform: translateX(-50%) translateY(calc(100% + 20px));
|
|
25
|
+
will-change: transform;
|
|
26
|
+
}
|
|
27
|
+
.dashkit-action-panel-enter-active {
|
|
28
|
+
transform: translateX(-50%) translateY(0);
|
|
29
|
+
transition: transform 300ms ease;
|
|
30
|
+
}
|
|
31
|
+
.dashkit-action-panel-exit {
|
|
32
|
+
transform: translateX(-50%) translateY(0);
|
|
33
|
+
will-change: transform;
|
|
34
|
+
}
|
|
35
|
+
.dashkit-action-panel-exit-active {
|
|
36
|
+
transform: translateX(-50%) translateY(calc(100% + 20px));
|
|
37
|
+
transition: transform 300ms ease;
|
|
38
|
+
}
|
|
14
39
|
.dashkit-action-panel__item {
|
|
40
|
+
--_--dashkit-action-panel-item-color: var(--dashkit-action-panel-item-color, transparent);
|
|
41
|
+
--_--dashkit-action-panel-item-text-color: var(
|
|
42
|
+
--dashkit-action-panel-item-text-color,
|
|
43
|
+
var(--g-color-text-primary)
|
|
44
|
+
);
|
|
45
|
+
--_--dashkit-action-panel-item-color-hover: var(
|
|
46
|
+
--dashkit-action-panel-item-color-hover,
|
|
47
|
+
var(--g-color-base-simple-hover)
|
|
48
|
+
);
|
|
49
|
+
--_--dashkit-action-panel-item-text-color-hover: var(
|
|
50
|
+
--dashkit-action-panel-item-text-color-hover,
|
|
51
|
+
var(--g-color-text-primary)
|
|
52
|
+
);
|
|
15
53
|
height: 68px;
|
|
16
54
|
width: 98px;
|
|
17
55
|
display: flex;
|
|
18
56
|
flex-direction: column;
|
|
19
57
|
justify-content: center;
|
|
20
58
|
align-items: center;
|
|
21
|
-
transition:
|
|
59
|
+
transition: 300ms color ease-in-out, 300ms background-color ease-in-out;
|
|
22
60
|
border-radius: 6px;
|
|
23
61
|
padding: 0 12px;
|
|
24
62
|
box-sizing: border-box;
|
|
25
63
|
white-space: nowrap;
|
|
26
64
|
overflow: hidden;
|
|
65
|
+
background-color: var(--_--dashkit-action-panel-item-color);
|
|
66
|
+
color: var(--_--dashkit-action-panel-item-text-color);
|
|
67
|
+
will-change: color, backgroung-color;
|
|
27
68
|
}
|
|
28
69
|
.dashkit-action-panel__item:hover {
|
|
29
70
|
cursor: pointer;
|
|
30
|
-
background-color: var(--
|
|
71
|
+
background-color: var(--_--dashkit-action-panel-item-color-hover);
|
|
72
|
+
color: var(--_--dashkit-action-panel-item-text-color-hover);
|
|
31
73
|
}
|
|
32
74
|
.dashkit-action-panel__icon {
|
|
33
75
|
margin-bottom: 4px;
|
|
@@ -10,5 +10,7 @@ export type ActionPanelItem = {
|
|
|
10
10
|
export type ActionPanelProps = {
|
|
11
11
|
items: ActionPanelItem[];
|
|
12
12
|
className?: string;
|
|
13
|
+
disable?: boolean;
|
|
14
|
+
toggleAnimation?: boolean;
|
|
13
15
|
};
|
|
14
|
-
export declare const ActionPanel: (props: ActionPanelProps) => JSX.Element;
|
|
16
|
+
export declare const ActionPanel: (props: ActionPanelProps) => JSX.Element | null;
|
|
@@ -3,13 +3,24 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
3
3
|
exports.ActionPanel = void 0;
|
|
4
4
|
const tslib_1 = require("tslib");
|
|
5
5
|
const react_1 = tslib_1.__importDefault(require("react"));
|
|
6
|
+
const react_transition_group_1 = require("react-transition-group");
|
|
6
7
|
const cn_1 = require("../../utils/cn");
|
|
7
8
|
const b = (0, cn_1.cn)('dashkit-action-panel');
|
|
8
9
|
const ActionPanel = (props) => {
|
|
9
|
-
|
|
10
|
+
var _a, _b;
|
|
11
|
+
const isDisabled = (_a = props.disable) !== null && _a !== void 0 ? _a : false;
|
|
12
|
+
const isAnimated = (_b = props.toggleAnimation) !== null && _b !== void 0 ? _b : false;
|
|
13
|
+
const nodeRef = react_1.default.useRef(null);
|
|
14
|
+
const content = (react_1.default.createElement("div", { ref: nodeRef, className: b(null, props.className) }, props.items.map((item) => {
|
|
10
15
|
return (react_1.default.createElement("div", { role: "button", className: b('item', item.className), key: `dk-action-panel-${item.id}`, onClick: item.onClick, "data-qa": item.qa },
|
|
11
16
|
react_1.default.createElement("div", { className: b('icon') }, item.icon),
|
|
12
17
|
react_1.default.createElement("div", { className: b('title'), title: item.title }, item.title)));
|
|
13
18
|
})));
|
|
19
|
+
if (isAnimated) {
|
|
20
|
+
return (react_1.default.createElement(react_transition_group_1.CSSTransition, { in: !isDisabled, nodeRef: nodeRef, classNames: b(null), timeout: 300, unmountOnExit: true }, content));
|
|
21
|
+
}
|
|
22
|
+
else {
|
|
23
|
+
return isDisabled ? null : content;
|
|
24
|
+
}
|
|
14
25
|
};
|
|
15
26
|
exports.ActionPanel = ActionPanel;
|
|
@@ -2,25 +2,38 @@
|
|
|
2
2
|
position: relative;
|
|
3
3
|
}
|
|
4
4
|
.dashkit-grid-item__overlay {
|
|
5
|
+
--_-dashkit-overlay-color: var(--dashkit-overlay-color, var(--g-color-base-generic));
|
|
6
|
+
--_-dashkit-overlay-border-color: var(--dashkit-overlay-border-color, rgba(0, 0, 0, 0.1));
|
|
7
|
+
--_-dashkit-overlay-opacity: var(--dashkit-overlay-opacity, 1);
|
|
8
|
+
--_-dashkit-overlay-border-radius: var(
|
|
9
|
+
--dashkit-grid-item-border-radius,
|
|
10
|
+
3px
|
|
11
|
+
);
|
|
5
12
|
position: absolute;
|
|
6
13
|
top: 0;
|
|
7
14
|
bottom: 0;
|
|
8
15
|
left: 0;
|
|
9
16
|
right: 0;
|
|
10
|
-
border-radius:
|
|
11
|
-
background-color: var(--
|
|
12
|
-
border: solid 1px
|
|
17
|
+
border-radius: var(--_-dashkit-overlay-border-radius);
|
|
18
|
+
background-color: var(--_-dashkit-overlay-color);
|
|
19
|
+
border: solid 1px var(--_-dashkit-overlay-border-color);
|
|
20
|
+
opacity: var(--_-dashkit-overlay-opacity);
|
|
13
21
|
}
|
|
14
22
|
.dashkit-grid-item__item {
|
|
23
|
+
--_-dashkit-grid-item-border-radius: var(
|
|
24
|
+
--dashkit-grid-item-border-radius,
|
|
25
|
+
3px
|
|
26
|
+
);
|
|
27
|
+
--_-dashkit-grid-item-edit-opacity: var(--dashkit-grid-item-edit-opacity, 0.5);
|
|
15
28
|
position: absolute;
|
|
16
29
|
top: 0;
|
|
17
30
|
bottom: 0;
|
|
18
31
|
left: 0;
|
|
19
32
|
right: 0;
|
|
20
|
-
border-radius:
|
|
33
|
+
border-radius: var(--_-dashkit-grid-item-border-radius);
|
|
21
34
|
}
|
|
22
35
|
.dashkit-grid-item__item_editMode {
|
|
23
|
-
opacity:
|
|
36
|
+
opacity: var(--_-dashkit-grid-item-edit-opacity);
|
|
24
37
|
border-color: transparent;
|
|
25
38
|
pointer-events: none;
|
|
26
39
|
}
|
|
@@ -50,8 +63,10 @@
|
|
|
50
63
|
}
|
|
51
64
|
|
|
52
65
|
.react-grid-item.react-grid-placeholder {
|
|
53
|
-
|
|
54
|
-
opacity: 0.2;
|
|
66
|
+
--_-dashkit-placeholder-color: var(--dashkit-placeholder-color, #fc0);
|
|
67
|
+
--_-dashkit-placeholder-opacity: var(--dashkit-placeholder-opacity, 0.2);
|
|
68
|
+
background: var(--_-dashkit-placeholder-color);
|
|
69
|
+
opacity: var(--_-dashkit-placeholder-opacity);
|
|
55
70
|
transition-duration: 100ms;
|
|
56
71
|
z-index: 2;
|
|
57
72
|
user-select: none;
|
|
@@ -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: {
|
|
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: [
|
|
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 {
|
|
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:
|
|
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
|