lunatk / protobuf-auto-form Goto Github PK
View Code? Open in Web Editor NEWAuto-generated form to construct protobuf message object, in React
Home Page: https://npmjs.com/package/protobuf-auto-form
License: MIT License
Auto-generated form to construct protobuf message object, in React
Home Page: https://npmjs.com/package/protobuf-auto-form
License: MIT License
This document describes a new mechanism for providing field-specific attributes via special child component, namely AutoFormField
. With field-specific attributes (e.g., label
, disabled
, and render
), you can override how each field should be rendered.
Generally, protobuf definition itself is not containing enough information for constructing user-friendly UI. For example, message field name tends to be in form of programming terminologies, making it hard to be understood by the end-user not familiar with programming.
It is necessary for developers being able to provide such additional information to AutoForm.
In React UI framework ecosystem, this is usually done through component props. However, the object passed as props becomes too verbose when the field hierarchy is complicated. In order to make it neat and idiomatic, child component can be used to target a specific field of the form.
You can put AutoForm.Field
as a child of AutoForm
. AutoForm.Field
has a required prop name
, indicating which field of the current form should be associated with it.
Consider rendering protobuf message below.
message Article {
id: int32
title: string
content: string
}
Say we do not want our end-users to edit id
field, since it will be auto-generated.
We can achieve this by specifying disabled
attribute of the id
field like the code below.
<AutoForm messageType="Article" ... >
<AutoForm.Field name="id" disabled />
</AutoForm>
Here, AutoForm.Field
does not actually render any elements, it just delivers attributes to each field. Other fields not specified through AutoForm.Field
will be rendered just like the default. Note that AutoForm.Field
does not change ordering of the fields.
WIP
WIP
In most of my use case, most of the props props AutoForm shares common values (e.g., namespace).
It'd better create factory function that takes these common props, and return the component with defaultized props.
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.