@gravity-ui/dashkit 8.20.1 → 8.21.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/build/cjs/components/DashKit/DashKit.d.ts +5 -0
- package/build/cjs/components/DashKit/DashKit.js +12 -1
- package/build/cjs/components/GridLayout/GridLayout.d.ts +1 -1
- package/build/cjs/components/GridLayout/GridLayout.js +10 -3
- package/build/cjs/i18n/index.d.ts +5 -1
- package/build/esm/components/DashKit/DashKit.d.ts +5 -0
- package/build/esm/components/DashKit/DashKit.js +12 -1
- package/build/esm/components/GridLayout/GridLayout.d.ts +1 -1
- package/build/esm/components/GridLayout/GridLayout.js +10 -3
- package/build/esm/i18n/index.d.ts +5 -1
- package/package.json +4 -4
|
@@ -43,6 +43,7 @@ export interface DashKitProps extends DashKitGeneralProps, Partial<DashKitDefaul
|
|
|
43
43
|
type DashKitInnerProps = DashKitGeneralProps & DashKitDefaultProps;
|
|
44
44
|
export declare class DashKit extends React.PureComponent<DashKitInnerProps> {
|
|
45
45
|
static defaultProps: DashKitDefaultProps;
|
|
46
|
+
static contextType: React.Context<any>;
|
|
46
47
|
static registerPlugins(...plugins: Plugin[]): void;
|
|
47
48
|
static reloadPlugins(...plugins: Plugin[]): void;
|
|
48
49
|
static setSettings(settings: Settings): void;
|
|
@@ -69,5 +70,9 @@ export declare class DashKit extends React.PureComponent<DashKitInnerProps> {
|
|
|
69
70
|
metaRef: React.RefObject<GridLayout>;
|
|
70
71
|
render(): JSX.Element;
|
|
71
72
|
getItemsMeta(): any;
|
|
73
|
+
reloadItems(options?: {
|
|
74
|
+
targetIds?: string[];
|
|
75
|
+
force?: boolean;
|
|
76
|
+
}): void;
|
|
72
77
|
}
|
|
73
78
|
export {};
|
|
@@ -6,7 +6,9 @@ const react_1 = tslib_1.__importDefault(require("react"));
|
|
|
6
6
|
const noop_1 = tslib_1.__importDefault(require("lodash/noop"));
|
|
7
7
|
const pick_1 = tslib_1.__importDefault(require("lodash/pick"));
|
|
8
8
|
const constants_1 = require("../../constants");
|
|
9
|
+
const DashKitContext_1 = require("../../context/DashKitContext");
|
|
9
10
|
const utils_1 = require("../../utils");
|
|
11
|
+
const DashKitDnDWrapper_1 = require("../DashKitDnDWrapper/DashKitDnDWrapper");
|
|
10
12
|
const DashKitView_1 = tslib_1.__importDefault(require("../DashKitView/DashKitView"));
|
|
11
13
|
const registerManager = new utils_1.RegisterManager();
|
|
12
14
|
const getReflowProps = (props) => Object.assign({ compactType: 'vertical', cols: 36 }, (0, pick_1.default)(props, 'cols', 'maxRows', 'compactType'));
|
|
@@ -79,12 +81,20 @@ class DashKit extends react_1.default.PureComponent {
|
|
|
79
81
|
});
|
|
80
82
|
}
|
|
81
83
|
render() {
|
|
82
|
-
|
|
84
|
+
const content = (react_1.default.createElement(DashKitView_1.default, Object.assign({ registerManager: registerManager, ref: this.metaRef }, this.props)));
|
|
85
|
+
if (!this.context && this.props.groups) {
|
|
86
|
+
return react_1.default.createElement(DashKitDnDWrapper_1.DashKitDnDWrapper, null, content);
|
|
87
|
+
}
|
|
88
|
+
return content;
|
|
83
89
|
}
|
|
84
90
|
getItemsMeta() {
|
|
85
91
|
var _a;
|
|
86
92
|
return (_a = this.metaRef.current) === null || _a === void 0 ? void 0 : _a.getItemsMeta();
|
|
87
93
|
}
|
|
94
|
+
reloadItems(options) {
|
|
95
|
+
var _a;
|
|
96
|
+
(_a = this.metaRef.current) === null || _a === void 0 ? void 0 : _a.reloadItems(options);
|
|
97
|
+
}
|
|
88
98
|
}
|
|
89
99
|
exports.DashKit = DashKit;
|
|
90
100
|
DashKit.defaultProps = {
|
|
@@ -102,3 +112,4 @@ DashKit.defaultProps = {
|
|
|
102
112
|
noOverlay: false,
|
|
103
113
|
focusable: false,
|
|
104
114
|
};
|
|
115
|
+
DashKit.contextType = DashKitContext_1.DashKitDnDContext;
|
|
@@ -38,7 +38,7 @@ export default class GridLayout extends React.PureComponent<any, any, any> {
|
|
|
38
38
|
};
|
|
39
39
|
getMemoForwardRefCallback: (refIndex: any) => any;
|
|
40
40
|
mergeGroupsLayout(group: any, newLayout: any, temporaryItem: any): any;
|
|
41
|
-
reloadItems(): void;
|
|
41
|
+
reloadItems(options: any): void;
|
|
42
42
|
prepareDefaultArguments(group: any, layout: any, oldItem: any, newItem: any, placeholder: any, e: any, element: any): {
|
|
43
43
|
group: any;
|
|
44
44
|
layout: any;
|
|
@@ -252,19 +252,26 @@ class GridLayout extends react_1.default.PureComponent {
|
|
|
252
252
|
return currentItem;
|
|
253
253
|
});
|
|
254
254
|
}
|
|
255
|
-
reloadItems() {
|
|
255
|
+
reloadItems(options) {
|
|
256
|
+
const { targetIds, force } = options || {};
|
|
256
257
|
const { editMode, settings: { autoupdateInterval, silentLoading } = {}, reloadItems, } = this.context;
|
|
257
258
|
const { isPageHidden } = this.state;
|
|
258
259
|
const autoupdateIntervalMs = Number(autoupdateInterval) * 1000;
|
|
260
|
+
const targetPlugins = targetIds
|
|
261
|
+
? this.pluginsRefs.filter((plugin) => targetIds.includes(plugin.props.id))
|
|
262
|
+
: this.pluginsRefs;
|
|
259
263
|
if (autoupdateIntervalMs) {
|
|
260
264
|
const timeSinceLastReload = new Date().getTime() - (this._lastReloadAt || 0);
|
|
261
265
|
const reloadIntervalRemains = autoupdateIntervalMs - timeSinceLastReload;
|
|
262
|
-
if (!isPageHidden && !editMode && reloadIntervalRemains <= 0) {
|
|
266
|
+
if (force || (!isPageHidden && !editMode && reloadIntervalRemains <= 0)) {
|
|
263
267
|
this._lastReloadAt = new Date().getTime();
|
|
264
|
-
reloadItems(
|
|
268
|
+
reloadItems(targetPlugins, { silentLoading, noVeil: true });
|
|
265
269
|
}
|
|
266
270
|
this._timeout = setTimeout(() => this.reloadItems(), reloadIntervalRemains <= 0 ? autoupdateIntervalMs : reloadIntervalRemains);
|
|
267
271
|
}
|
|
272
|
+
else if (force || (!isPageHidden && !editMode)) {
|
|
273
|
+
reloadItems(targetPlugins, { silentLoading, noVeil: true });
|
|
274
|
+
}
|
|
268
275
|
}
|
|
269
276
|
prepareDefaultArguments(group, layout, oldItem, newItem, placeholder, e, element) {
|
|
270
277
|
return {
|
|
@@ -1 +1,5 @@
|
|
|
1
|
-
export declare const i18n: (key: "button_retry" | "label_render-markdown-error" | "label_settings" | "label_copy" | "label_delete" | "label_error", params?: import("@gravity-ui/i18n").Params | undefined) => string
|
|
1
|
+
export declare const i18n: ((key: "button_retry" | "label_render-markdown-error" | "label_settings" | "label_copy" | "label_delete" | "label_error", params?: import("@gravity-ui/i18n").Params | undefined) => string) & {
|
|
2
|
+
keysetData: {
|
|
3
|
+
dashkit: Record<"button_retry" | "label_render-markdown-error" | "label_settings" | "label_copy" | "label_delete" | "label_error", import("@gravity-ui/i18n").KeyData>;
|
|
4
|
+
};
|
|
5
|
+
};
|
|
@@ -43,6 +43,7 @@ export interface DashKitProps extends DashKitGeneralProps, Partial<DashKitDefaul
|
|
|
43
43
|
type DashKitInnerProps = DashKitGeneralProps & DashKitDefaultProps;
|
|
44
44
|
export declare class DashKit extends React.PureComponent<DashKitInnerProps> {
|
|
45
45
|
static defaultProps: DashKitDefaultProps;
|
|
46
|
+
static contextType: React.Context<any>;
|
|
46
47
|
static registerPlugins(...plugins: Plugin[]): void;
|
|
47
48
|
static reloadPlugins(...plugins: Plugin[]): void;
|
|
48
49
|
static setSettings(settings: Settings): void;
|
|
@@ -69,5 +70,9 @@ export declare class DashKit extends React.PureComponent<DashKitInnerProps> {
|
|
|
69
70
|
metaRef: React.RefObject<GridLayout>;
|
|
70
71
|
render(): JSX.Element;
|
|
71
72
|
getItemsMeta(): any;
|
|
73
|
+
reloadItems(options?: {
|
|
74
|
+
targetIds?: string[];
|
|
75
|
+
force?: boolean;
|
|
76
|
+
}): void;
|
|
72
77
|
}
|
|
73
78
|
export {};
|
|
@@ -2,7 +2,9 @@ import React from 'react';
|
|
|
2
2
|
import noop from 'lodash/noop';
|
|
3
3
|
import pick from 'lodash/pick';
|
|
4
4
|
import { DEFAULT_GROUP, DEFAULT_NAMESPACE } from '../../constants';
|
|
5
|
+
import { DashKitDnDContext } from '../../context/DashKitContext';
|
|
5
6
|
import { RegisterManager, UpdateManager, reflowLayout } from '../../utils';
|
|
7
|
+
import { DashKitDnDWrapper } from '../DashKitDnDWrapper/DashKitDnDWrapper';
|
|
6
8
|
import DashKitView from '../DashKitView/DashKitView';
|
|
7
9
|
const registerManager = new RegisterManager();
|
|
8
10
|
const getReflowProps = (props) => Object.assign({ compactType: 'vertical', cols: 36 }, pick(props, 'cols', 'maxRows', 'compactType'));
|
|
@@ -75,12 +77,20 @@ export class DashKit extends React.PureComponent {
|
|
|
75
77
|
});
|
|
76
78
|
}
|
|
77
79
|
render() {
|
|
78
|
-
|
|
80
|
+
const content = (React.createElement(DashKitView, Object.assign({ registerManager: registerManager, ref: this.metaRef }, this.props)));
|
|
81
|
+
if (!this.context && this.props.groups) {
|
|
82
|
+
return React.createElement(DashKitDnDWrapper, null, content);
|
|
83
|
+
}
|
|
84
|
+
return content;
|
|
79
85
|
}
|
|
80
86
|
getItemsMeta() {
|
|
81
87
|
var _a;
|
|
82
88
|
return (_a = this.metaRef.current) === null || _a === void 0 ? void 0 : _a.getItemsMeta();
|
|
83
89
|
}
|
|
90
|
+
reloadItems(options) {
|
|
91
|
+
var _a;
|
|
92
|
+
(_a = this.metaRef.current) === null || _a === void 0 ? void 0 : _a.reloadItems(options);
|
|
93
|
+
}
|
|
84
94
|
}
|
|
85
95
|
DashKit.defaultProps = {
|
|
86
96
|
onItemEdit: noop,
|
|
@@ -97,3 +107,4 @@ DashKit.defaultProps = {
|
|
|
97
107
|
noOverlay: false,
|
|
98
108
|
focusable: false,
|
|
99
109
|
};
|
|
110
|
+
DashKit.contextType = DashKitDnDContext;
|
|
@@ -38,7 +38,7 @@ export default class GridLayout extends React.PureComponent<any, any, any> {
|
|
|
38
38
|
};
|
|
39
39
|
getMemoForwardRefCallback: (refIndex: any) => any;
|
|
40
40
|
mergeGroupsLayout(group: any, newLayout: any, temporaryItem: any): any;
|
|
41
|
-
reloadItems(): void;
|
|
41
|
+
reloadItems(options: any): void;
|
|
42
42
|
prepareDefaultArguments(group: any, layout: any, oldItem: any, newItem: any, placeholder: any, e: any, element: any): {
|
|
43
43
|
group: any;
|
|
44
44
|
layout: any;
|
|
@@ -249,19 +249,26 @@ class GridLayout extends React.PureComponent {
|
|
|
249
249
|
return currentItem;
|
|
250
250
|
});
|
|
251
251
|
}
|
|
252
|
-
reloadItems() {
|
|
252
|
+
reloadItems(options) {
|
|
253
|
+
const { targetIds, force } = options || {};
|
|
253
254
|
const { editMode, settings: { autoupdateInterval, silentLoading } = {}, reloadItems, } = this.context;
|
|
254
255
|
const { isPageHidden } = this.state;
|
|
255
256
|
const autoupdateIntervalMs = Number(autoupdateInterval) * 1000;
|
|
257
|
+
const targetPlugins = targetIds
|
|
258
|
+
? this.pluginsRefs.filter((plugin) => targetIds.includes(plugin.props.id))
|
|
259
|
+
: this.pluginsRefs;
|
|
256
260
|
if (autoupdateIntervalMs) {
|
|
257
261
|
const timeSinceLastReload = new Date().getTime() - (this._lastReloadAt || 0);
|
|
258
262
|
const reloadIntervalRemains = autoupdateIntervalMs - timeSinceLastReload;
|
|
259
|
-
if (!isPageHidden && !editMode && reloadIntervalRemains <= 0) {
|
|
263
|
+
if (force || (!isPageHidden && !editMode && reloadIntervalRemains <= 0)) {
|
|
260
264
|
this._lastReloadAt = new Date().getTime();
|
|
261
|
-
reloadItems(
|
|
265
|
+
reloadItems(targetPlugins, { silentLoading, noVeil: true });
|
|
262
266
|
}
|
|
263
267
|
this._timeout = setTimeout(() => this.reloadItems(), reloadIntervalRemains <= 0 ? autoupdateIntervalMs : reloadIntervalRemains);
|
|
264
268
|
}
|
|
269
|
+
else if (force || (!isPageHidden && !editMode)) {
|
|
270
|
+
reloadItems(targetPlugins, { silentLoading, noVeil: true });
|
|
271
|
+
}
|
|
265
272
|
}
|
|
266
273
|
prepareDefaultArguments(group, layout, oldItem, newItem, placeholder, e, element) {
|
|
267
274
|
return {
|
|
@@ -1 +1,5 @@
|
|
|
1
|
-
export declare const i18n: (key: "button_retry" | "label_render-markdown-error" | "label_settings" | "label_copy" | "label_delete" | "label_error", params?: import("@gravity-ui/i18n").Params | undefined) => string
|
|
1
|
+
export declare const i18n: ((key: "button_retry" | "label_render-markdown-error" | "label_settings" | "label_copy" | "label_delete" | "label_error", params?: import("@gravity-ui/i18n").Params | undefined) => string) & {
|
|
2
|
+
keysetData: {
|
|
3
|
+
dashkit: Record<"button_retry" | "label_render-markdown-error" | "label_settings" | "label_copy" | "label_delete" | "label_error", import("@gravity-ui/i18n").KeyData>;
|
|
4
|
+
};
|
|
5
|
+
};
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@gravity-ui/dashkit",
|
|
3
|
-
"version": "8.
|
|
3
|
+
"version": "8.21.0",
|
|
4
4
|
"description": "Library for rendering dashboard grid layout",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"repository": {
|
|
@@ -61,7 +61,7 @@
|
|
|
61
61
|
},
|
|
62
62
|
"dependencies": {
|
|
63
63
|
"@bem-react/classname": "^1.6.0",
|
|
64
|
-
"@gravity-ui/icons": "^2.
|
|
64
|
+
"@gravity-ui/icons": "^2.11.0",
|
|
65
65
|
"hashids": "^2.2.8",
|
|
66
66
|
"immutability-helper": "^3.1.1",
|
|
67
67
|
"prop-types": "^15.8.1",
|
|
@@ -75,11 +75,11 @@
|
|
|
75
75
|
"devDependencies": {
|
|
76
76
|
"@commitlint/cli": "^17.0.3",
|
|
77
77
|
"@commitlint/config-conventional": "^17.0.3",
|
|
78
|
-
"@gravity-ui/eslint-config": "^3.
|
|
78
|
+
"@gravity-ui/eslint-config": "^3.2.0",
|
|
79
79
|
"@gravity-ui/prettier-config": "^1.1.0",
|
|
80
80
|
"@gravity-ui/stylelint-config": "^4.0.1",
|
|
81
81
|
"@gravity-ui/tsconfig": "^1.0.0",
|
|
82
|
-
"@gravity-ui/uikit": "^6.
|
|
82
|
+
"@gravity-ui/uikit": "^6.37.0",
|
|
83
83
|
"@storybook/addon-essentials": "^7.6.15",
|
|
84
84
|
"@storybook/addon-knobs": "^7.0.2",
|
|
85
85
|
"@storybook/cli": "^7.6.15",
|