forked from codebdy/rxdrag
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request codebdy#85 from rxdrag/next
Next
- Loading branch information
Showing
181 changed files
with
6,639 additions
and
1,385 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,7 @@ | ||
Reaction editor,Reaction的svg图标如果有多个path,那么每个path要加key | ||
|
||
Context 下发 reaction,能保证列表里的控件能拿到唯一id的reaction | ||
Context 下发 reaction,能保证列表里的控件能拿到唯一id的reaction | ||
|
||
可以进一步简化属性面板的schema,现在的还是太罗嗦 OK | ||
|
||
一个组件可以由多个部分组成,比如表格列由列头单元格跟body单元格组合而成,需要修改core以及plugin相关 |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,6 +1,6 @@ | ||
import { useDesignComponents } from "./useDesignComponents"; | ||
import { useDesignComponentsParams } from "./useDesignComponentsParams"; | ||
|
||
export function useDesignComponent(name?: string) { | ||
const {components} = useDesignComponents(); | ||
const {components} = useDesignComponentsParams(); | ||
return name ? (components[name] || name): null | ||
} |
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,8 @@ | ||
import { DesignComponentsContext, IDesignerComponentsParams } from "core-react/contexts"; | ||
import { useContext } from "react"; | ||
|
||
export function useDesignComponentsParams() { | ||
const params = useContext<IDesignerComponentsParams>(DesignComponentsContext) | ||
|
||
return params | ||
} |
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,12 @@ | ||
import { useCallback } from "react"; | ||
import { useDesignerEngine } from "./useDesignerEngine"; | ||
|
||
export function useGetElement(){ | ||
|
||
const engine = useDesignerEngine() | ||
const getElement = useCallback((rxId?:string)=>{ | ||
return rxId && engine?.getShell()?.getElement(rxId) | ||
}, [engine]) | ||
|
||
return getElement | ||
} |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,38 @@ | ||
import { ITreeNode, ID } from "core"; | ||
import { useCallback, useEffect, useState } from "react"; | ||
import { UnListener } from "runner/reaction"; | ||
import { useDesignerEngine } from "./useDesignerEngine"; | ||
|
||
export function useTreeNodes(ids: ID[]) { | ||
const [nodes, setNodes] = useState<(ITreeNode | null)[] | null>() | ||
const monitor = useDesignerEngine()?.getMonitor() | ||
const handleNodeChange = useCallback((nd: ITreeNode) => { | ||
setNodes(nodes => { | ||
if (nodes?.find(node => node?.id === nd.id)) { | ||
return nodes?.map(node => node?.id === nd.id ? nd : node) | ||
} | ||
return nodes; | ||
}) | ||
}, []) | ||
|
||
useEffect(() => { | ||
if (monitor) { | ||
const nds: (ITreeNode | null)[] = [] | ||
const offs: UnListener[] = [] | ||
for (const id of ids) { | ||
nds.push(monitor.getNode(id)) | ||
offs.push(monitor?.subscribeToNodeChanged(id, handleNodeChange)) | ||
} | ||
setNodes(nds) | ||
|
||
return () => { | ||
for (const off of offs) { | ||
off?.() | ||
} | ||
} | ||
} | ||
|
||
}, [handleNodeChange, ids, monitor]) | ||
|
||
return nodes | ||
} |
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 |
---|---|---|
@@ -1,31 +1,19 @@ | ||
import { IComponentConfig, IResource } from "core/interfaces"; | ||
import { ILocales } from "core/interfaces/loacales"; | ||
import React from "react"; | ||
import { IComponentConfig } from "core/interfaces"; | ||
import { ReactComponent } from "runner/ComponentRender/types"; | ||
|
||
//export type ReactComponent = React.FC<any> | React.ComponentClass<any> | ||
|
||
export interface IComponents { | ||
[key: string]: React.FC<any> | React.ComponentClass<any> | ||
[key: string]: ReactComponent | undefined | ||
} | ||
|
||
export interface IMaterialResource extends IResource { | ||
icon?: React.ReactElement, | ||
color?: string, | ||
resourceLocales?: ILocales, | ||
imageUrl?: string, | ||
} | ||
|
||
export interface IComponentMaterial extends IComponentConfig { | ||
packageName?: string //npm包名 生成代码用 | ||
component: React.FC<any> | React.ComponentClass<any>, | ||
designer: React.FC<any> | React.ComponentClass<any>, | ||
resource?: IMaterialResource, | ||
export interface IComponentMaterial extends IComponentConfig<ReactComponent> { | ||
//packageName?: string //npm包名 生成代码用 | ||
//resource?: IMaterialResource, | ||
//slots用到的组件,值为true时,用缺省组件DefaultSlot, string时,存的是已经注册过的component resource名字 | ||
slots?: { | ||
[name: string]: IComponentMaterial | true | string | undefined | ||
}, | ||
|
||
//控制器 | ||
controller?: { | ||
|
||
} | ||
// slots?: { | ||
// [name: string]: IComponentMaterial | true | string | 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,19 @@ | ||
import { forwardRef, memo, useCallback } from "react" | ||
import { ReactComponent } from "runner/ComponentRender/types" | ||
import { isFunction } from "lodash" | ||
|
||
type Callback = (element?: HTMLElement | null) => HTMLElement | undefined | null | ||
const defaultCallback = (element?: HTMLElement | null) => element | ||
|
||
export function switchRef(WrappedComponent: ReactComponent, callback: Callback = defaultCallback): ReactComponent { | ||
|
||
return memo(forwardRef<HTMLInputElement>((props: any, ref) => { | ||
const handleRefChange = useCallback((element: HTMLElement | null) => { | ||
if (isFunction(ref)) { | ||
ref(callback(element)) | ||
} | ||
}, [ref]) | ||
|
||
return <WrappedComponent ref={handleRefChange} {...props} /> | ||
})) | ||
} |
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,23 @@ | ||
import { forwardRef, memo, useLayoutEffect } from "react" | ||
import { ReactComponent } from "runner/ComponentRender/types" | ||
import { useNode } from "./hooks/useNode" | ||
import { isFunction } from "lodash" | ||
|
||
type Callback = (element?: HTMLElement | null) => HTMLElement | undefined | null | ||
const defaultCallback = (element?: HTMLElement | null) => element | ||
|
||
export function switchRefById(WrappedComponent: ReactComponent, callback: Callback = defaultCallback): ReactComponent { | ||
|
||
return memo(forwardRef<HTMLInputElement>((props: any, ref) => { | ||
const node = useNode() | ||
useLayoutEffect(() => { | ||
const element = node?.id ? document.getElementById(node?.id) : null | ||
if (isFunction(ref)) { | ||
ref(callback(element)) | ||
} | ||
|
||
}, [node?.id, ref]) | ||
|
||
return <WrappedComponent id={node?.id} {...props} /> | ||
})) | ||
} |
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.