@cfasim-ui/docs 0.6.3 → 0.7.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/charts/BarChart/BarChart.md +7 -8
- package/charts/BarChart/BarChart.vue +13 -7
- package/charts/ChoroplethMap/ChoroplethMap.md +99 -29
- package/charts/ChoroplethMap/ChoroplethMap.vue +456 -127
- package/charts/DataTable/DataTable.vue +1 -7
- package/charts/LineChart/LineChart.md +7 -8
- package/charts/LineChart/LineChart.vue +13 -7
- package/charts/_shared/ChartZoomControls.vue +138 -0
- package/charts/_shared/chartProps.ts +7 -7
- package/charts/_shared/index.ts +4 -15
- package/charts/_shared/seriesCsv.ts +2 -2
- package/charts/_shared/touch.ts +8 -0
- package/charts/_shared/useChartFoundation.ts +0 -1
- package/components/MultiSelect/MultiSelect.md +1 -1
- package/components/MultiSelect/MultiSelect.vue +24 -83
- package/components/NumberInput/NumberInput.md +5 -5
- package/components/NumberInput/NumberInput.vue +12 -59
- package/components/SelectBox/SelectBox.md +1 -0
- package/components/SelectBox/SelectBox.vue +34 -125
- package/components/TextInput/TextInput.md +2 -1
- package/components/TextInput/TextInput.vue +11 -51
- package/components/ToggleGroup/ToggleGroup.md +2 -2
- package/components/ToggleGroup/ToggleGroup.vue +21 -26
- package/components/_internal/FieldLabel.vue +27 -0
- package/components/_internal/field.ts +27 -0
- package/components/_internal/input.css +54 -0
- package/components/_internal/listbox.css +53 -0
- package/components/env.d.ts +4 -0
- package/index.json +8 -8
- package/package.json +1 -1
- package/pyodide/messages.ts +23 -0
- package/pyodide/pyodide.worker.ts +2 -21
- package/pyodide/pyodideWorkerApi.ts +7 -44
- package/shared/index.ts +1 -0
- package/shared/workerError.ts +17 -0
- package/wasm/messages.ts +6 -0
- package/wasm/wasm.worker.ts +1 -7
- package/wasm/wasmWorkerApi.ts +8 -26
|
@@ -0,0 +1,54 @@
|
|
|
1
|
+
/* Shared text-field skin for TextInput/NumberInput. Global (not scoped)
|
|
2
|
+
* so both components can use one copy; prefixed to avoid consumer
|
|
3
|
+
* collisions. */
|
|
4
|
+
|
|
5
|
+
.cfasim-input-label {
|
|
6
|
+
display: flex;
|
|
7
|
+
flex-direction: column;
|
|
8
|
+
gap: 0.25em;
|
|
9
|
+
font-size: var(--font-size-sm);
|
|
10
|
+
}
|
|
11
|
+
|
|
12
|
+
.cfasim-input-label-row {
|
|
13
|
+
display: flex;
|
|
14
|
+
align-items: center;
|
|
15
|
+
justify-content: space-between;
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
.cfasim-input {
|
|
19
|
+
display: block;
|
|
20
|
+
width: 100%;
|
|
21
|
+
height: 2.5em;
|
|
22
|
+
padding: 0 0.75em;
|
|
23
|
+
font-size: inherit;
|
|
24
|
+
background-color: var(--color-bg-0);
|
|
25
|
+
color: var(--color-text);
|
|
26
|
+
border: 1px solid var(--color-border);
|
|
27
|
+
border-radius: 0.375em;
|
|
28
|
+
transition:
|
|
29
|
+
border-color var(--transition-fast),
|
|
30
|
+
box-shadow var(--transition-fast);
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
.cfasim-input:hover {
|
|
34
|
+
border-color: var(--color-border-hover);
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
.cfasim-input:focus {
|
|
38
|
+
outline: none;
|
|
39
|
+
border-color: var(--color-border-focus);
|
|
40
|
+
box-shadow: var(--shadow-focus);
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
.cfasim-input[aria-invalid="true"] {
|
|
44
|
+
border-color: var(--color-error);
|
|
45
|
+
}
|
|
46
|
+
|
|
47
|
+
.cfasim-input[aria-invalid="true"]:focus {
|
|
48
|
+
border-color: var(--color-error);
|
|
49
|
+
box-shadow: 0 0 0 3px color-mix(in srgb, var(--color-error) 25%, transparent);
|
|
50
|
+
}
|
|
51
|
+
|
|
52
|
+
.cfasim-input::placeholder {
|
|
53
|
+
color: var(--color-text-tertiary);
|
|
54
|
+
}
|
|
@@ -0,0 +1,53 @@
|
|
|
1
|
+
/* Shared skin for the SelectBox/MultiSelect dropdown (reka-ui Select and
|
|
2
|
+
* Combobox portals render outside the component, so these are global).
|
|
3
|
+
* Sizing (width/max-height from the reka trigger vars) stays per-component. */
|
|
4
|
+
|
|
5
|
+
.cfasim-listbox-content {
|
|
6
|
+
z-index: 100;
|
|
7
|
+
background: var(--color-bg-0);
|
|
8
|
+
border: 1px solid var(--color-border);
|
|
9
|
+
border-radius: 0.25em;
|
|
10
|
+
box-shadow:
|
|
11
|
+
0 4px 6px -1px rgba(0, 0, 0, 0.1),
|
|
12
|
+
0 2px 4px -2px rgba(0, 0, 0, 0.1);
|
|
13
|
+
}
|
|
14
|
+
|
|
15
|
+
.cfasim-listbox-viewport {
|
|
16
|
+
padding: 0.25em;
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
.cfasim-listbox-empty {
|
|
20
|
+
padding: 0.5em;
|
|
21
|
+
font-size: var(--font-size-sm);
|
|
22
|
+
color: var(--color-text-secondary);
|
|
23
|
+
text-align: center;
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
.cfasim-listbox-item {
|
|
27
|
+
display: flex;
|
|
28
|
+
align-items: center;
|
|
29
|
+
justify-content: space-between;
|
|
30
|
+
gap: 0.5em;
|
|
31
|
+
padding: 0.25em 0.5em;
|
|
32
|
+
border-radius: 0.25em;
|
|
33
|
+
font-size: var(--font-size-sm);
|
|
34
|
+
white-space: nowrap;
|
|
35
|
+
cursor: pointer;
|
|
36
|
+
user-select: none;
|
|
37
|
+
outline: none;
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
.cfasim-listbox-item[data-highlighted] {
|
|
41
|
+
background: var(--color-primary);
|
|
42
|
+
color: white;
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
.cfasim-listbox-item[data-state="checked"] {
|
|
46
|
+
font-weight: 600;
|
|
47
|
+
}
|
|
48
|
+
|
|
49
|
+
.cfasim-listbox-indicator {
|
|
50
|
+
display: flex;
|
|
51
|
+
align-items: center;
|
|
52
|
+
flex-shrink: 0;
|
|
53
|
+
}
|
package/index.json
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
{
|
|
2
|
-
"version": "0.
|
|
2
|
+
"version": "0.7.0",
|
|
3
3
|
"package": "@cfasim-ui/docs",
|
|
4
4
|
"content": {
|
|
5
5
|
"components": [
|
|
@@ -216,6 +216,13 @@
|
|
|
216
216
|
"source": "charts/ChoroplethMap/ChoroplethMap.vue",
|
|
217
217
|
"keywords": []
|
|
218
218
|
},
|
|
219
|
+
{
|
|
220
|
+
"name": "DataTable",
|
|
221
|
+
"slug": "data-table",
|
|
222
|
+
"docs": "charts/DataTable/DataTable.md",
|
|
223
|
+
"source": "charts/DataTable/DataTable.vue",
|
|
224
|
+
"keywords": []
|
|
225
|
+
},
|
|
219
226
|
{
|
|
220
227
|
"name": "LineChart",
|
|
221
228
|
"slug": "line-chart",
|
|
@@ -231,13 +238,6 @@
|
|
|
231
238
|
"confidence band",
|
|
232
239
|
"svg"
|
|
233
240
|
]
|
|
234
|
-
},
|
|
235
|
-
{
|
|
236
|
-
"name": "DataTable",
|
|
237
|
-
"slug": "data-table",
|
|
238
|
-
"docs": "charts/DataTable/DataTable.md",
|
|
239
|
-
"source": "charts/DataTable/DataTable.vue",
|
|
240
|
-
"keywords": []
|
|
241
241
|
}
|
|
242
242
|
]
|
|
243
243
|
}
|
package/package.json
CHANGED
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
export interface RunMessage {
|
|
2
|
+
id: number;
|
|
3
|
+
type?: "run";
|
|
4
|
+
python: string;
|
|
5
|
+
context?: Record<string, unknown>;
|
|
6
|
+
}
|
|
7
|
+
export interface CallMessage {
|
|
8
|
+
id: number;
|
|
9
|
+
type: "call";
|
|
10
|
+
module: string;
|
|
11
|
+
fn: string;
|
|
12
|
+
kwargs?: Record<string, unknown>;
|
|
13
|
+
}
|
|
14
|
+
export interface LoadModuleMessage {
|
|
15
|
+
id: number;
|
|
16
|
+
type: "loadModule";
|
|
17
|
+
module: string;
|
|
18
|
+
}
|
|
19
|
+
export type WorkerMessage = RunMessage | CallMessage | LoadModuleMessage;
|
|
20
|
+
export type OutgoingMessage =
|
|
21
|
+
| Omit<RunMessage, "id">
|
|
22
|
+
| Omit<CallMessage, "id">
|
|
23
|
+
| Omit<LoadModuleMessage, "id">;
|
|
@@ -4,26 +4,7 @@ import {
|
|
|
4
4
|
postErrorWithTransfer,
|
|
5
5
|
} from "@cfasim-ui/shared/transfer";
|
|
6
6
|
import type { ColumnDescriptor, ModelOutputsWire } from "@cfasim-ui/shared";
|
|
7
|
-
|
|
8
|
-
interface RunMessage {
|
|
9
|
-
id: number;
|
|
10
|
-
type?: "run";
|
|
11
|
-
python: string;
|
|
12
|
-
context?: Record<string, unknown>;
|
|
13
|
-
}
|
|
14
|
-
interface CallMessage {
|
|
15
|
-
id: number;
|
|
16
|
-
type: "call";
|
|
17
|
-
module: string;
|
|
18
|
-
fn: string;
|
|
19
|
-
kwargs?: Record<string, unknown>;
|
|
20
|
-
}
|
|
21
|
-
interface LoadModuleMessage {
|
|
22
|
-
id: number;
|
|
23
|
-
type: "loadModule";
|
|
24
|
-
module: string;
|
|
25
|
-
}
|
|
26
|
-
type WorkerMessage = RunMessage | CallMessage | LoadModuleMessage;
|
|
7
|
+
import type { WorkerMessage } from "./messages.js";
|
|
27
8
|
|
|
28
9
|
let wheelMap: Record<string, string> = {};
|
|
29
10
|
|
|
@@ -63,8 +44,8 @@ async function fetchPyodidePackages(): Promise<string[]> {
|
|
|
63
44
|
|
|
64
45
|
const pyodideReadyPromise = (async () => {
|
|
65
46
|
const [pyodideModule, packages] = await Promise.all([
|
|
66
|
-
// @ts-expect-error - Pyodide types from CDN
|
|
67
47
|
import(
|
|
48
|
+
// @ts-expect-error - Pyodide types from CDN
|
|
68
49
|
/* @vite-ignore */ "https://cdn.jsdelivr.net/pyodide/v0.29.3/full/pyodide.mjs"
|
|
69
50
|
),
|
|
70
51
|
fetchPyodidePackages(),
|
|
@@ -1,53 +1,18 @@
|
|
|
1
1
|
import type { TransferableResponse } from "@cfasim-ui/shared";
|
|
2
|
-
import {
|
|
2
|
+
import {
|
|
3
|
+
unwrapResponse,
|
|
4
|
+
describeWorkerError,
|
|
5
|
+
MESSAGEERROR_TEXT,
|
|
6
|
+
} from "@cfasim-ui/shared";
|
|
7
|
+
import type { WorkerMessage, OutgoingMessage } from "./messages.js";
|
|
3
8
|
|
|
4
9
|
let lastId = 0;
|
|
5
10
|
function getId(): number {
|
|
6
11
|
return ++lastId;
|
|
7
12
|
}
|
|
8
13
|
|
|
9
|
-
interface RunMessage {
|
|
10
|
-
id: number;
|
|
11
|
-
type?: "run";
|
|
12
|
-
python: string;
|
|
13
|
-
context?: Record<string, unknown>;
|
|
14
|
-
}
|
|
15
|
-
interface CallMessage {
|
|
16
|
-
id: number;
|
|
17
|
-
type: "call";
|
|
18
|
-
module: string;
|
|
19
|
-
fn: string;
|
|
20
|
-
kwargs?: Record<string, unknown>;
|
|
21
|
-
}
|
|
22
|
-
interface LoadModuleMessage {
|
|
23
|
-
id: number;
|
|
24
|
-
type: "loadModule";
|
|
25
|
-
module: string;
|
|
26
|
-
}
|
|
27
|
-
type WorkerMessage = RunMessage | CallMessage | LoadModuleMessage;
|
|
28
|
-
type OutgoingMessage =
|
|
29
|
-
| Omit<RunMessage, "id">
|
|
30
|
-
| Omit<CallMessage, "id">
|
|
31
|
-
| Omit<LoadModuleMessage, "id">;
|
|
32
|
-
|
|
33
14
|
export type PyodideResponse = { result?: unknown; error?: string };
|
|
34
15
|
|
|
35
|
-
/**
|
|
36
|
-
* Convert a worker `ErrorEvent` into a human-readable message. Cross-origin
|
|
37
|
-
* worker failures sanitize the event so every field is null/empty (e.g. a
|
|
38
|
-
* dynamic `import("https://cdn…")` that fails at module evaluation): in
|
|
39
|
-
* that case we fall back to a hint about likely causes instead of an
|
|
40
|
-
* empty string, which would otherwise surface as a blank error.
|
|
41
|
-
*/
|
|
42
|
-
function describeWorkerError(e: ErrorEvent): string {
|
|
43
|
-
const msg = e.message || e.error?.message || "";
|
|
44
|
-
if (msg) {
|
|
45
|
-
if (e.filename) return `${msg} (${e.filename}:${e.lineno})`;
|
|
46
|
-
return msg;
|
|
47
|
-
}
|
|
48
|
-
return "Worker failed to load (no error details available — most often a cross-origin script load failure or a syntax error in the worker module)";
|
|
49
|
-
}
|
|
50
|
-
|
|
51
16
|
/**
|
|
52
17
|
* Worker names are arbitrary string keys. Workers are spawned lazily on first
|
|
53
18
|
* use; each one is an independent Pyodide interpreter. Use distinct names when
|
|
@@ -96,9 +61,7 @@ function getWorker(name: string): WorkerEntry {
|
|
|
96
61
|
failAll(describeWorkerError(e));
|
|
97
62
|
});
|
|
98
63
|
worker.addEventListener("messageerror", () => {
|
|
99
|
-
failAll(
|
|
100
|
-
"Worker received a message it could not deserialize (messageerror)",
|
|
101
|
-
);
|
|
64
|
+
failAll(MESSAGEERROR_TEXT);
|
|
102
65
|
});
|
|
103
66
|
entry = newEntry;
|
|
104
67
|
workers.set(name, entry);
|
package/shared/index.ts
CHANGED
|
@@ -14,6 +14,7 @@ export type {
|
|
|
14
14
|
ModelOutputsWire,
|
|
15
15
|
} from "./ModelOutput.js";
|
|
16
16
|
export { modelOutputToCSV } from "./csv.js";
|
|
17
|
+
export { describeWorkerError, MESSAGEERROR_TEXT } from "./workerError.js";
|
|
17
18
|
export { formatNumber, isNumberFormat } from "./formatNumber.js";
|
|
18
19
|
export type { NumberFormat, NumberFormatPreset } from "./formatNumber.js";
|
|
19
20
|
export {
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Convert a worker `ErrorEvent` into a human-readable message. Cross-origin
|
|
3
|
+
* worker failures sanitize the event so every field is null/empty (e.g. the
|
|
4
|
+
* worker's module — or a dynamic CDN import inside it — fails to evaluate);
|
|
5
|
+
* fall back to a hint about likely causes rather than an empty string.
|
|
6
|
+
*/
|
|
7
|
+
export function describeWorkerError(e: ErrorEvent): string {
|
|
8
|
+
const msg = e.message || e.error?.message || "";
|
|
9
|
+
if (msg) {
|
|
10
|
+
if (e.filename) return `${msg} (${e.filename}:${e.lineno})`;
|
|
11
|
+
return msg;
|
|
12
|
+
}
|
|
13
|
+
return "Worker failed to load (no error details available — most often a cross-origin script load failure or a syntax error in the worker module)";
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
export const MESSAGEERROR_TEXT =
|
|
17
|
+
"Worker received a message it could not deserialize (messageerror)";
|
package/wasm/messages.ts
ADDED
package/wasm/wasm.worker.ts
CHANGED
|
@@ -3,13 +3,7 @@ import {
|
|
|
3
3
|
postModelOutputsWithTransfer,
|
|
4
4
|
postErrorWithTransfer,
|
|
5
5
|
} from "@cfasim-ui/shared/transfer";
|
|
6
|
-
|
|
7
|
-
interface WorkerMessage {
|
|
8
|
-
id: number;
|
|
9
|
-
model: string;
|
|
10
|
-
fn: string;
|
|
11
|
-
args: string[];
|
|
12
|
-
}
|
|
6
|
+
import type { WorkerMessage } from "./messages.js";
|
|
13
7
|
|
|
14
8
|
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
15
9
|
const modulePromises = new Map<string, Promise<Record<string, any>>>();
|
package/wasm/wasmWorkerApi.ts
CHANGED
|
@@ -1,30 +1,13 @@
|
|
|
1
1
|
import type { TransferableResponse } from "@cfasim-ui/shared";
|
|
2
|
-
import {
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
args: string[];
|
|
9
|
-
}
|
|
2
|
+
import {
|
|
3
|
+
unwrapResponse,
|
|
4
|
+
describeWorkerError,
|
|
5
|
+
MESSAGEERROR_TEXT,
|
|
6
|
+
} from "@cfasim-ui/shared";
|
|
7
|
+
import type { WorkerMessage } from "./messages.js";
|
|
10
8
|
|
|
11
9
|
let lastId = 0;
|
|
12
10
|
|
|
13
|
-
/**
|
|
14
|
-
* Convert a worker `ErrorEvent` into a human-readable message. Cross-origin
|
|
15
|
-
* worker failures sanitize the event so every field is null/empty (e.g.
|
|
16
|
-
* the worker's module fails to evaluate); fall back to a hint rather than
|
|
17
|
-
* an empty string.
|
|
18
|
-
*/
|
|
19
|
-
function describeWorkerError(e: ErrorEvent): string {
|
|
20
|
-
const msg = e.message || e.error?.message || "";
|
|
21
|
-
if (msg) {
|
|
22
|
-
if (e.filename) return `${msg} (${e.filename}:${e.lineno})`;
|
|
23
|
-
return msg;
|
|
24
|
-
}
|
|
25
|
-
return "Worker failed to load (no error details available — most often a cross-origin script load failure or a syntax error in the worker module)";
|
|
26
|
-
}
|
|
27
|
-
|
|
28
11
|
// Rejects keyed by request id so `cancelWasm` can fail in-flight promises
|
|
29
12
|
// when we terminate the worker mid-run, and so worker-level errors can drain
|
|
30
13
|
// every pending call at once.
|
|
@@ -40,6 +23,7 @@ function newWorker(): Worker {
|
|
|
40
23
|
type: "module",
|
|
41
24
|
});
|
|
42
25
|
function failAll(message: string) {
|
|
26
|
+
if (workerDeadError) return;
|
|
43
27
|
workerDeadError = new Error(message);
|
|
44
28
|
const rejects = Array.from(pendingRejects.values());
|
|
45
29
|
pendingRejects.clear();
|
|
@@ -49,9 +33,7 @@ function newWorker(): Worker {
|
|
|
49
33
|
failAll(describeWorkerError(e));
|
|
50
34
|
});
|
|
51
35
|
w.addEventListener("messageerror", () => {
|
|
52
|
-
failAll(
|
|
53
|
-
"Worker received a message it could not deserialize (messageerror)",
|
|
54
|
-
);
|
|
36
|
+
failAll(MESSAGEERROR_TEXT);
|
|
55
37
|
});
|
|
56
38
|
return w;
|
|
57
39
|
}
|