UNPKG

@arche-mc2/arche-controls

Version:

We know that there are a ton of react UI library projects to choose from. Our hope with this one is to provide the next generation of react components that you can use to bootstrap your next project, or as a reference for building a UIKit. Read on to get

46 lines 3.64 kB
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); var tslib_1 = require("tslib"); var React = require("react"); var classnames = require("classnames"); var UpButton_1 = require("../../Inputs/Button/UpButton"); var SvgIcon_1 = require("../../Display/SvgIcon"); var UpTooltip_1 = require("../../Display/Tooltip/UpTooltip"); var UpLigne_1 = require("../../Display/Ligne/UpLigne"); var _ = require("lodash"); var styles_1 = require("./styles"); var UpDataPanelItem = function (props) { var panelData = props.panelData, className = props.className, title = props.title, displayMode = props.displayMode, columns = props.columns, showOnlyNotEmptyValue = props.showOnlyNotEmptyValue, getColumnCustomClassName = props.getColumnCustomClassName; var Tooltip = function (props) { return (React.createElement(UpTooltip_1.default, { title: props.tooltip.title, place: 'bottom', content: props.tooltip.content }, React.createElement(UpLigne_1.default, null, React.createElement(SvgIcon_1.default, { width: 16, height: 16, iconName: 'info', className: 'col-tooltip' })))); }; return (React.createElement("div", { className: classnames('panel-container', className, styles_1.getStyles(props)) }, title && (React.createElement("div", { className: 'panel-title' }, React.createElement("span", { className: 'panel-title-general' }, _.isFunction(title.general.format) && title.general.format(panelData), _.isString(title.general) && title.general), title.specific && React.createElement("span", { className: 'panel-title-specific' }, _.isFunction(title.specific.format) && title.specific.format(panelData), _.isString(title.specific) && title.specific))), React.createElement("div", { className: 'panel-body' }, columns.map(function (element, index) { var customClassName = getColumnCustomClassName && getColumnCustomClassName(element.field) || ''; return ((panelData && panelData[element.field] && showOnlyNotEmptyValue) || element.field && !showOnlyNotEmptyValue ? (React.createElement(React.Fragment, { key: index }, React.createElement("div", { className: classnames("panel-col " + customClassName) }, React.createElement("span", { className: 'panel-col-label' }, element.label, displayMode === 'row' ? ': ' : null), element.formatter ? (element.formatter.format(panelData, element, element.getFormatterProps ? element.getFormatterProps(panelData ? panelData[element.field] : null) : {})) : (React.createElement("span", { className: 'panel-col-value' }, panelData && panelData[element.field])), element.tooltip && (React.createElement(Tooltip, { tooltip: element.tooltip }))))) : null); }), props.actions && (React.createElement("div", { className: 'panel-actions' }, props.actions.map(function (element, index) { return (React.createElement(UpButton_1.default, { key: "panel-action-" + index, actionType: element.type, intent: element.intent, width: 'icon', borderless: true, onClick: function () { return element.action({ value: tslib_1.__assign({}, panelData) }); } })); })))))); }; UpDataPanelItem.defaultProps = { displayMode: 'row', showOnlyNotEmptyValue: false }; exports.default = UpDataPanelItem; //# sourceMappingURL=UpDataPanelItem.js.map