feat: update VariableFilters to use CardItem and enhance form handling

This commit is contained in:
Sheldon Guo 2025-03-11 09:38:42 +08:00
parent 3f6cae33ec
commit b271f0cbc3

View File

@ -122,14 +122,20 @@ export function Filter({ config, filter, filterId, previousFilters }) {
}, },
}; };
}; };
const argsMap = config.uiSchema
? Object.fromEntries(config.uiSchema.map((param, index) => [param.name, filter.args[index]]))
: {};
const useFormBlockProps = () => { const useFormBlockProps = () => {
return { form, layout: 'vertical' }; return { form: createForm({ initialValues: argsMap }), layout: 'vertical' };
}; };
const WithPropOver = ({ children }) => {
const { value } = useVariable();
const schema = { const schema = {
'x-uid': uid(),
type: 'void',
'x-component': 'CardItem',
properties: {
form: {
'x-uid': uid(), 'x-uid': uid(),
type: 'void', type: 'void',
'x-component': 'FormV2', 'x-component': 'FormV2',
@ -186,20 +192,22 @@ export function Filter({ config, filter, filterId, previousFilters }) {
}, },
}, },
}, },
},
},
}; };
return ( const Content = (
<Popover
open={open}
onOpenChange={handleOpenChange}
content={
<SchemaComponent <SchemaComponent
schema={schema} schema={schema}
scope={{ useSaveActionProps, useFormBlockProps, useDeleteActionProps, outputValue, inputValue }} scope={{ useSaveActionProps, useFormBlockProps, useDeleteActionProps, outputValue, inputValue }}
basePath={['']} basePath={['']}
/> />
} );
trigger={'hover'}
> const WithPropOver = ({ children }) => {
const { value } = useVariable();
return (
<Popover open={open} onOpenChange={handleOpenChange} content={Content} trigger={'click'}>
{children} {children}
</Popover> </Popover>
); );