UNPKG

solid-panes

Version:

Solid-compatible Panes: applets and views for the mashlib and databrowser

57 lines (55 loc) 1.9 kB
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.default = void 0; var _solidUi = require("solid-ui"); /* Tabbed view of anything ** ** data-driven ** */ const TabbedPane = { icon: _solidUi.icons.iconBase + 'noun_688606.svg', name: 'tabbed', audience: [_solidUi.ns.solid('PowerUser')], // Does the subject deserve this pane? label: (subject, context) => { const kb = context.session.store; const typeURIs = kb.findTypeURIs(subject); if (_solidUi.ns.meeting('Cluster').uri in typeURIs) { return 'Tabbed'; } return null; }, render: (subject, context) => { const dom = context.dom; const store = context.session.store; const div = dom.createElement('div'); (async () => { if (!store.fetcher) { throw new Error('Store has no fetcher'); } await store.fetcher.load(subject); div.appendChild(_solidUi.tabs.tabWidget({ dom, subject, predicate: store.any(subject, _solidUi.ns.meeting('predicate')) || _solidUi.ns.meeting('toolList'), ordered: true, orientation: store.anyValue(subject, _solidUi.ns.meeting('orientation')) || '0', renderMain: (containerDiv, item) => { containerDiv.innerHTML = ''; const table = containerDiv.appendChild(context.dom.createElement('table')); context.getOutliner(context.dom).GotoSubject(item, true, null, false, undefined, table); }, renderTab: (containerDiv, item) => { const predicate = store.the(subject, _solidUi.ns.meeting('predicate')); containerDiv.appendChild(_solidUi.widgets.personTR(context.dom, predicate, item, {})); }, backgroundColor: store.anyValue(subject, _solidUi.ns.ui('backgroundColor')) || '#ddddcc' })); })(); return div; } }; var _default = exports.default = TabbedPane;