@gravity-ui/dashkit 5.5.0 → 5.6.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/CHANGELOG.md +7 -0
- package/build/cjs/components/OverlayControls/OverlayControls.d.ts +3 -2
- package/build/cjs/components/OverlayControls/OverlayControls.js +3 -2
- package/build/esm/components/OverlayControls/OverlayControls.d.ts +3 -2
- package/build/esm/components/OverlayControls/OverlayControls.js +3 -2
- package/package.json +1 -1
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,12 @@
|
|
|
1
1
|
# Changelog
|
|
2
2
|
|
|
3
|
+
## [5.6.0](https://github.com/gravity-ui/dashkit/compare/v5.5.0...v5.6.0) (2023-04-18)
|
|
4
|
+
|
|
5
|
+
|
|
6
|
+
### Features
|
|
7
|
+
|
|
8
|
+
* add item state to overlay dropdown menu action handler ([#57](https://github.com/gravity-ui/dashkit/issues/57)) ([78b13fa](https://github.com/gravity-ui/dashkit/commit/78b13fa4107e94abd93c6e469a36840b61b6a10a))
|
|
9
|
+
|
|
3
10
|
## [5.5.0](https://github.com/gravity-ui/dashkit/compare/v5.4.0...v5.5.0) (2023-04-17)
|
|
4
11
|
|
|
5
12
|
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import React from 'react';
|
|
2
2
|
import { ButtonView, ButtonSize, IconProps, MenuItemProps } from '@gravity-ui/uikit';
|
|
3
|
-
import { ConfigItem, PluginBase, StringParams, Config } from '../../shared';
|
|
3
|
+
import { ConfigItem, PluginBase, StringParams, Config, ItemState } from '../../shared';
|
|
4
4
|
import type { RegisterManager } from '../../utils/register-manager';
|
|
5
5
|
export declare enum OverlayControlsPosition {
|
|
6
6
|
TopRight = "top_right",
|
|
@@ -23,7 +23,7 @@ export interface OverlayCustomControlItem {
|
|
|
23
23
|
title?: string;
|
|
24
24
|
icon?: MenuItemProps['icon'];
|
|
25
25
|
iconSize?: number | string;
|
|
26
|
-
handler?: (item: ConfigItem, params: StringParams) => void;
|
|
26
|
+
handler?: (item: ConfigItem, params: StringParams, state: ItemState) => void;
|
|
27
27
|
visible?: (item: ConfigItem) => boolean;
|
|
28
28
|
className?: string;
|
|
29
29
|
qa?: string;
|
|
@@ -41,6 +41,7 @@ interface OverlayControlsProps extends OverlayControlsDefaultProps {
|
|
|
41
41
|
type DashKitCtx = React.Context<{
|
|
42
42
|
registerManager: RegisterManager;
|
|
43
43
|
itemsParams: Record<string, StringParams>;
|
|
44
|
+
itemsState: Record<string, ItemState>;
|
|
44
45
|
editItem: (item: ConfigItem) => void;
|
|
45
46
|
removeItem: (id: string) => void;
|
|
46
47
|
config: Config;
|
|
@@ -143,9 +143,10 @@ class OverlayControls extends react_1.default.Component {
|
|
|
143
143
|
}
|
|
144
144
|
renderDropdownMenu() {
|
|
145
145
|
const { view, size } = this.props;
|
|
146
|
-
const { registerManager, itemsParams } = this.context;
|
|
146
|
+
const { registerManager, itemsParams, itemsState } = this.context;
|
|
147
147
|
const configItem = this.props.configItem;
|
|
148
148
|
const itemParams = itemsParams[configItem.id];
|
|
149
|
+
const itemState = itemsState[configItem.id];
|
|
149
150
|
let menu = registerManager.settings.menu;
|
|
150
151
|
if (!menu.length) {
|
|
151
152
|
menu = DEFAULT_DROPDOWN_MENU;
|
|
@@ -164,7 +165,7 @@ class OverlayControls extends react_1.default.Component {
|
|
|
164
165
|
}
|
|
165
166
|
const itemHandler = item.handler;
|
|
166
167
|
const itemAction = typeof itemHandler === 'function'
|
|
167
|
-
? () => itemHandler(configItem, itemParams)
|
|
168
|
+
? () => itemHandler(configItem, itemParams, itemState)
|
|
168
169
|
: ((_a = this.getDropDownMenuItemConfig(item.id)) === null || _a === void 0 ? void 0 : _a.action) || (() => { });
|
|
169
170
|
return {
|
|
170
171
|
text: item.title || (0, i18n_1.default)(item.id),
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import React from 'react';
|
|
2
2
|
import { ButtonView, ButtonSize, IconProps, MenuItemProps } from '@gravity-ui/uikit';
|
|
3
|
-
import { ConfigItem, PluginBase, StringParams, Config } from '../../shared';
|
|
3
|
+
import { ConfigItem, PluginBase, StringParams, Config, ItemState } from '../../shared';
|
|
4
4
|
import type { RegisterManager } from '../../utils/register-manager';
|
|
5
5
|
import './OverlayControls.css';
|
|
6
6
|
export declare enum OverlayControlsPosition {
|
|
@@ -24,7 +24,7 @@ export interface OverlayCustomControlItem {
|
|
|
24
24
|
title?: string;
|
|
25
25
|
icon?: MenuItemProps['icon'];
|
|
26
26
|
iconSize?: number | string;
|
|
27
|
-
handler?: (item: ConfigItem, params: StringParams) => void;
|
|
27
|
+
handler?: (item: ConfigItem, params: StringParams, state: ItemState) => void;
|
|
28
28
|
visible?: (item: ConfigItem) => boolean;
|
|
29
29
|
className?: string;
|
|
30
30
|
qa?: string;
|
|
@@ -42,6 +42,7 @@ interface OverlayControlsProps extends OverlayControlsDefaultProps {
|
|
|
42
42
|
type DashKitCtx = React.Context<{
|
|
43
43
|
registerManager: RegisterManager;
|
|
44
44
|
itemsParams: Record<string, StringParams>;
|
|
45
|
+
itemsState: Record<string, ItemState>;
|
|
45
46
|
editItem: (item: ConfigItem) => void;
|
|
46
47
|
removeItem: (id: string) => void;
|
|
47
48
|
config: Config;
|
|
@@ -140,9 +140,10 @@ class OverlayControls extends React.Component {
|
|
|
140
140
|
}
|
|
141
141
|
renderDropdownMenu() {
|
|
142
142
|
const { view, size } = this.props;
|
|
143
|
-
const { registerManager, itemsParams } = this.context;
|
|
143
|
+
const { registerManager, itemsParams, itemsState } = this.context;
|
|
144
144
|
const configItem = this.props.configItem;
|
|
145
145
|
const itemParams = itemsParams[configItem.id];
|
|
146
|
+
const itemState = itemsState[configItem.id];
|
|
146
147
|
let menu = registerManager.settings.menu;
|
|
147
148
|
if (!menu.length) {
|
|
148
149
|
menu = DEFAULT_DROPDOWN_MENU;
|
|
@@ -161,7 +162,7 @@ class OverlayControls extends React.Component {
|
|
|
161
162
|
}
|
|
162
163
|
const itemHandler = item.handler;
|
|
163
164
|
const itemAction = typeof itemHandler === 'function'
|
|
164
|
-
? () => itemHandler(configItem, itemParams)
|
|
165
|
+
? () => itemHandler(configItem, itemParams, itemState)
|
|
165
166
|
: ((_a = this.getDropDownMenuItemConfig(item.id)) === null || _a === void 0 ? void 0 : _a.action) || (() => { });
|
|
166
167
|
return {
|
|
167
168
|
text: item.title || i18n(item.id),
|