@gravity-ui/dashkit 3.1.0 → 3.2.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 CHANGED
@@ -1,5 +1,12 @@
1
1
  # Changelog
2
2
 
3
+ ## [3.2.0](https://github.com/gravity-ui/dashkit/compare/v3.1.0...v3.2.0) (2022-10-27)
4
+
5
+
6
+ ### Features
7
+
8
+ * add item params to edit menu item handler ([#22](https://github.com/gravity-ui/dashkit/issues/22)) ([f220322](https://github.com/gravity-ui/dashkit/commit/f2203224699a3b5ab3e9915ed236736009dfb27a))
9
+
3
10
  ## [3.1.0](https://github.com/gravity-ui/dashkit/compare/v3.0.2...v3.1.0) (2022-10-27)
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 } from '../../shared';
3
+ import { ConfigItem, PluginBase, StringParams } from '../../shared';
4
4
  export declare enum OverlayControlsPosition {
5
5
  TopRight = "top_right",
6
6
  TopLeft = "top_left",
@@ -21,7 +21,7 @@ export interface OverlayCustomControlItem {
21
21
  title?: string;
22
22
  icon?: MenuItemProps['icon'];
23
23
  iconSize?: number | string;
24
- handler?: (item: ConfigItem) => void;
24
+ handler?: (item: ConfigItem, params: StringParams) => void;
25
25
  visible?: (item: ConfigItem) => boolean;
26
26
  className?: string;
27
27
  }
@@ -144,6 +144,9 @@ class OverlayControls extends react_1.default.Component {
144
144
  renderDropdownMenu() {
145
145
  const { view, size } = this.props;
146
146
  const { registerManager } = this.context;
147
+ const itemsParams = this.context.itemsParams;
148
+ const configItem = this.props.configItem;
149
+ const itemParams = itemsParams[configItem.id];
147
150
  let menu = registerManager.settings.menu;
148
151
  if (!menu.length) {
149
152
  menu = DEFAULT_DROPDOWN_MENU;
@@ -157,12 +160,12 @@ class OverlayControls extends react_1.default.Component {
157
160
  return null;
158
161
  }
159
162
  // custom menu dropdown item filter
160
- if (item.visible && !item.visible(this.props.configItem)) {
163
+ if (item.visible && !item.visible(configItem)) {
161
164
  return null;
162
165
  }
163
166
  const itemHandler = item.handler;
164
167
  const itemAction = typeof itemHandler === 'function'
165
- ? () => itemHandler(this.props.configItem)
168
+ ? () => itemHandler(configItem, itemParams)
166
169
  : ((_a = this.getDropDownMenuItemConfig(item.id)) === null || _a === void 0 ? void 0 : _a.action) || (() => { });
167
170
  return {
168
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 } from '../../shared';
3
+ import { ConfigItem, PluginBase, StringParams } from '../../shared';
4
4
  import './OverlayControls.css';
5
5
  export declare enum OverlayControlsPosition {
6
6
  TopRight = "top_right",
@@ -22,7 +22,7 @@ export interface OverlayCustomControlItem {
22
22
  title?: string;
23
23
  icon?: MenuItemProps['icon'];
24
24
  iconSize?: number | string;
25
- handler?: (item: ConfigItem) => void;
25
+ handler?: (item: ConfigItem, params: StringParams) => void;
26
26
  visible?: (item: ConfigItem) => boolean;
27
27
  className?: string;
28
28
  }
@@ -141,6 +141,9 @@ class OverlayControls extends React.Component {
141
141
  renderDropdownMenu() {
142
142
  const { view, size } = this.props;
143
143
  const { registerManager } = this.context;
144
+ const itemsParams = this.context.itemsParams;
145
+ const configItem = this.props.configItem;
146
+ const itemParams = itemsParams[configItem.id];
144
147
  let menu = registerManager.settings.menu;
145
148
  if (!menu.length) {
146
149
  menu = DEFAULT_DROPDOWN_MENU;
@@ -154,12 +157,12 @@ class OverlayControls extends React.Component {
154
157
  return null;
155
158
  }
156
159
  // custom menu dropdown item filter
157
- if (item.visible && !item.visible(this.props.configItem)) {
160
+ if (item.visible && !item.visible(configItem)) {
158
161
  return null;
159
162
  }
160
163
  const itemHandler = item.handler;
161
164
  const itemAction = typeof itemHandler === 'function'
162
- ? () => itemHandler(this.props.configItem)
165
+ ? () => itemHandler(configItem, itemParams)
163
166
  : ((_a = this.getDropDownMenuItemConfig(item.id)) === null || _a === void 0 ? void 0 : _a.action) || (() => { });
164
167
  return {
165
168
  text: item.title || i18n(item.id),
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@gravity-ui/dashkit",
3
- "version": "3.1.0",
3
+ "version": "3.2.0",
4
4
  "description": "Library for rendering dashboard grid layout",
5
5
  "license": "MIT",
6
6
  "repository": {