Skip to content

Commit f7ab5e5

Browse files
authored
Mark TODOs as comments and add Inputs.search documentation (#518)
* change todos to comments and add Inputs.search doc * add API reference
1 parent 1e9a79d commit f7ab5e5

File tree

8 files changed

+41
-18
lines changed

8 files changed

+41
-18
lines changed

docs/inputs/checkbox.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -79,7 +79,7 @@ const size2 = view(Inputs.checkbox(
7979
size2
8080
```
8181

82-
[TODO] check if okay, removed link to Hello, Inputs.
82+
<!--[TODO] check if okay, removed link to Hello, Inputs. -->
8383

8484
Passing a Map to Checkbox is especially useful in conjunction with [d3.group](https://observablehq.com/@d3/d3-group). For example, given a tabular dataset of Olympic athletes, we can use d3.group to group them by gold medal count, and then Checkbox to select the athletes for the chosen count. Note that the value of the Checkbox will be an array of arrays, since d3.group returns a Map from key to array; use [*array*.flat](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/flat) to merge these arrays if desired.
8585

docs/inputs/color.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ const fill = view(Inputs.color({label: "Fill", value: d3.color("steelblue").form
1818

1919
If you specify the *datalist* option as an array of hexadecimal color strings, the color picker will show this set of colors for convenient picking. (The user will still be allowed to pick another color, however; if you want to limit the choice to a specific set, then a radio or select input may be more appropriate.)
2020

21-
[TODO] update to the new Observable color palette?
21+
<!-- [TODO] update to the new Observable color palette? -->
2222

2323
```js echo
2424
const stroke = view(Inputs.color({label: "Stroke", datalist: d3.schemeTableau10}));

docs/inputs/file.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,12 @@
11
# File input
22

3-
[TODO] check okay, updated to point to /javascript/files rather than FileAttachment info in docs
3+
<!-- [TODO] check okay, updated to point to /javascript/files rather than FileAttachment info in docs -->
44

55
The File input specifies a local file. The exposed value provides the same interface as an Observable [file attachment](../javascript/files) for convenient parsing in various formats such as text, image, JSON, CSV, ZIP, and XLSX; however, the file is not uploaded and is only available temporarily in memory.
66

77
By default, any file is allowed, and the value of the input resolves to null.
88

9-
[TODO] check error, return to File input after hearing back (Fil has PR submitted)
9+
<!-- [TODO] check error, return to File input after hearing back (Fil has PR submitted) -->
1010

1111
```js echo
1212
const file = view(Inputs.file())

docs/inputs/radio.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -87,9 +87,9 @@ const size2 = view(Inputs.radio(
8787
size2
8888
```
8989
90-
[TODO] check okay to remove ref to Hello, Inputs below
90+
<!-- [TODO] check okay to remove ref to Hello, Inputs below -->
9191
92-
[TODO] check if linking to d3-group notebook below is best
92+
<!-- [TODO] check if linking to d3-group notebook below is best -->
9393
9494
Passing a Map to Radio is especially useful in conjunction with [d3.group](https://observablehq.com/@d3/d3-group). For example, given a tabular dataset of Olympic athletes, we can use d3.group to group them by gold medal 🥇 count, and then Radio to select the athletes for the chosen count.
9595

docs/inputs/search.md

Lines changed: 29 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,8 @@
11
# Search input
22

3-
[TODO] check on Hello, Inputs removed below.
3+
[Examples ›](https://observablehq.com/@observablehq/input-search) [API Reference ›](https://github.com/observablehq/inputs/blob/main/README.md#search)
4+
5+
<!-- [TODO] check on Hello, Inputs removed below. -->
46

57
The Search input allows freeform, full-text search of a tabular dataset (or a single column of values) using a simple query parser. It is often paired with a [Table input](./table).
68

@@ -11,7 +13,12 @@ const penguins = FileAttachment("penguins.csv").csv({typed: true});
1113
```
1214

1315
```js echo
14-
const search = view(Inputs.search(penguins));
16+
const searchInput = Inputs.search(penguins);
17+
const search = Generators.input(searchInput);
18+
```
19+
20+
```js echo
21+
searchInput
1522
```
1623

1724
```js echo
@@ -23,13 +30,29 @@ Or, as a table:
2330
```js echo
2431
Inputs.table(search)
2532
```
26-
[TODO] fix below to interactively search on click
2733

28-
If you search for multiple terms, such as ${htl.html`<a style="cursor: pointer; border-bottom: dotted 1px;" onclick=${() => { viewof search.query = "gen bis"; viewof search.dispatchEvent(new CustomEvent("input")); }}>“gen bis”`} (for Gentoos on the Biscoe Islands) or ${htl.html`<a style="cursor: pointer; border-bottom: dotted 1px;" onclick=${() => { viewof search.query = "gen fem"; viewof search.dispatchEvent(new CustomEvent("input")); }}>“gen fem”`} (for female Gentoos), every term must match: there’s an implicit logical AND.
2934

30-
[TODO] where should Observable Inputs general point now? Add an "Inputs overview" page?
35+
```js
36+
import {html} from "npm:htl";
37+
```
38+
39+
```js echo
40+
function genBisSearch() {
41+
searchInput.query = "gen bis";
42+
searchInput.dispatchEvent(new CustomEvent("input"));
43+
}
44+
45+
function genFemSearch() {
46+
searchInput.query = "gen fem";
47+
searchInput.dispatchEvent(new CustomEvent("input"));
48+
}
49+
```
50+
51+
If you search for multiple terms, such as ${html`<a style="cursor: pointer; border-bottom: dotted 1px;" onclick=${genBisSearch}>“gen bis”`} (for Gentoos on the Biscoe Islands) or ${html`<a style="cursor: pointer; border-bottom: dotted 1px;" onclick=${genFemSearch}>“gen fem”`} (for female Gentoos), every term must match: there’s an implicit logical AND.
52+
53+
<!-- [TODO] where should Observable Inputs general point now? Add an "Inputs overview" page? -->
3154

32-
[TODO] view vs. viewof reference material? Currently points here: https://observablehq.com/@observablehq/views
55+
<!-- [TODO] view vs. viewof reference material? Currently points here: https://observablehq.com/@observablehq/views -->
3356

3457
The Search input is designed to work with other [Observable inputs](TODO) and especially [tables](./table). You can also refer to the current search results from any cell using a [view](https://observablehq.com/@observablehq/views). For example, to compute the median body mass of the matching penguins:
3558

docs/inputs/select.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -90,9 +90,9 @@ const size2 = view(Inputs.select(new Map([["Short", 8], ["Tall", 12], ["Grande",
9090
size2
9191
```
9292

93-
[TODO] check if removing Hello, Inputs okay.
93+
<!-- [TODO] check if removing Hello, Inputs okay. -->
9494

95-
[TODO] check if pointing to d3-group notebook is best.
95+
<!-- [TODO] check if pointing to d3-group notebook is best. -->
9696

9797
Passing a Map to Select is especially useful in conjunction with [d3.group](https://observablehq.com/@d3/d3-group). For example, given a tabular dataset of Olympic athletes, we can use d3.group to group them by sport, and then Select to select the athletes for the chosen sport.
9898

docs/inputs/table.md

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
# Table input
22

3-
[TODO] check if removing Hello, Inputs okay.
3+
<!-- [TODO] check if removing Hello, Inputs okay. -->
44

55
A Table displays tabular data. It’s fast: rows are rendered lazily on scroll. It sorts: click a header to sort, and click again to reverse. And it selects: click a checkbox on any row, and the selected rows are exported as a view value. (And for searching, see the [Search input](./search).)
66

@@ -51,7 +51,7 @@ dataset, for example. Undefined values go to the end.
5151
Inputs.table(penguins, {sort: "body_mass_g", reverse: true})
5252
```
5353

54-
[TODO] these use view() instead of viewof operator. Is update below correct? Just changes "using the viewof operator" to "using the view function" (and do we need to update intro to views in docs?)
54+
<!-- [TODO] these use view() instead of viewof operator. Is update below correct? Just changes "using the viewof operator" to "using the view function" (and do we need to update intro to views in docs?) -->
5555

5656
Tables are [view-compatible](https://observablehq.com/@observablehq/views): using the
5757
view function, you can use a table to select rows and refer to them from other
@@ -171,7 +171,7 @@ array of references to the actual objects in your data.
171171

172172
For example, to preselect the first two items, you could write:
173173

174-
[TODO] eval: false option for JS code below?
174+
<!-- [TODO] eval: false option for JS code below? -->
175175

176176
```js echo
177177
// { value: penguins.slice(0, 2)}

docs/inputs/text.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,7 @@ The HTML5 *pattern*, *spellcheck*, *minlength*, and *maxlength* options are also
4848
const email = view(Inputs.text({type: "email", label: "Email", placeholder: "Enter your email"}));
4949
```
5050

51-
[TODO] fix below (had viewof operator before email.checkValidity(), not sure how to update)
51+
<!-- [TODO] fix below (had viewof operator before email.checkValidity(), not sure how to update) -->
5252

5353
```js echo
5454
//[email, email.checkValidity()]

0 commit comments

Comments
 (0)