UNPKG

@talend/react-components

Version:
100 lines (99 loc) 3.83 kB
function _defineProperty(e, r, t) { return (r = _toPropertyKey(r)) in e ? Object.defineProperty(e, r, { value: t, enumerable: !0, configurable: !0, writable: !0 }) : e[r] = t, e; } function _toPropertyKey(t) { var i = _toPrimitive(t, "string"); return "symbol" == typeof i ? i : i + ""; } function _toPrimitive(t, r) { if ("object" != typeof t || !t) return t; var e = t[Symbol.toPrimitive]; if (void 0 !== e) { var i = e.call(t, r || "default"); if ("object" != typeof i) return i; throw new TypeError("@@toPrimitive must return a primitive value."); } return ("string" === r ? String : Number)(t); } import classNames from 'classnames'; import PropTypes from 'prop-types'; import { Component as RComponent } from 'react'; import { withTranslation } from 'react-i18next'; import I18N_DOMAIN_COMPONENTS from '../../constants'; import getDefaultT from '../../translate'; import { TreeManager } from '../Managers'; import Branch from './Branch'; import Leaf from './Leaf'; import Component from './RecordsViewer.component'; import { getChilds, getChildsCount, getItemType, getJSONPath, getObjectBranchDatakey } from './RecordsViewer.parser'; import theme from './RecordsViewer.module.scss'; /** * Used in the branch to get the icon. * Allow custom icon. */ import { jsx as _jsx } from "react/jsx-runtime"; export function getIcon(opened) { if (opened) { return { name: 'talend-minus-circle', className: classNames(theme['tc-records-viewer-branch-icon'], 'tc-records-viewer-branch-icon') }; } return { name: 'talend-plus-circle', className: classNames(theme['tc-records-viewer-branch-icon'], 'tc-records-viewer-branch-icon') }; } export class RecordsViewer extends RComponent { constructor(..._args) { super(..._args); _defineProperty(this, "renderLeaf", args => /*#__PURE__*/_jsx(Leaf, { ...args, renderLeafAdditionalValue: this.props.renderLeafAdditionalValue })); _defineProperty(this, "renderBranch", args => /*#__PURE__*/_jsx(Branch, { ...args, getChilds: this.props.getChilds, getChildsCount: this.props.getChildsCount, getIcon: this.props.getIcon, getObjectBranchDatakey: this.props.getObjectBranchDatakey, t: this.props.t, renderBranchAdditionalValue: this.props.renderBranchAdditionalValue })); _defineProperty(this, "renderComponent", args => { const componentProps = { ...this.props, branch: this.renderBranch, getJSONPath: this.props.getJSONPath, getValueType: this.props.getItemType, leaf: this.renderLeaf, value: this.props.sample.data, t: this.props.t }; return /*#__PURE__*/_jsx(Component, { ...args, ...componentProps }); }); } render() { return /*#__PURE__*/_jsx(TreeManager, { componentId: this.props.componentId || 'RecordsViewer', highlighted: this.props.highlighted, wrappedComponent: this.renderComponent, sample: this.props.sample }); } } _defineProperty(RecordsViewer, "displayName", 'RecordsViewerContainer'); _defineProperty(RecordsViewer, "propTypes", { componentId: PropTypes.string, getChilds: PropTypes.func, getChildsCount: PropTypes.func, getIcon: PropTypes.func, getObjectBranchDatakey: PropTypes.func, getJSONPath: PropTypes.func, getItemType: PropTypes.func, highlighted: PropTypes.array, sample: PropTypes.object, t: PropTypes.func, renderBranchAdditionalValue: PropTypes.func, renderLeafAdditionalValue: PropTypes.func }); _defineProperty(RecordsViewer, "defaultProps", { getChilds, getChildsCount, getIcon, getObjectBranchDatakey, getJSONPath, getItemType, t: getDefaultT() }); export default withTranslation(I18N_DOMAIN_COMPONENTS)(RecordsViewer); //# sourceMappingURL=RecordsViewer.container.js.map