auto-views
Advanced tools
Comparing version 0.0.25 to 0.0.26
@@ -19,6 +19,6 @@ /// <reference types="react" /> | ||
constructor(props: AutoFormProps); | ||
render(): JSX.Element; | ||
private onEntryChange; | ||
private renderChildren(); | ||
render(): JSX.Element; | ||
} | ||
export declare function makeFormEntry(formData: any, displayMode: DisplayMode, erroneousProps?: Array<SchemaProperty>, onEntryChange?: (key: string, e: React.FormEvent<HTMLDivElement>) => void): (property: SchemaProperty, key: string) => JSX.Element; |
@@ -55,6 +55,2 @@ "use strict"; | ||
} | ||
AutoForm.prototype.render = function () { | ||
var children = this.renderChildren(); | ||
return React.createElement("form", __assign({}, this.props), children); | ||
}; | ||
AutoForm.prototype.renderChildren = function () { | ||
@@ -71,2 +67,6 @@ if (!this.props.repo) { | ||
}; | ||
AutoForm.prototype.render = function () { | ||
var children = this.renderChildren(); | ||
return React.createElement("form", __assign({}, this.props), children); | ||
}; | ||
return AutoForm; | ||
@@ -73,0 +73,0 @@ }(React.Component)); |
/// <reference types="react" /> | ||
import * as React from 'react'; | ||
import { Type } from "./schema-property"; | ||
export declare enum DisplayMode { | ||
View = 0, | ||
Edit = 1, | ||
View = "View", | ||
Edit = "Edit", | ||
} | ||
@@ -18,3 +19,3 @@ export interface EntryEventTarget extends EventTarget { | ||
displayMode: DisplayMode; | ||
type: string; | ||
type: Type; | ||
value?: any; | ||
@@ -21,0 +22,0 @@ onChange?: React.EventHandler<any>; |
@@ -26,4 +26,4 @@ "use strict"; | ||
(function (DisplayMode) { | ||
DisplayMode[DisplayMode["View"] = 0] = "View"; | ||
DisplayMode[DisplayMode["Edit"] = 1] = "Edit"; | ||
DisplayMode["View"] = "View"; | ||
DisplayMode["Edit"] = "Edit"; | ||
})(DisplayMode = exports.DisplayMode || (exports.DisplayMode = {})); | ||
@@ -30,0 +30,0 @@ function entrySelector(key) { |
@@ -0,6 +1,7 @@ | ||
export declare type Type = "string" | "number" | "boolean" | "array"; | ||
export declare class SchemaProperty { | ||
type: string; | ||
type: Type; | ||
title: string | undefined; | ||
[key: string]: any; | ||
constructor(type: string, title?: string | undefined, additionalProps?: any); | ||
constructor(type: Type, title?: string | undefined, additionalProps?: any); | ||
} |
@@ -19,5 +19,8 @@ /// <reference types="react" /> | ||
private renderAnyTypeForEdit; | ||
private renderBooleanTypeForEdit; | ||
private renderArrayTypeForEdit; | ||
boolean: (childProps: {}) => JSX.Element; | ||
string: (childProps: {}) => JSX.Element; | ||
number: (childProps: {}) => JSX.Element; | ||
array: (childProps: {}) => JSX.Element; | ||
} |
@@ -41,5 +41,16 @@ "use strict"; | ||
}; | ||
this.boolean = function (childProps) { return _this.renderAnyTypeForEdit(childProps, "boolean"); }; | ||
this.string = function (childProps) { return _this.renderAnyTypeForEdit(childProps, "string"); }; | ||
this.renderBooleanTypeForEdit = function (childProps) { | ||
return _this.renderAnyTypeForEdit(childProps, 'checkbox'); | ||
}; | ||
this.renderArrayTypeForEdit = function (childProps) { | ||
var parentAutomationId = childProps['data-automation-id']; | ||
var comps = childProps.value.map(function (value, index) { | ||
return React.createElement("li", { "data-automation-id": parentAutomationId + '_' + index }, value); | ||
}); | ||
return React.createElement("ol", __assign({}, childProps), comps); | ||
}; | ||
this.boolean = function (childProps) { return _this.renderBooleanTypeForEdit(childProps); }; | ||
this.string = function (childProps) { return _this.renderAnyTypeForEdit(childProps, "boolean!!"); }; // TODO: FIX!!! | ||
this.number = function (childProps) { return _this.renderAnyTypeForEdit(childProps, "number"); }; | ||
this.array = function (childProps) { return _this.renderArrayTypeForEdit(childProps); }; | ||
} | ||
@@ -46,0 +57,0 @@ return EditSkin; |
{ | ||
"name": "auto-views", | ||
"version": "0.0.25", | ||
"version": "0.0.26", | ||
"description": "Common, fully-tested, strictly-typed, Wix-styled, auto views library", | ||
@@ -5,0 +5,0 @@ "main": "./lib/index.js", |
export type Type ="string"|"number"|"boolean"|"array";//|"null";|"object"; | ||
export class SchemaProperty { | ||
[key:string]:any; | ||
constructor(public type: string,public title?: string, additionalProps: any = {}){ | ||
constructor(public type: Type,public title?: string, additionalProps: any = {}){ | ||
for (let key in additionalProps){ | ||
@@ -6,0 +8,0 @@ if (additionalProps.hasOwnProperty(key)){ |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
61643
838