since these links go to the same place and Input seems most useful with bind, i'd reframe this section to just talk about bind (instead of a list of "a few more advanced techniques"). bind is amazing!! having an officially supported path for synchronized inputs feels like a big reason to upgrade
Is there an easy way to make a slider that slides from the higher number to the lower number? I've had use for this in the past (https://next.observablehq.com/@borisvish/beyond-the-normal-distribution) and the trick that I used there needed to be explained to the person I was working with.
Suggestion: move the `Text = Inputs.Text`, `Button = Inputs.Button` etc. cells to be at the top of the relevant sections, so that when someone clicks on e.g. the link to `Button` in the output of their `import {Button, Text} from '@observablehq/inputs'` cell in a different notebook, the link which points at https://observablehq.com/@observablehq/inputs#Button will scroll to a description instead of to the decontextualized assignment at the bottom of this page.
You can style it with external CSS, but this is not recommended. Observable Inputs are intended to provide a well-designed, consistent appearance by default. For more customization, see https://observablehq.com/@bartok32/diy-inputs
What is the current method to require Observable Inputs in my Notebook?
I've been using: Inputs = require("@observablehq/inputs@0.7.21/dist/inputs.umd.min.js")
Any plans to add the Scrubber as a first class input? As this range input only supports numbers, it'd be nice to have one that supports non-numeric ranges, especially with the "Play" functionality.
Is there a way to distinguish between the empty selection and full selection? I have a use case for wanting to show some extra information for the selection, but my table has hundreds of rows and I don't want to show all details for all rows by default.
I though that comparing rows === search might work but this is false when there is no selection.
Yes, I agree. The value of a table with selectable rows should default to empty (for consistency with e.g. multi-select inputs), possibly with all rows available via a separate name.
The value of the Table is always an array, whereas the input can be an iterator, and also they can be in a different order if the table is sorted, so yeah, you can’t do an identity comparison to check whether the selection is empty.
You can preselect all rows by passing {value: data} (above, {value: search}), but I don’t think that’s what you want here because you’ll see lots of checked checkboxes.
We’re not going to change the default value to be the empty array, but I could see having an option, say {allowEmpty: true}, that when enabled would return the empty array when there is no selection, rather than all the data.
I'm pretty sure the dates here are inaccurate. Was every current state capitol really established exactly on Jan 1 of the relevant year? My guess is someone took the list of years from Wikipedia or similar and arbitrarily added -01-01 to the end of every one.
*capital
JavaScript has no built-in type for representing ambiguity or imprecision with dates. We’re using the Date type here, but it isn’t intended to imply that the state was established on January 1 of the given year, or for that matter, at UTC midnight. Furthermore, the Table doesn’t know the precision of the date, and the minimum precision of the default format is YYYY-MM-DD:
https://github.com/observablehq/inputs/blob/bf525033948bbdda452e65bc06c09a6b42f3b06c/src/format.js#L16-L27
This mirrors the behavior of d3.autoType, which is used by Observable’s typed: true option for CSV and TSV files, and needs at least YYYY-MM-DD to detect dates:
https://github.com/d3/d3-dsv/blob/aba1cce0e59500db67eab8f1a07dbd6a7a175064/src/autoType.js#L9-L12
We could use a year number here instead, but a Date is preferred to indicate that it’s a date. (And numbers can’t inherently represent ambiguity either.) If desired, you can specify a custom format when rendering dates in a Table so as to drop the -01-01, or perhaps to indicate ambiguity explicitly. I did not do that above because it slightly complicates the example code. For example:
Table(search, {format: {Since: d => d.getUTCFullYear()}})
Please upvote the tracking issue if you’re interested in this feature:
https://github.com/observablehq/inputs/issues/53
It’s not trivial to implement because it would require implementing a custom control (user interface), whereas all the existing inputs build no native controls provided by the browser. It’s not quite as good, but you could also consider using separate range inputs for start and end, or offset and limit.