@nullplatform/ui-plugin-sdk 0.2.0 → 0.5.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/dist/bridge.d.ts +3 -0
- package/dist/bridge.js +21 -1
- package/dist/catalog.d.ts +32 -1
- package/dist/catalog.js +257 -54
- package/dist/components.d.ts +162 -11
- package/dist/components.js +46 -25
- package/dist/contract/allowlist.d.ts +6 -0
- package/dist/contract/allowlist.js +14 -0
- package/dist/contract/index.d.ts +1 -1
- package/dist/contract/index.js +1 -1
- package/dist/contract/when.d.ts +12 -2
- package/dist/contract/when.js +63 -27
- package/dist/contract-cjs/allowlist.js +15 -0
- package/dist/contract-cjs/index.js +2 -1
- package/dist/contract-cjs/when.js +64 -28
- package/dist/protocol.d.ts +25 -1
- package/dist/protocol.js +96 -7
- package/dist/worker.js +23 -7
- package/package.json +2 -2
package/dist/bridge.d.ts
CHANGED
|
@@ -3,9 +3,12 @@
|
|
|
3
3
|
*/
|
|
4
4
|
import { type ApiRequest, type BridgeMethodName, type BridgeMethods, type HostMessage, type HttpRequest, type HttpResponse, type NavigationTarget, type PluginContext, type SnackbarOptions, type WorkerMessage } from './protocol.js';
|
|
5
5
|
export declare class BridgeClient {
|
|
6
|
+
private readonly timeoutMs;
|
|
6
7
|
private port;
|
|
7
8
|
private pending;
|
|
8
9
|
private seq;
|
|
10
|
+
constructor(timeoutMs?: number);
|
|
11
|
+
dispose(): void;
|
|
9
12
|
attach(port: MessagePort): void;
|
|
10
13
|
post(message: WorkerMessage, transfer?: Transferable[]): void;
|
|
11
14
|
call<M extends BridgeMethodName>(method: M, ...args: Parameters<BridgeMethods[M]>): ReturnType<BridgeMethods[M]>;
|
package/dist/bridge.js
CHANGED
|
@@ -3,10 +3,23 @@
|
|
|
3
3
|
*/
|
|
4
4
|
import { BridgeError, deserializeError, } from './protocol.js';
|
|
5
5
|
export class BridgeClient {
|
|
6
|
+
timeoutMs;
|
|
6
7
|
port = null;
|
|
7
8
|
pending = new Map();
|
|
8
9
|
seq = 0;
|
|
10
|
+
constructor(timeoutMs = 30000) {
|
|
11
|
+
this.timeoutMs = timeoutMs;
|
|
12
|
+
}
|
|
13
|
+
dispose() {
|
|
14
|
+
for (const pending of this.pending.values()) {
|
|
15
|
+
clearTimeout(pending.timer);
|
|
16
|
+
pending.reject(new BridgeError('Bridge closed', 'DISPOSED'));
|
|
17
|
+
}
|
|
18
|
+
this.pending.clear();
|
|
19
|
+
this.port = null;
|
|
20
|
+
}
|
|
9
21
|
attach(port) {
|
|
22
|
+
this.dispose();
|
|
10
23
|
this.port = port;
|
|
11
24
|
}
|
|
12
25
|
post(message, transfer) {
|
|
@@ -17,11 +30,17 @@ export class BridgeClient {
|
|
|
17
30
|
call(method, ...args) {
|
|
18
31
|
const id = `c${++this.seq}`;
|
|
19
32
|
const promise = new Promise((resolve, reject) => {
|
|
20
|
-
this.pending.
|
|
33
|
+
if (this.pending.size >= 32) {
|
|
34
|
+
reject(new BridgeError('Too many pending calls', 'RATE_LIMIT'));
|
|
35
|
+
return;
|
|
36
|
+
}
|
|
37
|
+
const timer = setTimeout(() => { this.pending.delete(id); reject(new BridgeError('Bridge call timed out', 'TIMEOUT')); }, this.timeoutMs);
|
|
38
|
+
this.pending.set(id, { resolve, reject, timer });
|
|
21
39
|
try {
|
|
22
40
|
this.post({ type: 'call', id, method, args });
|
|
23
41
|
}
|
|
24
42
|
catch (error) {
|
|
43
|
+
clearTimeout(timer);
|
|
25
44
|
this.pending.delete(id);
|
|
26
45
|
reject(error);
|
|
27
46
|
}
|
|
@@ -35,6 +54,7 @@ export class BridgeClient {
|
|
|
35
54
|
const pending = this.pending.get(message.id);
|
|
36
55
|
if (!pending)
|
|
37
56
|
return true;
|
|
57
|
+
clearTimeout(pending.timer);
|
|
38
58
|
this.pending.delete(message.id);
|
|
39
59
|
if (message.ok)
|
|
40
60
|
pending.resolve(message.value);
|
package/dist/catalog.d.ts
CHANGED
|
@@ -8,7 +8,7 @@
|
|
|
8
8
|
* This file is pure data so it can be imported by the host without pulling
|
|
9
9
|
* the DOM polyfill.
|
|
10
10
|
*/
|
|
11
|
-
export type PropertyType =
|
|
11
|
+
export type PropertyType = "string" | "number" | "boolean" | "object" | "array";
|
|
12
12
|
export interface CatalogElementSpec {
|
|
13
13
|
/** Custom element tag name. */
|
|
14
14
|
tag: string;
|
|
@@ -22,5 +22,36 @@ export interface CatalogElementSpec {
|
|
|
22
22
|
}
|
|
23
23
|
export declare const CATALOG: readonly CatalogElementSpec[];
|
|
24
24
|
export declare const CATALOG_BY_TAG: ReadonlyMap<string, CatalogElementSpec>;
|
|
25
|
+
/**
|
|
26
|
+
* The values a plugin may pass to these props. The SDK's components are typed from these lists, and
|
|
27
|
+
* the host checks each value against them again at runtime, falling back to the element's default:
|
|
28
|
+
* a published bundle has already left TypeScript behind.
|
|
29
|
+
*/
|
|
30
|
+
export declare const CATALOG_PROP_VALUES: {
|
|
31
|
+
readonly Text: {
|
|
32
|
+
readonly variant: readonly ["h1", "h2", "h3", "h4", "h5", "h6", "subtitle1", "subtitle2", "body1", "body2", "caption", "overline", "button"];
|
|
33
|
+
readonly align: readonly ["inherit", "left", "center", "right", "justify"];
|
|
34
|
+
};
|
|
35
|
+
readonly Button: {
|
|
36
|
+
readonly variant: readonly ["contained", "outlined", "text", "soft"];
|
|
37
|
+
readonly color: readonly ["inherit", "primary", "secondary", "success", "error", "info", "warning"];
|
|
38
|
+
};
|
|
39
|
+
readonly Chip: {
|
|
40
|
+
readonly color: readonly ["default", "primary", "secondary", "success", "error", "info", "warning"];
|
|
41
|
+
readonly variant: readonly ["filled", "outlined", "soft"];
|
|
42
|
+
readonly size: readonly ["small", "medium"];
|
|
43
|
+
};
|
|
44
|
+
readonly Skeleton: {
|
|
45
|
+
readonly variant: readonly ["text", "rectangular", "rounded", "circular"];
|
|
46
|
+
};
|
|
47
|
+
};
|
|
48
|
+
export type TextVariant = (typeof CATALOG_PROP_VALUES.Text.variant)[number];
|
|
49
|
+
export type TextAlign = (typeof CATALOG_PROP_VALUES.Text.align)[number];
|
|
50
|
+
export type ButtonVariant = (typeof CATALOG_PROP_VALUES.Button.variant)[number];
|
|
51
|
+
export type ButtonColor = (typeof CATALOG_PROP_VALUES.Button.color)[number];
|
|
52
|
+
export type ChipColor = (typeof CATALOG_PROP_VALUES.Chip.color)[number];
|
|
53
|
+
export type ChipVariant = (typeof CATALOG_PROP_VALUES.Chip.variant)[number];
|
|
54
|
+
export type ChipSize = (typeof CATALOG_PROP_VALUES.Chip.size)[number];
|
|
55
|
+
export type SkeletonVariant = (typeof CATALOG_PROP_VALUES.Skeleton.variant)[number];
|
|
25
56
|
/** Name of the wrapper element remote-dom uses for React elements passed as props. */
|
|
26
57
|
export declare const FRAGMENT_TAG = "remote-fragment";
|
package/dist/catalog.js
CHANGED
|
@@ -9,105 +9,308 @@
|
|
|
9
9
|
* the DOM polyfill.
|
|
10
10
|
*/
|
|
11
11
|
export const CATALOG = [
|
|
12
|
-
{ tag: 'np-image', component: 'Image', properties: { src: 'string', alt: 'string', width: 'number', height: 'number' }, events: {} },
|
|
13
12
|
{
|
|
14
|
-
tag:
|
|
15
|
-
component:
|
|
16
|
-
properties: {
|
|
13
|
+
tag: "np-network-graph",
|
|
14
|
+
component: "NetworkGraph",
|
|
15
|
+
properties: { nodes: "array", edges: "array", selected: "string" },
|
|
16
|
+
events: { nodePress: "onNodePress" },
|
|
17
|
+
},
|
|
18
|
+
{
|
|
19
|
+
tag: "np-text-field",
|
|
20
|
+
component: "TextField",
|
|
21
|
+
properties: {
|
|
22
|
+
label: "string",
|
|
23
|
+
value: "string",
|
|
24
|
+
multiline: "boolean",
|
|
25
|
+
disabled: "boolean",
|
|
26
|
+
placeholder: "string",
|
|
27
|
+
error: "string",
|
|
28
|
+
},
|
|
29
|
+
events: { valueChange: "onValueChange" },
|
|
30
|
+
},
|
|
31
|
+
{
|
|
32
|
+
tag: "np-select",
|
|
33
|
+
component: "Select",
|
|
34
|
+
properties: {
|
|
35
|
+
label: "string",
|
|
36
|
+
value: "string",
|
|
37
|
+
values: "array",
|
|
38
|
+
options: "array",
|
|
39
|
+
multiple: "boolean",
|
|
40
|
+
disabled: "boolean",
|
|
41
|
+
},
|
|
42
|
+
events: { valueChange: "onValueChange" },
|
|
43
|
+
},
|
|
44
|
+
{
|
|
45
|
+
tag: "np-switch",
|
|
46
|
+
component: "Switch",
|
|
47
|
+
properties: { label: "string", checked: "boolean", disabled: "boolean" },
|
|
48
|
+
events: { valueChange: "onValueChange" },
|
|
49
|
+
},
|
|
50
|
+
{
|
|
51
|
+
tag: "np-image",
|
|
52
|
+
component: "Image",
|
|
53
|
+
properties: {
|
|
54
|
+
src: "string",
|
|
55
|
+
alt: "string",
|
|
56
|
+
width: "number",
|
|
57
|
+
height: "number",
|
|
58
|
+
},
|
|
59
|
+
events: {},
|
|
60
|
+
},
|
|
61
|
+
{
|
|
62
|
+
tag: "np-card",
|
|
63
|
+
component: "Card",
|
|
64
|
+
properties: { title: "string", subtitle: "string", padding: "string" },
|
|
17
65
|
events: {},
|
|
18
|
-
slots: [
|
|
66
|
+
slots: ["action"],
|
|
19
67
|
},
|
|
20
68
|
{
|
|
21
|
-
tag:
|
|
22
|
-
component:
|
|
23
|
-
properties: {
|
|
69
|
+
tag: "np-stack",
|
|
70
|
+
component: "Stack",
|
|
71
|
+
properties: {
|
|
72
|
+
direction: "string",
|
|
73
|
+
spacing: "number",
|
|
74
|
+
align: "string",
|
|
75
|
+
justify: "string",
|
|
76
|
+
wrap: "boolean",
|
|
77
|
+
},
|
|
24
78
|
events: {},
|
|
25
79
|
},
|
|
26
80
|
{
|
|
27
|
-
tag:
|
|
28
|
-
component:
|
|
29
|
-
properties: {
|
|
81
|
+
tag: "np-text",
|
|
82
|
+
component: "Text",
|
|
83
|
+
properties: {
|
|
84
|
+
variant: "string",
|
|
85
|
+
color: "string",
|
|
86
|
+
align: "string",
|
|
87
|
+
noWrap: "boolean",
|
|
88
|
+
},
|
|
30
89
|
events: {},
|
|
31
90
|
},
|
|
32
91
|
{
|
|
33
|
-
tag:
|
|
34
|
-
component:
|
|
35
|
-
properties: {
|
|
36
|
-
|
|
92
|
+
tag: "np-button",
|
|
93
|
+
component: "Button",
|
|
94
|
+
properties: {
|
|
95
|
+
variant: "string",
|
|
96
|
+
color: "string",
|
|
97
|
+
size: "string",
|
|
98
|
+
disabled: "boolean",
|
|
99
|
+
loading: "boolean",
|
|
100
|
+
icon: "string",
|
|
101
|
+
},
|
|
102
|
+
events: { press: "onPress" },
|
|
37
103
|
},
|
|
38
104
|
{
|
|
39
|
-
tag:
|
|
40
|
-
component:
|
|
41
|
-
properties: {
|
|
105
|
+
tag: "np-chip",
|
|
106
|
+
component: "Chip",
|
|
107
|
+
properties: {
|
|
108
|
+
label: "string",
|
|
109
|
+
color: "string",
|
|
110
|
+
variant: "string",
|
|
111
|
+
size: "string",
|
|
112
|
+
},
|
|
42
113
|
events: {},
|
|
43
114
|
},
|
|
44
115
|
{
|
|
45
|
-
tag:
|
|
46
|
-
component:
|
|
47
|
-
properties: { to:
|
|
48
|
-
events: { press:
|
|
116
|
+
tag: "np-link",
|
|
117
|
+
component: "Link",
|
|
118
|
+
properties: { to: "string", params: "object", href: "string" },
|
|
119
|
+
events: { press: "onPress" },
|
|
49
120
|
},
|
|
50
121
|
{
|
|
51
|
-
tag:
|
|
52
|
-
component:
|
|
53
|
-
properties: {
|
|
54
|
-
|
|
122
|
+
tag: "np-table",
|
|
123
|
+
component: "Table",
|
|
124
|
+
properties: {
|
|
125
|
+
columns: "array",
|
|
126
|
+
rows: "array",
|
|
127
|
+
dense: "boolean",
|
|
128
|
+
emptyMessage: "string",
|
|
129
|
+
},
|
|
130
|
+
events: { rowPress: "onRowPress" },
|
|
55
131
|
},
|
|
56
132
|
{
|
|
57
|
-
tag:
|
|
58
|
-
component:
|
|
59
|
-
properties: { height:
|
|
133
|
+
tag: "np-skeleton",
|
|
134
|
+
component: "Skeleton",
|
|
135
|
+
properties: { height: "number", width: "string", variant: "string" },
|
|
60
136
|
events: {},
|
|
61
137
|
},
|
|
62
138
|
{
|
|
63
|
-
tag:
|
|
64
|
-
component:
|
|
65
|
-
properties: { title:
|
|
139
|
+
tag: "np-empty",
|
|
140
|
+
component: "Empty",
|
|
141
|
+
properties: { title: "string", description: "string" },
|
|
66
142
|
events: {},
|
|
67
143
|
},
|
|
68
144
|
{
|
|
69
|
-
tag:
|
|
70
|
-
component:
|
|
71
|
-
properties: { severity:
|
|
145
|
+
tag: "np-alert",
|
|
146
|
+
component: "Alert",
|
|
147
|
+
properties: { severity: "string", title: "string" },
|
|
72
148
|
events: {},
|
|
73
149
|
},
|
|
74
150
|
{
|
|
75
|
-
tag:
|
|
76
|
-
component:
|
|
77
|
-
properties: { icon:
|
|
151
|
+
tag: "np-icon",
|
|
152
|
+
component: "Icon",
|
|
153
|
+
properties: { icon: "string", size: "number", color: "string" },
|
|
78
154
|
events: {},
|
|
79
155
|
},
|
|
80
156
|
{
|
|
81
|
-
tag:
|
|
82
|
-
component:
|
|
157
|
+
tag: "np-divider",
|
|
158
|
+
component: "Divider",
|
|
83
159
|
properties: {},
|
|
84
160
|
events: {},
|
|
85
161
|
},
|
|
86
162
|
{
|
|
87
|
-
tag:
|
|
88
|
-
component:
|
|
89
|
-
properties: { content:
|
|
163
|
+
tag: "np-markdown",
|
|
164
|
+
component: "Markdown",
|
|
165
|
+
properties: { content: "string" },
|
|
90
166
|
events: {},
|
|
91
167
|
},
|
|
92
168
|
{
|
|
93
|
-
tag:
|
|
94
|
-
component:
|
|
95
|
-
properties: { content:
|
|
169
|
+
tag: "np-code",
|
|
170
|
+
component: "Code",
|
|
171
|
+
properties: { content: "string", language: "string", maxHeight: "number" },
|
|
96
172
|
events: {},
|
|
97
173
|
},
|
|
98
174
|
{
|
|
99
|
-
tag:
|
|
100
|
-
component:
|
|
101
|
-
properties: {
|
|
102
|
-
|
|
175
|
+
tag: "np-ego-graph",
|
|
176
|
+
component: "EgoGraph",
|
|
177
|
+
properties: {
|
|
178
|
+
focus: "string",
|
|
179
|
+
inbound: "array",
|
|
180
|
+
outbound: "array",
|
|
181
|
+
height: "number",
|
|
182
|
+
},
|
|
183
|
+
events: { nodePress: "onNodePress" },
|
|
184
|
+
},
|
|
185
|
+
{
|
|
186
|
+
tag: "np-box",
|
|
187
|
+
component: "Box",
|
|
188
|
+
properties: {
|
|
189
|
+
padding: "string",
|
|
190
|
+
height: "string",
|
|
191
|
+
width: "string",
|
|
192
|
+
grow: "boolean",
|
|
193
|
+
},
|
|
194
|
+
events: {},
|
|
103
195
|
},
|
|
104
196
|
{
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
197
|
+
// Responsive grid: as many columns as fit `min` px wide, up to `columns`.
|
|
198
|
+
tag: "np-grid",
|
|
199
|
+
component: "Grid",
|
|
200
|
+
properties: { columns: "number", min: "number", gap: "number" },
|
|
201
|
+
events: {},
|
|
202
|
+
},
|
|
203
|
+
{
|
|
204
|
+
// Big number tile: label, formatted value, optional delta with a trend arrow and tone.
|
|
205
|
+
tag: "np-metric",
|
|
206
|
+
component: "Metric",
|
|
207
|
+
properties: {
|
|
208
|
+
label: "string",
|
|
209
|
+
value: "string",
|
|
210
|
+
delta: "string",
|
|
211
|
+
trend: "string",
|
|
212
|
+
tone: "string",
|
|
213
|
+
hint: "string",
|
|
214
|
+
spark: "array",
|
|
215
|
+
color: "string",
|
|
216
|
+
},
|
|
217
|
+
events: {},
|
|
218
|
+
},
|
|
219
|
+
{
|
|
220
|
+
tag: "np-sparkline",
|
|
221
|
+
component: "Sparkline",
|
|
222
|
+
properties: {
|
|
223
|
+
values: "array",
|
|
224
|
+
height: "number",
|
|
225
|
+
color: "string",
|
|
226
|
+
area: "boolean",
|
|
227
|
+
},
|
|
228
|
+
events: {},
|
|
229
|
+
},
|
|
230
|
+
{
|
|
231
|
+
// Time series. `series: [{ name, values, color? }]`, `categories` are the x labels (same length as values).
|
|
232
|
+
tag: "np-line-chart",
|
|
233
|
+
component: "LineChart",
|
|
234
|
+
properties: {
|
|
235
|
+
series: "array",
|
|
236
|
+
categories: "array",
|
|
237
|
+
stacked: "boolean",
|
|
238
|
+
area: "boolean",
|
|
239
|
+
height: "number",
|
|
240
|
+
format: "string",
|
|
241
|
+
currency: "string",
|
|
242
|
+
hideLegend: "boolean",
|
|
243
|
+
},
|
|
244
|
+
events: { pointPress: "onPointPress" },
|
|
245
|
+
},
|
|
246
|
+
{
|
|
247
|
+
tag: "np-bar-chart",
|
|
248
|
+
component: "BarChart",
|
|
249
|
+
properties: {
|
|
250
|
+
series: "array",
|
|
251
|
+
categories: "array",
|
|
252
|
+
stacked: "boolean",
|
|
253
|
+
horizontal: "boolean",
|
|
254
|
+
height: "number",
|
|
255
|
+
format: "string",
|
|
256
|
+
currency: "string",
|
|
257
|
+
hideLegend: "boolean",
|
|
258
|
+
},
|
|
259
|
+
events: { barPress: "onBarPress" },
|
|
260
|
+
},
|
|
261
|
+
{
|
|
262
|
+
// Part-to-whole. `items: [{ name, value, color? }]`; the center shows `total` or the sum.
|
|
263
|
+
tag: "np-donut",
|
|
264
|
+
component: "Donut",
|
|
265
|
+
properties: {
|
|
266
|
+
items: "array",
|
|
267
|
+
total: "string",
|
|
268
|
+
height: "number",
|
|
269
|
+
format: "string",
|
|
270
|
+
currency: "string",
|
|
271
|
+
hideLegend: "boolean",
|
|
272
|
+
},
|
|
273
|
+
events: { slicePress: "onSlicePress" },
|
|
274
|
+
},
|
|
275
|
+
{
|
|
276
|
+
// Horizontal share bar, 0..1.
|
|
277
|
+
tag: "np-progress-bar",
|
|
278
|
+
component: "ProgressBar",
|
|
279
|
+
properties: {
|
|
280
|
+
value: "number",
|
|
281
|
+
label: "string",
|
|
282
|
+
color: "string",
|
|
283
|
+
height: "number",
|
|
284
|
+
},
|
|
108
285
|
events: {},
|
|
109
286
|
},
|
|
110
287
|
];
|
|
111
288
|
export const CATALOG_BY_TAG = new Map(CATALOG.map((spec) => [spec.tag, spec]));
|
|
289
|
+
/**
|
|
290
|
+
* The values a plugin may pass to these props. The SDK's components are typed from these lists, and
|
|
291
|
+
* the host checks each value against them again at runtime, falling back to the element's default:
|
|
292
|
+
* a published bundle has already left TypeScript behind.
|
|
293
|
+
*/
|
|
294
|
+
export const CATALOG_PROP_VALUES = {
|
|
295
|
+
Text: {
|
|
296
|
+
variant: [
|
|
297
|
+
"h1", "h2", "h3", "h4", "h5", "h6",
|
|
298
|
+
"subtitle1", "subtitle2", "body1", "body2", "caption", "overline", "button",
|
|
299
|
+
],
|
|
300
|
+
align: ["inherit", "left", "center", "right", "justify"],
|
|
301
|
+
},
|
|
302
|
+
Button: {
|
|
303
|
+
variant: ["contained", "outlined", "text", "soft"],
|
|
304
|
+
color: ["inherit", "primary", "secondary", "success", "error", "info", "warning"],
|
|
305
|
+
},
|
|
306
|
+
Chip: {
|
|
307
|
+
color: ["default", "primary", "secondary", "success", "error", "info", "warning"],
|
|
308
|
+
variant: ["filled", "outlined", "soft"],
|
|
309
|
+
size: ["small", "medium"],
|
|
310
|
+
},
|
|
311
|
+
Skeleton: {
|
|
312
|
+
variant: ["text", "rectangular", "rounded", "circular"],
|
|
313
|
+
},
|
|
314
|
+
};
|
|
112
315
|
/** Name of the wrapper element remote-dom uses for React elements passed as props. */
|
|
113
|
-
export const FRAGMENT_TAG =
|
|
316
|
+
export const FRAGMENT_TAG = "remote-fragment";
|
package/dist/components.d.ts
CHANGED
|
@@ -3,12 +3,59 @@ import "./polyfill.js";
|
|
|
3
3
|
* React components a plugin renders with. Each one maps to a catalog element;
|
|
4
4
|
* the host decides how it looks.
|
|
5
5
|
*/
|
|
6
|
-
import
|
|
7
|
-
import { type ComponentType, type ReactNode } from
|
|
6
|
+
import "@remote-dom/react/polyfill";
|
|
7
|
+
import { type ComponentType, type ReactNode } from "react";
|
|
8
|
+
import { type ButtonColor, type ButtonVariant, type ChipColor, type ChipSize, type ChipVariant, type SkeletonVariant, type TextAlign, type TextVariant } from "./catalog.js";
|
|
9
|
+
export type { ButtonColor, ButtonVariant, ChipColor, ChipSize, ChipVariant, SkeletonVariant, TextAlign, TextVariant, } from "./catalog.js";
|
|
10
|
+
export declare const TextField: ComponentType<{
|
|
11
|
+
label: string;
|
|
12
|
+
value: string;
|
|
13
|
+
multiline?: boolean;
|
|
14
|
+
disabled?: boolean;
|
|
15
|
+
placeholder?: string;
|
|
16
|
+
error?: string;
|
|
17
|
+
onValueChange?: (value: string) => void;
|
|
18
|
+
} & {
|
|
19
|
+
children?: ReactNode;
|
|
20
|
+
}>;
|
|
21
|
+
export declare const Select: ComponentType<{
|
|
22
|
+
label: string;
|
|
23
|
+
value?: string;
|
|
24
|
+
values?: string[];
|
|
25
|
+
options: Array<{
|
|
26
|
+
value: string;
|
|
27
|
+
label: string;
|
|
28
|
+
}>;
|
|
29
|
+
multiple?: boolean;
|
|
30
|
+
disabled?: boolean;
|
|
31
|
+
onValueChange?: (value: string | string[]) => void;
|
|
32
|
+
} & {
|
|
33
|
+
children?: ReactNode;
|
|
34
|
+
}>;
|
|
35
|
+
export declare const Switch: ComponentType<{
|
|
36
|
+
label: string;
|
|
37
|
+
checked: boolean;
|
|
38
|
+
disabled?: boolean;
|
|
39
|
+
onValueChange?: (value: boolean) => void;
|
|
40
|
+
} & {
|
|
41
|
+
children?: ReactNode;
|
|
42
|
+
}>;
|
|
43
|
+
export declare const NetworkGraph: ComponentType<{
|
|
44
|
+
nodes: Array<Record<string, unknown>>;
|
|
45
|
+
edges: Array<{
|
|
46
|
+
from: string;
|
|
47
|
+
to: string;
|
|
48
|
+
config_status?: string;
|
|
49
|
+
}>;
|
|
50
|
+
selected?: string;
|
|
51
|
+
onNodePress?: (id: string) => void;
|
|
52
|
+
} & {
|
|
53
|
+
children?: ReactNode;
|
|
54
|
+
}>;
|
|
8
55
|
export interface TableColumn {
|
|
9
56
|
key: string;
|
|
10
57
|
header: string;
|
|
11
|
-
align?:
|
|
58
|
+
align?: "left" | "right" | "center";
|
|
12
59
|
width?: number | string;
|
|
13
60
|
}
|
|
14
61
|
export type TableRow = Record<string, string | number | boolean | null | undefined> & {
|
|
@@ -40,16 +87,17 @@ export declare const Stack: ComponentType<{
|
|
|
40
87
|
children?: ReactNode;
|
|
41
88
|
}>;
|
|
42
89
|
export declare const Text: ComponentType<{
|
|
43
|
-
variant?:
|
|
90
|
+
variant?: TextVariant;
|
|
91
|
+
/** A theme color path (`text.secondary`, `error.main`) or any CSS color. */
|
|
44
92
|
color?: string;
|
|
45
|
-
align?:
|
|
93
|
+
align?: TextAlign;
|
|
46
94
|
noWrap?: boolean;
|
|
47
95
|
} & {
|
|
48
96
|
children?: ReactNode;
|
|
49
97
|
}>;
|
|
50
98
|
export declare const Button: ComponentType<{
|
|
51
|
-
variant?:
|
|
52
|
-
color?:
|
|
99
|
+
variant?: ButtonVariant;
|
|
100
|
+
color?: ButtonColor;
|
|
53
101
|
size?: "small" | "medium" | "large";
|
|
54
102
|
disabled?: boolean;
|
|
55
103
|
loading?: boolean;
|
|
@@ -60,9 +108,9 @@ export declare const Button: ComponentType<{
|
|
|
60
108
|
}>;
|
|
61
109
|
export declare const Chip: ComponentType<{
|
|
62
110
|
label: string;
|
|
63
|
-
color?:
|
|
64
|
-
variant?:
|
|
65
|
-
size?:
|
|
111
|
+
color?: ChipColor;
|
|
112
|
+
variant?: ChipVariant;
|
|
113
|
+
size?: ChipSize;
|
|
66
114
|
} & {
|
|
67
115
|
children?: ReactNode;
|
|
68
116
|
}>;
|
|
@@ -86,7 +134,7 @@ export declare const Table: ComponentType<{
|
|
|
86
134
|
export declare const Skeleton: ComponentType<{
|
|
87
135
|
height?: number;
|
|
88
136
|
width?: string;
|
|
89
|
-
variant?:
|
|
137
|
+
variant?: SkeletonVariant;
|
|
90
138
|
} & {
|
|
91
139
|
children?: ReactNode;
|
|
92
140
|
}>;
|
|
@@ -147,3 +195,106 @@ export declare const Box: ComponentType<{
|
|
|
147
195
|
} & {
|
|
148
196
|
children?: ReactNode;
|
|
149
197
|
}>;
|
|
198
|
+
/** Responsive grid: as many columns as fit `min` px, up to `columns`. */
|
|
199
|
+
export declare const Grid: ComponentType<{
|
|
200
|
+
columns?: number;
|
|
201
|
+
min?: number;
|
|
202
|
+
gap?: number;
|
|
203
|
+
} & {
|
|
204
|
+
children?: ReactNode;
|
|
205
|
+
}>;
|
|
206
|
+
export type ValueFormat = "number" | "currency" | "percent" | "compact";
|
|
207
|
+
/** Big number tile. `trend` draws the arrow; `tone` colors the delta (`positive` = good, whatever the direction). */
|
|
208
|
+
export declare const Metric: ComponentType<{
|
|
209
|
+
label: string;
|
|
210
|
+
value: string;
|
|
211
|
+
delta?: string;
|
|
212
|
+
trend?: "up" | "down" | "flat";
|
|
213
|
+
tone?: "positive" | "negative" | "neutral";
|
|
214
|
+
hint?: string;
|
|
215
|
+
/** Recent values drawn as a small sparkline next to the number. */
|
|
216
|
+
spark?: number[];
|
|
217
|
+
/** Theme color name (`primary`, `info`, `success`, `warning`, `error`, `secondary`) or `palette:<n>`. */
|
|
218
|
+
color?: string;
|
|
219
|
+
} & {
|
|
220
|
+
children?: ReactNode;
|
|
221
|
+
}>;
|
|
222
|
+
/**
|
|
223
|
+
* Colors a plugin can name without knowing the host theme: theme roles or palette slots.
|
|
224
|
+
* Use the same one for the same concept across charts so a category keeps its hue everywhere.
|
|
225
|
+
*/
|
|
226
|
+
export type ThemeColor = "primary" | "info" | "success" | "warning" | "error" | "secondary" | "grey" | "muted" | `palette:${number}`;
|
|
227
|
+
/** `area` fills under the line; off by default. */
|
|
228
|
+
export declare const Sparkline: ComponentType<{
|
|
229
|
+
values: number[];
|
|
230
|
+
height?: number;
|
|
231
|
+
color?: string;
|
|
232
|
+
area?: boolean;
|
|
233
|
+
} & {
|
|
234
|
+
children?: ReactNode;
|
|
235
|
+
}>;
|
|
236
|
+
export interface ChartSeries {
|
|
237
|
+
name: string;
|
|
238
|
+
values: Array<number | null>;
|
|
239
|
+
color?: ThemeColor | string;
|
|
240
|
+
}
|
|
241
|
+
export interface ChartPoint {
|
|
242
|
+
series: string;
|
|
243
|
+
category: string;
|
|
244
|
+
value: number;
|
|
245
|
+
index: number;
|
|
246
|
+
}
|
|
247
|
+
/** Time series; `categories` are the x labels, one per value. */
|
|
248
|
+
export declare const LineChart: ComponentType<{
|
|
249
|
+
series: ChartSeries[];
|
|
250
|
+
categories: string[];
|
|
251
|
+
stacked?: boolean;
|
|
252
|
+
area?: boolean;
|
|
253
|
+
height?: number;
|
|
254
|
+
format?: ValueFormat;
|
|
255
|
+
currency?: string;
|
|
256
|
+
/** Legends show by default; remote-dom booleans default to false, hence the negative flag. */
|
|
257
|
+
hideLegend?: boolean;
|
|
258
|
+
onPointPress?: (point: ChartPoint) => void;
|
|
259
|
+
} & {
|
|
260
|
+
children?: ReactNode;
|
|
261
|
+
}>;
|
|
262
|
+
export declare const BarChart: ComponentType<{
|
|
263
|
+
series: ChartSeries[];
|
|
264
|
+
categories: string[];
|
|
265
|
+
stacked?: boolean;
|
|
266
|
+
horizontal?: boolean;
|
|
267
|
+
height?: number;
|
|
268
|
+
format?: ValueFormat;
|
|
269
|
+
currency?: string;
|
|
270
|
+
hideLegend?: boolean;
|
|
271
|
+
onBarPress?: (point: ChartPoint) => void;
|
|
272
|
+
} & {
|
|
273
|
+
children?: ReactNode;
|
|
274
|
+
}>;
|
|
275
|
+
export interface DonutItem {
|
|
276
|
+
name: string;
|
|
277
|
+
value: number;
|
|
278
|
+
color?: ThemeColor | string;
|
|
279
|
+
}
|
|
280
|
+
/** Part-to-whole ring; the center shows `total` or the formatted sum. */
|
|
281
|
+
export declare const Donut: ComponentType<{
|
|
282
|
+
items: DonutItem[];
|
|
283
|
+
total?: string;
|
|
284
|
+
height?: number;
|
|
285
|
+
format?: ValueFormat;
|
|
286
|
+
currency?: string;
|
|
287
|
+
hideLegend?: boolean;
|
|
288
|
+
onSlicePress?: (item: DonutItem) => void;
|
|
289
|
+
} & {
|
|
290
|
+
children?: ReactNode;
|
|
291
|
+
}>;
|
|
292
|
+
/** Horizontal share bar, `value` in 0..1. */
|
|
293
|
+
export declare const ProgressBar: ComponentType<{
|
|
294
|
+
value: number;
|
|
295
|
+
label?: string;
|
|
296
|
+
color?: string;
|
|
297
|
+
height?: number;
|
|
298
|
+
} & {
|
|
299
|
+
children?: ReactNode;
|
|
300
|
+
}>;
|