UNPKG

@dorgtech/daocomponents

Version:

Componentizing [DAOstack's client library](https://github.com/daostack/client), enabling easier React application integration. The hope is to be able to turn any app into a DAO enabled dApp by adding ~2 components.

83 lines 3.86 kB
"use strict"; var __extends = (this && this.__extends) || (function () { var extendStatics = function (d, b) { extendStatics = Object.setPrototypeOf || ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) || function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; }; return extendStatics(d, b); }; return function (d, b) { extendStatics(d, b); function __() { this.constructor = d; } d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __()); }; })(); Object.defineProperty(exports, "__esModule", { value: true }); var React = require("react"); var runtime_1 = require("../runtime"); var protocol_1 = require("../protocol"); var _1 = require("./"); var ArcMembers = /** @class */ (function (_super) { __extends(ArcMembers, _super); function ArcMembers() { return _super !== null && _super.apply(this, arguments) || this; } ArcMembers.prototype.createObservableEntities = function () { var _a = this.props, arcConfig = _a.arcConfig, filter = _a.filter; if (!arcConfig) { throw Error("Arc Config Missing: Please provide this field as a prop, or use the inference component."); } return _1.MemberEntity.search(arcConfig.connection, filter); }; ArcMembers.prototype.renderComponent = function (entity, children) { // TODO: support creating Components with just an Entity, it makes no sense to recreate the Member entity here... return (React.createElement(_1.DAOMember, { address: entity.staticState.address, dao: new _1.DAOEntity(entity.staticState.dao, entity.context) }, children)); }; return ArcMembers; }(runtime_1.ComponentList)); exports.ArcMembers = ArcMembers; var DAOMembers = /** @class */ (function (_super) { __extends(DAOMembers, _super); function DAOMembers() { return _super !== null && _super.apply(this, arguments) || this; } // TODO: remove this when filters are added // also rename all instances of "Arc" to protocol? DAOMembers.prototype.createObservableEntities = function () { var _a = this.props, dao = _a.dao, filter = _a.filter; if (!dao) { throw Error("DAO Entity Missing: Please provide this field as a prop, or use the inference component."); } var daoFilter = filter ? filter : { where: {} }; if (!daoFilter.where) { daoFilter.where = {}; } daoFilter.where.dao = dao.id; return _1.MemberEntity.search(dao.context, daoFilter); }; DAOMembers.prototype.renderComponent = function (entity, children) { var dao = this.props.dao; return (React.createElement(_1.DAOMember, { address: entity.staticState.address, dao: dao }, children)); }; return DAOMembers; }(runtime_1.ComponentList)); exports.DAOMembers = DAOMembers; var Members = /** @class */ (function (_super) { __extends(Members, _super); function Members() { return _super !== null && _super.apply(this, arguments) || this; } Members.prototype.render = function () { var _a = this.props, children = _a.children, allDAOs = _a.allDAOs, sort = _a.sort, filter = _a.filter; if (allDAOs) { return (React.createElement(protocol_1.Arc.Config, null, function (arcConfig) { return (React.createElement(ArcMembers, { arcConfig: arcConfig, sort: sort, filter: filter }, children)); })); } else { return (React.createElement(_1.DAO.Entity, null, function (dao) { return (React.createElement(DAOMembers, { dao: dao, sort: sort, filter: filter }, children)); })); } }; return Members; }(React.Component)); exports.Members = Members; exports.default = Members; //# sourceMappingURL=Members.js.map