UNPKG

lincd-design-elems

Version:

45 lines 2.32 kB
"use strict"; var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) { var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d; if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc); else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r; return c > 3 && r && Object.defineProperty(target, key, r), r; }; var __importDefault = (this && this.__importDefault) || function (mod) { return (mod && mod.__esModule) ? mod : { "default": mod }; }; Object.defineProperty(exports, "__esModule", { value: true }); exports.List = void 0; const react_1 = __importDefault(require("react")); // import {ExampleShapeClass} from '../shapes/ExampleShapeClass'; const package_1 = require("../package"); const LinkedComponentClass_1 = require("lincd/lib/utils/LinkedComponentClass"); const Shape_1 = require("lincd/lib/shapes/Shape"); //TODO: make this a linked component of Shape /** * @description Shows a set of gives nodes as a list. Each node will be rendered with the provided component or render method. */ let List = class List extends LinkedComponentClass_1.LinkedComponentClass { render() { let renderFunction; //if this list was rendered with 1 child which was a child-render-function if (this.props.children.length === 1 && typeof this.props.children === 'function') { //then render the child node using the given child render function renderFunction = this.props.children; } //or if a render function was given as property, use that else if (this.props.renderItem) { renderFunction = this.props.renderItem; } let sources = this.props.sources; return (react_1.default.createElement("ul", null, sources.map((item) => { return (react_1.default.createElement("li", { key: item.toString() }, renderFunction && renderFunction(item))); }))); } }; exports.List = List; exports.List = List = __decorate([ (0, package_1.linkedComponentClass)(Shape_1.Shape) ], List); //# sourceMappingURL=List.js.map