@gravity-ui/dashkit 8.1.0-beta.5 → 8.1.0-beta.7

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.
@@ -9,7 +9,7 @@ const cn_1 = require("../../utils/cn");
9
9
  const b = (0, cn_1.cn)('dashkit-action-panel');
10
10
  const ActionPanelItemContainer = ({ item }) => {
11
11
  const dndProps = (0, useDnDItemProps_1.useDnDItemProps)(item);
12
- return (react_1.default.createElement("div", Object.assign({ role: "button", className: b('item', { draggable: Boolean(dndProps) }, item.className), key: `dk-action-panel-${item.id}`, onClick: item.onClick, "data-qa": item.qa }, dndProps),
12
+ return (react_1.default.createElement("div", Object.assign({ role: "button", className: b('item', { draggable: Boolean(dndProps) }, item.className), onClick: item.onClick, "data-qa": item.qa }, dndProps),
13
13
  react_1.default.createElement("div", { className: b('icon') }, item.icon),
14
14
  react_1.default.createElement("div", { className: b('title'), title: item.title }, item.title)));
15
15
  };
@@ -19,7 +19,7 @@ const ActionPanel = (props) => {
19
19
  const isDisabled = (_a = props.disable) !== null && _a !== void 0 ? _a : false;
20
20
  const isAnimated = (_b = props.toggleAnimation) !== null && _b !== void 0 ? _b : false;
21
21
  const nodeRef = react_1.default.useRef(null);
22
- const content = (react_1.default.createElement("div", { ref: nodeRef, className: b(null, props.className) }, props.items.map((item, i) => (react_1.default.createElement(exports.ActionPanelItemContainer, { key: `item_${i}`, item: item })))));
22
+ const content = (react_1.default.createElement("div", { ref: nodeRef, className: b(null, props.className) }, props.items.map((item) => (react_1.default.createElement(exports.ActionPanelItemContainer, { key: `dk-action-panel-${item.id}`, item: item })))));
23
23
  if (isAnimated) {
24
24
  return (react_1.default.createElement(react_transition_group_1.CSSTransition, { in: !isDisabled, nodeRef: nodeRef, classNames: b(null), timeout: 300, unmountOnExit: true }, content));
25
25
  }
@@ -1,5 +1,5 @@
1
1
  import React from 'react';
2
- import type { Config, ConfigItem, ConfigLayout, GlobalParams, ItemDragProps, ItemsStateAndParams } from '../../shared';
2
+ import type { Config, ConfigItem, GlobalParams, ItemDropProps, ItemsStateAndParams } from '../../shared';
3
3
  import { ContextProps, Plugin, SetConfigItem, SetNewItemOptions, Settings, SettingsProps } from '../../typings';
4
4
  import GridLayout from '../GridLayout/GridLayout';
5
5
  import { OverlayControlItem } from '../OverlayControls/OverlayControls';
@@ -15,12 +15,7 @@ interface DashKitDefaultProps {
15
15
  config: Config;
16
16
  itemsStateAndParams: ItemsStateAndParams;
17
17
  }) => void;
18
- onDrop: (dropProps: {
19
- commit: () => void;
20
- dragProps: ItemDragProps;
21
- itemLayout: ConfigLayout;
22
- newLayout: ConfigLayout[];
23
- }) => void;
18
+ onDrop: (dropProps: ItemDropProps) => void;
24
19
  defaultGlobalParams: GlobalParams;
25
20
  globalParams: GlobalParams;
26
21
  itemsStateAndParams: ItemsStateAndParams;
@@ -1,6 +1,9 @@
1
1
  import React from 'react';
2
+ import type { ItemDragProps } from '../../shared';
2
3
  type DashKitDnDWrapperProps = {
3
4
  dragImageSrc?: string;
5
+ onDragStart?: (dragProps: ItemDragProps) => void;
6
+ onDragEnd?: () => void;
4
7
  children: React.ReactElement;
5
8
  };
6
9
  export declare const DashKitDnDWrapper: React.FC<DashKitDnDWrapperProps>;
@@ -8,16 +8,20 @@ const defaultImageSrc = 'data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAEAAAABC
8
8
  const DashKitDnDWrapper = (props) => {
9
9
  const [dragProps, setDragProps] = react_1.default.useState(null);
10
10
  const dragImagePreview = react_1.default.useMemo(() => {
11
- const img = new Image(1, 1);
11
+ const img = new Image();
12
12
  img.src = props.dragImageSrc || defaultImageSrc;
13
13
  return img;
14
- }, [props]);
15
- const onDragStart = react_1.default.useCallback((_, currentProps) => {
16
- setDragProps(currentProps);
17
- }, [setDragProps]);
14
+ }, [props.dragImageSrc]);
15
+ const onDragStart = react_1.default.useCallback((_, itemDragProps) => {
16
+ var _a;
17
+ setDragProps(itemDragProps);
18
+ (_a = props.onDragStart) === null || _a === void 0 ? void 0 : _a.call(props, itemDragProps);
19
+ }, [setDragProps, props.onDragStart]);
18
20
  const onDragEnd = react_1.default.useCallback((_) => {
21
+ var _a;
19
22
  setDragProps(null);
20
- }, [setDragProps]);
23
+ (_a = props.onDragEnd) === null || _a === void 0 ? void 0 : _a.call(props);
24
+ }, [setDragProps, props.onDragEnd]);
21
25
  const contextValue = react_1.default.useMemo(() => {
22
26
  return {
23
27
  dragProps,
@@ -1,3 +1,4 @@
1
+ import { ConfigLayout } from './config';
1
2
  export type Dictionary<T = unknown> = Record<string, T>;
2
3
  export interface StringParams extends Dictionary<string | string[]> {
3
4
  }
@@ -9,4 +10,11 @@ export type ItemDragProps = {
9
10
  w?: number;
10
11
  h?: number;
11
12
  };
13
+ extra?: any;
14
+ };
15
+ export type ItemDropProps = {
16
+ commit: () => void;
17
+ dragProps: ItemDragProps;
18
+ itemLayout: ConfigLayout;
19
+ newLayout: ConfigLayout[];
12
20
  };
@@ -6,7 +6,7 @@ import './ActionPanel.css';
6
6
  const b = cn('dashkit-action-panel');
7
7
  export const ActionPanelItemContainer = ({ item }) => {
8
8
  const dndProps = useDnDItemProps(item);
9
- return (React.createElement("div", Object.assign({ role: "button", className: b('item', { draggable: Boolean(dndProps) }, item.className), key: `dk-action-panel-${item.id}`, onClick: item.onClick, "data-qa": item.qa }, dndProps),
9
+ return (React.createElement("div", Object.assign({ role: "button", className: b('item', { draggable: Boolean(dndProps) }, item.className), onClick: item.onClick, "data-qa": item.qa }, dndProps),
10
10
  React.createElement("div", { className: b('icon') }, item.icon),
11
11
  React.createElement("div", { className: b('title'), title: item.title }, item.title)));
12
12
  };
@@ -15,7 +15,7 @@ export const ActionPanel = (props) => {
15
15
  const isDisabled = (_a = props.disable) !== null && _a !== void 0 ? _a : false;
16
16
  const isAnimated = (_b = props.toggleAnimation) !== null && _b !== void 0 ? _b : false;
17
17
  const nodeRef = React.useRef(null);
18
- const content = (React.createElement("div", { ref: nodeRef, className: b(null, props.className) }, props.items.map((item, i) => (React.createElement(ActionPanelItemContainer, { key: `item_${i}`, item: item })))));
18
+ const content = (React.createElement("div", { ref: nodeRef, className: b(null, props.className) }, props.items.map((item) => (React.createElement(ActionPanelItemContainer, { key: `dk-action-panel-${item.id}`, item: item })))));
19
19
  if (isAnimated) {
20
20
  return (React.createElement(CSSTransition, { in: !isDisabled, nodeRef: nodeRef, classNames: b(null), timeout: 300, unmountOnExit: true }, content));
21
21
  }
@@ -1,5 +1,5 @@
1
1
  import React from 'react';
2
- import type { Config, ConfigItem, ConfigLayout, GlobalParams, ItemDragProps, ItemsStateAndParams } from '../../shared';
2
+ import type { Config, ConfigItem, GlobalParams, ItemDropProps, ItemsStateAndParams } from '../../shared';
3
3
  import { ContextProps, Plugin, SetConfigItem, SetNewItemOptions, Settings, SettingsProps } from '../../typings';
4
4
  import GridLayout from '../GridLayout/GridLayout';
5
5
  import { OverlayControlItem } from '../OverlayControls/OverlayControls';
@@ -15,12 +15,7 @@ interface DashKitDefaultProps {
15
15
  config: Config;
16
16
  itemsStateAndParams: ItemsStateAndParams;
17
17
  }) => void;
18
- onDrop: (dropProps: {
19
- commit: () => void;
20
- dragProps: ItemDragProps;
21
- itemLayout: ConfigLayout;
22
- newLayout: ConfigLayout[];
23
- }) => void;
18
+ onDrop: (dropProps: ItemDropProps) => void;
24
19
  defaultGlobalParams: GlobalParams;
25
20
  globalParams: GlobalParams;
26
21
  itemsStateAndParams: ItemsStateAndParams;
@@ -1,6 +1,9 @@
1
1
  import React from 'react';
2
+ import type { ItemDragProps } from '../../shared';
2
3
  type DashKitDnDWrapperProps = {
3
4
  dragImageSrc?: string;
5
+ onDragStart?: (dragProps: ItemDragProps) => void;
6
+ onDragEnd?: () => void;
4
7
  children: React.ReactElement;
5
8
  };
6
9
  export declare const DashKitDnDWrapper: React.FC<DashKitDnDWrapperProps>;
@@ -4,16 +4,20 @@ const defaultImageSrc = 'data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAEAAAABC
4
4
  export const DashKitDnDWrapper = (props) => {
5
5
  const [dragProps, setDragProps] = React.useState(null);
6
6
  const dragImagePreview = React.useMemo(() => {
7
- const img = new Image(1, 1);
7
+ const img = new Image();
8
8
  img.src = props.dragImageSrc || defaultImageSrc;
9
9
  return img;
10
- }, [props]);
11
- const onDragStart = React.useCallback((_, currentProps) => {
12
- setDragProps(currentProps);
13
- }, [setDragProps]);
10
+ }, [props.dragImageSrc]);
11
+ const onDragStart = React.useCallback((_, itemDragProps) => {
12
+ var _a;
13
+ setDragProps(itemDragProps);
14
+ (_a = props.onDragStart) === null || _a === void 0 ? void 0 : _a.call(props, itemDragProps);
15
+ }, [setDragProps, props.onDragStart]);
14
16
  const onDragEnd = React.useCallback((_) => {
17
+ var _a;
15
18
  setDragProps(null);
16
- }, [setDragProps]);
19
+ (_a = props.onDragEnd) === null || _a === void 0 ? void 0 : _a.call(props);
20
+ }, [setDragProps, props.onDragEnd]);
17
21
  const contextValue = React.useMemo(() => {
18
22
  return {
19
23
  dragProps,
@@ -1,3 +1,4 @@
1
+ import { ConfigLayout } from './config';
1
2
  export type Dictionary<T = unknown> = Record<string, T>;
2
3
  export interface StringParams extends Dictionary<string | string[]> {
3
4
  }
@@ -9,4 +10,11 @@ export type ItemDragProps = {
9
10
  w?: number;
10
11
  h?: number;
11
12
  };
13
+ extra?: any;
14
+ };
15
+ export type ItemDropProps = {
16
+ commit: () => void;
17
+ dragProps: ItemDragProps;
18
+ itemLayout: ConfigLayout;
19
+ newLayout: ConfigLayout[];
12
20
  };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@gravity-ui/dashkit",
3
- "version": "8.1.0-beta.5",
3
+ "version": "8.1.0-beta.7",
4
4
  "description": "Library for rendering dashboard grid layout",
5
5
  "license": "MIT",
6
6
  "repository": {