@pritzlaff/nano-elements 0.1.0 → 0.2.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/README.md CHANGED
@@ -14,3 +14,62 @@ Lit elements over `@pritzlaff/nano-core` components.
14
14
  - **Without a `name`,** it gets a generated one.
15
15
  - **`provide(document, registry)`:** sets the registry that placed elements use.
16
16
  - **`base`:** the shared styles (the puzzle prototype's palette).
17
+
18
+ ## Theming: the `--nano-*` contract
19
+
20
+ Every element reads its colours, fonts and radius from these CSS custom properties, which reach inside shadow roots.
21
+ A host sets them (or maps its own variables onto them, once); unset, each falls back to the default dark look
22
+ (`NANO_TOKENS`). Elements never know which host or theme they're in.
23
+
24
+ | Group | Tokens |
25
+ | --- | --- |
26
+ | surfaces | `bg` `surface` `surface-2` `border` `border-strong` |
27
+ | text | `fg` `fg-2` `muted` `on-accent` |
28
+ | intent | `accent` `accent-soft` `focus` `good` `good-bg` `bad` `bad-bg` `warn` `warn-bg` |
29
+ | type, shape | `font` `font-display` `font-mono` `radius` `radius-s` |
30
+ | series | `s1` … `s8` |
31
+
32
+ A host with its own vocabulary maps it, e.g. a newspaper page:
33
+
34
+ ```css
35
+ :root { --nano-bg: var(--paper); --nano-surface: var(--paper); --nano-fg: var(--ink); --nano-border: var(--rule);
36
+ --nano-accent: var(--accent); --nano-font: var(--body-font); --nano-font-display: var(--display-font); --nano-radius: 0; }
37
+ ```
38
+
39
+ In an element: `static styles = [base, css\`…${t('accent')}…\`]`, or `tv('accent')` in an inline style.
40
+
41
+ ## The component library (`base`)
42
+
43
+ Bare `button`, `input`, `select` and `textarea` are styled; and the classes: `.btn` (`.primary` `.danger` `.dashed`
44
+ `.small`), `.icon-btn`, `.badge` (`.good` `.bad` `.warn` `.accent`), `.chip`, `.pill`, `.card`, `.alert` (`.good`
45
+ `.bad`), `.problem`, `.field`, `.input`, `.meter` (a `span` inside, width = value), `.table`, `.tabs`
46
+ (`button[aria-selected]`), `.list-row`, `.kicker`, `.display-s/m/l`, `.muted`, `.mono`, `.row`, `.col`, `.grid-auto`.
47
+
48
+ Where the browser allows it (`appearance: base-select`), a bare `select`'s open list takes the theme too. Set
49
+ `color-scheme` (light or dark) on the page, so the browser's own pickers and scrollbars match.
50
+
51
+ ## The kit (`kit`), in shadcn's look
52
+
53
+ CSS only (`static styles = [base, kit]`, or a page's `document.adoptedStyleSheets`): `.avatar` (`.small` `.large`)
54
+ and `.avatar-stack`, `.bubble` (`.mine`), `.kbd`, `.code`, `.input-group` (with `.addon`s and buttons), `.toggle`
55
+ (`aria-pressed`) and `.toggle-group`, `input[type=checkbox].switch`, `dialog.dialog` and `dialog.drawer` (`.bottom`)
56
+ for native `<dialog>`s (`showModal()`; a `<form method="dialog">` closes one), `.pop` (a `[popover]` surface),
57
+ `.menu-item`, `.menu-sep`, `.menu-label`, `.shortcut`, `.toast`.
58
+
59
+ Elements, defined on import:
60
+
61
+ | Element | Takes | Emits |
62
+ | --- | --- | --- |
63
+ | `<nano-select>` (`multiple`, `placeholder`, `label`) | `options` (strings or `{ value, label?, group?, disabled? }`), `value` (string, or array when multiple) | `change` |
64
+ | `<nano-command>` | `items` (`{ value, label?, group?, shortcut? }`), `selected` | `pick` (the item) |
65
+ | `<nano-calendar>`, `<nano-date-picker>` | `value` (ISO `YYYY-MM-DD`) | `change` |
66
+ | `<nano-menu>` (wraps content; right-click opens it) | `items` (`{ label, shortcut?, danger?, disabled? }`, `{ separator: true }`, `{ heading }`) | `pick` (the item) |
67
+ | `<nano-hover-card>` (`open-delay`, `close-delay`) | content, and a `card` slot | |
68
+ | `<nano-data-table>` (`filter`, `selectable`, `page-size`) | `columns` (`{ key, label, sortable?, align?, render? }`), `rows` | `selection` (the rows) |
69
+ | `<nano-code-block>` (`language`) | `code` | |
70
+ | `toast(title, { description?, variant?, duration? })` | shows in one `<nano-toaster>`, made on first use | |
71
+
72
+ Agent pieces, display only, on the AI SDK's data shapes: `<nano-tool>` (`.tool`: a tool part — `type`, `state`,
73
+ `input`, `output`, `errorText`), `<nano-task>` (`.task`), `<nano-subagent>` (`.agent`: name, status, its tool
74
+ parts), `<nano-cli>` (`.runs`: command, output, exit code), `<nano-trace>` (`.spans`: OpenTelemetry-style `spanId`,
75
+ `parentSpanId`, `startTime`, `endTime`, `status`) and `<nano-test-results>` (`.results`: summary and suites).
@@ -0,0 +1,79 @@
1
+ import { LitElement, nothing } from 'lit';
2
+ /** A tool part: `type` is `tool-<name>`, or `dynamic-tool` with `toolName`. */
3
+ export interface ToolPart {
4
+ type: string;
5
+ toolName?: string;
6
+ toolCallId?: string;
7
+ state: 'input-streaming' | 'input-available' | 'output-available' | 'output-error';
8
+ input?: unknown;
9
+ output?: unknown;
10
+ errorText?: string;
11
+ }
12
+ export interface TaskItem {
13
+ text: string;
14
+ status?: 'pending' | 'in_progress' | 'completed';
15
+ file?: {
16
+ name: string;
17
+ };
18
+ }
19
+ export interface Task {
20
+ title: string;
21
+ items: TaskItem[];
22
+ }
23
+ export interface Subagent {
24
+ name: string;
25
+ description?: string;
26
+ status: 'running' | 'completed' | 'error';
27
+ parts: ToolPart[];
28
+ result?: string;
29
+ }
30
+ export interface Run {
31
+ command: string;
32
+ output?: string;
33
+ exitCode?: number;
34
+ running?: boolean;
35
+ cwd?: string;
36
+ }
37
+ /** What the agent pieces share: a card that opens, with a header row. */
38
+ export declare const agentStyles: import("lit").CSSResult;
39
+ export declare class NanoTool extends LitElement {
40
+ static properties: {
41
+ tool: {
42
+ attribute: boolean;
43
+ };
44
+ };
45
+ static styles: import("lit").CSSResult[];
46
+ tool: ToolPart | undefined;
47
+ render(): typeof nothing | import("lit").TemplateResult<1>;
48
+ }
49
+ export declare class NanoTask extends LitElement {
50
+ static properties: {
51
+ task: {
52
+ attribute: boolean;
53
+ };
54
+ };
55
+ static styles: import("lit").CSSResult[];
56
+ task: Task | undefined;
57
+ render(): typeof nothing | import("lit").TemplateResult<1>;
58
+ }
59
+ export declare class NanoSubagent extends LitElement {
60
+ static properties: {
61
+ agent: {
62
+ attribute: boolean;
63
+ };
64
+ };
65
+ static styles: import("lit").CSSResult[];
66
+ agent: Subagent | undefined;
67
+ render(): typeof nothing | import("lit").TemplateResult<1>;
68
+ }
69
+ export declare class NanoCli extends LitElement {
70
+ static properties: {
71
+ runs: {
72
+ attribute: boolean;
73
+ };
74
+ };
75
+ static styles: import("lit").CSSResult[];
76
+ runs: Run[];
77
+ constructor();
78
+ render(): import("lit").TemplateResult<1>;
79
+ }
@@ -0,0 +1,52 @@
1
+ import { LitElement, nothing } from 'lit';
2
+ export interface Span {
3
+ spanId: string;
4
+ parentSpanId?: string;
5
+ name: string;
6
+ startTime: number;
7
+ endTime: number;
8
+ status?: 'ok' | 'error' | 'unset';
9
+ }
10
+ export interface TestCase {
11
+ name: string;
12
+ status: 'passed' | 'failed' | 'skipped';
13
+ duration?: number;
14
+ error?: {
15
+ message: string;
16
+ stack?: string;
17
+ };
18
+ }
19
+ export interface TestResults {
20
+ summary: {
21
+ passed: number;
22
+ failed: number;
23
+ skipped: number;
24
+ total: number;
25
+ duration?: number;
26
+ };
27
+ suites: {
28
+ name: string;
29
+ tests: TestCase[];
30
+ }[];
31
+ }
32
+ export declare class NanoTrace extends LitElement {
33
+ static properties: {
34
+ spans: {
35
+ attribute: boolean;
36
+ };
37
+ };
38
+ static styles: import("lit").CSSResult[];
39
+ spans: Span[];
40
+ constructor();
41
+ render(): typeof nothing | import("lit").TemplateResult<1>;
42
+ }
43
+ export declare class NanoTestResults extends LitElement {
44
+ static properties: {
45
+ results: {
46
+ attribute: boolean;
47
+ };
48
+ };
49
+ static styles: import("lit").CSSResult[];
50
+ results: TestResults | undefined;
51
+ render(): typeof nothing | import("lit").TemplateResult<1>;
52
+ }
package/index.d.ts CHANGED
@@ -1,4 +1,12 @@
1
1
  export { ModelElement } from './model-element.js';
2
2
  export { PlacedElement, provide, providedRegistry } from './placed-element.js';
3
3
  export { base } from './styles.js';
4
+ export { kit } from './kit.js';
5
+ export { NANO_TOKENS, t, tv, type NanoToken } from './tokens.js';
4
6
  export type { Catalog, CatalogEntry } from './catalog.js';
7
+ export { NanoCommand, NanoSelect, type Item } from './kit/select.js';
8
+ export { NanoCalendar, NanoDatePicker } from './kit/calendar.js';
9
+ export { NanoMenu, NanoHoverCard, NanoToaster, NanoCodeBlock, toast, type MenuItem, type Toast } from './kit/overlays.js';
10
+ export { NanoDataTable, type Column } from './kit/data-table.js';
11
+ export { NanoTool, NanoTask, NanoSubagent, NanoCli, type ToolPart, type Task, type TaskItem, type Subagent, type Run } from './agent/parts.js';
12
+ export { NanoTrace, NanoTestResults, type Span, type TestCase, type TestResults } from './agent/timeline.js';