@ekanos/harness 0.26.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.
Files changed (159) hide show
  1. package/README.md +6 -4
  2. package/dist/api-types.d.ts +4 -0
  3. package/dist/internal/components/approvals-tray.d.ts +44 -6
  4. package/dist/internal/components/approvals-tray.js +252 -30
  5. package/dist/internal/components/connect-controls.js +4 -2
  6. package/dist/internal/components/connect-dialog.d.ts +8 -1
  7. package/dist/internal/components/connect-dialog.js +23 -10
  8. package/dist/internal/components/connect-panel.d.ts +3 -2
  9. package/dist/internal/components/connect-panel.js +680 -340
  10. package/dist/internal/components/connect-steps.d.ts +72 -0
  11. package/dist/internal/components/connect-steps.js +341 -0
  12. package/dist/internal/components/console-not-found.d.ts +14 -0
  13. package/dist/internal/components/console-not-found.js +57 -0
  14. package/dist/internal/components/dashboard-grid.d.ts +10 -5
  15. package/dist/internal/components/dashboard-grid.js +8 -9
  16. package/dist/internal/components/dev-toolbar.d.ts +27 -5
  17. package/dist/internal/components/dev-toolbar.js +214 -176
  18. package/dist/internal/components/ekanos-logo.d.ts +18 -0
  19. package/dist/internal/components/ekanos-logo.js +74 -0
  20. package/dist/internal/components/events-panel.d.ts +13 -4
  21. package/dist/internal/components/events-panel.js +478 -81
  22. package/dist/internal/components/harness-widget-provider.d.ts +6 -8
  23. package/dist/internal/components/harness-widget-provider.js +5 -19
  24. package/dist/internal/components/health-panel.d.ts +8 -1
  25. package/dist/internal/components/health-panel.js +328 -31
  26. package/dist/internal/components/integration-badge.js +4 -2
  27. package/dist/internal/components/integration-tab-skeletons.d.ts +8 -0
  28. package/dist/internal/components/integration-tab-skeletons.js +76 -0
  29. package/dist/internal/components/not-found-state.d.ts +39 -0
  30. package/dist/internal/components/not-found-state.js +127 -0
  31. package/dist/internal/components/operation-runner-panel.d.ts +1 -1
  32. package/dist/internal/components/operation-runner-panel.js +624 -189
  33. package/dist/internal/components/operation-scope.d.ts +13 -0
  34. package/dist/internal/components/operation-scope.js +79 -0
  35. package/dist/internal/components/page-skeletons.d.ts +11 -0
  36. package/dist/internal/components/page-skeletons.js +61 -0
  37. package/dist/internal/components/provenance-banner.d.ts +13 -4
  38. package/dist/internal/components/provenance-banner.js +35 -10
  39. package/dist/internal/components/run-log-copy.d.ts +17 -0
  40. package/dist/internal/components/run-log-copy.js +67 -0
  41. package/dist/internal/components/run-log-detail.d.ts +22 -0
  42. package/dist/internal/components/run-log-detail.js +295 -0
  43. package/dist/internal/components/run-log-empty.d.ts +13 -0
  44. package/dist/internal/components/run-log-empty.js +46 -0
  45. package/dist/internal/components/run-log.d.ts +23 -3
  46. package/dist/internal/components/run-log.js +384 -130
  47. package/dist/internal/components/runtime-strip.d.ts +5 -1
  48. package/dist/internal/components/runtime-strip.js +115 -10
  49. package/dist/internal/components/schema-form.d.ts +2 -1
  50. package/dist/internal/components/schema-form.js +212 -79
  51. package/dist/internal/components/scrollable-nav.js +14 -2
  52. package/dist/internal/components/segmented-control.d.ts +19 -0
  53. package/dist/internal/components/segmented-control.js +46 -0
  54. package/dist/internal/components/shell-header.d.ts +25 -0
  55. package/dist/internal/components/shell-header.js +126 -0
  56. package/dist/internal/components/surface-nav.d.ts +12 -3
  57. package/dist/internal/components/surface-nav.js +72 -83
  58. package/dist/internal/components/widget-surface.d.ts +5 -1
  59. package/dist/internal/components/widget-surface.js +86 -14
  60. package/dist/internal/components/workflow-runner.d.ts +23 -10
  61. package/dist/internal/components/workflow-runner.js +451 -69
  62. package/dist/internal/lib/connect-model.d.ts +134 -0
  63. package/dist/internal/lib/connect-model.js +282 -0
  64. package/dist/internal/lib/connection-facts.js +2 -1
  65. package/dist/internal/lib/console-client.js +5 -2
  66. package/dist/internal/lib/console-hooks.d.ts +4 -1
  67. package/dist/internal/lib/console-hooks.js +3 -2
  68. package/dist/internal/lib/console-types.d.ts +6 -0
  69. package/dist/internal/lib/docs-links.d.ts +28 -0
  70. package/dist/internal/lib/docs-links.js +57 -1
  71. package/dist/internal/lib/event-delivery.d.ts +33 -0
  72. package/dist/internal/lib/event-delivery.js +66 -0
  73. package/dist/internal/lib/experience-runtime.d.ts +2 -1
  74. package/dist/internal/lib/experience-runtime.js +5 -3
  75. package/dist/internal/lib/font-files/OFL-BricolageGrotesque.txt +93 -0
  76. package/dist/internal/lib/font-files/OFL-Figtree.txt +93 -0
  77. package/dist/internal/lib/font-files/bricolage-grotesque-latin-variable.woff2 +0 -0
  78. package/dist/internal/lib/font-files/figtree-latin-variable.woff2 +0 -0
  79. package/dist/internal/lib/fonts.js +13 -12
  80. package/dist/internal/lib/health-model.d.ts +58 -0
  81. package/dist/internal/lib/health-model.js +140 -0
  82. package/dist/internal/lib/integration-console-href.d.ts +15 -0
  83. package/dist/internal/lib/integration-console-href.js +16 -0
  84. package/dist/internal/lib/oauth-setup-guide.d.ts +28 -0
  85. package/dist/internal/lib/oauth-setup-guide.js +35 -1
  86. package/dist/internal/lib/operation-catalog.d.ts +70 -0
  87. package/dist/internal/lib/operation-catalog.js +261 -0
  88. package/dist/internal/lib/overview-model.d.ts +34 -0
  89. package/dist/internal/lib/overview-model.js +91 -0
  90. package/dist/internal/lib/registry-entry.d.ts +8 -0
  91. package/dist/internal/lib/registry-entry.js +11 -0
  92. package/dist/internal/lib/repo-name.d.ts +9 -0
  93. package/dist/internal/lib/repo-name.js +21 -0
  94. package/dist/internal/lib/run-log-view.d.ts +66 -1
  95. package/dist/internal/lib/run-log-view.js +183 -4
  96. package/dist/internal/lib/runner-view.d.ts +15 -0
  97. package/dist/internal/lib/runner-view.js +18 -0
  98. package/dist/internal/lib/schema-form-model.d.ts +17 -0
  99. package/dist/internal/lib/schema-form-model.js +50 -0
  100. package/dist/internal/lib/setup-checklist.d.ts +34 -0
  101. package/dist/internal/lib/setup-checklist.js +79 -0
  102. package/dist/internal/lib/toolbar-context.d.ts +0 -1
  103. package/dist/internal/lib/toolbar-context.js +0 -2
  104. package/dist/internal/lib/toolbar-visibility.d.ts +9 -2
  105. package/dist/internal/lib/toolbar-visibility.js +5 -0
  106. package/dist/internal/lib/use-operation-effects.d.ts +7 -0
  107. package/dist/internal/lib/use-operation-effects.js +28 -0
  108. package/dist/internal/lib/use-run-log-query.d.ts +9 -0
  109. package/dist/internal/lib/use-run-log-query.js +35 -0
  110. package/dist/internal/lib/widget-grid-gaps.d.ts +18 -0
  111. package/dist/internal/lib/widget-grid-gaps.js +41 -0
  112. package/dist/internal/lib/workflow-summary.d.ts +54 -0
  113. package/dist/internal/lib/workflow-summary.js +147 -0
  114. package/dist/internal/routes/console-home-page.js +2 -1
  115. package/dist/internal/routes/experience-connect-page.js +51 -22
  116. package/dist/internal/routes/experience-layout-page.js +75 -26
  117. package/dist/internal/routes/experience-page-host.js +63 -5
  118. package/dist/internal/routes/experience-review-queue-page.d.ts +4 -1
  119. package/dist/internal/routes/experience-review-queue-page.js +108 -12
  120. package/dist/internal/routes/experience-runs-page.js +57 -4
  121. package/dist/internal/routes/experience-summary-page.d.ts +19 -0
  122. package/dist/internal/routes/experience-summary-page.js +219 -62
  123. package/dist/internal/routes/experience-widget-page.js +58 -7
  124. package/dist/internal/routes/experience-widgets-page.d.ts +2 -3
  125. package/dist/internal/routes/experience-widgets-page.js +29 -4
  126. package/dist/internal/routes/experience-workflow-page.js +81 -9
  127. package/dist/internal/routes/experience-workflows-page.js +85 -21
  128. package/dist/internal/routes/integration-layout.js +28 -3
  129. package/dist/internal/routes/integrations-connect-page.js +16 -6
  130. package/dist/internal/routes/integrations-events-page.js +22 -1
  131. package/dist/internal/routes/integrations-health-page.js +16 -1
  132. package/dist/internal/routes/integrations-layout.js +28 -4
  133. package/dist/internal/routes/integrations-list-page.d.ts +0 -1
  134. package/dist/internal/routes/integrations-list-page.js +11 -9
  135. package/dist/internal/routes/integrations-operation-page.js +53 -17
  136. package/dist/internal/routes/integrations-operations-page.js +539 -49
  137. package/dist/internal/routes/integrations-overview-page.js +332 -69
  138. package/dist/internal/routes/integrations-runs-page.js +53 -3
  139. package/dist/internal/routes/integrations-scope.d.ts +15 -2
  140. package/dist/internal/routes/integrations-scope.js +66 -18
  141. package/dist/internal/routes/preview-index-page.js +2 -2
  142. package/dist/internal/routes/repo-home-page.d.ts +2 -2
  143. package/dist/internal/routes/repo-home-page.js +428 -236
  144. package/dist/internal/routes/repo-layout.d.ts +12 -0
  145. package/dist/internal/routes/repo-layout.js +50 -38
  146. package/dist/internal/routes/repo-package-layouts.js +22 -8
  147. package/dist/internal/routes/single-widget-page.d.ts +1 -1
  148. package/dist/internal/routes/single-widget-page.js +28 -5
  149. package/dist/internal/routes/tile-page.d.ts +1 -1
  150. package/dist/internal/routes/tile-page.js +1 -2
  151. package/dist/internal/routes/widgets-page.d.ts +1 -1
  152. package/dist/internal/routes/widgets-page.js +5 -3
  153. package/dist/internal/server/ekanos-api-router.js +20 -5
  154. package/dist/internal/server/repo-api-router.js +20 -7
  155. package/dist/registry.d.ts +4 -5
  156. package/dist/registry.js +0 -1
  157. package/dist/routes.d.ts +5 -0
  158. package/dist/routes.js +2 -0
  159. package/package.json +8 -8
@@ -1,8 +1,13 @@
1
1
  "use client";
2
- import { jsx, jsxs } from "react/jsx-runtime";
2
+ import { Fragment, jsx, jsxs } from "react/jsx-runtime";
3
+ import Link from "next/link";
3
4
  import { usePathname } from "next/navigation";
4
5
  import { Button } from "@ekanos/ui/button";
6
+ import { Card } from "@ekanos/ui/card";
5
7
  import { ConfirmDialog } from "@ekanos/ui/confirm-dialog";
8
+ import { Icon } from "@ekanos/ui/icon";
9
+ import { StatusBadge } from "@ekanos/ui/status-badge";
10
+ import { cn } from "@ekanos/ui/utils";
6
11
  import { answerLabel } from "../lib/connection-facts.js";
7
12
  import { useConsoleClient } from "../lib/console-context.js";
8
13
  import {
@@ -10,17 +15,112 @@ import {
10
15
  useProject,
11
16
  useRefreshRuntime
12
17
  } from "../lib/console-hooks.js";
18
+ import { integrationConsoleHref } from "../lib/integration-console-href.js";
13
19
  import { ConnectDialog } from "./connect-dialog.js";
14
20
  import { ConnectionChip } from "./connection-chip.js";
21
+ import { FOCUS_RING } from "./scrollable-nav.js";
15
22
  function runtimeChipText(integration) {
16
23
  const facts = integration.runtime?.facts;
17
24
  if (!facts) return null;
18
25
  return `${integration.integration} \xB7 ${answerLabel(facts)}`;
19
26
  }
27
+ function IntegrationName({
28
+ integration
29
+ }) {
30
+ const id = integration.integration;
31
+ const slash = id.lastIndexOf("/");
32
+ const namespace = slash === -1 ? null : id.slice(0, slash + 1);
33
+ const name = slash === -1 ? id : id.slice(slash + 1);
34
+ const href = integrationConsoleHref(integration);
35
+ const parts = /* @__PURE__ */ jsxs(Fragment, { children: [
36
+ namespace ? /* @__PURE__ */ jsx("span", { className: "text-muted-foreground min-w-0 truncate", children: namespace }) : null,
37
+ /* @__PURE__ */ jsx("span", { className: "shrink-0", children: name })
38
+ ] });
39
+ const className = "flex min-w-0 items-baseline rounded-sm font-mono text-sm font-medium";
40
+ return href ? /* @__PURE__ */ jsx(
41
+ Link,
42
+ {
43
+ href,
44
+ className: cn(className, "hover:underline", FOCUS_RING),
45
+ title: `Open the ${id} console`,
46
+ "data-test": "runtime-integration-name",
47
+ children: parts
48
+ }
49
+ ) : /* @__PURE__ */ jsx("span", { className, title: id, "data-test": "runtime-integration-name", children: parts });
50
+ }
20
51
  function onConnectTab(pathname) {
21
52
  return Boolean(pathname && /\/connect\/?$/.test(pathname));
22
53
  }
23
- 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() {
24
124
  const project = useProject();
25
125
  const client = useConsoleClient();
26
126
  const refresh = useRefreshRuntime();
@@ -41,7 +141,7 @@ function RuntimeStrip() {
41
141
  const list = /* @__PURE__ */ jsx(
42
142
  "ul",
43
143
  {
44
- className: "flex flex-col gap-2",
144
+ className: "flex flex-col gap-2 sm:grid sm:grid-cols-[max-content_minmax(0,1fr)_auto] sm:gap-x-3",
45
145
  "data-test": "runtime-strip",
46
146
  "aria-label": "Where each integration gets its answers",
47
147
  children: rows.map((integration) => {
@@ -53,14 +153,14 @@ function RuntimeStrip() {
53
153
  return /* @__PURE__ */ jsxs(
54
154
  "li",
55
155
  {
56
- className: "flex flex-wrap items-center gap-x-3 gap-y-2",
156
+ className: "flex flex-wrap items-center gap-x-3 gap-y-2 sm:col-span-3 sm:grid sm:grid-cols-subgrid",
57
157
  "data-test": `runtime-${integration.integration}`,
58
158
  "data-mode": runtime.mode,
59
159
  "data-reason": runtime.reason,
60
160
  children: [
61
- /* @__PURE__ */ jsx("code", { className: "w-28 shrink-0 truncate text-sm font-medium", children: integration.integration }),
161
+ /* @__PURE__ */ jsx(IntegrationName, { integration }),
62
162
  /* @__PURE__ */ jsx("span", { className: "flex min-w-48 flex-1 flex-wrap items-center gap-x-3 gap-y-1", children: /* @__PURE__ */ jsx(ConnectionChip, { facts, variant: "answer" }) }),
63
- /* @__PURE__ */ jsxs("span", { className: "flex items-center gap-2", children: [
163
+ /* @__PURE__ */ jsxs("span", { className: "flex items-center gap-2 sm:justify-end", children: [
64
164
  connectable && facts.state === "not_connected" ? /* @__PURE__ */ jsx(
65
165
  ConnectDialog,
66
166
  {
@@ -147,10 +247,15 @@ function RuntimeStrip() {
147
247
  }
148
248
  );
149
249
  }
150
- return /* @__PURE__ */ jsxs("section", { className: "flex flex-col gap-2 rounded-md border px-4 py-3", children: [
151
- /* @__PURE__ */ jsx("h2", { className: "text-sm font-medium", children: "Integrations" }),
152
- list
153
- ] });
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
+ );
154
259
  }
155
260
  export {
156
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
- objectProperties,
16
- parseJsonText
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__ */ jsxs(Label, { htmlFor: fieldId(path), className: "text-sm font-medium", children: [
36
- label,
37
- required ? /* @__PURE__ */ jsxs("span", { className: "text-destructive", "aria-hidden": true, children: [
38
- " ",
39
- "*"
40
- ] }) : null
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) => onChange(event.target.value)
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) => onChange(event.target.value)
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__ */ jsx(
210
- Switch,
211
- {
212
- id: fieldId(path),
213
- checked: value === true,
214
- onCheckedChange: (checked) => onChange(checked)
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-3",
290
+ className: "flex flex-col gap-2",
245
291
  "data-test": `array-${fieldId(path)}`,
246
292
  children: [
247
- items.map((item, index) => (
248
- // Items are positional: an index key is the identity here.
249
- /* @__PURE__ */ jsxs(
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-muted/50 flex flex-col gap-2 rounded-md border p-3",
329
+ className: "bg-muted flex flex-col gap-2 rounded-md border p-3",
253
330
  children: [
254
- /* @__PURE__ */ jsx(
255
- Field,
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__ */ jsx(
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
- onClick: () => onChange([...items, initialValue(itemSchema)]),
295
- children: "Add item"
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__ */ jsx(
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: objectProperties(schema).map((property) => /* @__PURE__ */ jsx(
314
- Field,
315
- {
316
- path: `${path}/${property.key}`,
317
- label: property.key,
318
- required: property.required,
319
- schema: property.schema,
320
- value: record[property.key],
321
- onChange: (next) => {
322
- const { [property.key]: _previous, ...rest } = record;
323
- onChange(
324
- next === void 0 ? rest : { ...rest, [property.key]: next }
325
- );
326
- },
327
- errors
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 (kind === "object" && objectProperties(classify(schema).schema).length === 0) {
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: measure,
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;