优化状态容器配置 & listSelect自定义label value适配 #8663
Merged
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
What
🤖 Generated by Copilot at 2c140f6
This pull request enhances the AMIS editor plugins for list controls and switch containers, and fixes some bugs related to them. It introduces a new
getSubEditorVariable
function to support dynamic variables based on the schema, and adds some new options and validations to the plugins. It also fixes a bug in theSwitchContainer
renderer that caused the active index to be reset when the items array was empty.🤖 Generated by Copilot at 2c140f6
Why
How
🤖 Generated by Copilot at 2c140f6
subEditorVariable
property of theRendererInfo
interface and theBasePlugin
class to a functiongetSubEditorVariable
that takes an optional schema argument and returns an array of custom variables for the sub-editor. This allows the sub-editor variables to be dynamically generated based on the schema of the host node. (link, link)resolveVariablesFromScope
function inutil.ts
to use thegetSubEditorVariable
function of the host node info instead of thesubEditorVariable
property. This allows the variables to be resolved based on the schema of the host node. (link)getSubEditorVariable
function in theListControlPlugin
class inListSelect.tsx
to return the label and value fields of the current option based on the schema of the list select control. (link)ListControlPlugin
class inListSelect.tsx
where the option label was not displayed correctly when the value was an object. Use thedata
variable instead of thevalue
variable in the template of the option label. (link)getDisplayField
function in theListControlPlugin
class inListSelect.tsx
. Return the label field of the data or the default 'label' field. Remove the unnecessary logic for handling the source and map properties of the data, which are not relevant for the list select control. (link)minLength
property to theitems
field of the schema in theSwitchContainerPlugin
class inSwitchContainer.tsx
. This property specifies the minimum number of items that the switch container should have. This is used to prevent deleting items below the minimum length in the sub-editor. (link)theme:base
schema template to thetheme
field of the schema in theSwitchContainerPlugin
class inSwitchContainer.tsx
. This template provides some common theme properties for the switch container, such as collapsed and extra. (link)theme-cssCode
type to the schema in theSwitchContainerPlugin
class inSwitchContainer.tsx
. This type allows the user to customize the CSS style of the switch container using a code editor. (link)toast
function fromamis
inListItemControl.tsx
. This function is used to show a warning message when the user tries to delete an item below the minimum length in the sub-editor. (link)api
property of theOptionControlState
interface and theOptionControl
class inListItemControl.tsx
. Use thesource
property of the data instead. (link, link)minLength
property of the props before deleting an item in thehandleDelete
function of theOptionControl
class inListItemControl.tsx
. If the minimum length is greater than zero and the items length is equal or less than the minimum length, show a warning message using thetoast
function and return without deleting the item. This prevents deleting items below the minimum length in the sub-editor. (link)