Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

auto-views

Package Overview
Dependencies
Maintainers
1
Versions
55
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

auto-views - npm Package Compare versions

Comparing version 0.0.2 to 0.0.3

25

lib/components/auto-form/auto-form.d.ts
/// <reference types="react" />
import * as React from 'react';
export interface AutoFormProps extends React.HTMLAttributes<HTMLFormElement> {
repo: SchemaRepository;
schemaId: string;
displayMode: DisplayMode;
}
export declare enum DisplayMode {
View = 0,
Edit = 1,
}
export interface AutoFormSchema {
id: string;
properties: {
[key: string]: SchemaProperty;
};
}
export interface SchemaProperty {
title: string;
}
export declare class SchemaRepository {
schemas: {
[key: string]: AutoFormSchema;
};
addSchema(schema: AutoFormSchema): void;
getSchema(id: string): AutoFormSchema;
clear(): void;
}
export declare function newSchemaRepository(): SchemaRepository;
export declare class AutoForm extends React.Component<AutoFormProps, {}> {
render(): JSX.Element;
}

47

lib/components/auto-form/auto-form.js

@@ -22,2 +22,27 @@ "use strict";

var React = require("react");
var DisplayMode;
(function (DisplayMode) {
DisplayMode[DisplayMode["View"] = 0] = "View";
DisplayMode[DisplayMode["Edit"] = 1] = "Edit";
})(DisplayMode = exports.DisplayMode || (exports.DisplayMode = {}));
var SchemaRepository = (function () {
function SchemaRepository() {
this.schemas = {};
}
SchemaRepository.prototype.addSchema = function (schema) {
this.schemas[schema.id] = schema;
};
SchemaRepository.prototype.getSchema = function (id) {
return this.schemas[id];
};
SchemaRepository.prototype.clear = function () {
this.schemas = {};
};
return SchemaRepository;
}());
exports.SchemaRepository = SchemaRepository;
function newSchemaRepository() {
return new SchemaRepository();
}
exports.newSchemaRepository = newSchemaRepository;
var AutoForm = (function (_super) {

@@ -29,3 +54,23 @@ __extends(AutoForm, _super);

AutoForm.prototype.render = function () {
return React.createElement("form", __assign({}, this.props));
var _this = this;
var children = [];
if (!this.props.repo) {
children.push(React.createElement("label", { "data-automation-id": "errMessage" }, "can't render form - missing properties"));
}
else {
var schemaProperties_1 = this.props.repo.getSchema(this.props.schemaId).properties;
children = Object.keys(schemaProperties_1).map(function (property) {
var comp;
if (_this.props.displayMode == DisplayMode.Edit) {
comp = React.createElement("input", { "data-automation-id": "input_" + property });
}
else {
comp = React.createElement("label", { "data-automation-id": "input_" + property });
}
return React.createElement("div", null,
React.createElement("label", { "data-automation-id": "label_" + property }, schemaProperties_1[property].title),
comp);
});
}
return React.createElement("form", __assign({}, this.props), children);
};

@@ -32,0 +77,0 @@ return AutoForm;

2

package.json
{
"name": "auto-views",
"version": "0.0.2",
"version": "0.0.3",
"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

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc