Giter VIP home page Giter VIP logo

protobuf-auto-form's People

Contributors

dependabot[bot] avatar github-actions[bot] avatar lunatk avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar

Forkers

hyp3rflow

protobuf-auto-form's Issues

Proposal: providing field attributes via child component

Field Override Pattern Using Child Component

Abstract

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.

Background

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.

Proposal

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.

Nested Field

WIP

Repeated and Map

WIP

AutoForm component factory function

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.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.