solid-panes
Version:
Solid-compatible Panes: applets and views for the mashlib and databrowser
58 lines (54 loc) • 2.89 kB
JavaScript
;
function _typeof(o) { "@babel/helpers - typeof"; return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function (o) { return typeof o; } : function (o) { return o && "function" == typeof Symbol && o.constructor === Symbol && o !== Symbol.prototype ? "symbol" : typeof o; }, _typeof(o); }
Object.defineProperty(exports, "__esModule", {
value: true
});
exports.tableViewPane = void 0;
var UI = _interopRequireWildcard(require("solid-ui"));
function _interopRequireWildcard(e, t) { if ("function" == typeof WeakMap) var r = new WeakMap(), n = new WeakMap(); return (_interopRequireWildcard = function _interopRequireWildcard(e, t) { if (!t && e && e.__esModule) return e; var o, i, f = { __proto__: null, "default": e }; if (null === e || "object" != _typeof(e) && "function" != typeof e) return f; if (o = t ? n : r) { if (o.has(e)) return o.get(e); o.set(e, f); } for (var _t in e) "default" !== _t && {}.hasOwnProperty.call(e, _t) && ((i = (o = Object.defineProperty) && Object.getOwnPropertyDescriptor(e, _t)) && (i.get || i.set) ? o(f, _t, i) : f[_t] = e[_t]); return f; })(e, t); }
// Format an array of RDF statements as an HTML table.
//
// This can operate in one of three modes: when the class of object is given
// or when the source document from which data is taken is given,
// or if a prepared query object is given.
// (In principle it could operate with neither class nor document
// given but typically
// there would be too much data.)
// When the tableClass is not given, it looks for common classes in the data,
// and gives the user the option.
//
// 2008 Written, Ilaria Liccardi
// 2014 core functionality now in common/table.js -timbl
// ///////////////////////////////////////////////////////////////////
// Table view pane -- view of a class as a table of properties of class members
var tableViewPane = exports.tableViewPane = {
icon: UI.icons.originalIconBase + 'table.png',
name: 'tableOfClass',
label: function label(subject, context) {
var store = context.session.store;
// if (!store.holds(subject, UI.ns.rdf('type'),UI.ns.rdfs('Class'))) return null
if (!store.any(undefined, UI.ns.rdf('type'), subject)) {
return null;
}
var n = store.statementsMatching(undefined, UI.ns.rdf('type'), subject).length;
if (n === 0) {
// None, suppress pane
return null;
}
if (n > 15) {
// @@ At the moment this pane can be slow with too many @@ fixme by using limits
return null;
}
return UI.utils.label(subject) + ' table';
},
render: function render(subject, context) {
var myDocument = context.dom;
var div = myDocument.createElement('div');
div.setAttribute('class', 'tablePane');
div.appendChild(UI.table(myDocument, {
tableClass: subject
}));
return div;
}
};
//# sourceMappingURL=tableViewPane.js.map