@makoai/app-sdk 2.5.0 → 2.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/README.md +89 -5
- package/index.d.ts +6 -0
- package/index.js +111 -9
- package/package.json +14 -4
- package/ui-core.js +48 -0
- package/ui.css +280 -0
- package/ui.d.ts +141 -0
- package/ui.js +685 -0
- package/vite.d.ts +8 -0
- package/vite.js +116 -27
package/ui.d.ts
ADDED
|
@@ -0,0 +1,141 @@
|
|
|
1
|
+
import type * as React from "react";
|
|
2
|
+
|
|
3
|
+
/** ok | warn | bad (or green | amber | red), plus loading and neutral. */
|
|
4
|
+
export type Tone =
|
|
5
|
+
| "ok"
|
|
6
|
+
| "warn"
|
|
7
|
+
| "bad"
|
|
8
|
+
| "green"
|
|
9
|
+
| "amber"
|
|
10
|
+
| "red"
|
|
11
|
+
| "warning"
|
|
12
|
+
| "error"
|
|
13
|
+
| "fresh"
|
|
14
|
+
| "stale"
|
|
15
|
+
| "loading"
|
|
16
|
+
| "neutral";
|
|
17
|
+
|
|
18
|
+
/** Join class names, skipping falsy ones. */
|
|
19
|
+
export function cx(...parts: Array<string | false | null | undefined>): string;
|
|
20
|
+
|
|
21
|
+
export function normalizeTone(tone: Tone | string | undefined): "ok" | "warn" | "bad" | "loading" | "neutral";
|
|
22
|
+
|
|
23
|
+
/**
|
|
24
|
+
* The order RefreshAllButton runs bindings in: `first`, the rest by name,
|
|
25
|
+
* then `last`. Patterns ending in `*` match a prefix; `skip` drops bindings.
|
|
26
|
+
*/
|
|
27
|
+
export function refreshOrder(
|
|
28
|
+
bindings: readonly string[],
|
|
29
|
+
options?: { first?: readonly string[]; last?: readonly string[]; skip?: readonly string[] },
|
|
30
|
+
): string[];
|
|
31
|
+
|
|
32
|
+
export interface ButtonProps extends React.ButtonHTMLAttributes<HTMLButtonElement> {
|
|
33
|
+
variant?: "outline" | "primary" | "ghost";
|
|
34
|
+
size?: "md" | "sm";
|
|
35
|
+
}
|
|
36
|
+
export const Button: React.ForwardRefExoticComponent<ButtonProps & React.RefAttributes<HTMLButtonElement>>;
|
|
37
|
+
|
|
38
|
+
export function StatusDot(props: { tone?: Tone; className?: string }): React.ReactElement;
|
|
39
|
+
|
|
40
|
+
export function PageHeader(props: {
|
|
41
|
+
title: React.ReactNode;
|
|
42
|
+
subtitle?: React.ReactNode;
|
|
43
|
+
actions?: React.ReactNode;
|
|
44
|
+
className?: string;
|
|
45
|
+
children?: React.ReactNode;
|
|
46
|
+
}): React.ReactElement;
|
|
47
|
+
|
|
48
|
+
export interface CardProps extends Omit<React.HTMLAttributes<HTMLElement>, "title"> {
|
|
49
|
+
title?: React.ReactNode;
|
|
50
|
+
description?: React.ReactNode;
|
|
51
|
+
actions?: React.ReactNode;
|
|
52
|
+
}
|
|
53
|
+
export function Card(props: CardProps): React.ReactElement;
|
|
54
|
+
|
|
55
|
+
export function KpiTile(props: {
|
|
56
|
+
label: React.ReactNode;
|
|
57
|
+
value: React.ReactNode;
|
|
58
|
+
delta?: React.ReactNode;
|
|
59
|
+
/** Colours the delta. */
|
|
60
|
+
tone?: Tone;
|
|
61
|
+
hint?: React.ReactNode;
|
|
62
|
+
className?: string;
|
|
63
|
+
}): React.ReactElement;
|
|
64
|
+
|
|
65
|
+
export function KpiRow(props: { className?: string; children?: React.ReactNode }): React.ReactElement;
|
|
66
|
+
|
|
67
|
+
export interface MultiSelectOption<V extends string = string> {
|
|
68
|
+
value: V;
|
|
69
|
+
label: string;
|
|
70
|
+
/** A colour swatch shown next to the label (e.g. a chart series colour). */
|
|
71
|
+
color?: string;
|
|
72
|
+
}
|
|
73
|
+
|
|
74
|
+
export interface MultiSelectProps<V extends string = string> {
|
|
75
|
+
options: ReadonlyArray<V | MultiSelectOption<V>>;
|
|
76
|
+
value: readonly V[];
|
|
77
|
+
onChange: (next: V[]) => void;
|
|
78
|
+
allLabel?: string;
|
|
79
|
+
/**
|
|
80
|
+
* true (default): an empty selection means "all".
|
|
81
|
+
* false: "all" is every value selected; the All row selects every option.
|
|
82
|
+
*/
|
|
83
|
+
emptyMeansAll?: boolean;
|
|
84
|
+
/** An "Only" button on each row that selects just that value. */
|
|
85
|
+
showOnly?: boolean;
|
|
86
|
+
/** Chips shown in the trigger before "+n". Default 2. */
|
|
87
|
+
maxChips?: number;
|
|
88
|
+
/** Which edge the menu aligns to before flipping. Default "start". */
|
|
89
|
+
align?: "start" | "end";
|
|
90
|
+
className?: string;
|
|
91
|
+
"aria-label"?: string;
|
|
92
|
+
}
|
|
93
|
+
export function MultiSelect<V extends string = string>(props: MultiSelectProps<V>): React.ReactElement;
|
|
94
|
+
|
|
95
|
+
export interface FreshnessSource {
|
|
96
|
+
key?: string;
|
|
97
|
+
label: React.ReactNode;
|
|
98
|
+
note?: React.ReactNode;
|
|
99
|
+
detail?: React.ReactNode;
|
|
100
|
+
/** Right-aligned, e.g. "Synced 09:05" or "2h ago". */
|
|
101
|
+
value?: React.ReactNode;
|
|
102
|
+
tone?: Tone;
|
|
103
|
+
}
|
|
104
|
+
|
|
105
|
+
export interface FreshnessBadgeProps {
|
|
106
|
+
tone?: Tone;
|
|
107
|
+
headline: React.ReactNode;
|
|
108
|
+
/** Panel heading, e.g. "Data as of 09:05". */
|
|
109
|
+
title?: React.ReactNode;
|
|
110
|
+
/** Right of the heading, e.g. "12m ago". */
|
|
111
|
+
meta?: React.ReactNode;
|
|
112
|
+
schedule?: React.ReactNode;
|
|
113
|
+
sources?: FreshnessSource[];
|
|
114
|
+
/** A callout above the sources, e.g. a "Load latest" button. */
|
|
115
|
+
action?: React.ReactNode;
|
|
116
|
+
footer?: React.ReactNode;
|
|
117
|
+
align?: "start" | "end";
|
|
118
|
+
className?: string;
|
|
119
|
+
}
|
|
120
|
+
export function FreshnessBadge(props: FreshnessBadgeProps): React.ReactElement;
|
|
121
|
+
|
|
122
|
+
export interface RefreshAllButtonProps {
|
|
123
|
+
/** The app's binding names (see the README for the build-time define). */
|
|
124
|
+
bindings: readonly string[];
|
|
125
|
+
/** Human labels per binding name; unlisted names show as-is. */
|
|
126
|
+
labels?: Record<string, string>;
|
|
127
|
+
/** Run these first (heaviest/slowest). `*` suffix = prefix match. */
|
|
128
|
+
first?: readonly string[];
|
|
129
|
+
/** Run these last (e.g. the freshness snapshot). */
|
|
130
|
+
last?: readonly string[];
|
|
131
|
+
/** Never rebuild these on demand (static, or too big for a request). */
|
|
132
|
+
skip?: readonly string[];
|
|
133
|
+
/** Bindings rebuilt at once. Default 3; keep it low. */
|
|
134
|
+
concurrency?: number;
|
|
135
|
+
/** Appended to the description, e.g. "Data also refreshes at 06:30." */
|
|
136
|
+
schedule?: string;
|
|
137
|
+
/** Override the rebuild (tests, custom engines). Default refreshBinding. */
|
|
138
|
+
refresh?: (name: string) => Promise<unknown>;
|
|
139
|
+
className?: string;
|
|
140
|
+
}
|
|
141
|
+
export function RefreshAllButton(props: RefreshAllButtonProps): React.ReactElement;
|