@extclp/vexip-ui
Version:
A Vue 3 UI library, Highly customizability, full TypeScript, performance pretty good
40 lines (39 loc) • 1.56 kB
TypeScript
import { ComputedRef } from 'vue';
import { ComponentSize, ComponentState } from '@vexip-ui/config';
/**
* 根据路径读取对象中的值 (实现 ?. 的逻辑)
*
* @param obj 需要被读取的对象
* @param path 读取的路径
* @param strict 是否开启严格模式 (非法路径报错)
*/
export declare function getValueByPath<T = unknown>(obj: Record<string, any>, path: string | string[], strict?: boolean): T | null;
/**
* 根据路径设置对象中的值
*
* @param obj 需要被设置的对象
* @param path 设置的路径
* @param value 需要设置的值
* @param strict 是否开启严格模式 (非法路径报错)
*/
export declare function setValueByPath(obj: Record<string, any>, path: string | string[], value: unknown, strict?: boolean): boolean;
export interface FormFieldStore<V = unknown> {
isField: boolean;
idFor: ComputedRef<string | undefined>;
labelId: ComputedRef<string | undefined>;
state: ComputedRef<ComponentState>;
disabled: ComputedRef<boolean>;
loading: ComputedRef<boolean>;
size: ComputedRef<ComponentSize>;
validateField: () => Promise<string[] | null>;
clearField: (defaultValue?: V) => void;
resetField: () => boolean;
getFieldValue: (defaultValue?: V) => V;
setFieldValue: (value: V, strict?: boolean) => void;
}
/**
* Create a field store, provide field states and control methods
*
* @param onFocus a focus method for focusing when label is clicked
*/
export declare function useFieldStore<V = unknown>(onFocus?: () => void): FormFieldStore<V>;