Skip to content

Commit 7591028

Browse files
mbostockFil
andauthored
vanilla stdlib; server-side render implicit stylesheets; async Generators; width(target) (#294)
* vanilla stdlib * libs * duckdb * sqlite * xlsx * remove todo * simplify database resolution * ignore unresolved databases * incremental implicit stylesheets * async generators * don’t masquerade as sql.js * width(target: Element) * rm docs/stdlib.md * remove stdlib dependency * Update src/libraries.ts Co-authored-by: Philippe Rivière <[email protected]> * sqlite docs; FileAttachment support * template literal string coercion * build & deploy client bundles * remove unused example-dist --------- Co-authored-by: Philippe Rivière <[email protected]>
1 parent 5874262 commit 7591028

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

93 files changed

+1828
-642
lines changed

.eslintrc.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,8 +24,8 @@
2424
"@typescript-eslint/no-unused-vars": ["error", {"ignoreRestSiblings": true}],
2525
"import/first": "warn",
2626
"import/newline-after-import": "warn",
27+
"import/no-duplicates": "off",
2728
"import/no-import-module-exports": "warn",
28-
"import/no-namespace": "error",
2929
"import/no-relative-packages": "warn",
3030
"import/no-unresolved": "off",
3131
"import/no-unused-modules": "error",

docs/.observablehq/config.ts

Lines changed: 17 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -2,9 +2,10 @@ export default {
22
title: "Observable CLI",
33
pages: [
44
{name: "Getting started", path: "/getting-started"},
5-
{name: "Markdown", path: "/markdown"},
65
{name: "JavaScript", path: "/javascript"},
76
{name: "Data loaders", path: "/loaders"},
7+
{name: "Markdown", path: "/markdown"},
8+
{name: "HTML", path: "/html"},
89
{
910
name: "JavaScript",
1011
open: false,
@@ -17,17 +18,26 @@ export default {
1718
{name: "Mutables", path: "/javascript/mutables"},
1819
{name: "Imports", path: "/javascript/imports"},
1920
{name: "Inputs", path: "/javascript/inputs"},
20-
{name: "DuckDB", path: "/javascript/duckdb"}
2121
]
2222
},
2323
{
24-
name: "Features",
24+
name: "Libraries",
2525
open: false,
2626
pages: [
27-
{name: "HTML", path: "/html"},
28-
{name: "DOT", path: "/dot"},
29-
{name: "Mermaid", path: "/mermaid"},
30-
{name: "TeX", path: "/tex"}
27+
{name: "Arquero", path: "/lib/arquero"},
28+
{name: "Apache Arrow", path: "/lib/arrow"},
29+
{name: "D3", path: "/lib/d3"},
30+
{name: "DOT (Graphviz)", path: "/lib/dot"},
31+
{name: "DuckDB", path: "/lib/duckdb"},
32+
{name: "Hypertext Literal", path: "/lib/htl"},
33+
{name: "Leaflet", path: "/lib/leaflet"},
34+
{name: "Lodash", path: "/lib/lodash"},
35+
{name: "Mermaid", path: "/lib/mermaid"},
36+
{name: "Observable Inputs", path: "/lib/inputs"},
37+
{name: "Observable Plot", path: "/lib/plot"},
38+
{name: "SQLite", path: "/lib/sqlite"},
39+
{name: "TeX", path: "/lib/tex"},
40+
{name: "TopoJSON", path: "/lib/topojson"}
3141
]
3242
},
3343
{name: "Contributing", path: "/contributing"}

docs/javascript/inputs.md

Lines changed: 0 additions & 220 deletions
Original file line numberDiff line numberDiff line change
@@ -17,223 +17,3 @@ The current gain is ${gain.toFixed(1)}!
1717
## view(*input*)
1818

1919
As described above, this function [displays](./display) the given input element and then returns its corresponding [generator](./generators) via `Generators.input`. Use this to display an input element while also exposing the input’s value as a [reactive top-level variable](./reactivity).
20-
21-
## Built-in inputs
22-
23-
These basic inputs will get you started.
24-
25-
* [Button](#button) - do something when a button is clicked
26-
* [Toggle](#toggle) - toggle between two values (on or off)
27-
* [Checkbox](#checkbox) - choose any from a set
28-
* [Radio](#radio) - choose one from a set
29-
* [Range](#range) or [Number](https://observablehq.com/@observablehq/input-range) - choose a number in a range (slider)
30-
* [Select](#select) - choose one or any from a set (drop-down menu)
31-
* [Text](#text) - enter freeform single-line text
32-
* [Textarea](#textarea) - enter freeform multi-line text
33-
* [Date](#date) or [Datetime](https://observablehq.com/@observablehq/input-date) - choose a date
34-
* [Color](#color) - choose a color
35-
* [File](#file) - choose a local file
36-
37-
These fancy inputs are designed to work with tabular data such as CSV or TSV [file attachments](./files).
38-
39-
* [Search](#search) - query a tabular dataset
40-
* [Table](#table) - browse a tabular dataset
41-
42-
---
43-
44-
### Button
45-
46-
Do something when a button is clicked. [Examples ›](https://observablehq.com/@observablehq/input-button) [API Reference ›](https://github.com/observablehq/inputs/blob/main/README.md#button)
47-
48-
```js echo
49-
const clicks = view(Inputs.button("Click me"));
50-
```
51-
52-
```js
53-
clicks
54-
```
55-
56-
---
57-
58-
### Toggle
59-
60-
Toggle between two values (on or off). [Examples ›](https://observablehq.com/@observablehq/input-toggle) [API Reference ›](https://github.com/observablehq/inputs/blob/main/README.md#toggle)
61-
62-
```js echo
63-
const mute = view(Inputs.toggle({label: "Mute"}));
64-
```
65-
66-
```js
67-
mute
68-
```
69-
70-
---
71-
72-
### Checkbox
73-
74-
Choose any from a set. [Examples ›](https://observablehq.com/@observablehq/input-checkbox) [API Reference ›](https://github.com/observablehq/inputs/blob/main/README.md#checkbox)
75-
76-
```js echo
77-
const flavors = view(Inputs.checkbox(["salty", "sweet", "bitter", "sour", "umami"], {label: "Flavors"}));
78-
```
79-
80-
```js
81-
flavors
82-
```
83-
84-
---
85-
86-
### Radio
87-
88-
Choose one from a set. [Examples ›](https://observablehq.com/@observablehq/input-radio) [API Reference ›](https://github.com/observablehq/inputs/blob/main/README.md#radio)
89-
90-
```js echo
91-
const flavor = view(Inputs.radio(["salty", "sweet", "bitter", "sour", "umami"], {label: "Flavor"}));
92-
```
93-
94-
```js
95-
flavor
96-
```
97-
98-
---
99-
100-
### Range
101-
102-
Pick a number. [Examples ›](https://observablehq.com/@observablehq/input-range) [API Reference ›](https://github.com/observablehq/inputs/blob/main/README.md#range)
103-
104-
```js echo
105-
const n = view(Inputs.range([0, 255], {step: 1, label: "Favorite number"}));
106-
```
107-
108-
```js
109-
n
110-
```
111-
112-
---
113-
114-
### Select
115-
116-
Choose one, or any, from a menu. [Examples ›](https://observablehq.com/@observablehq/input-select) [API Reference ›](https://github.com/observablehq/inputs/blob/main/README.md#select)
117-
118-
```js
119-
const capitals = FileAttachment("us-state-capitals.tsv").tsv({typed: true});
120-
const stateNames = capitals.then((capitals) => capitals.map(d => d.State));
121-
```
122-
123-
```js echo
124-
const homeState = view(Inputs.select([null].concat(stateNames), {label: "Home state"}));
125-
```
126-
127-
```js
128-
homeState
129-
```
130-
131-
```js echo
132-
const visitedStates = view(Inputs.select(stateNames, {label: "Visited states", multiple: true}));
133-
```
134-
135-
```js
136-
visitedStates
137-
```
138-
139-
---
140-
141-
### Text
142-
143-
Enter freeform single-line text. [Examples ›](https://observablehq.com/@observablehq/input-text) [API Reference ›](https://github.com/observablehq/inputs/blob/main/README.md#text)
144-
145-
```js echo
146-
const name = view(Inputs.text({label: "Name", placeholder: "What’s your name?"}));
147-
```
148-
149-
```js
150-
name
151-
```
152-
153-
---
154-
155-
### Textarea
156-
157-
Enter freeform multi-line text. [Examples ›](https://observablehq.com/@observablehq/input-textarea) [API Reference ›](https://github.com/observablehq/inputs/blob/main/README.md#textarea)
158-
159-
```js echo
160-
const bio = view(Inputs.textarea({label: "Biography", placeholder: "What’s your story?"}));
161-
```
162-
163-
```js
164-
bio
165-
```
166-
167-
---
168-
169-
### Date
170-
171-
Choose a date, or a date and time. [Examples ›](https://observablehq.com/@observablehq/input-date) [API Reference ›](https://github.com/observablehq/inputs/blob/main/README.md#date)
172-
173-
```js echo
174-
const birthday = view(Inputs.date({label: "Birthday"}));
175-
```
176-
177-
```js
178-
birthday
179-
```
180-
181-
---
182-
183-
### Color
184-
185-
Choose a color. [Examples ›](https://observablehq.com/@observablehq/input-color) [API Reference ›](https://github.com/observablehq/inputs/blob/main/README.md#color)
186-
187-
```js echo
188-
const color = view(Inputs.color({label: "Favorite color", value: "#4682b4"}));
189-
```
190-
191-
```js
192-
color
193-
```
194-
195-
---
196-
197-
### File
198-
199-
Choose a local file. [Examples ›](https://observablehq.com/@observablehq/input-file) [API Reference ›](https://github.com/observablehq/inputs/blob/main/README.md#file)
200-
201-
```js echo
202-
const file = view(Inputs.file({label: "CSV file", accept: ".csv", required: true}));
203-
```
204-
205-
```js
206-
data = file.csv({typed: true})
207-
```
208-
209-
---
210-
211-
### Search
212-
213-
Query a tabular dataset. [Examples ›](https://observablehq.com/@observablehq/input-search) [API Reference ›](https://github.com/observablehq/inputs/blob/main/README.md#search)
214-
215-
```js echo
216-
const search = view(Inputs.search(capitals, {placeholder: "Search U.S. capitals"}));
217-
```
218-
219-
```js
220-
search // see table below!
221-
```
222-
223-
---
224-
225-
### Table
226-
227-
Browse a tabular dataset. [Examples ›](https://observablehq.com/@observablehq/input-table) [API Reference ›](https://github.com/observablehq/inputs/blob/main/README.md#table)
228-
229-
```js echo
230-
const rows = view(Inputs.table(search));
231-
```
232-
233-
```js
234-
rows // click a checkbox in the leftmost column
235-
```
236-
237-
---
238-
239-
* [Form](https://observablehq.com/@observablehq/input-form?collection=@observablehq/inputs) - combine multiple inputs for a compact display

docs/lib/arquero.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
# Arquero
2+
3+
```js echo
4+
aq
5+
```

docs/lib/arrow.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
# Apache Arrow
2+
3+
```js echo
4+
Arrow
5+
```

docs/lib/chinook.db

864 KB
Binary file not shown.

docs/lib/d3.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
# D3
2+
3+
```js echo
4+
d3
5+
```
File renamed without changes.

docs/javascript/duckdb.md renamed to docs/lib/duckdb.md

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,10 @@
11
# DuckDB
22

3-
Observable Markdown has built-in support for DuckDB via [duckdb-wasm](https://github.com/duckdb/duckdb-wasm). It’s easiest to use in conjunction with [`FileAttachment`](./files). Declare a database with `DuckDBClient`, passing in a set of named tables:
3+
Observable Markdown has built-in support for DuckDB via [duckdb-wasm](https://github.com/duckdb/duckdb-wasm). It’s easiest to use in conjunction with [`FileAttachment`](../javascript/files). Declare a database with `DuckDBClient`, passing in a set of named tables:
4+
5+
```js echo
6+
duckdb
7+
```
48

59
```js echo
610
const db = DuckDBClient.of({gaia: FileAttachment("gaia-sample.parquet")});
File renamed without changes.

docs/lib/htl.md

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
# Hypertext Literal
2+
3+
```js echo
4+
htl
5+
```
6+
7+
```js echo
8+
html
9+
```
10+
11+
```js echo
12+
svg
13+
```

0 commit comments

Comments
 (0)