UNPKG

@talend/react-containers

Version:

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

64 lines 1.89 kB
import PropTypes from 'prop-types'; import Form from '@talend/react-forms'; import { Badge, VirtualizedList } from "@talend/react-components"; import { jsx as _jsx } from "react/jsx-runtime"; function renderItem(props) { const item = VirtualizedList.rowUtils.getRowData(props.parent, props.index); return /*#__PURE__*/_jsx(Badge, { style: props.style, label: item.name, selected: true }, props.index); } renderItem.height = 35; renderItem.propTypes = { parent: PropTypes.object, style: PropTypes.object, index: PropTypes.number }; export default function MultiSelectTextMode(props) { const names = props.resolveName(props.value); const titleMap = props.value.map((nextVal, index) => ({ name: names[index], value: nextVal })); const TextModeTemplate = Form.UIForm.TextModeTemplate; return /*#__PURE__*/_jsx(TextModeTemplate, { id: props.id, label: props.schema.title, children: /*#__PURE__*/_jsx("div", { style: { height: 300 }, children: /*#__PURE__*/_jsx(VirtualizedList, { type: "tc-multiselect", rowHeight: props.itemViewRender.rowHeight, rowRenderers: { 'tc-multiselect': props.itemViewRender }, collection: titleMap }) }) }); } if (process.env.NODE_ENV !== 'production') { MultiSelectTextMode.propTypes = { itemViewRender: PropTypes.func, id: PropTypes.string, resolveName: PropTypes.func, schema: PropTypes.shape({ title: PropTypes.string, titleMap: PropTypes.arrayOf(PropTypes.shape({ name: PropTypes.string.isRequired, value: PropTypes.string.isRequired })) }).isRequired, value: PropTypes.arrayOf(PropTypes.string) }; } MultiSelectTextMode.defaultProps = { value: [], itemViewRender: renderItem, resolveName: value => value }; //# sourceMappingURL=TextMode.component.js.map