Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 2 additions & 5 deletions src/components/DashKitView/DashKitView.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -2,20 +2,17 @@ import React from 'react';

import {DashKitContext} from '../../context';
import {withContext} from '../../hocs/withContext';
import type {DashKitWithContextProps} from '../../hocs/withContext';
import {useCalcPropsLayout} from '../../hooks/useCalcLayout';
import type {RegisterManager} from '../../utils';
import {cn} from '../../utils/cn';
import type {DashKitProps} from '../DashKit';
import GridLayout from '../GridLayout/GridLayout';
import MobileLayout from '../MobileLayout/MobileLayout';

import './DashKitView.scss';

const b = cn('dashkit');

type DashKitViewProps = DashKitProps & {
registerManager: RegisterManager;
};
type DashKitViewProps = Omit<DashKitWithContextProps, 'layout' | 'forwardedMetaRef'>;

function DashKitView() {
const context = React.useContext(DashKitContext);
Expand Down
4 changes: 2 additions & 2 deletions src/components/GridLayout/GridLayout.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ import {
} from '../../constants';
import {DashKitContext} from '../../context';
import type {DashKitCtxShape} from '../../context';
import type {ConfigItem, ConfigLayout} from '../../shared';
import type {ConfigItem, ConfigLayout, DraggedOverItem} from '../../shared';
import {resolveLayoutGroup} from '../../utils';
import GridItem from '../GridItem/GridItem';

Expand Down Expand Up @@ -682,7 +682,7 @@ export default class GridLayout extends React.PureComponent<GridLayoutProps, Gri
if (currentDraggingElement) {
const {h, w, i} = currentDraggingElement.layoutItem;
const {type} = currentDraggingElement.item;
const sharedItem = {
const sharedItem: DraggedOverItem = {
h,
w,
i,
Expand Down
21 changes: 11 additions & 10 deletions src/context/DashKitContext.ts
Original file line number Diff line number Diff line change
@@ -1,10 +1,13 @@
import React from 'react';

import type {RegisterManager} from '..//utils';
import type {DragOverEvent} from 'react-grid-layout';

import type {RegisterManager, RegisterManagerPlugin} from '..//utils';
import type {DashKitProps} from '../components/DashKit';
import type {
ConfigItem,
ConfigLayout,
DraggedOverItem,
ItemDragProps,
ItemParams,
ItemState,
Expand Down Expand Up @@ -35,9 +38,7 @@ type DashkitPropsPassedToCtx = Pick<
| 'onResizeStop'
>;

type PluginType = string;

type TemporaryLayout = {
export type TemporaryLayout = {
data: ConfigLayout[];
dragProps: ItemDragProps;
};
Expand Down Expand Up @@ -76,16 +77,16 @@ export type DashKitCtxShape = Omit<DashkitPropsPassedToCtx, 'context' | 'setting

onDrop: (newLayout: ConfigLayout[], item: ConfigLayout, e?: MouseEvent) => void;
onDropDragOver: (
e: DragEvent | MouseEvent,
group: string | void,
e: DragOverEvent,
group: string | undefined,
gridProps: ReactGridLayoutProps,
groupLayout: ConfigLayout[],
sharedItem: (Partial<ConfigLayout> & {type: PluginType}) | void,
sharedItem?: DraggedOverItem,
) => {w?: number; h?: number} | false | undefined;
onItemBlur: (item: ConfigItem) => void;
onItemFocus: (item: ConfigItem) => void;
onItemBlur?: (item: ConfigItem) => void;
onItemFocus?: (item: ConfigItem) => void;
outerDnDEnable: boolean;
dragOverPlugin: null | PluginType;
dragOverPlugin: null | RegisterManagerPlugin;
};

const DashKitContext = React.createContext<DashKitCtxShape>({} as DashKitCtxShape);
Expand Down
Loading
Loading