auto-views
Advanced tools
Comparing version 0.0.12 to 0.0.13
/// <reference types="react" /> | ||
import * as React from 'react'; | ||
import { SchemaRepository } from "./schema-repo"; | ||
import { SchemaProperty, SchemaRepository } from "./schema-repo"; | ||
export interface AutoFormProps extends React.HTMLAttributes<HTMLFormElement> { | ||
@@ -21,3 +21,3 @@ repo: SchemaRepository; | ||
private renderChildren(); | ||
private makeComponent(property, key); | ||
} | ||
export declare function makeFormEntry(formData: any, displayMode: DisplayMode): (property: SchemaProperty, key: string) => JSX.Element; |
@@ -23,2 +23,3 @@ "use strict"; | ||
var schema_repo_1 = require("./schema-repo"); | ||
var form_entry_1 = require("./form-entry"); | ||
var DisplayMode; | ||
@@ -44,5 +45,3 @@ (function (DisplayMode) { | ||
function AutoForm(props) { | ||
var _this = _super.call(this, props) || this; | ||
_this.makeComponent = _this.makeComponent.bind(_this); | ||
return _this; | ||
return _super.call(this, props) || this; | ||
} | ||
@@ -58,26 +57,14 @@ AutoForm.prototype.render = function () { | ||
else { | ||
return this.props.repo.mapOverProperties(this.props.schemaId, this.makeComponent); | ||
return this.props.repo.mapOverProperties(this.props.schemaId, makeFormEntry(this.props.formData, this.props.displayMode)); | ||
} | ||
}; | ||
AutoForm.prototype.makeComponent = function (property, key) { | ||
var formEntryProps = (_a = { | ||
type: property.type | ||
}, | ||
_a['data-automation-id'] = fieldValueSelector(key), | ||
_a); | ||
var value = this.props.formData[key]; | ||
if (value) { | ||
formEntryProps['value'] = value; | ||
} | ||
var comp = (this.props.displayMode == DisplayMode.Edit) ? | ||
React.createElement("input", __assign({}, formEntryProps)) : | ||
React.createElement("label", __assign({}, formEntryProps)); | ||
return React.createElement("div", null, | ||
React.createElement("label", { "data-automation-id": fieldLabelSelector(key) }, property.title), | ||
comp); | ||
var _a; | ||
}; | ||
return AutoForm; | ||
}(React.Component)); | ||
exports.AutoForm = AutoForm; | ||
function makeFormEntry(formData, displayMode) { | ||
return function (property, key) { | ||
return React.createElement(form_entry_1.Entry, { "data-automation-id": form_entry_1.entrySelector(key), entryKey: key, title: property.title, displayMode: displayMode, type: property.type, value: formData[key] }); | ||
}; | ||
} | ||
exports.makeFormEntry = makeFormEntry; | ||
//# sourceMappingURL=auto-form.js.map |
{ | ||
"name": "auto-views", | ||
"version": "0.0.12", | ||
"version": "0.0.13", | ||
"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
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
37
523
44011