-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
chore: reworked contexts js files into ts
- Loading branch information
Showing
18 changed files
with
191 additions
and
94 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,79 @@ | ||
import React from 'react'; | ||
|
||
import type {RegisterManager} from '..//utils'; | ||
import type {DashKitProps} from '../components/DashKit'; | ||
import type { | ||
ConfigItem, | ||
ConfigLayout, | ||
ItemParams, | ||
ItemState, | ||
ItemStateAndParams, | ||
ItemStateAndParamsChangeOptions, | ||
} from '../shared'; | ||
|
||
type DashkitPropsPassedToCtx = Pick< | ||
DashKitProps, | ||
| 'config' | ||
| 'groups' | ||
| 'context' | ||
| 'noOverlay' | ||
| 'focusable' | ||
| 'globalParams' | ||
| 'editMode' | ||
| 'settings' | ||
| 'onItemMountChange' | ||
| 'onItemRender' | ||
| 'draggableHandleClassName' | ||
// default handlers bypass | ||
| 'onDragStart' | ||
| 'onDrag' | ||
| 'onDragStop' | ||
| 'onResizeStart' | ||
| 'onResize' | ||
| 'onResizeStop' | ||
>; | ||
|
||
type PluginType = string; | ||
|
||
export type DashKitCtxShape = DashkitPropsPassedToCtx & { | ||
registerManager: RegisterManager; | ||
forwardedMetaRef: React.ForwardedRef<any>; | ||
|
||
layout: ConfigLayout[]; | ||
temporaryLayout: ConfigLayout[] | null; | ||
memorizeOriginalLayout: ( | ||
widgetId: string, | ||
preAutoHeightLayout: ConfigLayout, | ||
postAutoHeightLayout: ConfigLayout, | ||
) => void; | ||
revertToOriginalLayout: (widgetId: string) => void; | ||
|
||
itemsState?: Record<string, ItemState>; | ||
itemsParams: Record<string, ItemParams>; | ||
onItemStateAndParamsChange: ( | ||
id: string, | ||
stateAndParams: ItemStateAndParams, | ||
options: ItemStateAndParamsChangeOptions, | ||
) => void; | ||
|
||
getItemsMeta: (pluginsRefs: Array<React.RefObject<any>>) => Array<Promise<any>>; | ||
reloadItems: ( | ||
pluginsRefs: Array<React.RefObject<any>>, | ||
data: {silentLoading: boolean; noVeil: boolean}, | ||
) => void; | ||
|
||
onDrop: (newLayout: ConfigLayout, item: ConfigItem) => void; | ||
onDropDragOver: ( | ||
e: DragEvent | MouseEvent, | ||
group: string | void, | ||
gridProps: Partial<ReactGridLayout.ReactGridLayoutProps>, | ||
groupLayout: ConfigLayout[], | ||
sharedItem: (Partial<ConfigLayout> & {type: PluginType}) | void, | ||
) => void | boolean; | ||
outerDnDEnable: boolean; | ||
dragOverPlugin: null | PluginType; | ||
}; | ||
|
||
const DashKitContext = React.createContext<DashKitCtxShape>({} as DashKitCtxShape); | ||
|
||
export {DashKitContext}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
import React from 'react'; | ||
|
||
import type {DraggedOverItem, ItemDragProps} from '../shared/types'; | ||
|
||
export type DashKitDnDCtxShape = { | ||
dragProps: ItemDragProps | null; | ||
dragImagePreview: HTMLImageElement; | ||
onDragStart: (e: React.DragEvent<Element>, itemDragProps: ItemDragProps) => void; | ||
onDragEnd: (e: React.DragEvent<Element>) => void; | ||
onDropDragOver?: ( | ||
draggedItem: DraggedOverItem, | ||
sharedItem: DraggedOverItem | null, | ||
) => void | boolean; | ||
}; | ||
|
||
export const DashKitDnDContext = React.createContext<DashKitDnDCtxShape | void>(undefined); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
import React from 'react'; | ||
|
||
import type {DashKitProps} from '../components'; | ||
import type {ConfigLayout, ItemParams, ItemState} from '../shared'; | ||
import type {MenuItem} from '../typings'; | ||
|
||
export type OverlayControlsCtxShape = Pick< | ||
DashKitProps, | ||
| 'context' | ||
| 'overlayControls' | ||
| 'itemsStateAndParams' | ||
| 'getPreparedCopyItemOptions' | ||
| 'onCopyFulfill' | ||
> & { | ||
menu: DashKitProps['overlayMenuItems'] | MenuItem[]; | ||
itemsState?: Record<string, ItemState>; | ||
itemsParams: Record<string, ItemParams>; | ||
|
||
editItem: DashKitProps['onItemEdit']; | ||
removeItem: (id: string) => void; | ||
getLayoutItem: (id: string) => ConfigLayout | void; | ||
}; | ||
|
||
export const DashkitOvelayControlsContext = React.createContext<OverlayControlsCtxShape | void>( | ||
undefined, | ||
); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
export * from './DashKitContext'; | ||
export * from './DashkitOverlayControlsContext'; | ||
export * from './DashKitDnDContext'; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.