UNPKG

@lobehub/ui

Version:

Lobe UI is an open-source UI component library for building AIGC web apps

23 lines (22 loc) • 1.09 kB
//#region src/base-ui/FormKit/binding.ts const isEventLike = (arg) => typeof arg === "object" && arg !== null && "target" in arg && typeof arg.target === "object" && arg.target !== null; const defaultGetValue = (arg) => { if (!isEventLike(arg)) return arg; const { target } = arg; return target.type === "checkbox" || target.type === "radio" ? target.checked : target.value; }; const resolveBinding = (child, override) => { const { type } = child; const declared = typeof type === "object" || typeof type === "function" ? type.formBinding : void 0; const props = child.props; const nativeCheckable = type === "input" && (props.type === "checkbox" || props.type === "radio"); return { emptyValue: override.emptyValue ?? declared?.emptyValue, getValue: override.getValue ?? declared?.getValue ?? defaultGetValue, trigger: override.trigger ?? declared?.trigger ?? "onChange", valueProp: override.valueProp ?? declared?.valueProp ?? (nativeCheckable ? "checked" : "value") }; }; //#endregion export { defaultGetValue, resolveBinding }; //# sourceMappingURL=binding.mjs.map