UNPKG

@discoveryjs/discovery

Version:

Frontend framework for rapid data (JSON) analysis, shareable serverless reports and dashboards

21 lines (18 loc) 749 B
/* eslint-env browser */ import usage from './section.usage.js'; export default function(host) { host.view.define('section', function(el, config, data, context) { const { header, content = [], onInit, onChange } = config; const mixinHandlersIfNeeded = (config) => typeof onInit !== 'function' && typeof onChange !== 'function' ? config // left as is since nothing to mix in : this.composeConfig(config, { onInit, onChange }); return host.view.render(el, [ { view: 'header', content: mixinHandlersIfNeeded(header) }, mixinHandlersIfNeeded(content) ], data, context); }, { usage }); }