@pritzlaff/nano-elements 0.0.0-stage → 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/LICENSE +21 -0
- package/README.md +74 -2
- package/agent/parts.d.ts +79 -0
- package/agent/timeline.d.ts +52 -0
- package/catalog.d.ts +9 -0
- package/index.d.ts +12 -0
- package/index.js +1035 -0
- package/index.js.map +21 -0
- package/kit/calendar.d.ts +48 -0
- package/kit/data-table.d.ts +62 -0
- package/kit/overlays.d.ts +109 -0
- package/kit/popup.d.ts +7 -0
- package/kit/select.d.ts +88 -0
- package/kit.d.ts +2 -0
- package/model-element.d.ts +31 -0
- package/package.json +27 -4
- package/placed-element.d.ts +17 -0
- package/styles.d.ts +2 -0
- package/tokens.d.ts +39 -0
package/LICENSE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2026 Aaron Pritzlaff
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
package/README.md
CHANGED
|
@@ -1,3 +1,75 @@
|
|
|
1
|
-
#
|
|
1
|
+
# @pritzlaff/nano-elements
|
|
2
2
|
|
|
3
|
-
|
|
3
|
+
Lit elements over `@pritzlaff/nano-core` components.
|
|
4
|
+
|
|
5
|
+
- **`ModelElement`:** shows and drives one model. Give it a `registry` and a `model` (an instance id), and
|
|
6
|
+
optionally a `watch` list of more instances whose sources it reads. It joins the registry as a hidden
|
|
7
|
+
subscriber of each, re-renders when they publish, and calls the model's actions through its own handle:
|
|
8
|
+
`this.read(op)` gives the latest value, and `this.act(op, arg)` calls an action, keeping a refusal in
|
|
9
|
+
`this.problem`.
|
|
10
|
+
- **`PlacedElement`:** a ModelElement that brings its own component (`static component`).
|
|
11
|
+
- **On the page,** it shows the instance named by its `name` attribute, in the registry provided for the
|
|
12
|
+
document. If no instance has that name, it creates one and removes it when the element goes.
|
|
13
|
+
- **Moving it** (as a dock does) keeps the instance.
|
|
14
|
+
- **Without a `name`,** it gets a generated one.
|
|
15
|
+
- **`provide(document, registry)`:** sets the registry that placed elements use.
|
|
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).
|
package/agent/parts.d.ts
ADDED
|
@@ -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/catalog.d.ts
ADDED
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import type { Component } from '@pritzlaff/nano-core';
|
|
2
|
+
/** One kind of component: the component, a title for people, and the tag of the element that shows it. */
|
|
3
|
+
export type CatalogEntry = {
|
|
4
|
+
component: Component;
|
|
5
|
+
title: string;
|
|
6
|
+
tag?: string;
|
|
7
|
+
};
|
|
8
|
+
/** A package's kinds of component, by kind. A host merges these to list everything it can make. */
|
|
9
|
+
export type Catalog = Record<string, CatalogEntry>;
|
package/index.d.ts
ADDED
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
export { ModelElement } from './model-element.js';
|
|
2
|
+
export { PlacedElement, provide, providedRegistry } from './placed-element.js';
|
|
3
|
+
export { base } from './styles.js';
|
|
4
|
+
export { kit } from './kit.js';
|
|
5
|
+
export { NANO_TOKENS, t, tv, type NanoToken } from './tokens.js';
|
|
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';
|