magner
Version:
Universal admin panel magnetic to any backend
32 lines (31 loc) • 1.7 kB
TypeScript
import { ComputedRef } from 'vue';
import type { GenericComponent } from '../../types/form/form';
import { FormLayout, GenericFormLayout } from '../../types/form/layout';
import { ActionButton } from '../../types/utils/actions';
export type MixedChecker<ENTITY extends {}> = (data: {
role: string;
isNew: boolean;
state: ENTITY;
}) => boolean;
export declare const useLayoutChecks: (layout: GenericFormLayout<any> | GenericFormLayout<any>[]) => {
hidden: ComputedRef<boolean>;
};
export declare const getUpdatedLayoutsValue: (layout: FormLayout<any>, form: Record<string, any>, isNew?: boolean) => FormLayout<any>;
export declare const useChecks: (field: GenericComponent<any>, value?: unknown) => {
disabled: ComputedRef<boolean>;
hidden: ComputedRef<boolean>;
readOnly: ComputedRef<boolean>;
readOnlyText: ComputedRef<string>;
hiddenCollectionAddButton: ComputedRef<boolean>;
changed: ComputedRef<boolean>;
};
/**
* `disabled`, `hidden`, `readOnly` accept `mixedChecks` function that returns a boolean depending on the
* state of the form and the user role. Here, we bind those values to the function that will
* be executed in the FormItem.
*/
export declare const updateFieldValues: (field: GenericComponent<any>, form: Record<string, any>, isNew?: boolean, force?: Record<'readOnly' | 'disabled' | 'hidden' | 'hiddenCollectionAddButton' | 'changed', undefined | boolean | MixedChecker<any>>) => void;
export declare const updateActionValues: (action: ActionButton<any, any>, form: Record<string, any>, isNew: boolean) => void;
export declare const useActionButtonChecks: (action: ActionButton<string, any>) => {
hidden: ComputedRef<boolean>;
};