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 = () => {
return { form, layout: 'vertical' };
return { form: createForm({ initialValues: argsMap }), layout: 'vertical' };
};
const WithPropOver = ({ children }) => {
const { value } = useVariable();
const schema = {
'x-uid': uid(),
type: 'void',
'x-component': 'CardItem',
properties: {
form: {
'x-uid': uid(),
type: 'void',
'x-component': 'FormV2',
@ -186,20 +192,22 @@ export function Filter({ config, filter, filterId, previousFilters }) {
},
},
},
},
},
};
return (
<Popover
open={open}
onOpenChange={handleOpenChange}
content={
const Content = (
<SchemaComponent
schema={schema}
scope={{ useSaveActionProps, useFormBlockProps, useDeleteActionProps, outputValue, inputValue }}
basePath={['']}
/>
}
trigger={'hover'}
>
);
const WithPropOver = ({ children }) => {
const { value } = useVariable();
return (
<Popover open={open} onOpenChange={handleOpenChange} content={Content} trigger={'click'}>
{children}
</Popover>
);