@talend/react-containers
Version:
Provide connected components aka containers for @talend/react-cmf based on @talend/react-components.
90 lines • 2.71 kB
JavaScript
import ImmutablePropTypes from 'react-immutable-proptypes';
import classNames from 'classnames';
import PropTypes from 'prop-types';
import Action from '../Action';
import FilterBar from '../FilterBar';
import List from '../List';
import TreeView from '../TreeView';
import theme from './SelectObject.module.scss';
import { JSONSchemaRenderer } from "@talend/react-components";
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
function SelectObject({
filteredData,
idAttr,
nameAttr,
results,
sourceData,
tree,
filter = {},
...props
}) {
let schema;
if (props.schema && props.selected) {
schema = {
properties: props.selected,
...props.schema
};
}
return /*#__PURE__*/_jsxs("div", {
className: `tc-select-object ${theme.wrapper}`,
children: [/*#__PURE__*/_jsx(FilterBar, {
...filter,
className: classNames(filter.className, theme.filter),
id: props.id,
dockable: false,
navbar: false
}), /*#__PURE__*/_jsxs("div", {
className: theme.container,
children: [!tree && !filteredData && /*#__PURE__*/_jsx(List, {
...props.list,
id: `${props.id}-list`,
data: sourceData,
className: theme.list
}), tree && !filteredData && /*#__PURE__*/_jsx(TreeView, {
...tree,
componentId: props.id,
noHeader: true,
data: sourceData,
className: theme.tree
}), filteredData && /*#__PURE__*/_jsx("div", {
className: theme.results,
children: filteredData.map(data => /*#__PURE__*/_jsxs(Action, {
className: classNames({
active: results.selectedId === data.get(idAttr)
}),
onClick: event => results.onClick(event, data),
children: [/*#__PURE__*/_jsx("h3", {
children: data.get(nameAttr)
}), /*#__PURE__*/_jsx("span", {
children: data.get('currentPosition')
})]
}, data.get(idAttr)))
}), schema && /*#__PURE__*/_jsx(JSONSchemaRenderer, {
schema: schema,
className: theme.preview
})]
})]
});
}
SelectObject.displayName = 'SelectObject';
SelectObject.propTypes = {
id: PropTypes.string,
idAttr: PropTypes.string,
nameAttr: PropTypes.string,
tree: PropTypes.object,
list: PropTypes.object,
filter: PropTypes.object,
schema: PropTypes.object,
filteredData: ImmutablePropTypes.List,
results: PropTypes.shape({
selectedId: PropTypes.string,
onClick: PropTypes.func
}),
sourceData: ImmutablePropTypes.List,
selected: PropTypes.object
};
SelectObject.defaultProps = {
idAttr: 'id'
};
export default SelectObject;
//# sourceMappingURL=SelectObject.component.js.map