@gravity-ui/dashkit 6.5.0-beta.0 → 6.5.0-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/DashKit/DashKit.d.ts +13 -0
- package/build/cjs/components/DashKit/DashKit.js +10 -0
- package/build/cjs/components/GridLayout/GridLayout.d.ts +1 -0
- package/build/cjs/components/GridLayout/GridLayout.js +5 -0
- package/build/cjs/hocs/withContext.js +11 -1
- package/build/esm/components/DashKit/DashKit.d.ts +13 -0
- package/build/esm/components/DashKit/DashKit.js +10 -0
- package/build/esm/components/GridLayout/GridLayout.d.ts +1 -0
- package/build/esm/components/GridLayout/GridLayout.js +5 -0
- package/build/esm/hocs/withContext.js +11 -1
- package/package.json +1 -1
|
@@ -21,6 +21,10 @@ interface DashKitDefaultProps {
|
|
|
21
21
|
settings: SettingsProps;
|
|
22
22
|
context: ContextProps;
|
|
23
23
|
noOverlay: boolean;
|
|
24
|
+
hideWidgetOverlayControl: (args: {
|
|
25
|
+
id: string;
|
|
26
|
+
controlId: string;
|
|
27
|
+
}) => void;
|
|
24
28
|
}
|
|
25
29
|
export interface DashKitProps extends DashKitGeneralProps, Partial<DashKitDefaultProps> {
|
|
26
30
|
}
|
|
@@ -46,5 +50,14 @@ export declare class DashKit extends React.PureComponent<DashKitInnerProps> {
|
|
|
46
50
|
metaRef: React.RefObject<GridLayout>;
|
|
47
51
|
render(): JSX.Element;
|
|
48
52
|
getItemsMeta(): any;
|
|
53
|
+
/**
|
|
54
|
+
* public method for hiding overlayControl item by id
|
|
55
|
+
* for ex. can be triggered after data render
|
|
56
|
+
* @param args
|
|
57
|
+
*/
|
|
58
|
+
hideWidgetOverlayControl(args: {
|
|
59
|
+
id: string;
|
|
60
|
+
controlId: string;
|
|
61
|
+
}): any;
|
|
49
62
|
}
|
|
50
63
|
export {};
|
|
@@ -54,11 +54,21 @@ class DashKit extends react_1.default.PureComponent {
|
|
|
54
54
|
var _a;
|
|
55
55
|
return (_a = this.metaRef.current) === null || _a === void 0 ? void 0 : _a.getItemsMeta();
|
|
56
56
|
}
|
|
57
|
+
/**
|
|
58
|
+
* public method for hiding overlayControl item by id
|
|
59
|
+
* for ex. can be triggered after data render
|
|
60
|
+
* @param args
|
|
61
|
+
*/
|
|
62
|
+
hideWidgetOverlayControl(args) {
|
|
63
|
+
var _a;
|
|
64
|
+
return (_a = this.metaRef.current) === null || _a === void 0 ? void 0 : _a.hideWidgetOverlayControl(args);
|
|
65
|
+
}
|
|
57
66
|
}
|
|
58
67
|
exports.DashKit = DashKit;
|
|
59
68
|
DashKit.defaultProps = {
|
|
60
69
|
onItemEdit: noop_1.default,
|
|
61
70
|
onChange: noop_1.default,
|
|
71
|
+
hideWidgetOverlayControl: noop_1.default,
|
|
62
72
|
defaultGlobalParams: {},
|
|
63
73
|
globalParams: {},
|
|
64
74
|
itemsStateAndParams: {},
|
|
@@ -18,6 +18,7 @@ export default class GridLayout extends React.PureComponent<any, any, any> {
|
|
|
18
18
|
adjustedWidgetLayout: any;
|
|
19
19
|
}) => void;
|
|
20
20
|
getItemsMeta: () => any;
|
|
21
|
+
hideWidgetOverlayControl: (args: any) => any;
|
|
21
22
|
reloadItems(): void;
|
|
22
23
|
_onStart: () => void;
|
|
23
24
|
_onStop: (newLayout: any) => void;
|
|
@@ -30,6 +30,11 @@ class GridLayout extends react_1.default.PureComponent {
|
|
|
30
30
|
const { getItemsMeta } = this.context;
|
|
31
31
|
return getItemsMeta(this.pluginsRefs);
|
|
32
32
|
};
|
|
33
|
+
this.hideWidgetOverlayControl = (args) => {
|
|
34
|
+
const { hideWidgetOverlayControl } = this.context;
|
|
35
|
+
const plugin = this.pluginsRefs.find((item) => item.props.id);
|
|
36
|
+
return hideWidgetOverlayControl(Object.assign(Object.assign({}, args), { plugin }));
|
|
37
|
+
};
|
|
33
38
|
this._onStart = () => {
|
|
34
39
|
this.setState({ isDragging: true });
|
|
35
40
|
};
|
|
@@ -15,6 +15,7 @@ function useMemoStateContext(props) {
|
|
|
15
15
|
// (высота) из конфига будет запоминаться в originalLayouts, новое значение высоты в adjustedLayouts
|
|
16
16
|
const originalLayouts = react_1.default.useRef({});
|
|
17
17
|
const adjustedLayouts = react_1.default.useRef({});
|
|
18
|
+
const [filteredOverlayControls, setFilteredOverlayControls] = react_1.default.useState(props.overlayControls || []);
|
|
18
19
|
// TODO: need move originalLayouts, adjustedLayouts to state
|
|
19
20
|
const [layoutUpdateCounter, forceUpdateLayout] = react_1.default.useState(0);
|
|
20
21
|
const onChange = react_1.default.useCallback(({ config = props.config, itemsStateAndParams = props.itemsStateAndParams }) => {
|
|
@@ -110,6 +111,10 @@ function useMemoStateContext(props) {
|
|
|
110
111
|
})
|
|
111
112
|
.filter(Boolean);
|
|
112
113
|
}, []);
|
|
114
|
+
const hideWidgetOverlayControl = react_1.default.useCallback((args) => {
|
|
115
|
+
const newOverlayControls = props.overlayControls.allWidgetsControls.filter((item) => item.id !== args.controlId);
|
|
116
|
+
setFilteredOverlayControls(Object.assign(Object.assign({}, props.overlayControls), { allWidgetsControls: newOverlayControls }));
|
|
117
|
+
}, [props.overlayControls]);
|
|
113
118
|
const resultLayout = react_1.default.useMemo(() => {
|
|
114
119
|
return props.layout.map((item) => {
|
|
115
120
|
if (item.i in adjustedLayouts.current) {
|
|
@@ -140,6 +145,8 @@ function useMemoStateContext(props) {
|
|
|
140
145
|
editItem: props.onItemEdit,
|
|
141
146
|
layoutChange: onLayoutChange,
|
|
142
147
|
getItemsMeta,
|
|
148
|
+
hideWidgetOverlayControl,
|
|
149
|
+
filteredOverlayControls,
|
|
143
150
|
reloadItems,
|
|
144
151
|
memorizeOriginalLayout,
|
|
145
152
|
revertToOriginalLayout,
|
|
@@ -161,6 +168,8 @@ function useMemoStateContext(props) {
|
|
|
161
168
|
props.onItemEdit,
|
|
162
169
|
onLayoutChange,
|
|
163
170
|
getItemsMeta,
|
|
171
|
+
hideWidgetOverlayControl,
|
|
172
|
+
filteredOverlayControls,
|
|
164
173
|
reloadItems,
|
|
165
174
|
memorizeOriginalLayout,
|
|
166
175
|
revertToOriginalLayout,
|
|
@@ -171,8 +180,9 @@ function useMemoStateContext(props) {
|
|
|
171
180
|
function withContext(Component) {
|
|
172
181
|
const WithContext = (props) => {
|
|
173
182
|
const contextValue = useMemoStateContext(props);
|
|
183
|
+
const overlayControls = contextValue.filteredOverlayControls;
|
|
174
184
|
return (react_1.default.createElement(DashKitContext_1.DashKitContext.Provider, { value: contextValue },
|
|
175
|
-
react_1.default.createElement(Component, { overlayControls:
|
|
185
|
+
react_1.default.createElement(Component, { overlayControls: overlayControls })));
|
|
176
186
|
};
|
|
177
187
|
WithContext.displayName = `withContext(${Component.displayName || Component.name || 'Component'}`;
|
|
178
188
|
return WithContext;
|
|
@@ -21,6 +21,10 @@ interface DashKitDefaultProps {
|
|
|
21
21
|
settings: SettingsProps;
|
|
22
22
|
context: ContextProps;
|
|
23
23
|
noOverlay: boolean;
|
|
24
|
+
hideWidgetOverlayControl: (args: {
|
|
25
|
+
id: string;
|
|
26
|
+
controlId: string;
|
|
27
|
+
}) => void;
|
|
24
28
|
}
|
|
25
29
|
export interface DashKitProps extends DashKitGeneralProps, Partial<DashKitDefaultProps> {
|
|
26
30
|
}
|
|
@@ -46,5 +50,14 @@ export declare class DashKit extends React.PureComponent<DashKitInnerProps> {
|
|
|
46
50
|
metaRef: React.RefObject<GridLayout>;
|
|
47
51
|
render(): JSX.Element;
|
|
48
52
|
getItemsMeta(): any;
|
|
53
|
+
/**
|
|
54
|
+
* public method for hiding overlayControl item by id
|
|
55
|
+
* for ex. can be triggered after data render
|
|
56
|
+
* @param args
|
|
57
|
+
*/
|
|
58
|
+
hideWidgetOverlayControl(args: {
|
|
59
|
+
id: string;
|
|
60
|
+
controlId: string;
|
|
61
|
+
}): any;
|
|
49
62
|
}
|
|
50
63
|
export {};
|
|
@@ -50,10 +50,20 @@ export class DashKit extends React.PureComponent {
|
|
|
50
50
|
var _a;
|
|
51
51
|
return (_a = this.metaRef.current) === null || _a === void 0 ? void 0 : _a.getItemsMeta();
|
|
52
52
|
}
|
|
53
|
+
/**
|
|
54
|
+
* public method for hiding overlayControl item by id
|
|
55
|
+
* for ex. can be triggered after data render
|
|
56
|
+
* @param args
|
|
57
|
+
*/
|
|
58
|
+
hideWidgetOverlayControl(args) {
|
|
59
|
+
var _a;
|
|
60
|
+
return (_a = this.metaRef.current) === null || _a === void 0 ? void 0 : _a.hideWidgetOverlayControl(args);
|
|
61
|
+
}
|
|
53
62
|
}
|
|
54
63
|
DashKit.defaultProps = {
|
|
55
64
|
onItemEdit: noop,
|
|
56
65
|
onChange: noop,
|
|
66
|
+
hideWidgetOverlayControl: noop,
|
|
57
67
|
defaultGlobalParams: {},
|
|
58
68
|
globalParams: {},
|
|
59
69
|
itemsStateAndParams: {},
|
|
@@ -18,6 +18,7 @@ export default class GridLayout extends React.PureComponent<any, any, any> {
|
|
|
18
18
|
adjustedWidgetLayout: any;
|
|
19
19
|
}) => void;
|
|
20
20
|
getItemsMeta: () => any;
|
|
21
|
+
hideWidgetOverlayControl: (args: any) => any;
|
|
21
22
|
reloadItems(): void;
|
|
22
23
|
_onStart: () => void;
|
|
23
24
|
_onStop: (newLayout: any) => void;
|
|
@@ -27,6 +27,11 @@ export default class GridLayout extends React.PureComponent {
|
|
|
27
27
|
const { getItemsMeta } = this.context;
|
|
28
28
|
return getItemsMeta(this.pluginsRefs);
|
|
29
29
|
};
|
|
30
|
+
this.hideWidgetOverlayControl = (args) => {
|
|
31
|
+
const { hideWidgetOverlayControl } = this.context;
|
|
32
|
+
const plugin = this.pluginsRefs.find((item) => item.props.id);
|
|
33
|
+
return hideWidgetOverlayControl(Object.assign(Object.assign({}, args), { plugin }));
|
|
34
|
+
};
|
|
30
35
|
this._onStart = () => {
|
|
31
36
|
this.setState({ isDragging: true });
|
|
32
37
|
};
|
|
@@ -11,6 +11,7 @@ function useMemoStateContext(props) {
|
|
|
11
11
|
// (высота) из конфига будет запоминаться в originalLayouts, новое значение высоты в adjustedLayouts
|
|
12
12
|
const originalLayouts = React.useRef({});
|
|
13
13
|
const adjustedLayouts = React.useRef({});
|
|
14
|
+
const [filteredOverlayControls, setFilteredOverlayControls] = React.useState(props.overlayControls || []);
|
|
14
15
|
// TODO: need move originalLayouts, adjustedLayouts to state
|
|
15
16
|
const [layoutUpdateCounter, forceUpdateLayout] = React.useState(0);
|
|
16
17
|
const onChange = React.useCallback(({ config = props.config, itemsStateAndParams = props.itemsStateAndParams }) => {
|
|
@@ -106,6 +107,10 @@ function useMemoStateContext(props) {
|
|
|
106
107
|
})
|
|
107
108
|
.filter(Boolean);
|
|
108
109
|
}, []);
|
|
110
|
+
const hideWidgetOverlayControl = React.useCallback((args) => {
|
|
111
|
+
const newOverlayControls = props.overlayControls.allWidgetsControls.filter((item) => item.id !== args.controlId);
|
|
112
|
+
setFilteredOverlayControls(Object.assign(Object.assign({}, props.overlayControls), { allWidgetsControls: newOverlayControls }));
|
|
113
|
+
}, [props.overlayControls]);
|
|
109
114
|
const resultLayout = React.useMemo(() => {
|
|
110
115
|
return props.layout.map((item) => {
|
|
111
116
|
if (item.i in adjustedLayouts.current) {
|
|
@@ -136,6 +141,8 @@ function useMemoStateContext(props) {
|
|
|
136
141
|
editItem: props.onItemEdit,
|
|
137
142
|
layoutChange: onLayoutChange,
|
|
138
143
|
getItemsMeta,
|
|
144
|
+
hideWidgetOverlayControl,
|
|
145
|
+
filteredOverlayControls,
|
|
139
146
|
reloadItems,
|
|
140
147
|
memorizeOriginalLayout,
|
|
141
148
|
revertToOriginalLayout,
|
|
@@ -157,6 +164,8 @@ function useMemoStateContext(props) {
|
|
|
157
164
|
props.onItemEdit,
|
|
158
165
|
onLayoutChange,
|
|
159
166
|
getItemsMeta,
|
|
167
|
+
hideWidgetOverlayControl,
|
|
168
|
+
filteredOverlayControls,
|
|
160
169
|
reloadItems,
|
|
161
170
|
memorizeOriginalLayout,
|
|
162
171
|
revertToOriginalLayout,
|
|
@@ -167,8 +176,9 @@ function useMemoStateContext(props) {
|
|
|
167
176
|
export function withContext(Component) {
|
|
168
177
|
const WithContext = (props) => {
|
|
169
178
|
const contextValue = useMemoStateContext(props);
|
|
179
|
+
const overlayControls = contextValue.filteredOverlayControls;
|
|
170
180
|
return (React.createElement(DashKitContext.Provider, { value: contextValue },
|
|
171
|
-
React.createElement(Component, { overlayControls:
|
|
181
|
+
React.createElement(Component, { overlayControls: overlayControls })));
|
|
172
182
|
};
|
|
173
183
|
WithContext.displayName = `withContext(${Component.displayName || Component.name || 'Component'}`;
|
|
174
184
|
return WithContext;
|