auto-views
Advanced tools
Comparing version 0.0.21 to 0.0.22
@@ -17,3 +17,3 @@ /// <reference types="react" /> | ||
title: string; | ||
displayMode?: DisplayMode; | ||
displayMode: DisplayMode; | ||
type: string; | ||
@@ -30,2 +30,3 @@ value?: any; | ||
render(): JSX.Element; | ||
private renderInternalComponent(); | ||
} |
@@ -54,18 +54,36 @@ "use strict"; | ||
Entry.prototype.render = function () { | ||
var childProps = (_a = {}, | ||
_a['data-automation-id'] = auto_form_1.fieldValueSelector(this.props.entryKey), | ||
_a); | ||
childProps = Object.assign(childProps, this.props.value != undefined ? { value: this.props.value } : {}, (this.props.valid) ? {} : { style: { borderColor: 'red' } }); | ||
var comp; | ||
if (this.props.displayMode == DisplayMode.Edit) { | ||
comp = React.createElement("input", __assign({}, childProps, { type: this.props.type, onChange: this.onChange })); | ||
} | ||
else { | ||
comp = React.createElement("label", __assign({}, childProps)); | ||
} | ||
var comp = this.renderInternalComponent(); | ||
return React.createElement("div", __assign({}, this.props), | ||
React.createElement("label", { "data-automation-id": auto_form_1.fieldLabelSelector(this.props.entryKey) }, this.props.title), | ||
comp); | ||
var _a; | ||
}; | ||
Entry.prototype.renderInternalComponent = function () { | ||
var _this = this; | ||
var childProps = Object.assign((_a = {}, _a['data-automation-id'] = auto_form_1.fieldValueSelector(this.props.entryKey), _a), this.props.value != undefined ? { value: this.props.value } : {}, (this.props.valid) ? {} : { style: { borderColor: 'red' } }); | ||
var renderForView = function () { | ||
if (_this.props.type != 'boolean') { | ||
return React.createElement("label", __assign({}, childProps)); | ||
} | ||
else { | ||
childProps = Object.assign(childProps, { | ||
onChange: _this.onChange, | ||
type: _this.props.type == "boolean" ? "checkbox" : _this.props.type | ||
}); | ||
return React.createElement("input", __assign({}, childProps)); | ||
} | ||
}; | ||
var renderForEdit = function () { | ||
childProps = Object.assign(childProps, { | ||
onChange: _this.onChange, | ||
type: _this.props.type == "boolean" ? "checkbox" : _this.props.type | ||
}); | ||
return React.createElement("input", __assign({}, childProps)); | ||
}; | ||
var myMap = (_b = {}, | ||
_b[DisplayMode.Edit] = renderForEdit, | ||
_b[DisplayMode.View] = renderForView, | ||
_b); | ||
return myMap[this.props.displayMode](); | ||
var _a, _b; | ||
}; | ||
Entry.defaultProps = { | ||
@@ -72,0 +90,0 @@ displayMode: DisplayMode.View, |
{ | ||
"name": "auto-views", | ||
"version": "0.0.21", | ||
"version": "0.0.22", | ||
"description": "Common, fully-tested, strictly-typed, Wix-styled, auto views library", | ||
@@ -5,0 +5,0 @@ "main": "./lib/index.js", |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
55616
729