@gravity-ui/dashkit 6.5.1-beta.0 → 6.5.1-beta.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.
- package/build/cjs/components/GridLayout/GridLayout.d.ts +0 -3
- package/build/cjs/components/GridLayout/GridLayout.js +9 -31
- package/build/cjs/components/OverlayControls/OverlayControls.d.ts +1 -0
- package/build/cjs/components/OverlayControls/OverlayControls.js +6 -2
- package/build/cjs/constants/common.d.ts +0 -1
- package/build/cjs/constants/common.js +1 -2
- package/build/cjs/hocs/withContext.js +1 -2
- package/build/cjs/typings/common.d.ts +0 -1
- package/build/esm/components/GridLayout/GridLayout.d.ts +0 -3
- package/build/esm/components/GridLayout/GridLayout.js +9 -31
- package/build/esm/components/OverlayControls/OverlayControls.d.ts +1 -0
- package/build/esm/components/OverlayControls/OverlayControls.js +7 -3
- package/build/esm/constants/common.d.ts +0 -1
- package/build/esm/constants/common.js +0 -1
- package/build/esm/hocs/withContext.js +1 -2
- package/build/esm/typings/common.d.ts +0 -1
- package/package.json +1 -1
|
@@ -18,9 +18,6 @@ export default class GridLayout extends React.PureComponent<any, any, any> {
|
|
|
18
18
|
adjustedWidgetLayout: any;
|
|
19
19
|
}) => void;
|
|
20
20
|
getItemsMeta: () => any;
|
|
21
|
-
getAutoupdateIntervalMs(): number;
|
|
22
|
-
getReloadIntervalRemains(): number;
|
|
23
|
-
startReloadItems(): any;
|
|
24
21
|
reloadItems(): void;
|
|
25
22
|
_onStart: () => void;
|
|
26
23
|
_onStop: (newLayout: any) => void;
|
|
@@ -5,7 +5,6 @@ const react_1 = tslib_1.__importDefault(require("react"));
|
|
|
5
5
|
const react_grid_layout_1 = tslib_1.__importStar(require("react-grid-layout"));
|
|
6
6
|
const GridItem_1 = tslib_1.__importDefault(require("../GridItem/GridItem"));
|
|
7
7
|
const DashKitContext_1 = require("../../context/DashKitContext");
|
|
8
|
-
const constants_1 = require("../../constants");
|
|
9
8
|
const Layout = (0, react_grid_layout_1.WidthProvider)(react_grid_layout_1.default); // eslint-disable-line new-cap
|
|
10
9
|
class GridLayout extends react_1.default.PureComponent {
|
|
11
10
|
constructor(props, context) {
|
|
@@ -57,37 +56,16 @@ class GridLayout extends react_1.default.PureComponent {
|
|
|
57
56
|
clearTimeout(this._timeout);
|
|
58
57
|
document.removeEventListener('visibilitychange', this.onVisibilityChange);
|
|
59
58
|
}
|
|
60
|
-
getAutoupdateIntervalMs() {
|
|
61
|
-
const { settings: { autoupdateInterval } = {} } = this.context;
|
|
62
|
-
const autoupdateIntervalMs = Number(autoupdateInterval) * 1000;
|
|
63
|
-
return autoupdateIntervalMs;
|
|
64
|
-
}
|
|
65
|
-
getReloadIntervalRemains() {
|
|
66
|
-
const autoupdateIntervalMs = this.getAutoupdateIntervalMs();
|
|
67
|
-
const timeSinceLastReload = new Date().getTime() - (this._lastReloadAt || 0);
|
|
68
|
-
const reloadIntervalRemains = autoupdateIntervalMs - timeSinceLastReload;
|
|
69
|
-
return reloadIntervalRemains;
|
|
70
|
-
}
|
|
71
|
-
startReloadItems() {
|
|
72
|
-
const { editMode, settings: { silentLoading } = {}, reloadItems } = this.context;
|
|
73
|
-
const { isPageHidden } = this.state;
|
|
74
|
-
if (!isPageHidden && !editMode) {
|
|
75
|
-
this._lastReloadAt = new Date().getTime();
|
|
76
|
-
return reloadItems(this.pluginsRefs, { silentLoading, noVeil: true });
|
|
77
|
-
}
|
|
78
|
-
return Promise.resolve();
|
|
79
|
-
}
|
|
80
59
|
reloadItems() {
|
|
81
|
-
const { settings: {
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
return;
|
|
85
|
-
}
|
|
86
|
-
const autoupdateIntervalMs = this.getAutoupdateIntervalMs();
|
|
87
|
-
const reloadIntervalRemains = this.getReloadIntervalRemains();
|
|
60
|
+
const { editMode, settings: { autoupdateInterval, silentLoading } = {}, reloadItems, } = this.context;
|
|
61
|
+
const { isPageHidden } = this.state;
|
|
62
|
+
const autoupdateIntervalMs = Number(autoupdateInterval) * 1000;
|
|
88
63
|
if (autoupdateIntervalMs) {
|
|
89
|
-
|
|
90
|
-
|
|
64
|
+
const timeSinceLastReload = new Date().getTime() - (this._lastReloadAt || 0);
|
|
65
|
+
const reloadIntervalRemains = autoupdateIntervalMs - timeSinceLastReload;
|
|
66
|
+
if (!isPageHidden && !editMode && reloadIntervalRemains <= 0) {
|
|
67
|
+
this._lastReloadAt = new Date().getTime();
|
|
68
|
+
reloadItems(this.pluginsRefs, { silentLoading, noVeil: true });
|
|
91
69
|
}
|
|
92
70
|
this._timeout = setTimeout(() => this.reloadItems(), reloadIntervalRemains <= 0 ? autoupdateIntervalMs : reloadIntervalRemains);
|
|
93
71
|
}
|
|
@@ -97,7 +75,7 @@ class GridLayout extends react_1.default.PureComponent {
|
|
|
97
75
|
this.pluginsRefs.length = config.items.length;
|
|
98
76
|
return (react_1.default.createElement(Layout, Object.assign({}, registerManager.gridLayout, { layout: layout, isDraggable: editMode, isResizable: editMode, onDragStart: this._onStart, onDragStop: this._onStop, onResizeStart: this._onStart, onResizeStop: this._onStop }, (draggableHandleClassName
|
|
99
77
|
? { draggableHandle: `.${draggableHandleClassName}` }
|
|
100
|
-
: null)
|
|
78
|
+
: null)), config.items.map((item, i) => {
|
|
101
79
|
return (react_1.default.createElement(GridItem_1.default, { forwardedPluginRef: (pluginRef) => {
|
|
102
80
|
this.pluginsRefs[i] = pluginRef;
|
|
103
81
|
}, key: item.id, id: item.id, item: item, layout: layout, adjustWidgetLayout: this.adjustWidgetLayout, isDragging: this.state.isDragging, noOverlay: noOverlay, withCustomHandle: Boolean(draggableHandleClassName), overlayControls: this.props.overlayControls }));
|
|
@@ -39,6 +39,7 @@ interface OverlayControlsProps extends OverlayControlsDefaultProps {
|
|
|
39
39
|
overlayControls?: Record<string, OverlayControlItem[]>;
|
|
40
40
|
}
|
|
41
41
|
type DashKitCtx = React.Context<{
|
|
42
|
+
context: Record<string, any>;
|
|
42
43
|
registerManager: RegisterManager;
|
|
43
44
|
itemsParams: Record<string, StringParams>;
|
|
44
45
|
itemsState: Record<string, ItemState>;
|
|
@@ -12,7 +12,7 @@ const DotsIcon_1 = require("../../icons/DotsIcon");
|
|
|
12
12
|
const CogIcon_1 = require("../../icons/CogIcon");
|
|
13
13
|
const CloseIcon_1 = require("../../icons/CloseIcon");
|
|
14
14
|
const cn_1 = require("../../utils/cn");
|
|
15
|
-
const b = (0, cn_1.cn)(
|
|
15
|
+
const b = (0, cn_1.cn)('dashkit-overlay-controls');
|
|
16
16
|
var OverlayControlsPosition;
|
|
17
17
|
(function (OverlayControlsPosition) {
|
|
18
18
|
OverlayControlsPosition["TopRight"] = "top_right";
|
|
@@ -56,10 +56,11 @@ class OverlayControls extends react_1.default.Component {
|
|
|
56
56
|
return controls;
|
|
57
57
|
};
|
|
58
58
|
this.onCopyItem = () => {
|
|
59
|
+
var _a;
|
|
59
60
|
const correspondedItemLayout = this.context.config.layout.find((item) => {
|
|
60
61
|
return item.i === this.props.configItem.id;
|
|
61
62
|
});
|
|
62
|
-
|
|
63
|
+
let options = {
|
|
63
64
|
timestamp: Date.now(),
|
|
64
65
|
data: this.props.configItem.data,
|
|
65
66
|
type: this.props.configItem.type,
|
|
@@ -70,6 +71,9 @@ class OverlayControls extends react_1.default.Component {
|
|
|
70
71
|
h: correspondedItemLayout.h,
|
|
71
72
|
},
|
|
72
73
|
};
|
|
74
|
+
if (typeof ((_a = this.context.context) === null || _a === void 0 ? void 0 : _a.getPreparedCopyItemOptions) === 'function') {
|
|
75
|
+
options = this.context.context.getPreparedCopyItemOptions(options);
|
|
76
|
+
}
|
|
73
77
|
localStorage.setItem(constants_1.COPIED_WIDGET_STORE_KEY, JSON.stringify(options));
|
|
74
78
|
// https://stackoverflow.com/questions/35865481/storage-event-not-firing
|
|
75
79
|
window.dispatchEvent(new Event('storage'));
|
|
@@ -1,6 +1,5 @@
|
|
|
1
1
|
export declare const COPIED_WIDGET_STORE_KEY = "dashCopiedItem";
|
|
2
2
|
export declare const DEFAULT_NAMESPACE = "default";
|
|
3
|
-
export declare const OVERLAY_CONTROLS_CLASS_NAME = "dashkit-overlay-controls";
|
|
4
3
|
export declare const MenuItems: {
|
|
5
4
|
readonly Copy: "copy";
|
|
6
5
|
readonly Delete: "delete";
|
|
@@ -1,9 +1,8 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.MenuItems = exports.
|
|
3
|
+
exports.MenuItems = exports.DEFAULT_NAMESPACE = exports.COPIED_WIDGET_STORE_KEY = void 0;
|
|
4
4
|
exports.COPIED_WIDGET_STORE_KEY = 'dashCopiedItem';
|
|
5
5
|
exports.DEFAULT_NAMESPACE = 'default';
|
|
6
|
-
exports.OVERLAY_CONTROLS_CLASS_NAME = 'dashkit-overlay-controls';
|
|
7
6
|
exports.MenuItems = {
|
|
8
7
|
Copy: 'copy',
|
|
9
8
|
Delete: 'delete',
|
|
@@ -121,8 +121,7 @@ function useMemoStateContext(props) {
|
|
|
121
121
|
});
|
|
122
122
|
}, [props.layout, layoutUpdateCounter]);
|
|
123
123
|
const reloadItems = react_1.default.useCallback((pluginsRefs, data) => {
|
|
124
|
-
|
|
125
|
-
return Promise.all(promises);
|
|
124
|
+
pluginsRefs.forEach((ref) => ref && ref.reload && ref.reload(data));
|
|
126
125
|
}, []);
|
|
127
126
|
return react_1.default.useMemo(() => ({
|
|
128
127
|
layout: resultLayout,
|
|
@@ -11,7 +11,6 @@ export type MenuItem = (typeof MenuItems)[keyof typeof MenuItems] | OverlayCusto
|
|
|
11
11
|
export interface SettingsProps {
|
|
12
12
|
autoupdateInterval: number;
|
|
13
13
|
silentLoading: boolean;
|
|
14
|
-
realtimeMode?: boolean;
|
|
15
14
|
}
|
|
16
15
|
export interface ContextProps {
|
|
17
16
|
[key: string]: any;
|
|
@@ -18,9 +18,6 @@ export default class GridLayout extends React.PureComponent<any, any, any> {
|
|
|
18
18
|
adjustedWidgetLayout: any;
|
|
19
19
|
}) => void;
|
|
20
20
|
getItemsMeta: () => any;
|
|
21
|
-
getAutoupdateIntervalMs(): number;
|
|
22
|
-
getReloadIntervalRemains(): number;
|
|
23
|
-
startReloadItems(): any;
|
|
24
21
|
reloadItems(): void;
|
|
25
22
|
_onStart: () => void;
|
|
26
23
|
_onStop: (newLayout: any) => void;
|
|
@@ -2,7 +2,6 @@ import React from 'react';
|
|
|
2
2
|
import ReactGridLayout, { WidthProvider } from 'react-grid-layout';
|
|
3
3
|
import GridItem from '../GridItem/GridItem';
|
|
4
4
|
import { DashKitContext } from '../../context/DashKitContext';
|
|
5
|
-
import { OVERLAY_CONTROLS_CLASS_NAME } from '../../constants';
|
|
6
5
|
const Layout = WidthProvider(ReactGridLayout); // eslint-disable-line new-cap
|
|
7
6
|
export default class GridLayout extends React.PureComponent {
|
|
8
7
|
constructor(props, context) {
|
|
@@ -54,37 +53,16 @@ export default class GridLayout extends React.PureComponent {
|
|
|
54
53
|
clearTimeout(this._timeout);
|
|
55
54
|
document.removeEventListener('visibilitychange', this.onVisibilityChange);
|
|
56
55
|
}
|
|
57
|
-
getAutoupdateIntervalMs() {
|
|
58
|
-
const { settings: { autoupdateInterval } = {} } = this.context;
|
|
59
|
-
const autoupdateIntervalMs = Number(autoupdateInterval) * 1000;
|
|
60
|
-
return autoupdateIntervalMs;
|
|
61
|
-
}
|
|
62
|
-
getReloadIntervalRemains() {
|
|
63
|
-
const autoupdateIntervalMs = this.getAutoupdateIntervalMs();
|
|
64
|
-
const timeSinceLastReload = new Date().getTime() - (this._lastReloadAt || 0);
|
|
65
|
-
const reloadIntervalRemains = autoupdateIntervalMs - timeSinceLastReload;
|
|
66
|
-
return reloadIntervalRemains;
|
|
67
|
-
}
|
|
68
|
-
startReloadItems() {
|
|
69
|
-
const { editMode, settings: { silentLoading } = {}, reloadItems } = this.context;
|
|
70
|
-
const { isPageHidden } = this.state;
|
|
71
|
-
if (!isPageHidden && !editMode) {
|
|
72
|
-
this._lastReloadAt = new Date().getTime();
|
|
73
|
-
return reloadItems(this.pluginsRefs, { silentLoading, noVeil: true });
|
|
74
|
-
}
|
|
75
|
-
return Promise.resolve();
|
|
76
|
-
}
|
|
77
56
|
reloadItems() {
|
|
78
|
-
const { settings: {
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
return;
|
|
82
|
-
}
|
|
83
|
-
const autoupdateIntervalMs = this.getAutoupdateIntervalMs();
|
|
84
|
-
const reloadIntervalRemains = this.getReloadIntervalRemains();
|
|
57
|
+
const { editMode, settings: { autoupdateInterval, silentLoading } = {}, reloadItems, } = this.context;
|
|
58
|
+
const { isPageHidden } = this.state;
|
|
59
|
+
const autoupdateIntervalMs = Number(autoupdateInterval) * 1000;
|
|
85
60
|
if (autoupdateIntervalMs) {
|
|
86
|
-
|
|
87
|
-
|
|
61
|
+
const timeSinceLastReload = new Date().getTime() - (this._lastReloadAt || 0);
|
|
62
|
+
const reloadIntervalRemains = autoupdateIntervalMs - timeSinceLastReload;
|
|
63
|
+
if (!isPageHidden && !editMode && reloadIntervalRemains <= 0) {
|
|
64
|
+
this._lastReloadAt = new Date().getTime();
|
|
65
|
+
reloadItems(this.pluginsRefs, { silentLoading, noVeil: true });
|
|
88
66
|
}
|
|
89
67
|
this._timeout = setTimeout(() => this.reloadItems(), reloadIntervalRemains <= 0 ? autoupdateIntervalMs : reloadIntervalRemains);
|
|
90
68
|
}
|
|
@@ -94,7 +72,7 @@ export default class GridLayout extends React.PureComponent {
|
|
|
94
72
|
this.pluginsRefs.length = config.items.length;
|
|
95
73
|
return (React.createElement(Layout, Object.assign({}, registerManager.gridLayout, { layout: layout, isDraggable: editMode, isResizable: editMode, onDragStart: this._onStart, onDragStop: this._onStop, onResizeStart: this._onStart, onResizeStop: this._onStop }, (draggableHandleClassName
|
|
96
74
|
? { draggableHandle: `.${draggableHandleClassName}` }
|
|
97
|
-
: null)
|
|
75
|
+
: null)), config.items.map((item, i) => {
|
|
98
76
|
return (React.createElement(GridItem, { forwardedPluginRef: (pluginRef) => {
|
|
99
77
|
this.pluginsRefs[i] = pluginRef;
|
|
100
78
|
}, key: item.id, id: item.id, item: item, layout: layout, adjustWidgetLayout: this.adjustWidgetLayout, isDragging: this.state.isDragging, noOverlay: noOverlay, withCustomHandle: Boolean(draggableHandleClassName), overlayControls: this.props.overlayControls }));
|
|
@@ -40,6 +40,7 @@ interface OverlayControlsProps extends OverlayControlsDefaultProps {
|
|
|
40
40
|
overlayControls?: Record<string, OverlayControlItem[]>;
|
|
41
41
|
}
|
|
42
42
|
type DashKitCtx = React.Context<{
|
|
43
|
+
context: Record<string, any>;
|
|
43
44
|
registerManager: RegisterManager;
|
|
44
45
|
itemsParams: Record<string, StringParams>;
|
|
45
46
|
itemsState: Record<string, ItemState>;
|
|
@@ -3,13 +3,13 @@ import i18n from '../../i18n';
|
|
|
3
3
|
import noop from 'lodash/noop';
|
|
4
4
|
import { DashKitContext } from '../../context/DashKitContext';
|
|
5
5
|
import { Icon, DropdownMenu, Button, } from '@gravity-ui/uikit';
|
|
6
|
-
import { COPIED_WIDGET_STORE_KEY,
|
|
6
|
+
import { COPIED_WIDGET_STORE_KEY, MenuItems } from '../../constants';
|
|
7
7
|
import { DotsIcon } from '../../icons/DotsIcon';
|
|
8
8
|
import { CogIcon } from '../../icons/CogIcon';
|
|
9
9
|
import { CloseIcon } from '../../icons/CloseIcon';
|
|
10
10
|
import { cn } from '../../utils/cn';
|
|
11
11
|
import './OverlayControls.css';
|
|
12
|
-
const b = cn(
|
|
12
|
+
const b = cn('dashkit-overlay-controls');
|
|
13
13
|
export var OverlayControlsPosition;
|
|
14
14
|
(function (OverlayControlsPosition) {
|
|
15
15
|
OverlayControlsPosition["TopRight"] = "top_right";
|
|
@@ -53,10 +53,11 @@ class OverlayControls extends React.Component {
|
|
|
53
53
|
return controls;
|
|
54
54
|
};
|
|
55
55
|
this.onCopyItem = () => {
|
|
56
|
+
var _a;
|
|
56
57
|
const correspondedItemLayout = this.context.config.layout.find((item) => {
|
|
57
58
|
return item.i === this.props.configItem.id;
|
|
58
59
|
});
|
|
59
|
-
|
|
60
|
+
let options = {
|
|
60
61
|
timestamp: Date.now(),
|
|
61
62
|
data: this.props.configItem.data,
|
|
62
63
|
type: this.props.configItem.type,
|
|
@@ -67,6 +68,9 @@ class OverlayControls extends React.Component {
|
|
|
67
68
|
h: correspondedItemLayout.h,
|
|
68
69
|
},
|
|
69
70
|
};
|
|
71
|
+
if (typeof ((_a = this.context.context) === null || _a === void 0 ? void 0 : _a.getPreparedCopyItemOptions) === 'function') {
|
|
72
|
+
options = this.context.context.getPreparedCopyItemOptions(options);
|
|
73
|
+
}
|
|
70
74
|
localStorage.setItem(COPIED_WIDGET_STORE_KEY, JSON.stringify(options));
|
|
71
75
|
// https://stackoverflow.com/questions/35865481/storage-event-not-firing
|
|
72
76
|
window.dispatchEvent(new Event('storage'));
|
|
@@ -1,6 +1,5 @@
|
|
|
1
1
|
export declare const COPIED_WIDGET_STORE_KEY = "dashCopiedItem";
|
|
2
2
|
export declare const DEFAULT_NAMESPACE = "default";
|
|
3
|
-
export declare const OVERLAY_CONTROLS_CLASS_NAME = "dashkit-overlay-controls";
|
|
4
3
|
export declare const MenuItems: {
|
|
5
4
|
readonly Copy: "copy";
|
|
6
5
|
readonly Delete: "delete";
|
|
@@ -117,8 +117,7 @@ function useMemoStateContext(props) {
|
|
|
117
117
|
});
|
|
118
118
|
}, [props.layout, layoutUpdateCounter]);
|
|
119
119
|
const reloadItems = React.useCallback((pluginsRefs, data) => {
|
|
120
|
-
|
|
121
|
-
return Promise.all(promises);
|
|
120
|
+
pluginsRefs.forEach((ref) => ref && ref.reload && ref.reload(data));
|
|
122
121
|
}, []);
|
|
123
122
|
return React.useMemo(() => ({
|
|
124
123
|
layout: resultLayout,
|
|
@@ -11,7 +11,6 @@ export type MenuItem = (typeof MenuItems)[keyof typeof MenuItems] | OverlayCusto
|
|
|
11
11
|
export interface SettingsProps {
|
|
12
12
|
autoupdateInterval: number;
|
|
13
13
|
silentLoading: boolean;
|
|
14
|
-
realtimeMode?: boolean;
|
|
15
14
|
}
|
|
16
15
|
export interface ContextProps {
|
|
17
16
|
[key: string]: any;
|