UNPKG

@talend/react-containers

Version:

Provide connected components aka containers for @talend/react-cmf based on @talend/react-components.

33 lines 1.03 kB
import PropTypes from 'prop-types'; import Form from '@talend/react-forms'; import { jsx as _jsx } from "react/jsx-runtime"; export default function withNameResolver(WrappedComponent) { function NameResolver(props) { function resolveName(value) { // create schema to get entry name from internal properties const key = Array.from(props.schema.key); key[key.length - 1] = `$${key[key.length - 1]}_name`; const nameSchema = { ...props.schema, key }; const { getValue } = Form.UIForm.utils.properties; return getValue(props.properties, nameSchema) || value; } return /*#__PURE__*/_jsx(WrappedComponent, { ...props, resolveName: resolveName }); } NameResolver.displayName = `NameResolver(${WrappedComponent.displayName})`; NameResolver.propTypes = { properties: PropTypes.object, schema: PropTypes.shape({ key: PropTypes.array }) }; return NameResolver; } //# sourceMappingURL=NameResolver.component.js.map