observablehq / inputs

Better input elements
https://observablehq.com/framework/lib/inputs
ISC License
125 stars 34 forks source link

Add Inputs.form #195

Closed mbostock closed 2 years ago

mbostock commented 2 years ago

Fixes #73. Demo: https://observablehq.com/d/4108c4771279ad1a

mbostock commented 2 years ago

I feel this should also support assignment as described here: https://github.com/observablehq/inputs/issues/73#issuecomment-779358949

Update: done.

mbostock commented 2 years ago

This implementation doesn't seem to handle native inputs in the same way Generators.input does, right?

It doesn’t automatically adapt inputs that don’t emit input events and expose an input.value, no, but it will work with any native inputs that conform to this representation (such as type=range, though you’ll get a string value instead of a number).

mbostock commented 2 years ago

Any thoughts on this one, @Fil? (I’ll get to that Legends PR soon…)

Fil commented 2 years ago

I like the fact that it's hierarchical, like the good old dat-gui; however in that case, we could want a way to pass styling or fieldset+label options to the children, if we want the inputs structure to be visible? This would be useful in general but particularly so for nested inputs. But maybe that's for another project.

Another idea is that we could also support a Map of inputs, that would return a Map of values (or maybe a key.value object). It would seem more consistent with Inputs.select, for example, and lists of options generated by, say, d3.rollup.

mbostock commented 2 years ago

I'd love see an option for a template callback added that simply receives the inputs array/object as passed to Inputs.form(), and returns the outermost element.

Nice idea. Added.

mootari commented 2 years ago

When will the new release get deployed to Observable?

mbostock commented 2 years ago

In the near future.

harrybiddle commented 2 years ago

Is it possible for the properties of an input in a form to depend on the value of another in the same form?