UNPKG

@darwino/darwino-react-onsenui

Version:

A set of Javascript classes and utilities for OnsenUI

50 lines (41 loc) 1.35 kB
import _objectWithoutProperties from "@babel/runtime/helpers/esm/objectWithoutProperties"; /* * (c) Copyright Darwino Inc. 2014-2017. */ import React, { Component } from "react"; class FieldStatic extends Component { static labelFor(options, value) { if (options) { for (var i = 0; i < options.length; i++) { var val = options[i]; if (typeof val === "object" && val.value == value) { return val.label !== undefined ? val.label : val.value; } } } return value; } static labelsFor(options, values) { return values.map(v => FieldStatic.labelFor(options, v)); } render() { var _this$props = this.props, { input, multiple, type, options, editable, separator, disabled } = _this$props, props = _objectWithoutProperties(_this$props, ["input", "multiple", "type", "options", "editable", "separator", "disabled"]); var { value } = input; var inputValue = multiple ? Array.isArray(value) ? FieldStatic.labelsFor(options, value).join(separator || ',') : "" : value !== undefined && value !== null ? FieldStatic.labelFor(options, value.toString()) : ""; return /*#__PURE__*/React.createElement("div", props, inputValue); } } export default FieldStatic; //# sourceMappingURL=FieldStatic.js.map