@nullplatform/ui-plugin-sdk 0.7.1 → 0.8.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/catalog.d.ts +13 -0
- package/dist/catalog.js +67 -5
- package/dist/component.js +18 -9
- package/dist/components.d.ts +103 -3
- package/dist/components.generated.d.ts +34 -0
- package/dist/components.generated.js +3 -1
- package/dist/components.js +11 -1
- package/dist/contractProps.d.ts +18 -1
- package/dist/contracts.generated.d.ts +39 -0
- package/dist/contracts.generated.js +18 -3
- package/dist/dataTable.d.ts +138 -0
- package/dist/dataTable.js +1 -0
- package/dist/host.d.ts +10 -0
- package/dist/host.js +19 -0
- package/dist/index.d.ts +1 -0
- package/dist/index.js +1 -0
- package/dist/protocol.d.ts +7 -3
- package/dist/protocol.js +19 -8
- package/dist/worker.js +2 -0
- package/package.json +2 -2
package/dist/catalog.d.ts
CHANGED
|
@@ -55,11 +55,18 @@ export declare const CATALOG_PROP_VALUES: {
|
|
|
55
55
|
readonly color: readonly ["inherit", "primary", "secondary", "success", "error", "info", "warning"];
|
|
56
56
|
readonly size: readonly ["small", "medium", "large"];
|
|
57
57
|
};
|
|
58
|
+
readonly EgoGraph: {
|
|
59
|
+
readonly layout: readonly ["columns", "constellation"];
|
|
60
|
+
};
|
|
58
61
|
readonly Chip: {
|
|
59
62
|
readonly color: readonly ["default", "primary", "secondary", "success", "error", "info", "warning"];
|
|
60
63
|
readonly variant: readonly ["filled", "outlined", "soft"];
|
|
61
64
|
readonly size: readonly ["small", "medium"];
|
|
62
65
|
};
|
|
66
|
+
readonly Link: {
|
|
67
|
+
readonly color: readonly ["primary", "secondary", "error", "inherit", "textPrimary", "textSecondary"];
|
|
68
|
+
readonly underline: readonly ["none", "hover", "always"];
|
|
69
|
+
};
|
|
63
70
|
readonly Skeleton: {
|
|
64
71
|
readonly variant: readonly ["text", "rectangular", "rounded", "circular"];
|
|
65
72
|
};
|
|
@@ -69,6 +76,9 @@ export declare const CATALOG_PROP_VALUES: {
|
|
|
69
76
|
readonly Alert: {
|
|
70
77
|
readonly severity: readonly ["success", "info", "warning", "error"];
|
|
71
78
|
};
|
|
79
|
+
readonly Scatter: {
|
|
80
|
+
readonly xScale: readonly ["linear", "log"];
|
|
81
|
+
};
|
|
72
82
|
};
|
|
73
83
|
/**
|
|
74
84
|
* Every element a plugin can render: the SDK's own, then the design-system components whose contracts
|
|
@@ -87,5 +97,8 @@ export type SkeletonVariant = (typeof CATALOG_PROP_VALUES.Skeleton.variant)[numb
|
|
|
87
97
|
export type ButtonSize = (typeof CATALOG_PROP_VALUES.Button.size)[number];
|
|
88
98
|
export type StackDirection = (typeof CATALOG_PROP_VALUES.Stack.direction)[number];
|
|
89
99
|
export type AlertSeverity = (typeof CATALOG_PROP_VALUES.Alert.severity)[number];
|
|
100
|
+
export type LinkColor = (typeof CATALOG_PROP_VALUES.Link.color)[number];
|
|
101
|
+
export type LinkUnderline = (typeof CATALOG_PROP_VALUES.Link.underline)[number];
|
|
102
|
+
export type ScatterScale = (typeof CATALOG_PROP_VALUES.Scatter.xScale)[number];
|
|
90
103
|
/** Name of the wrapper element remote-dom uses for React elements passed as props. */
|
|
91
104
|
export declare const FRAGMENT_TAG = "remote-fragment";
|
package/dist/catalog.js
CHANGED
|
@@ -27,11 +27,19 @@ export const CATALOG_PROP_VALUES = {
|
|
|
27
27
|
color: ["inherit", "primary", "secondary", "success", "error", "info", "warning"],
|
|
28
28
|
size: ["small", "medium", "large"],
|
|
29
29
|
},
|
|
30
|
+
EgoGraph: {
|
|
31
|
+
layout: ["columns", "constellation"],
|
|
32
|
+
},
|
|
30
33
|
Chip: {
|
|
31
34
|
color: ["default", "primary", "secondary", "success", "error", "info", "warning"],
|
|
32
35
|
variant: ["filled", "outlined", "soft"],
|
|
33
36
|
size: ["small", "medium"],
|
|
34
37
|
},
|
|
38
|
+
// MUI's Link resolves only these colors; any other one breaks its underline.
|
|
39
|
+
Link: {
|
|
40
|
+
color: ["primary", "secondary", "error", "inherit", "textPrimary", "textSecondary"],
|
|
41
|
+
underline: ["none", "hover", "always"],
|
|
42
|
+
},
|
|
35
43
|
Skeleton: {
|
|
36
44
|
variant: ["text", "rectangular", "rounded", "circular"],
|
|
37
45
|
},
|
|
@@ -41,6 +49,9 @@ export const CATALOG_PROP_VALUES = {
|
|
|
41
49
|
Alert: {
|
|
42
50
|
severity: ["success", "info", "warning", "error"],
|
|
43
51
|
},
|
|
52
|
+
Scatter: {
|
|
53
|
+
xScale: ["linear", "log"],
|
|
54
|
+
},
|
|
44
55
|
};
|
|
45
56
|
/** The elements the SDK defines itself. */
|
|
46
57
|
const OWN_CATALOG = [
|
|
@@ -96,9 +107,15 @@ const OWN_CATALOG = [
|
|
|
96
107
|
{
|
|
97
108
|
tag: "np-card",
|
|
98
109
|
component: "Card",
|
|
99
|
-
properties: {
|
|
100
|
-
|
|
101
|
-
|
|
110
|
+
properties: {
|
|
111
|
+
title: "string",
|
|
112
|
+
subtitle: "string",
|
|
113
|
+
padding: "string",
|
|
114
|
+
to: "string",
|
|
115
|
+
params: "object",
|
|
116
|
+
},
|
|
117
|
+
events: { press: "onPress" },
|
|
118
|
+
slots: ["action", "avatar", "header"],
|
|
102
119
|
children: true,
|
|
103
120
|
},
|
|
104
121
|
{
|
|
@@ -144,6 +161,7 @@ const OWN_CATALOG = [
|
|
|
144
161
|
icon: "string",
|
|
145
162
|
},
|
|
146
163
|
events: { press: "onPress" },
|
|
164
|
+
slots: ["endIcon"],
|
|
147
165
|
values: CATALOG_PROP_VALUES.Button,
|
|
148
166
|
children: true,
|
|
149
167
|
defaults: { variant: "contained", color: "primary", size: "small" },
|
|
@@ -164,8 +182,15 @@ const OWN_CATALOG = [
|
|
|
164
182
|
{
|
|
165
183
|
tag: "np-link",
|
|
166
184
|
component: "Link",
|
|
167
|
-
properties: {
|
|
185
|
+
properties: {
|
|
186
|
+
to: "string",
|
|
187
|
+
params: "object",
|
|
188
|
+
href: "string",
|
|
189
|
+
color: "string",
|
|
190
|
+
underline: "string",
|
|
191
|
+
},
|
|
168
192
|
events: { press: "onPress" },
|
|
193
|
+
values: CATALOG_PROP_VALUES.Link,
|
|
169
194
|
children: true,
|
|
170
195
|
},
|
|
171
196
|
{
|
|
@@ -233,22 +258,35 @@ const OWN_CATALOG = [
|
|
|
233
258
|
{
|
|
234
259
|
tag: "np-ego-graph",
|
|
235
260
|
component: "EgoGraph",
|
|
261
|
+
// `columns` lists each side as rows; `constellation` draws each side's `group`s as clusters around the focus.
|
|
236
262
|
properties: {
|
|
237
263
|
focus: "string",
|
|
238
264
|
inbound: "array",
|
|
239
265
|
outbound: "array",
|
|
240
266
|
height: "number",
|
|
267
|
+
layout: "string",
|
|
268
|
+
selected: "object",
|
|
241
269
|
},
|
|
242
|
-
|
|
270
|
+
values: CATALOG_PROP_VALUES.EgoGraph,
|
|
271
|
+
defaults: { layout: "columns" },
|
|
272
|
+
events: { nodePress: "onNodePress", neighborPress: "onNeighborPress", groupPress: "onGroupPress" },
|
|
243
273
|
},
|
|
244
274
|
{
|
|
245
275
|
tag: "np-box",
|
|
246
276
|
component: "Box",
|
|
247
277
|
properties: {
|
|
248
278
|
padding: "string",
|
|
279
|
+
paddingX: "number",
|
|
280
|
+
paddingY: "number",
|
|
281
|
+
paddingTop: "number",
|
|
282
|
+
paddingRight: "number",
|
|
283
|
+
paddingBottom: "number",
|
|
284
|
+
paddingLeft: "number",
|
|
249
285
|
height: "string",
|
|
250
286
|
width: "string",
|
|
251
287
|
grow: "boolean",
|
|
288
|
+
// stays in view as the page scrolls (a side index, a table of contents); scrolls inside when taller than the screen
|
|
289
|
+
sticky: "boolean",
|
|
252
290
|
},
|
|
253
291
|
events: {},
|
|
254
292
|
cssValues: ["height", "width"],
|
|
@@ -335,10 +373,34 @@ const OWN_CATALOG = [
|
|
|
335
373
|
format: "string",
|
|
336
374
|
currency: "string",
|
|
337
375
|
hideLegend: "boolean",
|
|
376
|
+
hidePercent: "boolean",
|
|
338
377
|
},
|
|
339
378
|
events: { slicePress: "onSlicePress" },
|
|
340
379
|
cssValues: ["items[].color"],
|
|
341
380
|
},
|
|
381
|
+
{
|
|
382
|
+
// Two measures per item, size as a third. `points: [{ id?, label, x, y, size?, color?, hollow? }]`; `quadrants`
|
|
383
|
+
// splits the plane at `{ x, y }` and names and tints the four corners. Not every host draws it: see `hostRenders`.
|
|
384
|
+
tag: "np-scatter",
|
|
385
|
+
component: "Scatter",
|
|
386
|
+
properties: {
|
|
387
|
+
points: "array",
|
|
388
|
+
quadrants: "object",
|
|
389
|
+
xLabel: "string",
|
|
390
|
+
yLabel: "string",
|
|
391
|
+
sizeLabel: "string",
|
|
392
|
+
xScale: "string",
|
|
393
|
+
xFormat: "string",
|
|
394
|
+
yFormat: "string",
|
|
395
|
+
xMax: "number",
|
|
396
|
+
yMax: "number",
|
|
397
|
+
selected: "string",
|
|
398
|
+
height: "number",
|
|
399
|
+
},
|
|
400
|
+
events: { pointPress: "onPointPress" },
|
|
401
|
+
values: CATALOG_PROP_VALUES.Scatter,
|
|
402
|
+
cssValues: ["points[].color"],
|
|
403
|
+
},
|
|
342
404
|
{
|
|
343
405
|
// Horizontal share bar, 0..1.
|
|
344
406
|
tag: "np-progress-bar",
|
package/dist/component.js
CHANGED
|
@@ -4,6 +4,7 @@ import { createRemoteComponent } from "@remote-dom/react";
|
|
|
4
4
|
import { createElement, useLayoutEffect, useRef } from "react";
|
|
5
5
|
import { CATALOG_BY_TAG } from "./catalog.js";
|
|
6
6
|
import { defineCatalogElements } from "./elements.js";
|
|
7
|
+
import { registerTag } from "./host.js";
|
|
7
8
|
const elements = defineCatalogElements();
|
|
8
9
|
/** The React component a plugin renders a catalog element with. */
|
|
9
10
|
export function component(tag) {
|
|
@@ -30,19 +31,27 @@ export function component(tag) {
|
|
|
30
31
|
passed.current = Object.keys(props).filter((prop) => prop !== "children");
|
|
31
32
|
});
|
|
32
33
|
// remote-dom delivers a RemoteEvent to listeners; plugin authors want the payload the host sent.
|
|
34
|
+
// One wrapper per handler prop for the element's whole life, reading the latest handler from a ref:
|
|
35
|
+
// a new function every render would make the host release the one its rendered element still holds,
|
|
36
|
+
// and an event fired before the host re-renders (a fast keystroke) would call a released id.
|
|
37
|
+
const latest = useRef({});
|
|
38
|
+
const stable = useRef({});
|
|
39
|
+
latest.current = props;
|
|
33
40
|
for (const prop of handlerProps) {
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
}
|
|
41
|
+
if (typeof props[prop] !== "function")
|
|
42
|
+
continue;
|
|
43
|
+
stable.current[prop] ??= (event) => {
|
|
44
|
+
const detail = event && typeof event === "object" && "detail" in event
|
|
45
|
+
? event.detail
|
|
46
|
+
: event;
|
|
47
|
+
const handler = latest.current[prop];
|
|
48
|
+
return typeof handler === "function" ? handler(detail) : undefined;
|
|
49
|
+
};
|
|
50
|
+
mapped[prop] = stable.current[prop];
|
|
43
51
|
}
|
|
44
52
|
return createElement(Remote, mapped);
|
|
45
53
|
};
|
|
46
54
|
Wrapped.displayName = spec.component;
|
|
55
|
+
registerTag(Wrapped, tag);
|
|
47
56
|
return Wrapped;
|
|
48
57
|
}
|
package/dist/components.d.ts
CHANGED
|
@@ -4,10 +4,11 @@ import "./polyfill.js";
|
|
|
4
4
|
* the host decides how it looks.
|
|
5
5
|
*/
|
|
6
6
|
import type { ReactNode } from "react";
|
|
7
|
-
import { type AlertSeverity, type ButtonColor, type ButtonSize, type ButtonVariant, type ChipColor, type ChipSize, type ChipVariant, type SkeletonVariant, type StackDirection, type TextAlign, type TextVariant } from "./catalog.js";
|
|
8
|
-
export type { AlertSeverity, ButtonColor, ButtonSize, ButtonVariant, ChipColor, ChipSize, ChipVariant, SkeletonVariant, StackDirection, TextAlign, TextVariant, } from "./catalog.js";
|
|
7
|
+
import { type AlertSeverity, type ButtonColor, type ButtonSize, type ButtonVariant, type ChipColor, type ChipSize, type ChipVariant, type LinkColor, type LinkUnderline, type ScatterScale, type SkeletonVariant, type StackDirection, type TextAlign, type TextVariant } from "./catalog.js";
|
|
8
|
+
export type { AlertSeverity, ButtonColor, ButtonSize, ButtonVariant, ChipColor, ChipSize, ChipVariant, LinkColor, LinkUnderline, ScatterScale, SkeletonVariant, StackDirection, TextAlign, TextVariant, } from "./catalog.js";
|
|
9
9
|
export * from "./components.generated.js";
|
|
10
10
|
export type { ContractProps, UiComponentsTag } from "./contractProps.js";
|
|
11
|
+
export type { DataTableAvatar, DataTableColor, DataTableColumn, DataTableFormatter, DataTableLabelVariant, DataTableLink, DataTablePagination, DataTableRow, DataTableRowAction, DataTableState, DataTableTypography, } from "./dataTable.js";
|
|
11
12
|
export declare const TextField: import("react").ComponentType<{
|
|
12
13
|
label: string;
|
|
13
14
|
value: string;
|
|
@@ -75,6 +76,15 @@ export declare const Card: import("react").ComponentType<{
|
|
|
75
76
|
subtitle?: string;
|
|
76
77
|
padding?: string;
|
|
77
78
|
action?: ReactNode;
|
|
79
|
+
/** Drawn before the title, such as `<Icon icon="lucide:shield-alert" />`. */
|
|
80
|
+
avatar?: ReactNode;
|
|
81
|
+
/** Drawn in place of `title` and `subtitle`, for a title that text alone can't say. */
|
|
82
|
+
header?: ReactNode;
|
|
83
|
+
/** A logical route of the host: the whole card links to it. */
|
|
84
|
+
to?: string;
|
|
85
|
+
params?: Record<string, string | number>;
|
|
86
|
+
/** Makes the whole card clickable. `action` stays outside the clickable area; keep other controls out of it. */
|
|
87
|
+
onPress?: () => void;
|
|
78
88
|
} & {
|
|
79
89
|
children?: ReactNode;
|
|
80
90
|
}>;
|
|
@@ -103,6 +113,8 @@ export declare const Button: import("react").ComponentType<{
|
|
|
103
113
|
disabled?: boolean;
|
|
104
114
|
loading?: boolean;
|
|
105
115
|
icon?: string;
|
|
116
|
+
/** Drawn after the label, such as `<Icon icon="lucide:chevron-right" />`. */
|
|
117
|
+
endIcon?: ReactNode;
|
|
106
118
|
onPress?: () => void;
|
|
107
119
|
} & {
|
|
108
120
|
children?: ReactNode;
|
|
@@ -119,6 +131,10 @@ export declare const Link: import("react").ComponentType<{
|
|
|
119
131
|
to?: string;
|
|
120
132
|
params?: Record<string, string | number>;
|
|
121
133
|
href?: string;
|
|
134
|
+
/** Unset, the theme's link color. `inherit` takes the surrounding text's. */
|
|
135
|
+
color?: LinkColor;
|
|
136
|
+
/** Unset, the theme's: underlined on hover. */
|
|
137
|
+
underline?: LinkUnderline;
|
|
122
138
|
onPress?: () => void;
|
|
123
139
|
} & {
|
|
124
140
|
children?: ReactNode;
|
|
@@ -177,22 +193,56 @@ export interface EgoEdge {
|
|
|
177
193
|
node: string;
|
|
178
194
|
label?: string;
|
|
179
195
|
kind?: string;
|
|
196
|
+
/** The cluster the node joins in the `constellation` layout (a namespace, a kind); its `kind` when absent. */
|
|
197
|
+
group?: string;
|
|
180
198
|
}
|
|
181
|
-
/**
|
|
199
|
+
/** Which side of the ego graph: `in` uses the focus, the focus uses `out`. */
|
|
200
|
+
export type EgoDirection = "in" | "out";
|
|
201
|
+
/** What the ego graph highlights: one node, or one side's group. */
|
|
202
|
+
export interface EgoSelection {
|
|
203
|
+
node?: string;
|
|
204
|
+
direction?: EgoDirection;
|
|
205
|
+
group?: string;
|
|
206
|
+
}
|
|
207
|
+
/**
|
|
208
|
+
* Ego graph: the focus node in the center, what consumes it on the left, what it depends on on the right.
|
|
209
|
+
* `layout: "constellation"` draws each side's groups as clusters of dots around the focus, for large neighborhoods.
|
|
210
|
+
*/
|
|
182
211
|
export declare const EgoGraph: import("react").ComponentType<{
|
|
183
212
|
focus: string;
|
|
184
213
|
inbound: EgoEdge[];
|
|
185
214
|
outbound: EgoEdge[];
|
|
186
215
|
height?: number;
|
|
216
|
+
layout?: "columns" | "constellation";
|
|
217
|
+
selected?: EgoSelection;
|
|
187
218
|
onNodePress?: (node: string) => void;
|
|
219
|
+
/** Constellation only: the pressed dot with its side and group (a node can sit on both sides). */
|
|
220
|
+
onNeighborPress?: (neighbor: {
|
|
221
|
+
node: string;
|
|
222
|
+
direction: EgoDirection;
|
|
223
|
+
group: string;
|
|
224
|
+
}) => void;
|
|
225
|
+
onGroupPress?: (group: {
|
|
226
|
+
direction: EgoDirection;
|
|
227
|
+
group: string;
|
|
228
|
+
}) => void;
|
|
188
229
|
} & {
|
|
189
230
|
children?: ReactNode;
|
|
190
231
|
}>;
|
|
232
|
+
/** `sticky` keeps the box in view as the page scrolls; the host sets the offset, and a taller box scrolls inside. */
|
|
191
233
|
export declare const Box: import("react").ComponentType<{
|
|
192
234
|
padding?: string;
|
|
235
|
+
/** In the theme's spacing units (1 = 8px). Each one overrides `padding` on its sides. */
|
|
236
|
+
paddingX?: number;
|
|
237
|
+
paddingY?: number;
|
|
238
|
+
paddingTop?: number;
|
|
239
|
+
paddingRight?: number;
|
|
240
|
+
paddingBottom?: number;
|
|
241
|
+
paddingLeft?: number;
|
|
193
242
|
height?: string;
|
|
194
243
|
width?: string;
|
|
195
244
|
grow?: boolean;
|
|
245
|
+
sticky?: boolean;
|
|
196
246
|
} & {
|
|
197
247
|
children?: ReactNode;
|
|
198
248
|
}>;
|
|
@@ -286,10 +336,60 @@ export declare const Donut: import("react").ComponentType<{
|
|
|
286
336
|
format?: ValueFormat;
|
|
287
337
|
currency?: string;
|
|
288
338
|
hideLegend?: boolean;
|
|
339
|
+
/** Leaves each slice's share out of the legend; the center still shows it for the slice under the cursor. */
|
|
340
|
+
hidePercent?: boolean;
|
|
289
341
|
onSlicePress?: (item: DonutItem) => void;
|
|
290
342
|
} & {
|
|
291
343
|
children?: ReactNode;
|
|
292
344
|
}>;
|
|
345
|
+
export interface ScatterPoint {
|
|
346
|
+
/** What `selected` and the press payload identify the point by; the label when left out. */
|
|
347
|
+
id?: string;
|
|
348
|
+
label: string;
|
|
349
|
+
x: number;
|
|
350
|
+
y: number;
|
|
351
|
+
/** Relative area: the largest point gets the largest dot. Every dot is the same size when left out. */
|
|
352
|
+
size?: number;
|
|
353
|
+
color?: ThemeColor | string;
|
|
354
|
+
/** Outline with a faint fill, for points that matter less. */
|
|
355
|
+
hollow?: boolean;
|
|
356
|
+
}
|
|
357
|
+
/**
|
|
358
|
+
* Splits the plane at `x` and `y`. `labels` names the corners and `colors` tints them, both in reading order
|
|
359
|
+
* (top left, top right, bottom left, bottom right); `null` leaves a corner untinted.
|
|
360
|
+
*/
|
|
361
|
+
export interface ScatterQuadrants {
|
|
362
|
+
x: number;
|
|
363
|
+
y: number;
|
|
364
|
+
labels?: [string, string, string, string];
|
|
365
|
+
colors?: [ThemeColor | string | null, ThemeColor | string | null, ThemeColor | string | null, ThemeColor | string | null];
|
|
366
|
+
}
|
|
367
|
+
/**
|
|
368
|
+
* Items placed by two measures, with a third as dot size: where each sits says what to do with it.
|
|
369
|
+
* Labels show where they fit; the rest show on hover. With `sizeLabel` the chart keys the dot sizes below it.
|
|
370
|
+
* Not every host draws it: check `hostRenders(Scatter)`.
|
|
371
|
+
*/
|
|
372
|
+
export declare const Scatter: import("react").ComponentType<{
|
|
373
|
+
points: ScatterPoint[];
|
|
374
|
+
quadrants?: ScatterQuadrants;
|
|
375
|
+
xLabel?: string;
|
|
376
|
+
yLabel?: string;
|
|
377
|
+
/** What `size` counts, for the tooltip; the tooltip leaves size out without it. */
|
|
378
|
+
sizeLabel?: string;
|
|
379
|
+
/** `log` spreads points that crowd the low end, such as counts from 2 to 50. */
|
|
380
|
+
xScale?: ScatterScale;
|
|
381
|
+
xFormat?: ValueFormat;
|
|
382
|
+
yFormat?: ValueFormat;
|
|
383
|
+
/** Axis ends; the data's maximum, rounded, when left out. Both axes start at the data's minimum on `log`, at 0 otherwise. */
|
|
384
|
+
xMax?: number;
|
|
385
|
+
yMax?: number;
|
|
386
|
+
/** The `id` of the point drawn as chosen. */
|
|
387
|
+
selected?: string;
|
|
388
|
+
height?: number;
|
|
389
|
+
onPointPress?: (point: ScatterPoint) => void;
|
|
390
|
+
} & {
|
|
391
|
+
children?: ReactNode;
|
|
392
|
+
}>;
|
|
293
393
|
/** Horizontal share bar, `value` in 0..1. */
|
|
294
394
|
export declare const ProgressBar: import("react").ComponentType<{
|
|
295
395
|
value: number;
|
|
@@ -263,6 +263,7 @@ export declare const CountdownButton: import("react").ComponentType<{
|
|
|
263
263
|
export declare const Label: import("react").ComponentType<{
|
|
264
264
|
color?: "default" | "success" | "error" | "warning" | "info" | "primary" | "secondary" | undefined;
|
|
265
265
|
variant?: "outlined" | "filled" | "ghost" | "soft" | undefined;
|
|
266
|
+
textTransform?: "capitalize" | "none" | undefined;
|
|
266
267
|
} & {} & {
|
|
267
268
|
startIcon?: import("react").ReactNode;
|
|
268
269
|
endIcon?: import("react").ReactNode;
|
|
@@ -328,3 +329,36 @@ export declare const ActivityTimeline: import("react").ComponentType<{
|
|
|
328
329
|
} & {} & {} & {
|
|
329
330
|
children?: import("react").ReactNode;
|
|
330
331
|
}>;
|
|
332
|
+
export declare const ListItemButton: import("react").ComponentType<{
|
|
333
|
+
selected?: boolean | undefined;
|
|
334
|
+
disabled?: boolean | undefined;
|
|
335
|
+
dense?: boolean | undefined;
|
|
336
|
+
divider?: boolean | undefined;
|
|
337
|
+
disableGutters?: boolean | undefined;
|
|
338
|
+
alignItems?: "center" | "flex-start" | undefined;
|
|
339
|
+
} & {
|
|
340
|
+
readonly onClick?: ((payload: unknown) => void) | undefined;
|
|
341
|
+
} & {} & {
|
|
342
|
+
children?: import("react").ReactNode;
|
|
343
|
+
}>;
|
|
344
|
+
export declare const DataTable: import("react").ComponentType<Omit<{
|
|
345
|
+
columns?: readonly unknown[] | undefined;
|
|
346
|
+
data?: readonly unknown[] | undefined;
|
|
347
|
+
serverSide?: boolean | undefined;
|
|
348
|
+
isLoading?: boolean | undefined;
|
|
349
|
+
initialState?: Readonly<Record<string, unknown>> | undefined;
|
|
350
|
+
paginationProps?: Readonly<Record<string, unknown>> | undefined;
|
|
351
|
+
variant?: "default" | "embedded" | undefined;
|
|
352
|
+
} & {
|
|
353
|
+
readonly onChangeTableState?: ((payload: unknown) => void) | undefined;
|
|
354
|
+
readonly onRowClick?: ((payload: unknown) => void) | undefined;
|
|
355
|
+
} & {}, "data" | "onChangeTableState" | "onRowClick" | "columns" | "initialState" | "paginationProps"> & Pick<{
|
|
356
|
+
columns?: readonly import("./dataTable").DataTableColumn[];
|
|
357
|
+
data?: readonly import("./dataTable").DataTableRow[];
|
|
358
|
+
initialState?: import("./dataTable").DataTableState;
|
|
359
|
+
paginationProps?: import("./dataTable").DataTablePagination;
|
|
360
|
+
onChangeTableState?: (state: import("./dataTable").DataTableState) => void;
|
|
361
|
+
onRowClick?: (row: import("./dataTable").DataTableRow) => void;
|
|
362
|
+
}, "data" | "onChangeTableState" | "onRowClick" | "columns" | "initialState" | "paginationProps"> & {
|
|
363
|
+
children?: import("react").ReactNode;
|
|
364
|
+
}>;
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
// Generated by scripts/sync-contracts.mjs from @nullplatform/react-ui-components@0.15.
|
|
1
|
+
// Generated by scripts/sync-contracts.mjs from @nullplatform/react-ui-components@0.15.12. Don't edit: change the contract in
|
|
2
2
|
// react-ui-components, bump `uiComponentsContracts` in package.json and run `pnpm sync:contracts`.
|
|
3
3
|
import { component } from "./component.js";
|
|
4
4
|
export const Badge = component("np-badge");
|
|
@@ -38,3 +38,5 @@ export const TabBar = component("np-tab-bar");
|
|
|
38
38
|
export const BreadcrumbTrail = component("np-breadcrumb-trail");
|
|
39
39
|
export const ChipList = component("np-chip-list");
|
|
40
40
|
export const ActivityTimeline = component("np-activity-timeline");
|
|
41
|
+
export const ListItemButton = component("np-list-item-button");
|
|
42
|
+
export const DataTable = component("np-data-table");
|
package/dist/components.js
CHANGED
|
@@ -21,8 +21,12 @@ export const Icon = component("np-icon");
|
|
|
21
21
|
export const Divider = component("np-divider");
|
|
22
22
|
export const Markdown = component("np-markdown");
|
|
23
23
|
export const Code = component("np-code");
|
|
24
|
-
/**
|
|
24
|
+
/**
|
|
25
|
+
* Ego graph: the focus node in the center, what consumes it on the left, what it depends on on the right.
|
|
26
|
+
* `layout: "constellation"` draws each side's groups as clusters of dots around the focus, for large neighborhoods.
|
|
27
|
+
*/
|
|
25
28
|
export const EgoGraph = component("np-ego-graph");
|
|
29
|
+
/** `sticky` keeps the box in view as the page scrolls; the host sets the offset, and a taller box scrolls inside. */
|
|
26
30
|
export const Box = component("np-box");
|
|
27
31
|
/** Responsive grid: as many columns as fit `min` px, up to `columns`. */
|
|
28
32
|
export const Grid = component("np-grid");
|
|
@@ -35,5 +39,11 @@ export const LineChart = component("np-line-chart");
|
|
|
35
39
|
export const BarChart = component("np-bar-chart");
|
|
36
40
|
/** Part-to-whole ring; the center shows `total` or the formatted sum. */
|
|
37
41
|
export const Donut = component("np-donut");
|
|
42
|
+
/**
|
|
43
|
+
* Items placed by two measures, with a third as dot size: where each sits says what to do with it.
|
|
44
|
+
* Labels show where they fit; the rest show on hover. With `sizeLabel` the chart keys the dot sizes below it.
|
|
45
|
+
* Not every host draws it: check `hostRenders(Scatter)`.
|
|
46
|
+
*/
|
|
47
|
+
export const Scatter = component("np-scatter");
|
|
38
48
|
/** Horizontal share bar, `value` in 0..1. */
|
|
39
49
|
export const ProgressBar = component("np-progress-bar");
|
package/dist/contractProps.d.ts
CHANGED
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import type { ReactNode } from "react";
|
|
2
2
|
import type { UI_COMPONENTS_CONTRACTS } from "./contracts.generated.js";
|
|
3
|
+
import type { DataTableColumn, DataTablePagination, DataTableRow, DataTableState } from "./dataTable.js";
|
|
3
4
|
type Contract = (typeof UI_COMPONENTS_CONTRACTS)[number];
|
|
4
5
|
/** The elements the SDK takes from @nullplatform/react-ui-components' contracts. */
|
|
5
6
|
export type UiComponentsTag = Contract["tag"];
|
|
@@ -13,11 +14,27 @@ type Events<C> = C extends {
|
|
|
13
14
|
type Slots<C> = C extends {
|
|
14
15
|
slots: readonly (infer S extends string)[];
|
|
15
16
|
} ? S : never;
|
|
17
|
+
/**
|
|
18
|
+
* What a contract can only type loosely, an array's items or an event's payload, typed by hand for the elements
|
|
19
|
+
* that need it. A key the contract doesn't declare is left out, so this can't add a prop the host would drop.
|
|
20
|
+
*/
|
|
21
|
+
interface ContractPropTypes {
|
|
22
|
+
"np-data-table": {
|
|
23
|
+
columns?: readonly DataTableColumn[];
|
|
24
|
+
data?: readonly DataTableRow[];
|
|
25
|
+
initialState?: DataTableState;
|
|
26
|
+
paginationProps?: DataTablePagination;
|
|
27
|
+
onChangeTableState?: (state: DataTableState) => void;
|
|
28
|
+
onRowClick?: (row: DataTableRow) => void;
|
|
29
|
+
};
|
|
30
|
+
}
|
|
31
|
+
type Typed<Tag, Props> = Tag extends keyof ContractPropTypes ? Omit<Props, keyof ContractPropTypes[Tag]> & Pick<ContractPropTypes[Tag], Extract<keyof ContractPropTypes[Tag], keyof Props>> : Props;
|
|
16
32
|
/**
|
|
17
33
|
* The props a plugin renders an element with, read off its contract: each property with its type, a value list
|
|
18
34
|
* as the union of its values, each event as a callback and each slot as an element.
|
|
19
35
|
*/
|
|
20
|
-
export type ContractProps<Tag extends UiComponentsTag
|
|
36
|
+
export type ContractProps<Tag extends UiComponentsTag> = Typed<Tag, LooseContractProps<Tag>>;
|
|
37
|
+
type LooseContractProps<Tag extends UiComponentsTag, C = Extract<Contract, {
|
|
21
38
|
tag: Tag;
|
|
22
39
|
}>> = C extends {
|
|
23
40
|
properties: infer Properties;
|
|
@@ -372,12 +372,14 @@ export declare const UI_COMPONENTS_CONTRACTS: readonly [{
|
|
|
372
372
|
readonly properties: {
|
|
373
373
|
readonly color: "string";
|
|
374
374
|
readonly variant: "string";
|
|
375
|
+
readonly textTransform: "string";
|
|
375
376
|
};
|
|
376
377
|
readonly events: {};
|
|
377
378
|
readonly slots: readonly ["startIcon", "endIcon"];
|
|
378
379
|
readonly values: {
|
|
379
380
|
readonly color: readonly ["default", "primary", "secondary", "info", "success", "warning", "error"];
|
|
380
381
|
readonly variant: readonly ["filled", "outlined", "ghost", "soft"];
|
|
382
|
+
readonly textTransform: readonly ["capitalize", "none"];
|
|
381
383
|
};
|
|
382
384
|
readonly children: true;
|
|
383
385
|
}, {
|
|
@@ -469,4 +471,41 @@ export declare const UI_COMPONENTS_CONTRACTS: readonly [{
|
|
|
469
471
|
};
|
|
470
472
|
readonly events: {};
|
|
471
473
|
readonly imageValues: readonly ["items[].avatar"];
|
|
474
|
+
}, {
|
|
475
|
+
readonly tag: "np-list-item-button";
|
|
476
|
+
readonly component: "ListItemButton";
|
|
477
|
+
readonly properties: {
|
|
478
|
+
readonly selected: "boolean";
|
|
479
|
+
readonly disabled: "boolean";
|
|
480
|
+
readonly dense: "boolean";
|
|
481
|
+
readonly divider: "boolean";
|
|
482
|
+
readonly disableGutters: "boolean";
|
|
483
|
+
readonly alignItems: "string";
|
|
484
|
+
};
|
|
485
|
+
readonly events: {
|
|
486
|
+
readonly press: "onClick";
|
|
487
|
+
};
|
|
488
|
+
readonly values: {
|
|
489
|
+
readonly alignItems: readonly ["center", "flex-start"];
|
|
490
|
+
};
|
|
491
|
+
readonly children: true;
|
|
492
|
+
}, {
|
|
493
|
+
readonly tag: "np-data-table";
|
|
494
|
+
readonly component: "DataTable";
|
|
495
|
+
readonly properties: {
|
|
496
|
+
readonly columns: "array";
|
|
497
|
+
readonly data: "array";
|
|
498
|
+
readonly serverSide: "boolean";
|
|
499
|
+
readonly isLoading: "boolean";
|
|
500
|
+
readonly initialState: "object";
|
|
501
|
+
readonly paginationProps: "object";
|
|
502
|
+
readonly variant: "string";
|
|
503
|
+
};
|
|
504
|
+
readonly events: {
|
|
505
|
+
readonly stateChange: "onChangeTableState";
|
|
506
|
+
readonly rowClick: "onRowClick";
|
|
507
|
+
};
|
|
508
|
+
readonly values: {
|
|
509
|
+
readonly variant: readonly ["default", "embedded"];
|
|
510
|
+
};
|
|
472
511
|
}];
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
// Generated by scripts/sync-contracts.mjs from @nullplatform/react-ui-components@0.15.
|
|
1
|
+
// Generated by scripts/sync-contracts.mjs from @nullplatform/react-ui-components@0.15.12. Don't edit: change the contract in
|
|
2
2
|
// react-ui-components, bump `uiComponentsContracts` in package.json and run `pnpm sync:contracts`.
|
|
3
3
|
export const UI_COMPONENTS_CONTRACTS = [
|
|
4
4
|
{
|
|
@@ -216,10 +216,10 @@ export const UI_COMPONENTS_CONTRACTS = [
|
|
|
216
216
|
{
|
|
217
217
|
tag: "np-label",
|
|
218
218
|
component: "Label",
|
|
219
|
-
properties: { "color": "string", "variant": "string" },
|
|
219
|
+
properties: { "color": "string", "variant": "string", "textTransform": "string" },
|
|
220
220
|
events: {},
|
|
221
221
|
slots: ["startIcon", "endIcon"],
|
|
222
|
-
values: { "color": ["default", "primary", "secondary", "info", "success", "warning", "error"], "variant": ["filled", "outlined", "ghost", "soft"] },
|
|
222
|
+
values: { "color": ["default", "primary", "secondary", "info", "success", "warning", "error"], "variant": ["filled", "outlined", "ghost", "soft"], "textTransform": ["capitalize", "none"] },
|
|
223
223
|
children: true,
|
|
224
224
|
},
|
|
225
225
|
{
|
|
@@ -265,4 +265,19 @@ export const UI_COMPONENTS_CONTRACTS = [
|
|
|
265
265
|
events: {},
|
|
266
266
|
imageValues: ["items[].avatar"],
|
|
267
267
|
},
|
|
268
|
+
{
|
|
269
|
+
tag: "np-list-item-button",
|
|
270
|
+
component: "ListItemButton",
|
|
271
|
+
properties: { "selected": "boolean", "disabled": "boolean", "dense": "boolean", "divider": "boolean", "disableGutters": "boolean", "alignItems": "string" },
|
|
272
|
+
events: { "press": "onClick" },
|
|
273
|
+
values: { "alignItems": ["center", "flex-start"] },
|
|
274
|
+
children: true,
|
|
275
|
+
},
|
|
276
|
+
{
|
|
277
|
+
tag: "np-data-table",
|
|
278
|
+
component: "DataTable",
|
|
279
|
+
properties: { "columns": "array", "data": "array", "serverSide": "boolean", "isLoading": "boolean", "initialState": "object", "paginationProps": "object", "variant": "string" },
|
|
280
|
+
events: { "stateChange": "onChangeTableState", "rowClick": "onRowClick" },
|
|
281
|
+
values: { "variant": ["default", "embedded"] },
|
|
282
|
+
},
|
|
268
283
|
];
|
|
@@ -0,0 +1,138 @@
|
|
|
1
|
+
import type { TextVariant } from "./catalog.js";
|
|
2
|
+
/**
|
|
3
|
+
* The shapes the design system's `DataTable` takes from a plugin, which its contract can only type as arrays and
|
|
4
|
+
* objects. A subset of react-ui-components' own types: plain data only.
|
|
5
|
+
*/
|
|
6
|
+
export type DataTableColor = "default" | "primary" | "secondary" | "error" | "info" | "success" | "warning";
|
|
7
|
+
export type DataTableLabelVariant = "filled" | "outlined" | "ghost" | "soft";
|
|
8
|
+
/** A row's menu entry. `icon` is an iconify name, such as `mdi:open-in-new`. */
|
|
9
|
+
export interface DataTableRowAction {
|
|
10
|
+
id: string;
|
|
11
|
+
label: string;
|
|
12
|
+
icon?: string;
|
|
13
|
+
}
|
|
14
|
+
export interface DataTableTypography {
|
|
15
|
+
variant?: TextVariant;
|
|
16
|
+
/** A theme colour path, such as `text.secondary`, or a plain colour. */
|
|
17
|
+
color?: string;
|
|
18
|
+
maxLength?: number;
|
|
19
|
+
transform?: "uppercase" | "lowercase" | "capitalize" | "titlecase" | "none";
|
|
20
|
+
maxLines?: number;
|
|
21
|
+
}
|
|
22
|
+
/** How a column draws its cells. Without one, a cell draws its value as text. */
|
|
23
|
+
export type DataTableFormatter = {
|
|
24
|
+
type: "text";
|
|
25
|
+
typography?: DataTableTypography;
|
|
26
|
+
} | {
|
|
27
|
+
type: "date";
|
|
28
|
+
format?: "relative" | "absolute";
|
|
29
|
+
config?: {
|
|
30
|
+
tooltip?: {
|
|
31
|
+
enabled: boolean;
|
|
32
|
+
placement?: "top" | "bottom" | "left" | "right";
|
|
33
|
+
};
|
|
34
|
+
};
|
|
35
|
+
typography?: DataTableTypography;
|
|
36
|
+
} | {
|
|
37
|
+
type: "chip";
|
|
38
|
+
format?: "default" | "outlined" | "filled";
|
|
39
|
+
config?: {
|
|
40
|
+
color?: DataTableColor;
|
|
41
|
+
size?: "small" | "medium";
|
|
42
|
+
/** The text and colour each value draws with, such as a status → its colour. */
|
|
43
|
+
mapping?: Record<string, {
|
|
44
|
+
label?: string;
|
|
45
|
+
color?: DataTableColor;
|
|
46
|
+
}>;
|
|
47
|
+
};
|
|
48
|
+
typography?: DataTableTypography;
|
|
49
|
+
} | {
|
|
50
|
+
type: "label";
|
|
51
|
+
config?: {
|
|
52
|
+
color?: DataTableColor;
|
|
53
|
+
variant?: DataTableLabelVariant;
|
|
54
|
+
/** `none` keeps names such as repositories and slugs as they are. */
|
|
55
|
+
textTransform?: "capitalize" | "none";
|
|
56
|
+
mapping?: Record<string, {
|
|
57
|
+
label?: string;
|
|
58
|
+
color?: DataTableColor;
|
|
59
|
+
variant?: DataTableLabelVariant;
|
|
60
|
+
}>;
|
|
61
|
+
};
|
|
62
|
+
} | {
|
|
63
|
+
type: "link";
|
|
64
|
+
config?: {
|
|
65
|
+
underline?: "none" | "hover" | "always";
|
|
66
|
+
/** The colours MUI's Link resolves. */
|
|
67
|
+
color?: "primary" | "secondary" | "error";
|
|
68
|
+
displayText?: string;
|
|
69
|
+
};
|
|
70
|
+
typography?: DataTableTypography;
|
|
71
|
+
} | {
|
|
72
|
+
type: "avatar";
|
|
73
|
+
config?: {
|
|
74
|
+
size?: "small" | "medium" | "large";
|
|
75
|
+
};
|
|
76
|
+
} | {
|
|
77
|
+
type: "icon";
|
|
78
|
+
config?: {
|
|
79
|
+
color?: string;
|
|
80
|
+
size?: number;
|
|
81
|
+
};
|
|
82
|
+
} | {
|
|
83
|
+
type: "actions";
|
|
84
|
+
config: {
|
|
85
|
+
actions: DataTableRowAction[];
|
|
86
|
+
onAction?: (actionId: string, row: DataTableRow) => void;
|
|
87
|
+
};
|
|
88
|
+
};
|
|
89
|
+
export interface DataTableColumn {
|
|
90
|
+
id: string;
|
|
91
|
+
header: string;
|
|
92
|
+
/** The row key the column reads, or a dotted path such as `owner.name`. */
|
|
93
|
+
accessor: string;
|
|
94
|
+
sortable?: boolean;
|
|
95
|
+
sizing?: {
|
|
96
|
+
size?: number;
|
|
97
|
+
minSize?: number;
|
|
98
|
+
maxSize?: number;
|
|
99
|
+
};
|
|
100
|
+
fixed?: {
|
|
101
|
+
position: "left" | "right";
|
|
102
|
+
priority?: number;
|
|
103
|
+
};
|
|
104
|
+
formatter?: DataTableFormatter;
|
|
105
|
+
}
|
|
106
|
+
/** A link cell: a route of the host, or an `href` outside it, which opens in a new tab. */
|
|
107
|
+
export type DataTableLink = {
|
|
108
|
+
text: string;
|
|
109
|
+
to: string;
|
|
110
|
+
params?: Record<string, string | number>;
|
|
111
|
+
} | {
|
|
112
|
+
text: string;
|
|
113
|
+
href: string;
|
|
114
|
+
};
|
|
115
|
+
/** An avatar cell: a name, or a name with its colour. */
|
|
116
|
+
export type DataTableAvatar = string | {
|
|
117
|
+
name: string;
|
|
118
|
+
color?: DataTableColor;
|
|
119
|
+
};
|
|
120
|
+
/** A row: primitives, `DataTableLink`s in link columns, `DataTableAvatar`s in avatar columns. */
|
|
121
|
+
export type DataTableRow = Record<string, unknown>;
|
|
122
|
+
export interface DataTableState {
|
|
123
|
+
sorting?: Array<{
|
|
124
|
+
id: string;
|
|
125
|
+
desc: boolean;
|
|
126
|
+
}>;
|
|
127
|
+
/** `pageIndex` from 0. */
|
|
128
|
+
pagination?: {
|
|
129
|
+
pageIndex: number;
|
|
130
|
+
pageSize: number;
|
|
131
|
+
};
|
|
132
|
+
}
|
|
133
|
+
export interface DataTablePagination {
|
|
134
|
+
/** With `serverSide`, the number of rows in all pages. */
|
|
135
|
+
totalCount?: number;
|
|
136
|
+
hasNextPage?: boolean;
|
|
137
|
+
pageSizeOptions?: number[];
|
|
138
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
package/dist/host.d.ts
ADDED
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import type { ComponentType } from "react";
|
|
2
|
+
export declare function registerTag(component: object, tag: string): void;
|
|
3
|
+
/** Called by the worker runtime with the elements the host announced on `init`. */
|
|
4
|
+
export declare function setHostElements(elements: unknown): void;
|
|
5
|
+
/**
|
|
6
|
+
* Whether this host draws `component`. A host older than the element fails the whole widget when a plugin renders
|
|
7
|
+
* it, so render a newer element only when this is true. False on hosts that don't announce their elements, which
|
|
8
|
+
* predate every element that needs the check.
|
|
9
|
+
*/
|
|
10
|
+
export declare function hostRenders(component: ComponentType<any>): boolean;
|
package/dist/host.js
ADDED
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
// The tag each catalog component renders, filled in by `component()`.
|
|
2
|
+
const TAGS = new WeakMap();
|
|
3
|
+
let hostElements = new Set();
|
|
4
|
+
export function registerTag(component, tag) {
|
|
5
|
+
TAGS.set(component, tag);
|
|
6
|
+
}
|
|
7
|
+
/** Called by the worker runtime with the elements the host announced on `init`. */
|
|
8
|
+
export function setHostElements(elements) {
|
|
9
|
+
hostElements = new Set(Array.isArray(elements) ? elements.filter((tag) => typeof tag === "string") : []);
|
|
10
|
+
}
|
|
11
|
+
/**
|
|
12
|
+
* Whether this host draws `component`. A host older than the element fails the whole widget when a plugin renders
|
|
13
|
+
* it, so render a newer element only when this is true. False on hosts that don't announce their elements, which
|
|
14
|
+
* predate every element that needs the check.
|
|
15
|
+
*/
|
|
16
|
+
export function hostRenders(component) {
|
|
17
|
+
const tag = TAGS.get(component);
|
|
18
|
+
return tag !== undefined && hostElements.has(tag);
|
|
19
|
+
}
|
package/dist/index.d.ts
CHANGED
|
@@ -4,5 +4,6 @@ export { usePluginContext, useNullplatform, useQuery, type WidgetProps, type Que
|
|
|
4
4
|
export { nullplatform, type NullplatformBridge } from './bridge.js';
|
|
5
5
|
export { useTopic, useSetTopic, type UseTopicOptions, type UseTopicResult, type UseSetTopicOptions, type SetTopicState, type TopicMap, type ServiceDraftV1, } from './topics.js';
|
|
6
6
|
export * from './components.js';
|
|
7
|
+
export { hostRenders } from './host.js';
|
|
7
8
|
export type { PluginContext, ApiRequest, HttpRequest, HttpResponse, NavigationTarget, SnackbarOptions, TopicSnapshot, TopicStatus } from './protocol.js';
|
|
8
9
|
export { BridgeError } from './protocol.js';
|
package/dist/index.js
CHANGED
|
@@ -4,4 +4,5 @@ export { usePluginContext, useNullplatform, useQuery } from './context.js';
|
|
|
4
4
|
export { nullplatform } from './bridge.js';
|
|
5
5
|
export { useTopic, useSetTopic, } from './topics.js';
|
|
6
6
|
export * from './components.js';
|
|
7
|
+
export { hostRenders } from './host.js';
|
|
7
8
|
export { BridgeError } from './protocol.js';
|
package/dist/protocol.d.ts
CHANGED
|
@@ -146,10 +146,13 @@ export type WorkerMessage = {
|
|
|
146
146
|
mountId?: string;
|
|
147
147
|
error: SerializedError;
|
|
148
148
|
};
|
|
149
|
-
export type HostMessage =
|
|
149
|
+
export type HostMessage =
|
|
150
|
+
/** `elements`: the catalog tags this host draws. Hosts before it fail a widget that renders a tag they lack. */
|
|
151
|
+
{
|
|
150
152
|
type: 'init';
|
|
151
153
|
pluginId: string;
|
|
152
154
|
context: PluginContext;
|
|
155
|
+
elements?: string[];
|
|
153
156
|
} | {
|
|
154
157
|
type: 'mount';
|
|
155
158
|
mountId: string;
|
|
@@ -204,8 +207,9 @@ export declare function serializeFunctions(value: unknown, nextId: () => string,
|
|
|
204
207
|
/** Deeply replaces function tokens with functions produced by `resolve`. */
|
|
205
208
|
export declare function deserializeFunctions(value: unknown, resolve: (id: string) => (...args: unknown[]) => unknown): unknown;
|
|
206
209
|
/**
|
|
207
|
-
* Makes a value safe to post:
|
|
208
|
-
*
|
|
210
|
+
* Makes a value safe to post: keeps plain data (arrays and plain objects), flattens dates, and drops functions,
|
|
211
|
+
* DOM nodes, cycles and class instances, such as the window or a React fiber. An event keeps only its type and
|
|
212
|
+
* detail. Used for what flows host → worker: event handler arguments and bridge call results.
|
|
209
213
|
*/
|
|
210
214
|
export declare function toCloneable(value: unknown, seen?: WeakSet<object>): unknown;
|
|
211
215
|
export declare function createIdGenerator(prefix: string): () => string;
|
package/dist/protocol.js
CHANGED
|
@@ -109,9 +109,20 @@ export function deserializeFunctions(value, resolve) {
|
|
|
109
109
|
}
|
|
110
110
|
return value;
|
|
111
111
|
}
|
|
112
|
+
/** An object literal, `JSON.parse` output or `Object.create(null)`, from any realm: not a class instance. */
|
|
113
|
+
function isPlainObject(value) {
|
|
114
|
+
const proto = Object.getPrototypeOf(value);
|
|
115
|
+
return proto === null || Object.getPrototypeOf(proto) === null;
|
|
116
|
+
}
|
|
117
|
+
/** A React synthetic event: its target fiber and `view` (the window) reach the whole page. */
|
|
118
|
+
function isReactEvent(value) {
|
|
119
|
+
const event = value;
|
|
120
|
+
return typeof event.nativeEvent === 'object' && typeof event.isPropagationStopped === 'function';
|
|
121
|
+
}
|
|
112
122
|
/**
|
|
113
|
-
* Makes a value safe to post:
|
|
114
|
-
*
|
|
123
|
+
* Makes a value safe to post: keeps plain data (arrays and plain objects), flattens dates, and drops functions,
|
|
124
|
+
* DOM nodes, cycles and class instances, such as the window or a React fiber. An event keeps only its type and
|
|
125
|
+
* detail. Used for what flows host → worker: event handler arguments and bridge call results.
|
|
115
126
|
*/
|
|
116
127
|
export function toCloneable(value, seen = new WeakSet()) {
|
|
117
128
|
if (value === null || value === undefined)
|
|
@@ -129,14 +140,14 @@ export function toCloneable(value, seen = new WeakSet()) {
|
|
|
129
140
|
}
|
|
130
141
|
if (typeof Node !== 'undefined' && value instanceof Node)
|
|
131
142
|
return undefined;
|
|
132
|
-
if (
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
143
|
+
if (isReactEvent(value))
|
|
144
|
+
return { type: String(value.type) };
|
|
145
|
+
if (seen.has(value))
|
|
146
|
+
return undefined;
|
|
147
|
+
seen.add(value);
|
|
137
148
|
if (Array.isArray(value))
|
|
138
149
|
return value.map((item) => toCloneable(item, seen));
|
|
139
|
-
if (
|
|
150
|
+
if (isPlainObject(value)) {
|
|
140
151
|
const out = {};
|
|
141
152
|
for (const [key, item] of Object.entries(value)) {
|
|
142
153
|
const cloned = toCloneable(item, seen);
|
package/dist/worker.js
CHANGED
|
@@ -9,6 +9,7 @@ import { BatchingRemoteConnection } from '@remote-dom/core/elements';
|
|
|
9
9
|
import { defineCatalogElements, ROOT_TAG } from './elements.js';
|
|
10
10
|
import { bridge } from './bridge.js';
|
|
11
11
|
import { PluginContextProvider, broadcastContext } from './context.js';
|
|
12
|
+
import { setHostElements } from './host.js';
|
|
12
13
|
import { receiveTopic } from './topics.js';
|
|
13
14
|
import { PROTOCOL_VERSION, createIdGenerator, serializeError, serializeFunctions, } from './protocol.js';
|
|
14
15
|
const nextFunctionId = createIdGenerator('fn');
|
|
@@ -86,6 +87,7 @@ function handle(port, message) {
|
|
|
86
87
|
switch (message.type) {
|
|
87
88
|
case 'init':
|
|
88
89
|
pluginId = message.pluginId;
|
|
90
|
+
setHostElements(message.elements);
|
|
89
91
|
broadcastContext(message.context);
|
|
90
92
|
break;
|
|
91
93
|
case 'mount':
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@nullplatform/ui-plugin-sdk",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.8.0",
|
|
4
4
|
"description": "SDK for nullplatform UI plugins: catalog components, bridge client and defineUI",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"main": "./dist/index.js",
|
|
@@ -36,7 +36,7 @@
|
|
|
36
36
|
"test": "vitest run --passWithNoTests",
|
|
37
37
|
"sync:contracts": "node scripts/sync-contracts.mjs"
|
|
38
38
|
},
|
|
39
|
-
"uiComponentsContracts": "0.15.
|
|
39
|
+
"uiComponentsContracts": "0.15.12",
|
|
40
40
|
"dependencies": {
|
|
41
41
|
"@remote-dom/core": "^1.11.1",
|
|
42
42
|
"@remote-dom/react": "^1.2.2",
|