UNPKG

@fruits-chain/react-native-xiaoshu

Version:
32 lines (31 loc) • 1.11 kB
"use strict"; import { Field } from 'rc-field-form'; import React from 'react'; import { usePersistFn } from "../hooks/index.js"; import { jsx as _jsx } from "react/jsx-runtime"; const hasValidName = name => { return !(name === undefined || name === null); }; function FormItem(props) { const { children, ...restProps } = props; const hasName = hasValidName(restProps.name); const isRenderProps = typeof children === 'function'; const getValueFromEvent = usePersistFn((...args) => { const event = args[0]; const valuePropName = props.valuePropName || 'text'; if (event?.nativeEvent && typeof event.nativeEvent === 'object' && valuePropName in event.nativeEvent) { return event.nativeEvent[valuePropName]; } return event; }); return /*#__PURE__*/_jsx(Field, { ...restProps, getValueFromEvent: props.getValueFromEvent || getValueFromEvent, children: !hasName && (restProps.shouldUpdate || restProps.dependencies) && isRenderProps ? (_, __, context) => children(context) : children }); } export default FormItem; //# sourceMappingURL=form-item.js.map