Coder Social home page Coder Social logo

Comments (11)

Fer0x avatar Fer0x commented on August 26, 2024 1

While AutoGroups seems to be legal, AutoHeaders is something too specific, related to Table representation, which core not limited to. We could call it AutoTitles, or try to make it more universal, like taking additional prop with field key which would be mapped to children.

from autoviews.

tyv avatar tyv commented on August 26, 2024
  • AutoHeaders or AutoTitles it might be AutoViews when you use JSONSchema as data: fields of the object and optional titles becomes data. I think we need to explore and think about this idea a bit more. The proposed option wouldn't work for binding AutoHeaders in ComponentsRepo when AutoFields and AutoItems are bindable without necessity to define children
  • AutoGroups it is basically multiple AutoFields with ability to wrap them.

Both components are nice to have thing to hide direct usage of low level utils, but not yet sure they are the similar to AutoItems and AutoFields as they are also very low level.

Let's have a call about this proposal and try to think together on the best api. The problem though is very relevant.

from autoviews.

yoavaa avatar yoavaa commented on August 26, 2024

The reason I advocate for those two components is that is separates the higher level elements (auto items, auto groups, etc) with the low level concepts, making documentation way simpler and understanding the product simpler for a new user

from autoviews.

yoavaa avatar yoavaa commented on August 26, 2024

Adding more notes -

I can easily see how we can make AutoHeaders more generic by turning it into AutoSchemaFields which basically accepts the JSONSchema node for the map function.

The example from above turns into the following

<AutoSchemaFields {...props}>
  {(schemaField, i) => <TableCell key={i}>{schemaField.title}</TableCell>}
</AutoSchemaFields>

from autoviews.

tyv avatar tyv commented on August 26, 2024

Then why do we need a React component AutoSchemaFields, it could be just utility.

from autoviews.

tyv avatar tyv commented on August 26, 2024

Regarding AutoHeaders.
Here is how I see it today. It is combination of 2 things:

  1. some utility that converts schema to the data considering UISchema (remove hidden, order, etc..), builds a schema for that converted schema automatically.
  2. Ordinar AutoView usage.

Example: https://codesandbox.io/s/autoheaders-7xss6o?file=/src/AutoHeaders.tsx


Why I think it is important to to have schema=>data conversion?

  1. it is in fact what is needed
  2. there is no way with headers auto-events would work properly, so it should be clear that schema and data are new and if it is needed to have onclicks/onchange(s): they should consider this transformation.

I don't see any better way. This looks good I think.

@yoavaa and @Fer0x plz take a look

from autoviews.

yoavaa avatar yoavaa commented on August 26, 2024

I want to understand - your suggestion is basically the structure below

The second part is great, but the first is too strange, and the two schemas convertedSchema and convertedSchema2Data are again very strange.

The problem with the below is that the intent gets lost with a too verbose code.

  1. define the repo
const tableHeadRepo = new ComponentsRepo("tableHeadRepo")
  .register("array", {
    name: "tableHeaed",
    component: (props) => (
      <thead>
        <AutoItems {...props} />
      </thead>
    )
  })
  .register("object", {
    name: "tableHeadCell",
    component: (props) => <th>{props.data.schema.title}</th>
  });
  1. the table component is then
  new ComponentsRepo("complex")
    .register("array", {
      name: "table",
      component: (props) => {
        return (
          <table>
            <RepositoryProvider components={headRepo}>
              <AutoView schema={convertedSchema} data={convertedSchema2Data} />
            </RepositoryProvider>
            <tbody>
              <AutoItems {...props} render={(item) => <tr>{item}</tr>} />
            </tbody>
          </table>
        );
      }
    })
    .register("object", {
      name: "tableRow",
      component: (props) => (
        <AutoFields {...props} render={(item) => <td>{item}</td>} />
      )
    })

from autoviews.

yoavaa avatar yoavaa commented on August 26, 2024

What I am trying to say is that it looks too complicated.

What I am looking for is something like

  new ComponentsRepo("complex")
    .register("array", {
      name: "table",
      component: (props) => {
        return (
          <table>
            <schemaAsData {...props} path={items} > 
              <AutoItems {...props} > // the items here are the schema fields of the item
            </schemaAsData>
            <tbody>
              <AutoItems {...props} render={(item) => <tr>{item}</tr>} />
            </tbody>
          </table>
        );
      }
    })

from autoviews.

Fer0x avatar Fer0x commented on August 26, 2024

@yoavaa in terms of AutoViews if data is completely different so it should be different AutoView scope with own props /repo/repositoryContext. Code might be rewritten to something like this:

  new ComponentsRepo("complex")
    .register("array", {
      name: "table",
      component: (props) => {
        return (
          <table>
            <thead>
              <SchemaAsData {...props} path="/items"> 
                 {headerProps => <AutoItems {...headerProps} render={item => <th>{item}</th>} />}
              </SchemaAsData>
            </thead>
            <tbody>
              <AutoItems {...props} render={(item) => <tr>{item}</tr>} />
            </tbody>
          </table>
        );
      }
    })

But anyway, <SchemaAsData /> should contain RepositoryProvider with some different repo.

from autoviews.

tyv avatar tyv commented on August 26, 2024

@yoavaa the problem in your example is auto-passing props.
which is impossible, as the data and schema are different.
what if prop contains onClick, or other things that relates to original data structure.

from autoviews.

yoavaa avatar yoavaa commented on August 26, 2024

I think we are getting to an interesting direction.

The concept of schema as data, which replaces the props and can use a different component repo looks like a good ackaging for headers.

Given we translate schema to data, we can also translate using the UI schema for field ordering and filters, or create an equivalent UI schema to do so.

Anyway, it feels like something that takes a good form

from autoviews.

Related Issues (11)

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.