feat: CRUD 的 filterTogglable 支持配置文案和图标 Close: #7089 #7181
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 5881ca2
This pull request improves the usability and customization of the CRUD component's filter toggle feature. It adds documentation and code examples for the
filterTogglable
property indocs/zh-CN/components/crud.md
. It also adds support for custom labels and icons for the filter toggle button inpackages/amis/src/renderers/CRUD.tsx
.🤖 Generated by Copilot at 5881ca2
Why
Close: #7089
How
🤖 Generated by Copilot at 5881ca2
filterTogglable
property of the CRUD component, showing how to customize the label, icon, and active state of the filter toggle button (link, link)generateIcon
function fromamis-core
and theisPlainObject
function fromlodash
in the CRUD renderer, which are used to render and check the custom icon and label properties (link, link)filterTogglable
property of the CRUD component, changing it fromboolean
toboolean | {label?: string; icon?: string; activeLabel?: string; activeIcon?: string;}
(link)store.filterTogggable
tostore.filterTogglable
(link)filterTogglable
property to the props destructuring in therenderFilterToggler
method of the CRUD renderer, and assign the custom label and icon properties to a local variable, with fallbacks to the default values (link)renderFilterToggler
method of the CRUD renderer, which checks if thefilterTogglable
property is an object or a boolean, and handles the active state of the filter toggle button by switching the icon and label properties accordingly (link)renderFilterToggler
method of the CRUD renderer, using thegenerateIcon
function to render the custom icon if provided, or the default icon if not explicitly set to false, and rendering the custom label if provided, or the default label otherwise (link)