The left component supports synchronous import or asynchronous import.
If you need to import components asynchronously, you need to fill in urlfn and a function that returns promise. Remote loading of components can also be supported, as long as webpack is equipped with it.
If you need to import components synchronously, you need to put the components into the initcomponentcache of the configuration item, so that they will be registered in the componentregister when loaded.
The first parameter is the component registration name, and the second parameter is used to display the usage.
The third parameter is used to configure the configuration item component of the right panel. The key is the classification of the right panel, and the value is the configuration item component array.
The fourth parameter will configure the initial value of the component. In particular, the manufacturing component must have the initial width and height (not supported by the content), otherwise there will be problems when selecting all during adaptation.
There are many useful properties in this initial value. For example, fixed represents fixed positioning. You can change this value in combination with configuration items to make the component fixed positioning.
And candrag is similar to the lock command. Locked elements cannot be dragged.
The rotate in the initial value needs an object. Value represents the rotation angle and canrotate represents whether the rotation can be operated. (supported from version 0.7.0)
The fifth parameter is a function. You will get the configuration from the receive attribute in the configuration item (the default configuration is receive for the time being). For example, if the received in the above example is text, the field will be received in the data in the function.
The sixth parameter resize is to judge whether scaling can be performed. When it is false, scaling cannot be performed.
The seventh parameter is needposition. After some components are moved into the canvas, the drop point will be adopted by default. This configuration item is true by default, which is the position to be dragged. When it is false, the top and left positioning of the components will be used to place them.
The first parameter of usedynamicaddevencenter is an object composed of four parameters of render. The second parameter is the registered time name, which must be related to the ID, which is a convention. Otherwise, multiple components may cause name conflicts, and it is convenient to find the time.
After registering the timing, you need to put the timing into the corresponding trigger position. For example, the click execution timing of this button is put into onclick:
The function is thrown by the component and can be loaded into the event chain. For example, if I register a function to change the text, I can call the function at the time of any component, so as to trigger the component to change the text.
Function registration needs to be put into useeffect. At present, there is no need to uninstall actively, but when communicating with the function on the pop-up window, you may need to uninstall in the preview environment, otherwise the second execution may not take effect.
Note that the ID should be accompanied by the component ID, because a component can drag n components to generate n functions.
See later function development for parameters and configuration in the function.
### Right side panel
The configuration of the right panel is the same as that of the left panel:
Type will affect the key name of the third parameter of the left component during development. The key name represents the type displayed on the right.
Icon can put text or icons for panel switching.
If custom is true, the display under this panel can be customized through customrender.
### Right side assembly
#### Right side component import
When importing, just match the developed components into an object and put it into initformcomponents.
The generics of the createpaneloptions function are filled with the corresponding components, which will give a good prompt to the received configuration items.
All you need to do in the configuration item component is to receive the configuration item from the component, and then modify the property of current:
```js
function MInput(props: MInputProps) {
const option = useMemo(() => {
return props.data?.option || {};
}, [props.data]);
return (
<Rowstyle={{padding:'10px20px'}}>
<Colspan={6}style={{lineHeight:'30px'}}>
{(option as any)?.label || '文字'}:
</Col>
<Colspan={18}>
<Input
value={props.current.props[(option as any).receive] || ''}
The second parameter is the shortcut key name, and the shortcut key mapping is the key value of the keyboard event
The case of 26 English letters is ignored. At present, only one shortcut key can be registered for a command. If you do not need to register shortcut keys, you can fill in the blank string.
At present, the third parameter can only get store, which needs to be modified later. The second parameter in version 0.2.0 can obtain config. At the same time, the commander does not export from the index. If necessary, it can be obtained from config.