@ekanos/harness 0.27.0 → 0.28.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 +6 -4
- package/dist/internal/components/approvals-tray.d.ts +44 -6
- package/dist/internal/components/approvals-tray.js +252 -30
- package/dist/internal/components/connect-controls.js +4 -2
- package/dist/internal/components/connect-dialog.d.ts +8 -1
- package/dist/internal/components/connect-dialog.js +23 -10
- package/dist/internal/components/connect-panel.d.ts +3 -2
- package/dist/internal/components/connect-panel.js +680 -340
- package/dist/internal/components/connect-steps.d.ts +72 -0
- package/dist/internal/components/connect-steps.js +341 -0
- package/dist/internal/components/console-not-found.d.ts +14 -0
- package/dist/internal/components/console-not-found.js +57 -0
- package/dist/internal/components/dashboard-grid.d.ts +10 -5
- package/dist/internal/components/dashboard-grid.js +8 -9
- package/dist/internal/components/dev-toolbar.d.ts +27 -5
- package/dist/internal/components/dev-toolbar.js +214 -176
- package/dist/internal/components/ekanos-logo.d.ts +18 -0
- package/dist/internal/components/ekanos-logo.js +74 -0
- package/dist/internal/components/events-panel.d.ts +13 -4
- package/dist/internal/components/events-panel.js +478 -81
- package/dist/internal/components/harness-widget-provider.d.ts +6 -8
- package/dist/internal/components/harness-widget-provider.js +5 -19
- package/dist/internal/components/health-panel.d.ts +8 -1
- package/dist/internal/components/health-panel.js +328 -31
- package/dist/internal/components/integration-badge.js +4 -2
- package/dist/internal/components/integration-tab-skeletons.d.ts +8 -0
- package/dist/internal/components/integration-tab-skeletons.js +76 -0
- package/dist/internal/components/not-found-state.d.ts +39 -0
- package/dist/internal/components/not-found-state.js +127 -0
- package/dist/internal/components/operation-runner-panel.d.ts +1 -1
- package/dist/internal/components/operation-runner-panel.js +624 -189
- package/dist/internal/components/operation-scope.d.ts +13 -0
- package/dist/internal/components/operation-scope.js +79 -0
- package/dist/internal/components/page-skeletons.d.ts +11 -0
- package/dist/internal/components/page-skeletons.js +61 -0
- package/dist/internal/components/provenance-banner.d.ts +13 -4
- package/dist/internal/components/provenance-banner.js +35 -10
- package/dist/internal/components/run-log-copy.d.ts +17 -0
- package/dist/internal/components/run-log-copy.js +67 -0
- package/dist/internal/components/run-log-detail.d.ts +22 -0
- package/dist/internal/components/run-log-detail.js +295 -0
- package/dist/internal/components/run-log-empty.d.ts +13 -0
- package/dist/internal/components/run-log-empty.js +46 -0
- package/dist/internal/components/run-log.d.ts +23 -3
- package/dist/internal/components/run-log.js +384 -130
- package/dist/internal/components/runtime-strip.d.ts +5 -1
- package/dist/internal/components/runtime-strip.js +82 -5
- package/dist/internal/components/schema-form.d.ts +2 -1
- package/dist/internal/components/schema-form.js +212 -79
- package/dist/internal/components/scrollable-nav.js +14 -2
- package/dist/internal/components/segmented-control.d.ts +19 -0
- package/dist/internal/components/segmented-control.js +46 -0
- package/dist/internal/components/shell-header.d.ts +25 -0
- package/dist/internal/components/shell-header.js +126 -0
- package/dist/internal/components/surface-nav.d.ts +12 -4
- package/dist/internal/components/surface-nav.js +77 -77
- package/dist/internal/components/widget-surface.d.ts +5 -1
- package/dist/internal/components/widget-surface.js +86 -14
- package/dist/internal/components/workflow-runner.d.ts +23 -10
- package/dist/internal/components/workflow-runner.js +451 -69
- package/dist/internal/lib/connect-model.d.ts +134 -0
- package/dist/internal/lib/connect-model.js +282 -0
- package/dist/internal/lib/connection-facts.js +2 -1
- package/dist/internal/lib/console-client.js +5 -2
- package/dist/internal/lib/console-hooks.d.ts +4 -1
- package/dist/internal/lib/console-hooks.js +3 -2
- package/dist/internal/lib/console-types.d.ts +6 -0
- package/dist/internal/lib/docs-links.d.ts +28 -0
- package/dist/internal/lib/docs-links.js +57 -1
- package/dist/internal/lib/event-delivery.d.ts +33 -0
- package/dist/internal/lib/event-delivery.js +66 -0
- package/dist/internal/lib/font-files/OFL-BricolageGrotesque.txt +93 -0
- package/dist/internal/lib/font-files/OFL-Figtree.txt +93 -0
- package/dist/internal/lib/font-files/bricolage-grotesque-latin-variable.woff2 +0 -0
- package/dist/internal/lib/font-files/figtree-latin-variable.woff2 +0 -0
- package/dist/internal/lib/fonts.js +13 -12
- package/dist/internal/lib/health-model.d.ts +58 -0
- package/dist/internal/lib/health-model.js +140 -0
- package/dist/internal/lib/integration-console-href.d.ts +5 -0
- package/dist/internal/lib/integration-console-href.js +7 -1
- package/dist/internal/lib/oauth-setup-guide.d.ts +28 -0
- package/dist/internal/lib/oauth-setup-guide.js +35 -1
- package/dist/internal/lib/operation-catalog.d.ts +70 -0
- package/dist/internal/lib/operation-catalog.js +261 -0
- package/dist/internal/lib/overview-model.d.ts +34 -0
- package/dist/internal/lib/overview-model.js +91 -0
- package/dist/internal/lib/registry-entry.d.ts +8 -0
- package/dist/internal/lib/registry-entry.js +11 -0
- package/dist/internal/lib/repo-name.d.ts +9 -0
- package/dist/internal/lib/repo-name.js +21 -0
- package/dist/internal/lib/run-log-view.d.ts +66 -1
- package/dist/internal/lib/run-log-view.js +183 -4
- package/dist/internal/lib/runner-view.d.ts +15 -0
- package/dist/internal/lib/runner-view.js +18 -0
- package/dist/internal/lib/schema-form-model.d.ts +17 -0
- package/dist/internal/lib/schema-form-model.js +50 -0
- package/dist/internal/lib/setup-checklist.d.ts +34 -0
- package/dist/internal/lib/setup-checklist.js +79 -0
- package/dist/internal/lib/toolbar-context.d.ts +0 -1
- package/dist/internal/lib/toolbar-context.js +0 -2
- package/dist/internal/lib/toolbar-visibility.d.ts +9 -2
- package/dist/internal/lib/toolbar-visibility.js +5 -0
- package/dist/internal/lib/use-operation-effects.d.ts +7 -0
- package/dist/internal/lib/use-operation-effects.js +28 -0
- package/dist/internal/lib/use-run-log-query.d.ts +9 -0
- package/dist/internal/lib/use-run-log-query.js +35 -0
- package/dist/internal/lib/widget-grid-gaps.d.ts +18 -0
- package/dist/internal/lib/widget-grid-gaps.js +41 -0
- package/dist/internal/lib/workflow-summary.d.ts +54 -0
- package/dist/internal/lib/workflow-summary.js +147 -0
- package/dist/internal/routes/console-home-page.js +2 -1
- package/dist/internal/routes/experience-connect-page.js +46 -17
- package/dist/internal/routes/experience-layout-page.js +75 -26
- package/dist/internal/routes/experience-page-host.js +63 -5
- package/dist/internal/routes/experience-review-queue-page.d.ts +4 -1
- package/dist/internal/routes/experience-review-queue-page.js +108 -12
- package/dist/internal/routes/experience-runs-page.js +57 -4
- package/dist/internal/routes/experience-summary-page.d.ts +19 -0
- package/dist/internal/routes/experience-summary-page.js +212 -52
- package/dist/internal/routes/experience-widget-page.js +58 -7
- package/dist/internal/routes/experience-widgets-page.d.ts +2 -3
- package/dist/internal/routes/experience-widgets-page.js +29 -4
- package/dist/internal/routes/experience-workflow-page.js +81 -9
- package/dist/internal/routes/experience-workflows-page.js +85 -21
- package/dist/internal/routes/integration-layout.js +28 -3
- package/dist/internal/routes/integrations-connect-page.js +16 -6
- package/dist/internal/routes/integrations-events-page.js +22 -1
- package/dist/internal/routes/integrations-health-page.js +16 -1
- package/dist/internal/routes/integrations-layout.js +28 -4
- package/dist/internal/routes/integrations-list-page.d.ts +0 -1
- package/dist/internal/routes/integrations-list-page.js +11 -9
- package/dist/internal/routes/integrations-operation-page.js +53 -17
- package/dist/internal/routes/integrations-operations-page.js +539 -49
- package/dist/internal/routes/integrations-overview-page.js +332 -69
- package/dist/internal/routes/integrations-runs-page.js +53 -3
- package/dist/internal/routes/integrations-scope.d.ts +15 -2
- package/dist/internal/routes/integrations-scope.js +66 -18
- package/dist/internal/routes/preview-index-page.js +2 -2
- package/dist/internal/routes/repo-home-page.d.ts +2 -2
- package/dist/internal/routes/repo-home-page.js +428 -236
- package/dist/internal/routes/repo-layout.d.ts +12 -0
- package/dist/internal/routes/repo-layout.js +50 -38
- package/dist/internal/routes/repo-package-layouts.js +22 -8
- package/dist/internal/routes/single-widget-page.d.ts +1 -1
- package/dist/internal/routes/single-widget-page.js +28 -5
- package/dist/internal/routes/tile-page.d.ts +1 -1
- package/dist/internal/routes/tile-page.js +1 -2
- package/dist/internal/routes/widgets-page.d.ts +1 -1
- package/dist/internal/routes/widgets-page.js +5 -3
- package/dist/registry.d.ts +4 -5
- package/dist/registry.js +0 -1
- package/dist/routes.d.ts +5 -0
- package/dist/routes.js +2 -0
- package/package.json +8 -8
|
@@ -3,7 +3,10 @@ import { Fragment, jsx, jsxs } from "react/jsx-runtime";
|
|
|
3
3
|
import Link from "next/link";
|
|
4
4
|
import { usePathname } from "next/navigation";
|
|
5
5
|
import { Button } from "@ekanos/ui/button";
|
|
6
|
+
import { Card } from "@ekanos/ui/card";
|
|
6
7
|
import { ConfirmDialog } from "@ekanos/ui/confirm-dialog";
|
|
8
|
+
import { Icon } from "@ekanos/ui/icon";
|
|
9
|
+
import { StatusBadge } from "@ekanos/ui/status-badge";
|
|
7
10
|
import { cn } from "@ekanos/ui/utils";
|
|
8
11
|
import { answerLabel } from "../lib/connection-facts.js";
|
|
9
12
|
import { useConsoleClient } from "../lib/console-context.js";
|
|
@@ -48,7 +51,76 @@ function IntegrationName({
|
|
|
48
51
|
function onConnectTab(pathname) {
|
|
49
52
|
return Boolean(pathname && /\/connect\/?$/.test(pathname));
|
|
50
53
|
}
|
|
51
|
-
function RuntimeStrip(
|
|
54
|
+
function RuntimeStrip({
|
|
55
|
+
variant = "full",
|
|
56
|
+
manageHref
|
|
57
|
+
} = {}) {
|
|
58
|
+
const project = useProject();
|
|
59
|
+
const pathname = usePathname();
|
|
60
|
+
if (variant === "compact") {
|
|
61
|
+
const rows = (project.data?.integrations ?? []).filter(
|
|
62
|
+
(integration) => integration.runtime !== void 0
|
|
63
|
+
);
|
|
64
|
+
if (rows.length === 0 || onConnectTab(pathname)) return null;
|
|
65
|
+
return /* @__PURE__ */ jsx(CompactStrip, { rows, manageHref });
|
|
66
|
+
}
|
|
67
|
+
return /* @__PURE__ */ jsx(FullStrip, {});
|
|
68
|
+
}
|
|
69
|
+
function CompactStrip({
|
|
70
|
+
rows,
|
|
71
|
+
manageHref
|
|
72
|
+
}) {
|
|
73
|
+
const anyFixtures = rows.some((row) => row.runtime?.facts.answers !== "live");
|
|
74
|
+
return /* @__PURE__ */ jsxs(
|
|
75
|
+
"div",
|
|
76
|
+
{
|
|
77
|
+
className: "text-muted-foreground flex flex-wrap items-center gap-x-3 gap-y-2 text-sm",
|
|
78
|
+
"data-test": "runtime-strip-compact",
|
|
79
|
+
children: [
|
|
80
|
+
/* @__PURE__ */ jsxs("span", { className: "flex items-center gap-1.5", children: [
|
|
81
|
+
/* @__PURE__ */ jsx(Icon, { name: "database", className: "h-4 w-4" }),
|
|
82
|
+
"Answers from"
|
|
83
|
+
] }),
|
|
84
|
+
/* @__PURE__ */ jsx("ul", { className: "flex flex-wrap items-center gap-x-3 gap-y-1", children: rows.map((row) => {
|
|
85
|
+
const facts = row.runtime?.facts;
|
|
86
|
+
if (!facts) return null;
|
|
87
|
+
return /* @__PURE__ */ jsxs(
|
|
88
|
+
"li",
|
|
89
|
+
{
|
|
90
|
+
className: "flex items-center gap-1.5",
|
|
91
|
+
"data-test": `runtime-compact-${row.integration}`,
|
|
92
|
+
children: [
|
|
93
|
+
/* @__PURE__ */ jsx("span", { className: "text-foreground font-mono text-xs", children: row.integration.slice(row.integration.lastIndexOf("/") + 1) }),
|
|
94
|
+
/* @__PURE__ */ jsx(
|
|
95
|
+
StatusBadge,
|
|
96
|
+
{
|
|
97
|
+
tone: facts.answers === "live" ? "success" : "neutral",
|
|
98
|
+
"data-answer": facts.answers,
|
|
99
|
+
children: answerLabel(facts)
|
|
100
|
+
}
|
|
101
|
+
)
|
|
102
|
+
]
|
|
103
|
+
},
|
|
104
|
+
row.integration
|
|
105
|
+
);
|
|
106
|
+
}) }),
|
|
107
|
+
manageHref ? /* @__PURE__ */ jsx(
|
|
108
|
+
Link,
|
|
109
|
+
{
|
|
110
|
+
href: manageHref,
|
|
111
|
+
className: cn(
|
|
112
|
+
"text-foreground rounded-sm font-medium underline underline-offset-2",
|
|
113
|
+
FOCUS_RING
|
|
114
|
+
),
|
|
115
|
+
"data-test": "runtime-strip-manage",
|
|
116
|
+
children: anyFixtures ? "Connect to run live" : "Manage"
|
|
117
|
+
}
|
|
118
|
+
) : null
|
|
119
|
+
]
|
|
120
|
+
}
|
|
121
|
+
);
|
|
122
|
+
}
|
|
123
|
+
function FullStrip() {
|
|
52
124
|
const project = useProject();
|
|
53
125
|
const client = useConsoleClient();
|
|
54
126
|
const refresh = useRefreshRuntime();
|
|
@@ -175,10 +247,15 @@ function RuntimeStrip() {
|
|
|
175
247
|
}
|
|
176
248
|
);
|
|
177
249
|
}
|
|
178
|
-
return /* @__PURE__ */
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
250
|
+
return /* @__PURE__ */ jsx(
|
|
251
|
+
Card,
|
|
252
|
+
{
|
|
253
|
+
layout: "bleed",
|
|
254
|
+
render: /* @__PURE__ */ jsx("section", { "aria-label": "Integrations" }),
|
|
255
|
+
className: "flex flex-col gap-2 px-4 py-3",
|
|
256
|
+
children: list
|
|
257
|
+
}
|
|
258
|
+
);
|
|
182
259
|
}
|
|
183
260
|
export {
|
|
184
261
|
RuntimeStrip,
|
|
@@ -3,7 +3,8 @@ import type { JsonSchema, ValidationIssue } from '../lib/console-types.js';
|
|
|
3
3
|
* A controlled form generated from a JSON Schema. Supports object, array,
|
|
4
4
|
* enum, string (with `format`), number, integer, boolean and nullable
|
|
5
5
|
* variants; any node using a keyword outside that set is edited as JSON in
|
|
6
|
-
* place, with its parse error shown inline.
|
|
6
|
+
* place, with its parse error shown inline. Required inputs come first; more
|
|
7
|
+
* than a handful of optional ones fold under "Optional inputs".
|
|
7
8
|
*/
|
|
8
9
|
export declare function SchemaForm({ schema, value, onChange, issues, }: {
|
|
9
10
|
schema: JsonSchema;
|
|
@@ -2,18 +2,23 @@
|
|
|
2
2
|
import { jsx, jsxs } from "react/jsx-runtime";
|
|
3
3
|
import { useState } from "react";
|
|
4
4
|
import { Button } from "@ekanos/ui/button";
|
|
5
|
+
import { Icon } from "@ekanos/ui/icon";
|
|
5
6
|
import { Input } from "@ekanos/ui/input";
|
|
6
7
|
import { Label } from "@ekanos/ui/label";
|
|
7
8
|
import { Switch } from "@ekanos/ui/switch";
|
|
8
9
|
import { Textarea } from "@ekanos/ui/textarea";
|
|
9
10
|
import { cn } from "@ekanos/ui/utils";
|
|
10
11
|
import {
|
|
12
|
+
OPTIONAL_FOLD_AFTER,
|
|
11
13
|
classify,
|
|
12
14
|
formatJson,
|
|
15
|
+
hasValue,
|
|
13
16
|
initialValue,
|
|
14
17
|
issuesByPath,
|
|
15
|
-
|
|
16
|
-
|
|
18
|
+
orderedProperties,
|
|
19
|
+
takesNoInput,
|
|
20
|
+
parseJsonText,
|
|
21
|
+
typeLabel
|
|
17
22
|
} from "../lib/schema-form-model.js";
|
|
18
23
|
const NATIVE_SELECT = "border-input bg-background text-foreground text-sm h-control w-full rounded-md border px-3 focus-visible:border-ring focus-visible:outline-ring aria-invalid:border-destructive focus-visible:outline-2";
|
|
19
24
|
function fieldId(path) {
|
|
@@ -27,20 +32,34 @@ function FieldShell({
|
|
|
27
32
|
label,
|
|
28
33
|
required,
|
|
29
34
|
schema,
|
|
35
|
+
type,
|
|
30
36
|
error,
|
|
37
|
+
bare = false,
|
|
31
38
|
children
|
|
32
39
|
}) {
|
|
33
40
|
const help = describe(schema);
|
|
34
41
|
return /* @__PURE__ */ jsxs("div", { className: "flex flex-col gap-1.5", "data-test": `field-${fieldId(path)}`, children: [
|
|
35
|
-
path === "" ? null : /* @__PURE__ */
|
|
36
|
-
label,
|
|
37
|
-
|
|
38
|
-
"
|
|
39
|
-
|
|
40
|
-
|
|
42
|
+
path === "" ? null : bare ? /* @__PURE__ */ jsx(Label, { htmlFor: fieldId(path), className: "sr-only", children: label }) : /* @__PURE__ */ jsxs("div", { className: "flex flex-wrap items-baseline gap-x-2 gap-y-0.5", children: [
|
|
43
|
+
/* @__PURE__ */ jsx(Label, { htmlFor: fieldId(path), className: "font-mono text-sm", children: label }),
|
|
44
|
+
type ? /* @__PURE__ */ jsx(
|
|
45
|
+
"span",
|
|
46
|
+
{
|
|
47
|
+
className: "text-muted-foreground font-mono text-xs",
|
|
48
|
+
"data-test": `type-${fieldId(path)}`,
|
|
49
|
+
children: type
|
|
50
|
+
}
|
|
51
|
+
) : null,
|
|
52
|
+
required ? /* @__PURE__ */ jsx(
|
|
53
|
+
"span",
|
|
54
|
+
{
|
|
55
|
+
className: "text-foreground text-xs font-medium",
|
|
56
|
+
"data-test": `required-${fieldId(path)}`,
|
|
57
|
+
children: "Required"
|
|
58
|
+
}
|
|
59
|
+
) : null
|
|
41
60
|
] }),
|
|
42
61
|
children,
|
|
43
|
-
help ? /* @__PURE__ */ jsx("p", { className: "text-muted-foreground text-xs", children: help }) : null,
|
|
62
|
+
help && !bare ? /* @__PURE__ */ jsx("p", { className: "text-muted-foreground text-xs", children: help }) : null,
|
|
44
63
|
error ? /* @__PURE__ */ jsx(
|
|
45
64
|
"p",
|
|
46
65
|
{
|
|
@@ -74,6 +93,7 @@ function JsonField({
|
|
|
74
93
|
label,
|
|
75
94
|
required,
|
|
76
95
|
schema,
|
|
96
|
+
type: "json",
|
|
77
97
|
error: shown,
|
|
78
98
|
children: [
|
|
79
99
|
note ? /* @__PURE__ */ jsx("p", { className: "text-muted-foreground text-xs", children: note }) : null,
|
|
@@ -111,6 +131,20 @@ function inputTypeFor(schema) {
|
|
|
111
131
|
return "text";
|
|
112
132
|
}
|
|
113
133
|
}
|
|
134
|
+
const PLACEHOLDERS = {
|
|
135
|
+
"date-time": "2026-01-31T09:00:00Z",
|
|
136
|
+
uuid: "00000000-0000-0000-0000-000000000000",
|
|
137
|
+
email: "name@example.com",
|
|
138
|
+
uri: "https://",
|
|
139
|
+
url: "https://"
|
|
140
|
+
};
|
|
141
|
+
const INLINE_ITEMS = /* @__PURE__ */ new Set([
|
|
142
|
+
"string",
|
|
143
|
+
"number",
|
|
144
|
+
"integer",
|
|
145
|
+
"enum",
|
|
146
|
+
"boolean"
|
|
147
|
+
]);
|
|
114
148
|
function Field({
|
|
115
149
|
path,
|
|
116
150
|
label,
|
|
@@ -118,7 +152,8 @@ function Field({
|
|
|
118
152
|
schema: input,
|
|
119
153
|
value,
|
|
120
154
|
onChange,
|
|
121
|
-
errors
|
|
155
|
+
errors,
|
|
156
|
+
bare = false
|
|
122
157
|
}) {
|
|
123
158
|
const { kind, nullable, schema } = classify(input);
|
|
124
159
|
const error = errors.get(path);
|
|
@@ -130,7 +165,9 @@ function Field({
|
|
|
130
165
|
label,
|
|
131
166
|
required,
|
|
132
167
|
schema,
|
|
168
|
+
type: typeLabel(input),
|
|
133
169
|
error,
|
|
170
|
+
bare,
|
|
134
171
|
children: [
|
|
135
172
|
nullable ? /* @__PURE__ */ jsxs("label", { className: "text-muted-foreground flex items-center gap-2 text-xs", children: [
|
|
136
173
|
/* @__PURE__ */ jsx(
|
|
@@ -165,6 +202,7 @@ function Field({
|
|
|
165
202
|
);
|
|
166
203
|
case "string": {
|
|
167
204
|
const long = typeof schema.maxLength === "number" && schema.maxLength > 200;
|
|
205
|
+
const write = (text) => onChange(text === "" && !required ? void 0 : text);
|
|
168
206
|
return shell(
|
|
169
207
|
long ? /* @__PURE__ */ jsx(
|
|
170
208
|
Textarea,
|
|
@@ -172,7 +210,7 @@ function Field({
|
|
|
172
210
|
id: fieldId(path),
|
|
173
211
|
value: typeof value === "string" ? value : "",
|
|
174
212
|
"aria-invalid": error ? true : void 0,
|
|
175
|
-
onChange: (event) =>
|
|
213
|
+
onChange: (event) => write(event.target.value)
|
|
176
214
|
}
|
|
177
215
|
) : /* @__PURE__ */ jsx(
|
|
178
216
|
Input,
|
|
@@ -180,9 +218,9 @@ function Field({
|
|
|
180
218
|
id: fieldId(path),
|
|
181
219
|
type: inputTypeFor(schema),
|
|
182
220
|
value: typeof value === "string" ? value : "",
|
|
183
|
-
placeholder: typeof schema.format === "string" ? schema.format : void 0,
|
|
221
|
+
placeholder: typeof schema.format === "string" ? PLACEHOLDERS[schema.format] ?? schema.format : void 0,
|
|
184
222
|
"aria-invalid": error ? true : void 0,
|
|
185
|
-
onChange: (event) =>
|
|
223
|
+
onChange: (event) => write(event.target.value)
|
|
186
224
|
}
|
|
187
225
|
)
|
|
188
226
|
);
|
|
@@ -195,7 +233,10 @@ function Field({
|
|
|
195
233
|
{
|
|
196
234
|
id: fieldId(path),
|
|
197
235
|
type: "number",
|
|
236
|
+
inputMode: kind === "integer" ? "numeric" : "decimal",
|
|
198
237
|
step: kind === "integer" ? 1 : "any",
|
|
238
|
+
min: typeof schema.minimum === "number" ? schema.minimum : void 0,
|
|
239
|
+
max: typeof schema.maximum === "number" ? schema.maximum : void 0,
|
|
199
240
|
value: typeof value === "number" ? value : "",
|
|
200
241
|
"aria-invalid": error ? true : void 0,
|
|
201
242
|
onChange: (event) => onChange(
|
|
@@ -206,14 +247,17 @@ function Field({
|
|
|
206
247
|
);
|
|
207
248
|
case "boolean":
|
|
208
249
|
return shell(
|
|
209
|
-
/* @__PURE__ */
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
|
|
250
|
+
/* @__PURE__ */ jsxs("div", { className: "flex items-center gap-2", children: [
|
|
251
|
+
/* @__PURE__ */ jsx(
|
|
252
|
+
Switch,
|
|
253
|
+
{
|
|
254
|
+
id: fieldId(path),
|
|
255
|
+
checked: value === true,
|
|
256
|
+
onCheckedChange: (checked) => onChange(checked)
|
|
257
|
+
}
|
|
258
|
+
),
|
|
259
|
+
/* @__PURE__ */ jsx("span", { className: "text-muted-foreground font-mono text-xs", children: value === void 0 ? "unset" : String(value === true) })
|
|
260
|
+
] })
|
|
217
261
|
);
|
|
218
262
|
case "enum": {
|
|
219
263
|
const options = Array.isArray(schema.enum) ? schema.enum : [];
|
|
@@ -237,62 +281,73 @@ function Field({
|
|
|
237
281
|
case "array": {
|
|
238
282
|
const items = Array.isArray(value) ? value : [];
|
|
239
283
|
const itemSchema = schema.items ?? {};
|
|
284
|
+
const inline = INLINE_ITEMS.has(classify(itemSchema).kind);
|
|
285
|
+
const write = (next) => onChange(next.length === 0 && !required ? void 0 : next);
|
|
240
286
|
return shell(
|
|
241
287
|
/* @__PURE__ */ jsxs(
|
|
242
288
|
"div",
|
|
243
289
|
{
|
|
244
|
-
className: "flex flex-col gap-
|
|
290
|
+
className: "flex flex-col gap-2",
|
|
245
291
|
"data-test": `array-${fieldId(path)}`,
|
|
246
292
|
children: [
|
|
247
|
-
items.map((item, index) =>
|
|
248
|
-
|
|
249
|
-
|
|
293
|
+
items.map((item, index) => {
|
|
294
|
+
const remove = /* @__PURE__ */ jsxs(
|
|
295
|
+
Button,
|
|
296
|
+
{
|
|
297
|
+
type: "button",
|
|
298
|
+
variant: "ghost",
|
|
299
|
+
size: inline ? "icon" : "sm",
|
|
300
|
+
className: inline ? "shrink-0" : "self-start",
|
|
301
|
+
"aria-label": `Remove ${label} item ${index + 1}`,
|
|
302
|
+
"data-test": `remove-${fieldId(`${path}/${index}`)}`,
|
|
303
|
+
onClick: () => write(items.filter((_, i) => i !== index)),
|
|
304
|
+
children: [
|
|
305
|
+
/* @__PURE__ */ jsx(Icon, { name: "x", "aria-hidden": true, className: "size-4" }),
|
|
306
|
+
inline ? null : `Remove item ${index + 1}`
|
|
307
|
+
]
|
|
308
|
+
}
|
|
309
|
+
);
|
|
310
|
+
const field = /* @__PURE__ */ jsx(
|
|
311
|
+
Field,
|
|
312
|
+
{
|
|
313
|
+
path: `${path}/${index}`,
|
|
314
|
+
label: `${label} item ${index + 1}`,
|
|
315
|
+
required: true,
|
|
316
|
+
schema: itemSchema,
|
|
317
|
+
value: item,
|
|
318
|
+
onChange: (next) => write(items.map((entry, i) => i === index ? next : entry)),
|
|
319
|
+
errors,
|
|
320
|
+
bare: inline
|
|
321
|
+
}
|
|
322
|
+
);
|
|
323
|
+
return inline ? /* @__PURE__ */ jsxs("div", { className: "flex items-start gap-1", children: [
|
|
324
|
+
/* @__PURE__ */ jsx("div", { className: "min-w-0 flex-1", children: field }),
|
|
325
|
+
remove
|
|
326
|
+
] }, index) : /* @__PURE__ */ jsxs(
|
|
250
327
|
"div",
|
|
251
328
|
{
|
|
252
|
-
className: "bg-
|
|
329
|
+
className: "bg-muted flex flex-col gap-2 rounded-md border p-3",
|
|
253
330
|
children: [
|
|
254
|
-
|
|
255
|
-
|
|
256
|
-
{
|
|
257
|
-
path: `${path}/${index}`,
|
|
258
|
-
label: `Item ${index + 1}`,
|
|
259
|
-
required: true,
|
|
260
|
-
schema: itemSchema,
|
|
261
|
-
value: item,
|
|
262
|
-
onChange: (next) => onChange(
|
|
263
|
-
items.map((entry, i) => i === index ? next : entry)
|
|
264
|
-
),
|
|
265
|
-
errors
|
|
266
|
-
}
|
|
267
|
-
),
|
|
268
|
-
/* @__PURE__ */ jsxs(
|
|
269
|
-
Button,
|
|
270
|
-
{
|
|
271
|
-
type: "button",
|
|
272
|
-
variant: "ghost",
|
|
273
|
-
size: "sm",
|
|
274
|
-
className: "self-start",
|
|
275
|
-
onClick: () => onChange(items.filter((_, i) => i !== index)),
|
|
276
|
-
children: [
|
|
277
|
-
"Remove item ",
|
|
278
|
-
index + 1
|
|
279
|
-
]
|
|
280
|
-
}
|
|
281
|
-
)
|
|
331
|
+
field,
|
|
332
|
+
remove
|
|
282
333
|
]
|
|
283
334
|
},
|
|
284
335
|
index
|
|
285
|
-
)
|
|
286
|
-
)
|
|
287
|
-
/* @__PURE__ */
|
|
336
|
+
);
|
|
337
|
+
}),
|
|
338
|
+
/* @__PURE__ */ jsxs(
|
|
288
339
|
Button,
|
|
289
340
|
{
|
|
290
341
|
type: "button",
|
|
291
342
|
variant: "outline",
|
|
292
343
|
size: "sm",
|
|
293
344
|
className: "self-start",
|
|
294
|
-
|
|
295
|
-
|
|
345
|
+
"data-test": `add-${fieldId(path)}`,
|
|
346
|
+
onClick: () => write([...items, initialValue(itemSchema)]),
|
|
347
|
+
children: [
|
|
348
|
+
/* @__PURE__ */ jsx(Icon, { name: "plus", "aria-hidden": true, className: "size-4" }),
|
|
349
|
+
"Add item"
|
|
350
|
+
]
|
|
296
351
|
}
|
|
297
352
|
)
|
|
298
353
|
]
|
|
@@ -302,38 +357,116 @@ function Field({
|
|
|
302
357
|
}
|
|
303
358
|
case "object": {
|
|
304
359
|
const record = typeof value === "object" && value !== null && !Array.isArray(value) ? value : {};
|
|
360
|
+
const { required: needed, optional } = orderedProperties(schema);
|
|
361
|
+
const fieldFor = (property) => /* @__PURE__ */ jsx(
|
|
362
|
+
Field,
|
|
363
|
+
{
|
|
364
|
+
path: `${path}/${property.key}`,
|
|
365
|
+
label: property.key,
|
|
366
|
+
required: property.required,
|
|
367
|
+
schema: property.schema,
|
|
368
|
+
value: record[property.key],
|
|
369
|
+
onChange: (next) => {
|
|
370
|
+
const { [property.key]: _previous, ...rest } = record;
|
|
371
|
+
onChange(
|
|
372
|
+
next === void 0 ? rest : { ...rest, [property.key]: next }
|
|
373
|
+
);
|
|
374
|
+
},
|
|
375
|
+
errors
|
|
376
|
+
},
|
|
377
|
+
property.key
|
|
378
|
+
);
|
|
379
|
+
const fold = path === "" && optional.length > OPTIONAL_FOLD_AFTER;
|
|
305
380
|
return shell(
|
|
306
|
-
/* @__PURE__ */
|
|
381
|
+
/* @__PURE__ */ jsxs(
|
|
307
382
|
"div",
|
|
308
383
|
{
|
|
309
384
|
className: cn(
|
|
310
385
|
"flex flex-col gap-4",
|
|
311
386
|
path !== "" && "border-l-2 pl-4"
|
|
312
387
|
),
|
|
313
|
-
children:
|
|
314
|
-
|
|
315
|
-
|
|
316
|
-
|
|
317
|
-
|
|
318
|
-
|
|
319
|
-
|
|
320
|
-
|
|
321
|
-
|
|
322
|
-
|
|
323
|
-
|
|
324
|
-
|
|
325
|
-
)
|
|
326
|
-
}
|
|
327
|
-
|
|
328
|
-
|
|
329
|
-
property.key
|
|
330
|
-
))
|
|
388
|
+
children: [
|
|
389
|
+
needed.map(fieldFor),
|
|
390
|
+
fold ? /* @__PURE__ */ jsx(
|
|
391
|
+
OptionalFold,
|
|
392
|
+
{
|
|
393
|
+
count: optional.length,
|
|
394
|
+
needed: needed.length,
|
|
395
|
+
autoOpen: optional.some(
|
|
396
|
+
(property) => hasValue(record[property.key]) || [...errors.keys()].some(
|
|
397
|
+
(at) => at.startsWith(`/${property.key}`)
|
|
398
|
+
)
|
|
399
|
+
),
|
|
400
|
+
children: optional.map(fieldFor)
|
|
401
|
+
}
|
|
402
|
+
) : optional.map(fieldFor)
|
|
403
|
+
]
|
|
331
404
|
}
|
|
332
405
|
)
|
|
333
406
|
);
|
|
334
407
|
}
|
|
335
408
|
}
|
|
336
409
|
}
|
|
410
|
+
function OptionalFold({
|
|
411
|
+
count,
|
|
412
|
+
needed,
|
|
413
|
+
autoOpen,
|
|
414
|
+
children
|
|
415
|
+
}) {
|
|
416
|
+
const [choice, setChoice] = useState(null);
|
|
417
|
+
const open = choice ?? autoOpen;
|
|
418
|
+
return /* @__PURE__ */ jsxs(
|
|
419
|
+
"div",
|
|
420
|
+
{
|
|
421
|
+
className: cn("flex flex-col gap-4", needed > 0 && "border-t pt-4"),
|
|
422
|
+
"data-test": "optional-inputs",
|
|
423
|
+
"data-open": open,
|
|
424
|
+
children: [
|
|
425
|
+
needed === 0 ? /* @__PURE__ */ jsx(
|
|
426
|
+
"p",
|
|
427
|
+
{
|
|
428
|
+
className: "text-muted-foreground text-sm",
|
|
429
|
+
"data-test": "optional-only-hint",
|
|
430
|
+
children: "Nothing is required. Run it as is, or set optional inputs to shape the call."
|
|
431
|
+
}
|
|
432
|
+
) : null,
|
|
433
|
+
/* @__PURE__ */ jsxs(
|
|
434
|
+
Button,
|
|
435
|
+
{
|
|
436
|
+
variant: "ghost",
|
|
437
|
+
size: "sm",
|
|
438
|
+
type: "button",
|
|
439
|
+
"aria-expanded": open,
|
|
440
|
+
"aria-controls": "sf-optional",
|
|
441
|
+
"data-test": "optional-inputs-toggle",
|
|
442
|
+
onClick: () => setChoice(!open),
|
|
443
|
+
className: "-ml-2 w-fit",
|
|
444
|
+
children: [
|
|
445
|
+
/* @__PURE__ */ jsx(
|
|
446
|
+
Icon,
|
|
447
|
+
{
|
|
448
|
+
name: "caret-right",
|
|
449
|
+
"aria-hidden": true,
|
|
450
|
+
className: cn(
|
|
451
|
+
"text-muted-foreground size-4 transition-transform duration-(--duration-enter) motion-reduce:transition-none",
|
|
452
|
+
open && "rotate-90"
|
|
453
|
+
)
|
|
454
|
+
}
|
|
455
|
+
),
|
|
456
|
+
"Optional inputs",
|
|
457
|
+
/* @__PURE__ */ jsxs("span", { className: "text-muted-foreground tabular-nums", children: [
|
|
458
|
+
"(",
|
|
459
|
+
count,
|
|
460
|
+
")"
|
|
461
|
+
] })
|
|
462
|
+
]
|
|
463
|
+
}
|
|
464
|
+
),
|
|
465
|
+
/* @__PURE__ */ jsx("div", { id: "sf-optional", hidden: !open, className: "flex flex-col gap-4", children })
|
|
466
|
+
]
|
|
467
|
+
}
|
|
468
|
+
);
|
|
469
|
+
}
|
|
337
470
|
function SchemaForm({
|
|
338
471
|
schema,
|
|
339
472
|
value,
|
|
@@ -342,7 +475,7 @@ function SchemaForm({
|
|
|
342
475
|
}) {
|
|
343
476
|
const errors = issuesByPath(issues);
|
|
344
477
|
const { kind } = classify(schema);
|
|
345
|
-
if (
|
|
478
|
+
if (takesNoInput(schema)) {
|
|
346
479
|
return /* @__PURE__ */ jsx(
|
|
347
480
|
"p",
|
|
348
481
|
{
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
"use client";
|
|
2
2
|
import { jsx, jsxs } from "react/jsx-runtime";
|
|
3
|
-
import { useState } from "react";
|
|
3
|
+
import { useRef, useState } from "react";
|
|
4
4
|
import { cn } from "@ekanos/ui/utils";
|
|
5
5
|
function ScrollableNav({
|
|
6
6
|
label,
|
|
@@ -8,6 +8,7 @@ function ScrollableNav({
|
|
|
8
8
|
children
|
|
9
9
|
}) {
|
|
10
10
|
const [edges, setEdges] = useState({ start: false, end: false });
|
|
11
|
+
const centeredOn = useRef(null);
|
|
11
12
|
const measure = (element) => {
|
|
12
13
|
if (!element) return;
|
|
13
14
|
const start = element.scrollLeft > 1;
|
|
@@ -25,7 +26,18 @@ function ScrollableNav({
|
|
|
25
26
|
/* @__PURE__ */ jsx(
|
|
26
27
|
"nav",
|
|
27
28
|
{
|
|
28
|
-
ref:
|
|
29
|
+
ref: (element) => {
|
|
30
|
+
if (!element) return;
|
|
31
|
+
const current = element.querySelector(
|
|
32
|
+
'[aria-current="page"]'
|
|
33
|
+
);
|
|
34
|
+
const key = current?.getAttribute("href") ?? null;
|
|
35
|
+
if (current && key !== centeredOn.current && current.offsetLeft + current.offsetWidth > element.scrollLeft + element.clientWidth) {
|
|
36
|
+
centeredOn.current = key;
|
|
37
|
+
element.scrollLeft = current.offsetLeft - (element.clientWidth - current.offsetWidth) / 2;
|
|
38
|
+
}
|
|
39
|
+
measure(element);
|
|
40
|
+
},
|
|
29
41
|
"aria-label": label,
|
|
30
42
|
onScroll: (event) => measure(event.currentTarget),
|
|
31
43
|
className: cn(
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
import type { ReactNode } from 'react';
|
|
2
|
+
export interface SegmentOption<T extends string> {
|
|
3
|
+
value: T;
|
|
4
|
+
label: ReactNode;
|
|
5
|
+
/** Why the option cannot be chosen; the option renders disabled. */
|
|
6
|
+
disabledReason?: string | null;
|
|
7
|
+
}
|
|
8
|
+
/**
|
|
9
|
+
* A row of mutually exclusive toggle buttons. Each option carries
|
|
10
|
+
* `data-test="<testPrefix>-<value>"` and `aria-pressed`.
|
|
11
|
+
*/
|
|
12
|
+
export declare function SegmentedControl<T extends string>({ label, testPrefix, options, value, onChange, className, }: {
|
|
13
|
+
label: string;
|
|
14
|
+
testPrefix: string;
|
|
15
|
+
options: readonly SegmentOption<T>[];
|
|
16
|
+
value: T;
|
|
17
|
+
onChange: (value: T) => void;
|
|
18
|
+
className?: string;
|
|
19
|
+
}): import("react").JSX.Element;
|
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
import { jsx } from "react/jsx-runtime";
|
|
3
|
+
import { Button } from "@ekanos/ui/button";
|
|
4
|
+
import { cn } from "@ekanos/ui/utils";
|
|
5
|
+
function SegmentedControl({
|
|
6
|
+
label,
|
|
7
|
+
testPrefix,
|
|
8
|
+
options,
|
|
9
|
+
value,
|
|
10
|
+
onChange,
|
|
11
|
+
className
|
|
12
|
+
}) {
|
|
13
|
+
return /* @__PURE__ */ jsx(
|
|
14
|
+
"div",
|
|
15
|
+
{
|
|
16
|
+
role: "group",
|
|
17
|
+
"aria-label": label,
|
|
18
|
+
className: cn(
|
|
19
|
+
"bg-secondary inline-flex shrink-0 gap-0.5 rounded-md p-0.5",
|
|
20
|
+
className
|
|
21
|
+
),
|
|
22
|
+
children: options.map((option) => {
|
|
23
|
+
const active = option.value === value;
|
|
24
|
+
const reason = option.disabledReason ?? null;
|
|
25
|
+
return /* @__PURE__ */ jsx(
|
|
26
|
+
Button,
|
|
27
|
+
{
|
|
28
|
+
type: "button",
|
|
29
|
+
size: "sm",
|
|
30
|
+
variant: active ? "outline" : "ghost",
|
|
31
|
+
disabled: reason !== null,
|
|
32
|
+
title: reason ?? void 0,
|
|
33
|
+
"aria-pressed": active,
|
|
34
|
+
"data-test": `${testPrefix}-${option.value}`,
|
|
35
|
+
onClick: () => onChange(option.value),
|
|
36
|
+
children: option.label
|
|
37
|
+
},
|
|
38
|
+
option.value
|
|
39
|
+
);
|
|
40
|
+
})
|
|
41
|
+
}
|
|
42
|
+
);
|
|
43
|
+
}
|
|
44
|
+
export {
|
|
45
|
+
SegmentedControl
|
|
46
|
+
};
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
import { type ReactNode } from 'react';
|
|
2
|
+
export interface Crumb {
|
|
3
|
+
label: string;
|
|
4
|
+
/** Absent on the page you are on. */
|
|
5
|
+
href?: string;
|
|
6
|
+
}
|
|
7
|
+
export declare function ThemeToggleButton(): import("react").JSX.Element;
|
|
8
|
+
export declare function Breadcrumb({ crumbs }: {
|
|
9
|
+
crumbs: readonly Crumb[];
|
|
10
|
+
}): import("react").JSX.Element | null;
|
|
11
|
+
/**
|
|
12
|
+
* The one header every harness page wears: breadcrumb, the title with its
|
|
13
|
+
* quiet facts beside it, Docs (for the screen you are on) and the theme
|
|
14
|
+
* toggle on the same line, then the tabs.
|
|
15
|
+
*/
|
|
16
|
+
export declare function ShellHeader({ crumbs, title, kind, meta, tabs, testId, }: {
|
|
17
|
+
crumbs?: readonly Crumb[];
|
|
18
|
+
title: ReactNode;
|
|
19
|
+
/** `repo`, `integration`, `experience`. */
|
|
20
|
+
kind: string;
|
|
21
|
+
/** Chips beside the title. */
|
|
22
|
+
meta?: ReactNode;
|
|
23
|
+
tabs?: ReactNode;
|
|
24
|
+
testId?: string;
|
|
25
|
+
}): import("react").JSX.Element;
|