@pritzlaff/nano-elements 0.1.0 → 0.4.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.
@@ -0,0 +1,88 @@
1
+ import { LitElement } from 'lit';
2
+ export interface Item {
3
+ value: string;
4
+ label?: string;
5
+ group?: string;
6
+ shortcut?: string;
7
+ disabled?: boolean;
8
+ }
9
+ /** A search box over a list of items. Emits `pick` (detail: the item) on click or Enter. `selected` shows a check. */
10
+ export declare class NanoCommand extends LitElement {
11
+ static shadowRootOptions: {
12
+ clonable?: boolean;
13
+ customElementRegistry?: CustomElementRegistry | null;
14
+ mode: ShadowRootMode;
15
+ serializable?: boolean;
16
+ slotAssignment?: SlotAssignmentMode;
17
+ delegatesFocus: boolean;
18
+ };
19
+ static properties: {
20
+ items: {
21
+ attribute: boolean;
22
+ };
23
+ selected: {
24
+ attribute: boolean;
25
+ };
26
+ placeholder: {};
27
+ q: {
28
+ state: boolean;
29
+ };
30
+ active: {
31
+ state: boolean;
32
+ };
33
+ };
34
+ static styles: import("lit").CSSResult[];
35
+ items: Item[];
36
+ selected: string[];
37
+ placeholder: string;
38
+ q: string;
39
+ active: number;
40
+ private uid;
41
+ constructor();
42
+ /** The items that match what's typed (case-insensitive, anywhere in the label). */
43
+ get shown(): Item[];
44
+ /** Clears the search, ready to open again. */
45
+ reset(): void;
46
+ private pick;
47
+ private onKey;
48
+ updated(): void;
49
+ render(): import("lit").TemplateResult<1>;
50
+ }
51
+ /** A picker: a trigger showing the choice (chips when `multiple`), opening a filterable list. `value` is a string,
52
+ * or an array when `multiple`. Emits `change`. */
53
+ export declare class NanoSelect extends LitElement {
54
+ static properties: {
55
+ options: {
56
+ attribute: boolean;
57
+ };
58
+ value: {
59
+ attribute: boolean;
60
+ };
61
+ multiple: {
62
+ type: BooleanConstructor;
63
+ };
64
+ placeholder: {};
65
+ label: {};
66
+ open: {
67
+ state: boolean;
68
+ };
69
+ };
70
+ static styles: import("lit").CSSResult[];
71
+ options: (string | Item)[];
72
+ value: string | string[];
73
+ multiple: boolean;
74
+ placeholder: string;
75
+ label: string;
76
+ open: boolean;
77
+ constructor();
78
+ private get items();
79
+ private get chosen();
80
+ private labelFor;
81
+ private get pop();
82
+ private get trigger();
83
+ private set;
84
+ private show;
85
+ private onPick;
86
+ private onKey;
87
+ render(): import("lit").TemplateResult<1>;
88
+ }
package/kit/tree.d.ts ADDED
@@ -0,0 +1,49 @@
1
+ import { LitElement } from 'lit';
2
+ /** A node. `end` sits at the row's end (buttons); `body` shows inside it while open; `terms` are more text to match;
3
+ * `data` becomes `data-*` attributes on its row (`data-mark` is drawn as a tinted row). */
4
+ export interface TreeNode {
5
+ id: string;
6
+ label: string;
7
+ kind?: string;
8
+ count?: number;
9
+ badge?: string;
10
+ terms?: string[];
11
+ end?: unknown;
12
+ body?: unknown;
13
+ data?: Record<string, string>;
14
+ children?: TreeNode[];
15
+ }
16
+ /** Emits `select` (detail: `{ id }`, cancelable: cancel it to keep `selected` as the host sets it). */
17
+ export declare class NanoTree extends LitElement {
18
+ #private;
19
+ static properties: {
20
+ nodes: {
21
+ attribute: boolean;
22
+ };
23
+ query: {};
24
+ selected: {};
25
+ openDepth: {
26
+ type: NumberConstructor;
27
+ attribute: string;
28
+ };
29
+ flipped: {
30
+ state: boolean;
31
+ };
32
+ focused: {
33
+ state: boolean;
34
+ };
35
+ };
36
+ static styles: import("lit").CSSResult[];
37
+ nodes: TreeNode[];
38
+ query: string;
39
+ selected: string | null;
40
+ openDepth: number;
41
+ flipped: Set<string>;
42
+ focused: string | null;
43
+ constructor();
44
+ /** Opens the way to a node and scrolls it into view; focuses it unless `focus` is false (say, for a selection made elsewhere). */
45
+ reveal(id: string, { focus }?: {
46
+ focus?: boolean | undefined;
47
+ }): void;
48
+ render(): import("lit").TemplateResult<1>;
49
+ }
package/kit.d.ts ADDED
@@ -0,0 +1,2 @@
1
+ /** Avatar, bubble, kbd, input group, toggle, switch, dialog, drawer, popover surface, menu items, toast. */
2
+ export declare const kit: import("lit").CSSResult;
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@pritzlaff/nano-elements",
3
- "version": "0.1.0",
4
- "description": "Lit elements over core components: show and drive a model, or place a component by name.",
3
+ "version": "0.4.0",
4
+ "description": "Lit elements: the nano kit and the --nano-* theme contract.",
5
5
  "license": "MIT",
6
6
  "type": "module",
7
7
  "repository": {
@@ -18,8 +18,8 @@
18
18
  "types": "./index.d.ts",
19
19
  "module": "./index.js",
20
20
  "sideEffects": false,
21
+ "dependencies": {},
21
22
  "peerDependencies": {
22
- "@pritzlaff/nano-core": "^0.1.0",
23
23
  "lit": "^3.0.0",
24
24
  "typebox": "^1.4.0"
25
25
  },
package/styles.d.ts CHANGED
@@ -1,2 +1,2 @@
1
- /** Base styles for every editor element. */
1
+ /** The library: host type, bare controls, and the classes (buttons, labels, cards, forms, tables, type, layout). */
2
2
  export declare const base: import("lit").CSSResult;
package/tokens.d.ts ADDED
@@ -0,0 +1,39 @@
1
+ /** Every token, with the value an element uses when the host sets none. */
2
+ export declare const NANO_TOKENS: {
3
+ readonly bg: '#0D0F13';
4
+ readonly surface: '#14171D';
5
+ readonly 'surface-2': '#212632';
6
+ readonly border: '#2A303C';
7
+ readonly 'border-strong': '#3A4150';
8
+ readonly fg: '#E7E9EE';
9
+ readonly 'fg-2': '#C9CED6';
10
+ readonly muted: '#A3AAB8';
11
+ readonly 'on-accent': '#0D0F13';
12
+ readonly accent: '#6FA8FF';
13
+ readonly 'accent-soft': '#1C2A44';
14
+ readonly focus: '#6FA8FF';
15
+ readonly good: '#7EE787';
16
+ readonly 'good-bg': '#12301C';
17
+ readonly bad: '#FFB4A8';
18
+ readonly 'bad-bg': '#3A1D1D';
19
+ readonly warn: '#F2CC60';
20
+ readonly 'warn-bg': '#3A3016';
21
+ readonly font: 'Inter, system-ui, sans-serif';
22
+ readonly 'font-display': 'Inter, system-ui, sans-serif';
23
+ readonly 'font-mono': "'JetBrains Mono', ui-monospace, monospace";
24
+ readonly radius: '8px';
25
+ readonly 'radius-s': '6px';
26
+ readonly s1: '#7EE787';
27
+ readonly s2: '#F5A524';
28
+ readonly s3: '#4CC2FF';
29
+ readonly s4: '#FF7AB6';
30
+ readonly s5: '#D2A8FF';
31
+ readonly s6: '#FFA657';
32
+ readonly s7: '#79C0FF';
33
+ readonly s8: '#F2CC60';
34
+ };
35
+ export type NanoToken = keyof typeof NANO_TOKENS;
36
+ /** A token for use in `css`: `var(--nano-<name>, <fallback>)`. */
37
+ export declare const t: (name: NanoToken) => import("lit").CSSResult;
38
+ /** The same, as a string, for inline styles and SVG attributes. */
39
+ export declare const tv: (name: NanoToken) => string;
package/catalog.d.ts DELETED
@@ -1,9 +0,0 @@
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>;
@@ -1,31 +0,0 @@
1
- import { LitElement } from 'lit';
2
- import { type Op, type Registry, type Result } from '@pritzlaff/nano-core';
3
- /** Base class for an element that shows and drives one model: set `registry` and `model` (the instance id).
4
- * `watch` names more instances whose sources it reads too (it acts only on `model`). */
5
- export declare abstract class ModelElement extends LitElement {
6
- #private;
7
- static properties: {
8
- registry: {
9
- attribute: boolean;
10
- };
11
- model: {};
12
- watch: {
13
- attribute: boolean;
14
- };
15
- problem: {
16
- state: boolean;
17
- };
18
- };
19
- registry?: Registry;
20
- model?: string;
21
- watch?: string[];
22
- /** The last refusal from `act`, for rendering. */
23
- problem?: string;
24
- connectedCallback(): void;
25
- disconnectedCallback(): void;
26
- willUpdate(changed: Map<string, unknown>): void;
27
- /** The model's latest value for a source op. */
28
- read<T>(op: Op): T | undefined;
29
- /** Calls an action on the model; a refusal is kept in `problem`. */
30
- act(op: Op, arg?: unknown): Promise<Result>;
31
- }
@@ -1,17 +0,0 @@
1
- import { type Component, type Registry } from '@pritzlaff/nano-core';
2
- import { ModelElement } from './model-element.js';
3
- /** Sets the registry that placed elements in `doc` use. */
4
- export declare const provide: (doc: Document, registry: Registry) => void;
5
- /** The registry provided for `doc`, if any. */
6
- export declare const providedRegistry: (doc: Document) => Registry | undefined;
7
- /**
8
- * A ModelElement that brings its own component (`static component`). On the page it shows the instance named by
9
- * its `name` attribute, creating it if it doesn't exist; an instance it created goes when the element does,
10
- * unless the element has a `keep` attribute (a dock panel: closing it leaves the component in the system).
11
- */
12
- export declare abstract class PlacedElement extends ModelElement {
13
- #private;
14
- static component: Component;
15
- connectedCallback(): void;
16
- disconnectedCallback(): void;
17
- }