UNPKG

@jsonforms/material-tree-renderer

Version:

Material-based tree renderer for JSON Forms

59 lines (55 loc) 3.41 kB
"use strict"; var __importDefault = (this && this.__importDefault) || function (mod) { return (mod && mod.__esModule) ? mod : { "default": mod }; }; Object.defineProperty(exports, "__esModule", { value: true }); /* The MIT License Copyright (c) 2017-2019 EclipseSource Munich https://github.com/eclipsesource/jsonforms Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */ // tslint:disable:jsx-no-multiline-js var react_1 = __importDefault(require("react")); var core_1 = require("@jsonforms/core"); var ObjectListItem_1 = __importDefault(require("./ObjectListItem")); /** * Expands the given root data array by expanding every element. * If the parent data containing the array is provided, * a suitable delete function for the expanded elements is created. * * As a difference to the ExpandArray component this component does not use containment * properties because it is only used for the root nodes of a tree. * */ exports.ExpandRootArray = function (_a) { var rootData = _a.rootData, schema = _a.schema, path = _a.path, selection = _a.selection, handlers = _a.handlers, filterPredicate = _a.filterPredicate, labelProvider = _a.labelProvider, imageProvider = _a.imageProvider; var data = core_1.resolveData(rootData, path); if (data === undefined || data === null) { return 'No data'; } return data.map(function (_element, index) { var composedPath = core_1.Paths.compose(path, index.toString()); return (react_1.default.createElement(ObjectListItem_1.default, { key: composedPath, path: composedPath, schema: schema, selection: selection, handlers: handlers, isRoot: true, filterPredicate: filterPredicate, labelProvider: labelProvider, imageProvider: imageProvider })); }); }; // TODO: update selected element once selection has been changed exports.ExpandRootArrayContainer = function (_a) { var path = _a.path, schema = _a.schema, rootData = _a.rootData, selection = _a.selection, handlers = _a.handlers, filterPredicate = _a.filterPredicate, labelProvider = _a.labelProvider, imageProvider = _a.imageProvider; return (react_1.default.createElement(exports.ExpandRootArray, { schema: schema, path: path, rootData: rootData, selection: selection, handlers: handlers, filterPredicate: filterPredicate, labelProvider: labelProvider, imageProvider: imageProvider })); }; //# sourceMappingURL=ExpandRootArray.js.map