import { isValid, useFieldSchema } from "@tachybase/schema";
import { useSchemaToolbar } from "../../../application/index.mjs";
import { SchemaSettings } from "../../../application/schema-settings/SchemaSettings.mjs";
import { AfterSuccess, AssignedFieldValues, ButtonEditor, RemoveButton, SecondConFirm, SkipValidation, WorkflowConfig } from "../../../schema-component/antd/action/Action.Designer.mjs";
const customizeSaveRecordActionSettings = new SchemaSettings({
    name: 'actionSettings:saveRecord',
    items: [
        {
            name: 'editButton',
            Component: ButtonEditor,
            useComponentProps () {
                const { buttonEditorProps } = useSchemaToolbar();
                return buttonEditorProps;
            }
        },
        {
            name: 'secondConfirmation',
            Component: SecondConFirm
        },
        {
            name: 'assignFieldValues',
            Component: AssignedFieldValues
        },
        {
            name: 'skipRequiredValidation',
            Component: SkipValidation
        },
        {
            name: 'afterSuccessfulSubmission',
            Component: AfterSuccess,
            useVisible () {
                var _fieldSchema_xactionsettings;
                const fieldSchema = useFieldSchema();
                return isValid(null == fieldSchema ? void 0 : null == (_fieldSchema_xactionsettings = fieldSchema['x-action-settings']) ? void 0 : _fieldSchema_xactionsettings.onSuccess);
            }
        },
        {
            name: 'bindWorkflow',
            Component: WorkflowConfig
        },
        {
            name: 'delete',
            sort: 100,
            Component: RemoveButton,
            useComponentProps () {
                const { removeButtonProps } = useSchemaToolbar();
                return removeButtonProps;
            }
        }
    ]
});
export { customizeSaveRecordActionSettings };
