@flanksource/clicky-ui 0.3.83 → 0.3.84

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 (137) hide show
  1. package/dist/components/DateField.cjs.map +1 -1
  2. package/dist/components/DateField.d.ts +3 -2
  3. package/dist/components/DateField.d.ts.map +1 -1
  4. package/dist/components/DateField.js.map +1 -1
  5. package/dist/components/DatePicker.cjs +9 -61
  6. package/dist/components/DatePicker.cjs.map +1 -1
  7. package/dist/components/DatePicker.d.ts +5 -19
  8. package/dist/components/DatePicker.d.ts.map +1 -1
  9. package/dist/components/DatePicker.js +11 -63
  10. package/dist/components/DatePicker.js.map +1 -1
  11. package/dist/components/DateTimePicker.cjs +9 -78
  12. package/dist/components/DateTimePicker.cjs.map +1 -1
  13. package/dist/components/DateTimePicker.d.ts +5 -19
  14. package/dist/components/DateTimePicker.d.ts.map +1 -1
  15. package/dist/components/DateTimePicker.js +11 -80
  16. package/dist/components/DateTimePicker.js.map +1 -1
  17. package/dist/components/calendar-grid.cjs +83 -0
  18. package/dist/components/calendar-grid.cjs.map +1 -0
  19. package/dist/components/calendar-grid.d.ts +9 -0
  20. package/dist/components/calendar-grid.d.ts.map +1 -0
  21. package/dist/components/calendar-grid.js +83 -0
  22. package/dist/components/calendar-grid.js.map +1 -0
  23. package/dist/components/date-input-field.cjs +88 -0
  24. package/dist/components/date-input-field.cjs.map +1 -0
  25. package/dist/components/date-input-field.d.ts +37 -0
  26. package/dist/components/date-input-field.d.ts.map +1 -0
  27. package/dist/components/date-input-field.js +88 -0
  28. package/dist/components/date-input-field.js.map +1 -0
  29. package/dist/components/date-math.cjs +67 -0
  30. package/dist/components/date-math.cjs.map +1 -0
  31. package/dist/components/date-math.d.ts +33 -0
  32. package/dist/components/date-math.d.ts.map +1 -0
  33. package/dist/components/date-math.js +60 -0
  34. package/dist/components/date-math.js.map +1 -0
  35. package/dist/components/date-picker-menu.cjs +129 -0
  36. package/dist/components/date-picker-menu.cjs.map +1 -0
  37. package/dist/components/date-picker-menu.d.ts +18 -0
  38. package/dist/components/date-picker-menu.d.ts.map +1 -0
  39. package/dist/components/date-picker-menu.js +129 -0
  40. package/dist/components/date-picker-menu.js.map +1 -0
  41. package/dist/components/json-schema-form-date-math.cjs +15 -11
  42. package/dist/components/json-schema-form-date-math.cjs.map +1 -1
  43. package/dist/components/json-schema-form-date-math.d.ts +3 -0
  44. package/dist/components/json-schema-form-date-math.d.ts.map +1 -1
  45. package/dist/components/json-schema-form-date-math.js +15 -12
  46. package/dist/components/json-schema-form-date-math.js.map +1 -1
  47. package/dist/components.d.ts +1 -0
  48. package/dist/components.d.ts.map +1 -1
  49. package/dist/data/PromptDialog.cjs +19 -5
  50. package/dist/data/PromptDialog.cjs.map +1 -1
  51. package/dist/data/PromptDialog.d.ts +15 -1
  52. package/dist/data/PromptDialog.d.ts.map +1 -1
  53. package/dist/data/PromptDialog.js +19 -5
  54. package/dist/data/PromptDialog.js.map +1 -1
  55. package/dist/data/PromptIndicator.cjs +3 -2
  56. package/dist/data/PromptIndicator.cjs.map +1 -1
  57. package/dist/data/PromptIndicator.d.ts +4 -1
  58. package/dist/data/PromptIndicator.d.ts.map +1 -1
  59. package/dist/data/PromptIndicator.js +3 -2
  60. package/dist/data/PromptIndicator.js.map +1 -1
  61. package/dist/data/diagnostics/ErrorDetails.cjs +155 -110
  62. package/dist/data/diagnostics/ErrorDetails.cjs.map +1 -1
  63. package/dist/data/diagnostics/ErrorDetails.d.ts.map +1 -1
  64. package/dist/data/diagnostics/ErrorDetails.js +155 -110
  65. package/dist/data/diagnostics/ErrorDetails.js.map +1 -1
  66. package/dist/data/test-runner/TestDetailPanel.cjs +109 -46
  67. package/dist/data/test-runner/TestDetailPanel.cjs.map +1 -1
  68. package/dist/data/test-runner/TestDetailPanel.d.ts.map +1 -1
  69. package/dist/data/test-runner/TestDetailPanel.js +110 -47
  70. package/dist/data/test-runner/TestDetailPanel.js.map +1 -1
  71. package/dist/data/test-runner/TestTreeNode.cjs +84 -63
  72. package/dist/data/test-runner/TestTreeNode.cjs.map +1 -1
  73. package/dist/data/test-runner/TestTreeNode.d.ts.map +1 -1
  74. package/dist/data/test-runner/TestTreeNode.js +84 -63
  75. package/dist/data/test-runner/TestTreeNode.js.map +1 -1
  76. package/dist/data/test-runner/adapter.cjs.map +1 -1
  77. package/dist/data/test-runner/adapter.d.ts +2 -2
  78. package/dist/data/test-runner/adapter.d.ts.map +1 -1
  79. package/dist/data/test-runner/adapter.js.map +1 -1
  80. package/dist/data/test-runner/copy.cjs +62 -10
  81. package/dist/data/test-runner/copy.cjs.map +1 -1
  82. package/dist/data/test-runner/copy.d.ts +52 -9
  83. package/dist/data/test-runner/copy.d.ts.map +1 -1
  84. package/dist/data/test-runner/copy.js +60 -11
  85. package/dist/data/test-runner/copy.js.map +1 -1
  86. package/dist/data/test-runner/index.d.ts +1 -1
  87. package/dist/data/test-runner/index.d.ts.map +1 -1
  88. package/dist/data/verification/StepFilesView.cjs +90 -0
  89. package/dist/data/verification/StepFilesView.cjs.map +1 -0
  90. package/dist/data/verification/StepFilesView.d.ts +9 -0
  91. package/dist/data/verification/StepFilesView.d.ts.map +1 -0
  92. package/dist/data/verification/StepFilesView.js +90 -0
  93. package/dist/data/verification/StepFilesView.js.map +1 -0
  94. package/dist/data/verification/adapterViews.cjs +129 -69
  95. package/dist/data/verification/adapterViews.cjs.map +1 -1
  96. package/dist/data/verification/adapterViews.d.ts +3 -1
  97. package/dist/data/verification/adapterViews.d.ts.map +1 -1
  98. package/dist/data/verification/adapterViews.js +130 -70
  99. package/dist/data/verification/adapterViews.js.map +1 -1
  100. package/dist/data/verification/adapters.cjs +9 -0
  101. package/dist/data/verification/adapters.cjs.map +1 -1
  102. package/dist/data/verification/adapters.d.ts +2 -0
  103. package/dist/data/verification/adapters.d.ts.map +1 -1
  104. package/dist/data/verification/adapters.js +11 -2
  105. package/dist/data/verification/adapters.js.map +1 -1
  106. package/dist/data/verification/index.d.ts +2 -1
  107. package/dist/data/verification/index.d.ts.map +1 -1
  108. package/dist/data/verification/stepKind.cjs +63 -7
  109. package/dist/data/verification/stepKind.cjs.map +1 -1
  110. package/dist/data/verification/stepKind.d.ts +55 -6
  111. package/dist/data/verification/stepKind.d.ts.map +1 -1
  112. package/dist/data/verification/stepKind.js +62 -8
  113. package/dist/data/verification/stepKind.js.map +1 -1
  114. package/dist/data/verification/stepKindViews.cjs +318 -106
  115. package/dist/data/verification/stepKindViews.cjs.map +1 -1
  116. package/dist/data/verification/stepKindViews.d.ts +17 -6
  117. package/dist/data/verification/stepKindViews.d.ts.map +1 -1
  118. package/dist/data/verification/stepKindViews.js +319 -108
  119. package/dist/data/verification/stepKindViews.js.map +1 -1
  120. package/dist/data/version-info.cjs +3 -3
  121. package/dist/data/version-info.js +3 -3
  122. package/dist/data.cjs +4 -0
  123. package/dist/data.d.ts +1 -1
  124. package/dist/data.d.ts.map +1 -1
  125. package/dist/data.js +3 -2
  126. package/dist/hooks/use-prompts.cjs +52 -30
  127. package/dist/hooks/use-prompts.cjs.map +1 -1
  128. package/dist/hooks/use-prompts.d.ts +6 -0
  129. package/dist/hooks/use-prompts.d.ts.map +1 -1
  130. package/dist/hooks/use-prompts.js +52 -30
  131. package/dist/hooks/use-prompts.js.map +1 -1
  132. package/dist/index.cjs +5 -1
  133. package/dist/index.js +4 -3
  134. package/dist/runtime/barrels.json +5874 -5867
  135. package/dist/runtime/importmap.json +2175 -2170
  136. package/dist/styles.css +1 -1
  137. package/package.json +1 -1
@@ -1 +1 @@
1
- {"version":3,"file":"PromptDialog.d.ts","sourceRoot":"","sources":["../../src/data/PromptDialog.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,8CAA8C,CAAC;AAClF,OAAO,EAAS,KAAK,SAAS,EAAE,MAAM,kBAAkB,CAAC;AACzD,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,sBAAsB,CAAC;AAG3D,MAAM,WAAW,iBAAiB;IACh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a,GAAG,SAAS,CAAC;IAC1C,yHAAyH;IACzH,iBAAiB,CAAC,EAAE,MAAM,GAAG,SAAS,CAAC;IACvC,gFAAgF;IAChF,IAAI,CAAC,EAAE,SAAS,GAAG,SAAS,CAAC;IAC7B;;;;;OAKG;IACH,UAAU,CAAC,EAAE,kBAAkB,GAAG,SAAS,CAAC;CAC7C;AAED,2DAA2D;AAC3D,MAAM,MAAM,kBAAkB,GAAG,CAAC,KAAK,EAAE;IAAE,MAAM,EAAE,cAAc,CAAC;IAAC,QAAQ,EAAE,MAAM,CAAC;IAAC,UAAU,EAAE,MAAM,IAAI,CAAA;CAAE,KAAK,SAAS,GAAG,IAAI,CAAC;AAKnI,wBAAgB,YAAY,CAAC,EAAE,MAAM,EAAE,QAAQ,EAAE,IAAI,EAAE,OAAO,EAAE,UAAU,EAAE,aAAa,EAAE,iBAAiB,EAAE,IAAW,EAAE,UAAU,EAAE,EAAE,iBAAiB,+BA2BzJ"}
@@ -2,16 +2,30 @@ import { Modal } from "../overlay/Modal.js";
2
2
  import { PromptForm } from "./PromptForm.js";
3
3
  import { jsx } from "react/jsx-runtime";
4
4
  // src/data/PromptDialog.tsx
5
- function PromptDialog({ prompt, basePath, open, onClose, onResolved, lookupFetcher, connectionApiBase, size = "lg" }) {
5
+ function PromptDialog({ prompt, basePath, open, onClose, onResolved, lookupFetcher, connectionApiBase, size = "xl", renderForm }) {
6
+ const resolved = () => {
7
+ onResolved?.();
8
+ onClose();
9
+ };
10
+ const custom = renderForm?.({
11
+ prompt,
12
+ basePath,
13
+ onResolved: resolved
14
+ }) ?? null;
15
+ if (custom !== null) return /* @__PURE__ */ jsx(Modal, {
16
+ open,
17
+ size,
18
+ onClose,
19
+ title: prompt.title,
20
+ subtitle: prompt.description,
21
+ children: custom
22
+ });
6
23
  return /* @__PURE__ */ jsx(PromptForm, {
7
24
  prompt,
8
25
  basePath,
9
26
  lookupFetcher,
10
27
  connectionApiBase,
11
- onResolved: () => {
12
- onResolved?.();
13
- onClose();
14
- },
28
+ onResolved: resolved,
15
29
  frame: ({ form, actions }) => /* @__PURE__ */ jsx(Modal, {
16
30
  open,
17
31
  size,
@@ -1 +1 @@
1
- {"version":3,"file":"PromptDialog.js","names":[],"sources":["../../src/data/PromptDialog.tsx"],"sourcesContent":["import type { LookupFetcher } from \"../components/json-schema-form-runtime-types\";\nimport { Modal, type ModalSize } from \"../overlay/Modal\";\nimport type { PromptSnapshot } from \"../hooks/use-prompts\";\nimport { PromptForm } from \"./PromptForm\";\n\nexport interface PromptDialogProps {\n /** The pending prompt to answer. Its `schema` drives the rendered form. */\n prompt: PromptSnapshot;\n /** Base path the prompt API is mounted under, e.g. \"/api/todos\". */\n basePath: string;\n open: boolean;\n /** Closes the modal without answering (the prompt stays pending). */\n onClose: () => void;\n /** Called after the prompt is successfully answered or cancelled. */\n onResolved?: (() => void) | undefined;\n /** Resolves the options of the schema's `x-clicky-lookup` fields (e.g. a connection picker). */\n lookupFetcher?: LookupFetcher | undefined;\n /** Where the connections service is mounted; lets a `format: \"connection\"` field create the connection it is missing. */\n connectionApiBase?: string | undefined;\n /** The dialog width; a form of several fields needs more than a confirm box. */\n size?: ModalSize | undefined;\n}\n\n// PromptDialog is PromptForm inside a Modal: the prompt's title and description\n// head the dialog, Submit/Cancel are pinned in its footer, and answering closes\n// it. It is the human side of the same mechanism an AI model elicits through.\nexport function PromptDialog({ prompt, basePath, open, onClose, onResolved, lookupFetcher, connectionApiBase, size = \"lg\" }: PromptDialogProps) {\n return (\n <PromptForm\n prompt={prompt}\n basePath={basePath}\n lookupFetcher={lookupFetcher}\n connectionApiBase={connectionApiBase}\n onResolved={() => {\n onResolved?.();\n onClose();\n }}\n frame={({ form, actions }) => (\n <Modal open={open} size={size} onClose={onClose} title={prompt.title} subtitle={prompt.description} footer={actions}>\n {form}\n </Modal>\n )}\n />\n );\n}\n"],"mappings":";;;;AA0BA,SAAgB,aAAa,EAAE,QAAQ,UAAU,MAAM,SAAS,YAAY,eAAe,mBAAmB,OAAO,QAA2B;CAC9I,OACE,oBAAC,YAAD;EACU;EACE;EACK;EACI;EACnB,kBAAkB;GAChB,aAAa;GACb,QAAQ;EACV;EACA,QAAQ,EAAE,MAAM,cACd,oBAAC,OAAD;GAAa;GAAY;GAAe;GAAS,OAAO,OAAO;GAAO,UAAU,OAAO;GAAa,QAAQ;GACzG,UAAA;EACI,CAAA;CAEV,CAAA;AAEL"}
1
+ {"version":3,"file":"PromptDialog.js","names":[],"sources":["../../src/data/PromptDialog.tsx"],"sourcesContent":["import type { ReactNode } from \"react\";\nimport type { LookupFetcher } from \"../components/json-schema-form-runtime-types\";\nimport { Modal, type ModalSize } from \"../overlay/Modal\";\nimport type { PromptSnapshot } from \"../hooks/use-prompts\";\nimport { PromptForm } from \"./PromptForm\";\n\nexport interface PromptDialogProps {\n /** The pending prompt to answer. Its `schema` drives the rendered form. */\n prompt: PromptSnapshot;\n /** Base path the prompt API is mounted under, e.g. \"/api/todos\". */\n basePath: string;\n open: boolean;\n /** Closes the modal without answering (the prompt stays pending). */\n onClose: () => void;\n /** Called after the prompt is successfully answered or cancelled. */\n onResolved?: (() => void) | undefined;\n /** Resolves the options of the schema's `x-clicky-lookup` fields (e.g. a connection picker). */\n lookupFetcher?: LookupFetcher | undefined;\n /** Where the connections service is mounted; lets a `format: \"connection\"` field create the connection it is missing. */\n connectionApiBase?: string | undefined;\n /** The dialog width; a form of several fields needs more than a confirm box. */\n size?: ModalSize | undefined;\n /**\n * Answers the prompt with the host's own form instead of PromptForm (e.g. a\n * page-runtime form for a prompt that names a `page` or `runtime`). Returning\n * null keeps PromptForm. The returned form answers the prompt itself and calls\n * `onResolved` when it has.\n */\n renderForm?: PromptFormRenderer | undefined;\n}\n\n/** A host form for a prompt, or null to use PromptForm. */\nexport type PromptFormRenderer = (props: { prompt: PromptSnapshot; basePath: string; onResolved: () => void }) => ReactNode | null;\n\n// PromptDialog is PromptForm inside a Modal: the prompt's title and description\n// head the dialog, Submit/Cancel are pinned in its footer, and answering closes\n// it. It is the human side of the same mechanism an AI model elicits through.\nexport function PromptDialog({ prompt, basePath, open, onClose, onResolved, lookupFetcher, connectionApiBase, size = \"xl\", renderForm }: PromptDialogProps) {\n const resolved = () => {\n onResolved?.();\n onClose();\n };\n const custom = renderForm?.({ prompt, basePath, onResolved: resolved }) ?? null;\n if (custom !== null) {\n return (\n <Modal open={open} size={size} onClose={onClose} title={prompt.title} subtitle={prompt.description}>\n {custom}\n </Modal>\n );\n }\n return (\n <PromptForm\n prompt={prompt}\n basePath={basePath}\n lookupFetcher={lookupFetcher}\n connectionApiBase={connectionApiBase}\n onResolved={resolved}\n frame={({ form, actions }) => (\n <Modal open={open} size={size} onClose={onClose} title={prompt.title} subtitle={prompt.description} footer={actions}>\n {form}\n </Modal>\n )}\n />\n );\n}\n"],"mappings":";;;;AAqCA,SAAgB,aAAa,EAAE,QAAQ,UAAU,MAAM,SAAS,YAAY,eAAe,mBAAmB,OAAO,MAAM,cAAiC;CAC1J,MAAM,iBAAiB;EACrB,aAAa;EACb,QAAQ;CACV;CACA,MAAM,SAAS,aAAa;EAAE;EAAQ;EAAU,YAAY;CAAS,CAAC,KAAK;CAC3E,IAAI,WAAW,MACb,OACE,oBAAC,OAAD;EAAa;EAAY;EAAe;EAAS,OAAO,OAAO;EAAO,UAAU,OAAO;EACpF,UAAA;CACI,CAAA;CAGX,OACE,oBAAC,YAAD;EACU;EACE;EACK;EACI;EACnB,YAAY;EACZ,QAAQ,EAAE,MAAM,cACd,oBAAC,OAAD;GAAa;GAAY;GAAe;GAAS,OAAO,OAAO;GAAO,UAAU,OAAO;GAAa,QAAQ;GACzG,UAAA;EACI,CAAA;CAEV,CAAA;AAEL"}
@@ -11,7 +11,7 @@ const require_marks = require("./test-runner/marks.cjs");
11
11
  let react = require("react");
12
12
  let react_jsx_runtime = require("react/jsx-runtime");
13
13
  // src/data/PromptIndicator.tsx
14
- function PromptIndicator({ basePath = "/api/todos", enabled, className, lookupFetcher, connectionApiBase, autoOpen = false, state: _ignoredState, ...filter }) {
14
+ function PromptIndicator({ basePath = "/api/todos", enabled, className, lookupFetcher, connectionApiBase, autoOpen = false, renderForm, state: _ignoredState, ...filter }) {
15
15
  const { prompts, pending } = require_use_prompts.usePrompts({
16
16
  ...filter,
17
17
  basePath,
@@ -75,7 +75,8 @@ function PromptIndicator({ basePath = "/api/todos", enabled, className, lookupFe
75
75
  open: true,
76
76
  onClose: () => closePrompt(active.id),
77
77
  lookupFetcher,
78
- connectionApiBase
78
+ connectionApiBase,
79
+ renderForm
79
80
  }, active.id) : null] });
80
81
  }
81
82
  exports.PromptIndicator = PromptIndicator;
@@ -1 +1 @@
1
- {"version":3,"file":"PromptIndicator.cjs","names":["usePrompts","useState","useMemo","orderPrompts","summarizePrompts","useRef","_Fragment","DropdownMenu","Button","cn","TEST_OUTCOMES","Icon","UiQuestion","PromptList","PromptDialog"],"sources":["../../src/data/PromptIndicator.tsx"],"sourcesContent":["import { useEffect, useMemo, useRef, useState } from \"react\";\nimport { Button } from \"../components/button\";\nimport { DropdownMenu } from \"../overlay/DropdownMenu\";\nimport { Icon } from \"./Icon\";\nimport { UiQuestion } from \"../icons\";\nimport { cn } from \"../lib/utils\";\nimport { usePrompts, type PromptFilter, type PromptSnapshot } from \"../hooks/use-prompts\";\nimport type { LookupFetcher } from \"../components/json-schema-form-runtime-types\";\nimport { PromptDialog } from \"./PromptDialog\";\nimport { PromptList } from \"./PromptList\";\nimport { orderPrompts, summarizePrompts } from \"./PromptBanner.model\";\nimport { TEST_OUTCOMES } from \"./test-runner/marks\";\n\nexport interface PromptIndicatorProps extends PromptFilter {\n /** Base path the prompt API is mounted under, e.g. \"/api/todos\". */\n basePath?: string | undefined;\n enabled?: boolean | undefined;\n /** Classes for the trigger button. */\n className?: string | undefined;\n /** Passed to the answer dialog to resolve the schema's `x-clicky-lookup` fields. */\n lookupFetcher?: LookupFetcher | undefined;\n /** Passed to the answer dialog so a `format: \"connection\"` field can create the connection it is missing. */\n connectionApiBase?: string | undefined;\n /**\n * Open each prompt's answer dialog once, as soon as it becomes pending:\n * closing it without answering leaves it pending in the panel rather than\n * reopening it.\n */\n autoOpen?: boolean | undefined;\n}\n\n// PromptIndicator is the compact form of PromptBanner for a header: \"N pending\"\n// in amber while prompts wait, a muted \"Prompts\" otherwise. It toggles a panel\n// listing the scope's prompts (pending first), and a pending one opens the\n// answer dialog.\nexport function PromptIndicator({\n basePath = \"/api/todos\",\n enabled,\n className,\n lookupFetcher,\n connectionApiBase,\n autoOpen = false,\n state: _ignoredState,\n ...filter\n}: PromptIndicatorProps) {\n const { prompts, pending } = usePrompts({ ...filter, basePath, ...(enabled !== undefined ? { enabled } : {}) });\n const [active, setActive] = useState<PromptSnapshot | null>(null);\n // An open prompt belongs to the API it came from; answering it on another would post its id there.\n const [activeBase, setActiveBase] = useState(basePath);\n if (activeBase !== basePath) {\n setActiveBase(basePath);\n setActive(null);\n }\n const ordered = useMemo(() => orderPrompts(prompts), [prompts]);\n const count = useMemo(() => summarizePrompts(prompts).pending, [prompts]);\n\n const autoOpened = useRef(new Set<string>());\n const unopened = autoOpen ? pending.find((prompt) => !autoOpened.current.has(prompt.id)) : undefined;\n useEffect(() => {\n if (!unopened || active) return;\n autoOpened.current.add(unopened.id);\n setActive(unopened);\n }, [unopened, active]);\n\n // A dialog's answer can land after it was closed and another opened: clear only the prompt it was for.\n const closePrompt = (id: string) => setActive((current) => (current?.id === id ? null : current));\n\n const label = count > 0 ? `${count} pending` : \"Prompts\";\n return (\n <>\n <DropdownMenu\n role=\"dialog\"\n menuLabel=\"Prompts\"\n align=\"right\"\n menuClassName=\"w-80 max-w-[calc(100vw-2rem)] p-1\"\n trigger={\n <Button\n type=\"button\"\n variant=\"ghost\"\n size=\"sm\"\n title={count > 0 ? `${label} — answer from the list` : \"No pending prompts\"}\n className={cn(\"gap-1.5\", count > 0 ? TEST_OUTCOMES.warned.className : \"text-muted-foreground\", className)}\n >\n <span className=\"relative inline-flex\">\n <Icon icon={UiQuestion} className=\"size-4\" />\n {count > 0 ? (\n <span data-prompt-pulse=\"\" aria-hidden className=\"absolute -right-0.5 -top-0.5 size-1.5 animate-pulse rounded-full bg-current\" />\n ) : null}\n </span>\n {label}\n </Button>\n }\n >\n {(close) =>\n ordered.length === 0 ? (\n <div className=\"px-2 py-1.5 text-xs text-muted-foreground\">No prompts</div>\n ) : (\n <PromptList\n prompts={ordered}\n activeId={active?.id}\n className=\"border-0\"\n onSelect={(prompt) => {\n close();\n setActive(prompt);\n }}\n />\n )\n }\n </DropdownMenu>\n {active ? (\n <PromptDialog\n key={active.id}\n prompt={active}\n basePath={basePath}\n open={true}\n onClose={() => closePrompt(active.id)}\n lookupFetcher={lookupFetcher}\n connectionApiBase={connectionApiBase}\n />\n ) : null}\n </>\n );\n}\n"],"mappings":";;;;;;;;;;;;;AAmCA,SAAgB,gBAAgB,EAC9B,WAAW,cACX,SACA,WACA,eACA,mBACA,WAAW,OACX,OAAO,eACP,GAAG,UACoB;CACvB,MAAM,EAAE,SAAS,YAAYA,oBAAAA,WAAW;EAAE,GAAG;EAAQ;EAAU,GAAI,YAAY,KAAA,IAAY,EAAE,QAAQ,IAAI,CAAC;CAAG,CAAC;CAC9G,MAAM,CAAC,QAAQ,cAAA,GAAaC,MAAAA,SAAAA,CAAgC,IAAI;CAEhE,MAAM,CAAC,YAAY,kBAAA,GAAiBA,MAAAA,SAAAA,CAAS,QAAQ;CACrD,IAAI,eAAe,UAAU;EAC3B,cAAc,QAAQ;EACtB,UAAU,IAAI;CAChB;CACA,MAAM,WAAA,GAAUC,MAAAA,QAAAA,OAAcC,2BAAAA,aAAa,OAAO,GAAG,CAAC,OAAO,CAAC;CAC9D,MAAM,SAAA,GAAQD,MAAAA,QAAAA,OAAcE,2BAAAA,iBAAiB,OAAO,CAAC,CAAC,SAAS,CAAC,OAAO,CAAC;CAExE,MAAM,cAAA,GAAaC,MAAAA,OAAAA,iBAAO,IAAI,IAAY,CAAC;CAC3C,MAAM,WAAW,WAAW,QAAQ,MAAM,W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T,UAAU,QAAQ;GAClB,WAAU;GACV,WAAW,WAAW;IACpB,MAAM;IACN,UAAU,MAAM;GAClB;EACD,CAAA;CAGO,CAAA,GACb,SACC,iBAAA,GAAA,kBAAA,IAAA,CAACC,qBAAAA,cAAD;EAEE,QAAQ;EACE;EACV,MAAM;EACN,eAAe,YAAY,OAAO,EAAE;EACrB;EACI;CACpB,GAPM,OAAO,EAOb,IACC,IACJ,EAAA,CAAA;AAEN"}
1
+ {"version":3,"file":"PromptIndicator.cjs","names":["usePrompts","useState","useMemo","orderPrompts","summarizePrompts","useRef","_Fragment","DropdownMenu","Button","cn","TEST_OUTCOMES","Icon","UiQuestion","PromptList","PromptDialog"],"sources":["../../src/data/PromptIndicator.tsx"],"sourcesContent":["import { useEffect, useMemo, useRef, useState } from \"react\";\nimport { Button } from \"../components/button\";\nimport { DropdownMenu } from \"../overlay/DropdownMenu\";\nimport { Icon } from \"./Icon\";\nimport { UiQuestion } from \"../icons\";\nimport { cn } from \"../lib/utils\";\nimport { usePrompts, type PromptFilter, type PromptSnapshot } from \"../hooks/use-prompts\";\nimport type { LookupFetcher } from \"../components/json-schema-form-runtime-types\";\nimport { PromptDialog, type PromptFormRenderer } from \"./PromptDialog\";\nimport { PromptList } from \"./PromptList\";\nimport { orderPrompts, summarizePrompts } from \"./PromptBanner.model\";\nimport { TEST_OUTCOMES } from \"./test-runner/marks\";\n\nexport interface PromptIndicatorProps extends PromptFilter {\n /** Base path the prompt API is mounted under, e.g. \"/api/todos\". */\n basePath?: string | undefined;\n enabled?: boolean | undefined;\n /** Classes for the trigger button. */\n className?: string | undefined;\n /** Passed to the answer dialog to resolve the schema's `x-clicky-lookup` fields. */\n lookupFetcher?: LookupFetcher | undefined;\n /** Passed to the answer dialog so a `format: \"connection\"` field can create the connection it is missing. */\n connectionApiBase?: string | undefined;\n /**\n * Open each prompt's answer dialog once, as soon as it becomes pending:\n * closing it without answering leaves it pending in the panel rather than\n * reopening it.\n */\n autoOpen?: boolean | undefined;\n /** Passed to the answer dialog: the host's own form for a prompt, or null for PromptForm. */\n renderForm?: PromptFormRenderer | undefined;\n}\n\n// PromptIndicator is the compact form of PromptBanner for a header: \"N pending\"\n// in amber while prompts wait, a muted \"Prompts\" otherwise. It toggles a panel\n// listing the scope's prompts (pending first), and a pending one opens the\n// answer dialog.\nexport function PromptIndicator({\n basePath = \"/api/todos\",\n enabled,\n className,\n lookupFetcher,\n connectionApiBase,\n autoOpen = false,\n renderForm,\n state: _ignoredState,\n ...filter\n}: PromptIndicatorProps) {\n const { prompts, pending } = usePrompts({ ...filter, basePath, ...(enabled !== undefined ? { enabled } : {}) });\n const [active, setActive] = useState<PromptSnapshot | null>(null);\n // An open prompt belongs to the API it came from; answering it on another would post its id there.\n const [activeBase, setActiveBase] = useState(basePath);\n if (activeBase !== basePath) {\n setActiveBase(basePath);\n setActive(null);\n }\n const ordered = useMemo(() => orderPrompts(prompts), [prompts]);\n const count = useMemo(() => summarizePrompts(prompts).pending, [prompts]);\n\n const autoOpened = useRef(new Set<string>());\n const unopened = autoOpen ? pending.find((prompt) => !autoOpened.current.has(prompt.id)) : undefined;\n useEffect(() => {\n if (!unopened || active) return;\n autoOpened.current.add(unopened.id);\n setActive(unopened);\n }, [unopened, active]);\n\n // A dialog's answer can land after it was closed and another opened: clear only the prompt it was for.\n const closePrompt = (id: string) => setActive((current) => (current?.id === id ? null : current));\n\n const label = count > 0 ? `${count} pending` : \"Prompts\";\n return (\n <>\n <DropdownMenu\n role=\"dialog\"\n menuLabel=\"Prompts\"\n align=\"right\"\n menuClassName=\"w-80 max-w-[calc(100vw-2rem)] p-1\"\n trigger={\n <Button\n type=\"button\"\n variant=\"ghost\"\n size=\"sm\"\n title={count > 0 ? `${label} — answer from the list` : \"No pending prompts\"}\n className={cn(\"gap-1.5\", count > 0 ? TEST_OUTCOMES.warned.className : \"text-muted-foreground\", className)}\n >\n <span className=\"relative inline-flex\">\n <Icon icon={UiQuestion} className=\"size-4\" />\n {count > 0 ? (\n <span data-prompt-pulse=\"\" aria-hidden className=\"absolute -right-0.5 -top-0.5 size-1.5 animate-pulse rounded-full bg-current\" />\n ) : null}\n </span>\n {label}\n </Button>\n }\n >\n {(close) =>\n ordered.length === 0 ? (\n <div className=\"px-2 py-1.5 text-xs text-muted-foreground\">No prompts</div>\n ) : (\n <PromptList\n prompts={ordered}\n activeId={active?.id}\n className=\"border-0\"\n onSelect={(prompt) => {\n close();\n setActive(prompt);\n }}\n />\n )\n }\n </DropdownMenu>\n {active ? (\n <PromptDialog\n key={active.id}\n prompt={active}\n basePath={basePath}\n open={true}\n onClose={() => closePrompt(active.id)}\n lookupFetcher={lookupFetcher}\n connectionApiBase={connectionApiBase}\n renderForm={renderForm}\n />\n ) : null}\n </>\n );\n}\n"],"mappings":";;;;;;;;;;;;;AAqCA,SAAgB,gBAAgB,EAC9B,WAAW,cACX,SACA,WACA,eACA,mBACA,WAAW,OACX,YACA,OAAO,eACP,GAAG,UACoB;CACvB,MAAM,EAAE,SAAS,YAAYA,oBAAAA,WAAW;EAAE,GAAG;EAAQ;EAAU,GAAI,YAAY,KAAA,IAAY,EAAE,QAAQ,IAAI,CAAC;CAAG,CAAC;CAC9G,MAAM,CAAC,QAAQ,cAAA,GAAaC,MAAAA,SAAAA,CAAgC,IAAI;CAEhE,MAAM,CAAC,YAAY,kBAAA,GAAiBA,MAAAA,SAAAA,CAAS,QAAQ;CACrD,IAAI,eAAe,UAAU;EAC3B,cAAc,QAAQ;EACtB,UAAU,IAAI;CAChB;CACA,MAAM,WAAA,GAAUC,MAAAA,QAAAA,OAAcC,2BAAAA,aAAa,OAAO,GAAG,CAAC,OAAO,CAAC;CAC9D,MAAM,SAAA,GAAQD,MAAAA,QAAAA,OAAcE,2BAAAA,iBAAiB,OAAO,CAAC,CAAC,SAAS,CAAC,OAAO,CAAC;CAExE,MAAM,cAAA,GAAaC,MAAAA,OAAAA,iBAAO,IAAI,IAAY,CAAC;CAC3C,MAAM,WAAW,WAAW,QAAQ,MAAM,WAAW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AAU,QAAQ;GAClB,WAAU;GACV,WAAW,WAAW;IACpB,MAAM;IACN,UAAU,MAAM;GAClB;EACD,CAAA;CAGO,CAAA,GACb,SACC,iBAAA,GAAA,kBAAA,IAAA,CAACC,qBAAAA,cAAD;EAEE,QAAQ;EACE;EACV,MAAM;EACN,eAAe,YAAY,OAAO,EAAE;EACrB;EACI;EACP;CACb,GARM,OAAO,EAQb,IACC,IACJ,EAAA,CAAA;AAEN"}
@@ -1,5 +1,6 @@
1
1
  import { PromptFilter } from '../hooks/use-prompts.js';
2
2
  import { LookupFetcher } from '../components/json-schema-form-runtime-types.js';
3
+ import { PromptFormRenderer } from './PromptDialog.js';
3
4
  export interface PromptIndicatorProps extends PromptFilter {
4
5
  /** Base path the prompt API is mounted under, e.g. "/api/todos". */
5
6
  basePath?: string | undefined;
@@ -16,6 +17,8 @@ export interface PromptIndicatorProps extends PromptFilter {
16
17
  * reopening it.
17
18
  */
18
19
  autoOpen?: boolean | undefined;
20
+ /** Passed to the answer dialog: the host's own form for a prompt, or null for PromptForm. */
21
+ renderForm?: PromptFormRenderer | undefined;
19
22
  }
20
- export declare function PromptIndicator({ basePath, enabled, className, lookupFetcher, connectionApiBase, autoOpen, state: _ignoredState, ...filter }: PromptIndicatorProps): import("react").JSX.Element;
23
+ export declare function PromptIndicator({ basePath, enabled, className, lookupFetcher, connectionApiBase, autoOpen, renderForm, state: _ignoredState, ...filter }: PromptIndicatorProps): import("react").JSX.Element;
21
24
  //# sourceMappingURL=PromptIndicator.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"PromptIndicator.d.ts","sourceRoot":"","sources":["../../src/data/PromptIndicator.tsx"],"names":[],"mappings":"AAMA,OAAO,EAAc,KAAK,YAAY,EAAuB,MAAM,sBAAsB,CAAC;AAC1F,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,8CAA8C,CAAC;AAMlF,MAAM,WAAW,oBAAqB,SAAQ,YAAY;IACxD,oEAAoE;IACpE,QAAQ,CAAC,EAA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AkB,GAAG,SAAS,CAAC;CAC7C;AAMD,wBAAgB,eAAe,CAAC,EAC9B,QAAuB,EACvB,OAAO,EACP,SAAS,EACT,aAAa,EACb,iBAAiB,EACjB,QAAgB,EAChB,UAAU,EACV,KAAK,EAAE,aAAa,EACpB,GAAG,MAAM,EACV,EAAE,oBAAoB,+BA+EtB"}
@@ -11,7 +11,7 @@ import { TEST_OUTCOMES } from "./test-runner/marks.js";
11
11
  import { useEffect, useMemo, useRef, useState } from "react";
12
12
  import { Fragment as Fragment$1, jsx, jsxs } from "react/jsx-runtime";
13
13
  // src/data/PromptIndicator.tsx
14
- function PromptIndicator({ basePath = "/api/todos", enabled, className, lookupFetcher, connectionApiBase, autoOpen = false, state: _ignoredState, ...filter }) {
14
+ function PromptIndicator({ basePath = "/api/todos", enabled, className, lookupFetcher, connectionApiBase, autoOpen = false, renderForm, state: _ignoredState, ...filter }) {
15
15
  const { prompts, pending } = usePrompts({
16
16
  ...filter,
17
17
  basePath,
@@ -75,7 +75,8 @@ function PromptIndicator({ basePath = "/api/todos", enabled, className, lookupFe
75
75
  open: true,
76
76
  onClose: () => closePrompt(active.id),
77
77
  lookupFetcher,
78
- connectionApiBase
78
+ connectionApiBase,
79
+ renderForm
79
80
  }, active.id) : null] });
80
81
  }
81
82
  export { PromptIndicator };
@@ -1 +1 @@
1
- {"version":3,"file":"PromptIndicator.js","names":["_Fragment"],"sources":["../../src/data/PromptIndicator.tsx"],"sourcesContent":["import { useEffect, useMemo, useRef, useState } from \"react\";\nimport { Button } from \"../components/button\";\nimport { DropdownMenu } from \"../overlay/DropdownMenu\";\nimport { Icon } from \"./Icon\";\nimport { UiQuestion } from \"../icons\";\nimport { cn } from \"../lib/utils\";\nimport { usePrompts, type PromptFilter, type PromptSnapshot } from \"../hooks/use-prompts\";\nimport type { LookupFetcher } from \"../components/json-schema-form-runtime-types\";\nimport { PromptDialog } from \"./PromptDialog\";\nimport { PromptList } from \"./PromptList\";\nimport { orderPrompts, summarizePrompts } from \"./PromptBanner.model\";\nimport { TEST_OUTCOMES } from \"./test-runner/marks\";\n\nexport interface PromptIndicatorProps extends PromptFilter {\n /** Base path the prompt API is mounted under, e.g. \"/api/todos\". */\n basePath?: string | undefined;\n enabled?: boolean | undefined;\n /** Classes for the trigger button. */\n className?: string | undefined;\n /** Passed to the answer dialog to resolve the schema's `x-clicky-lookup` fields. */\n lookupFetcher?: LookupFetcher | undefined;\n /** Passed to the answer dialog so a `format: \"connection\"` field can create the connection it is missing. */\n connectionApiBase?: string | undefined;\n /**\n * Open each prompt's answer dialog once, as soon as it becomes pending:\n * closing it without answering leaves it pending in the panel rather than\n * reopening it.\n */\n autoOpen?: boolean | undefined;\n}\n\n// PromptIndicator is the compact form of PromptBanner for a header: \"N pending\"\n// in amber while prompts wait, a muted \"Prompts\" otherwise. It toggles a panel\n// listing the scope's prompts (pending first), and a pending one opens the\n// answer dialog.\nexport function PromptIndicator({\n basePath = \"/api/todos\",\n enabled,\n className,\n lookupFetcher,\n connectionApiBase,\n autoOpen = false,\n state: _ignoredState,\n ...filter\n}: PromptIndicatorProps) {\n const { prompts, pending } = usePrompts({ ...filter, basePath, ...(enabled !== undefined ? { enabled } : {}) });\n const [active, setActive] = useState<PromptSnapshot | null>(null);\n // An open prompt belongs to the API it came from; answering it on another would post its id there.\n const [activeBase, setActiveBase] = useState(basePath);\n if (activeBase !== basePath) {\n setActiveBase(basePath);\n setActive(null);\n }\n const ordered = useMemo(() => orderPrompts(prompts), [prompts]);\n const count = useMemo(() => summarizePrompts(prompts).pending, [prompts]);\n\n const autoOpened = useRef(new Set<string>());\n const unopened = autoOpen ? pending.find((prompt) => !autoOpened.current.has(prompt.id)) : undefined;\n useEffect(() => {\n if (!unopened || active) return;\n autoOpened.current.add(unopened.id);\n setActive(unopened);\n }, [unopened, active]);\n\n // A dialog's answer can land after it was closed and another opened: clear only the prompt it was for.\n const closePrompt = (id: string) => setActive((current) => (current?.id === id ? null : current));\n\n const label = count > 0 ? `${count} pending` : \"Prompts\";\n return (\n <>\n <DropdownMenu\n role=\"dialog\"\n menuLabel=\"Prompts\"\n align=\"right\"\n menuClassName=\"w-80 max-w-[calc(100vw-2rem)] p-1\"\n trigger={\n <Button\n type=\"button\"\n variant=\"ghost\"\n size=\"sm\"\n title={count > 0 ? `${label} — answer from the list` : \"No pending prompts\"}\n className={cn(\"gap-1.5\", count > 0 ? TEST_OUTCOMES.warned.className : \"text-muted-foreground\", className)}\n >\n <span className=\"relative inline-flex\">\n <Icon icon={UiQuestion} className=\"size-4\" />\n {count > 0 ? (\n <span data-prompt-pulse=\"\" aria-hidden className=\"absolute -right-0.5 -top-0.5 size-1.5 animate-pulse rounded-full bg-current\" />\n ) : null}\n </span>\n {label}\n </Button>\n }\n >\n {(close) =>\n ordered.length === 0 ? (\n <div className=\"px-2 py-1.5 text-xs text-muted-foreground\">No prompts</div>\n ) : (\n <PromptList\n prompts={ordered}\n activeId={active?.id}\n className=\"border-0\"\n onSelect={(prompt) => {\n close();\n setActive(prompt);\n }}\n />\n )\n }\n </DropdownMenu>\n {active ? (\n <PromptDialog\n key={active.id}\n prompt={active}\n basePath={basePath}\n open={true}\n onClose={() => closePrompt(active.id)}\n lookupFetcher={lookupFetcher}\n connectionApiBase={connectionApiBase}\n />\n ) : null}\n </>\n );\n}\n"],"mappings":";;;;;;;;;;;;;AAmCA,SAAgB,gBAAgB,EAC9B,WAAW,cACX,SACA,WACA,eACA,mBACA,WAAW,OACX,OAAO,eACP,GAAG,UACoB;CACvB,MAAM,EAAE,SAAS,YAAY,WAAW;EAAE,GAAG;EAAQ;EAAU,GAAI,YAAY,KAAA,IAAY,EAAE,QAAQ,IAAI,CAAC;CAAG,CAAC;CAC9G,MAAM,CAAC,QAAQ,aAAa,SAAgC,IAAI;CAEhE,MAAM,CAAC,YAAY,iBAAiB,SAAS,QAAQ;CACrD,IAAI,eAAe,UAAU;EAC3B,cAAc,QAAQ;EACtB,UAAU,IAAI;CAChB;CACA,MAAM,UAAU,cAAc,aAAa,O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GACb,SACC,oBAAC,cAAD;EAEE,QAAQ;EACE;EACV,MAAM;EACN,eAAe,YAAY,OAAO,EAAE;EACrB;EACI;CACpB,GAPM,OAAO,EAOb,IACC,IACJ,EAAA,CAAA;AAEN"}
1
+ {"version":3,"file":"PromptIndicator.js","names":["_Fragment"],"sources":["../../src/data/PromptIndicator.tsx"],"sourcesContent":["import { useEffect, useMemo, useRef, useState } from \"react\";\nimport { Button } from \"../components/button\";\nimport { DropdownMenu } from \"../overlay/DropdownMenu\";\nimport { Icon } from \"./Icon\";\nimport { UiQuestion } from \"../icons\";\nimport { cn } from \"../lib/utils\";\nimport { usePrompts, type PromptFilter, type PromptSnapshot } from \"../hooks/use-prompts\";\nimport type { LookupFetcher } from \"../components/json-schema-form-runtime-types\";\nimport { PromptDialog, type PromptFormRenderer } from \"./PromptDialog\";\nimport { PromptList } from \"./PromptList\";\nimport { orderPrompts, summarizePrompts } from \"./PromptBanner.model\";\nimport { TEST_OUTCOMES } from \"./test-runner/marks\";\n\nexport interface PromptIndicatorProps extends PromptFilter {\n /** Base path the prompt API is mounted under, e.g. \"/api/todos\". */\n basePath?: string | undefined;\n enabled?: boolean | undefined;\n /** Classes for the trigger button. */\n className?: string | undefined;\n /** Passed to the answer dialog to resolve the schema's `x-clicky-lookup` fields. */\n lookupFetcher?: LookupFetcher | undefined;\n /** Passed to the answer dialog so a `format: \"connection\"` field can create the connection it is missing. */\n connectionApiBase?: string | undefined;\n /**\n * Open each prompt's answer dialog once, as soon as it becomes pending:\n * closing it without answering leaves it pending in the panel rather than\n * reopening it.\n */\n autoOpen?: boolean | undefined;\n /** Passed to the answer dialog: the host's own form for a prompt, or null for PromptForm. */\n renderForm?: PromptFormRenderer | undefined;\n}\n\n// PromptIndicator is the compact form of PromptBanner for a header: \"N pending\"\n// in amber while prompts wait, a muted \"Prompts\" otherwise. It toggles a panel\n// listing the scope's prompts (pending first), and a pending one opens the\n// answer dialog.\nexport function PromptIndicator({\n basePath = \"/api/todos\",\n enabled,\n className,\n lookupFetcher,\n connectionApiBase,\n autoOpen = false,\n renderForm,\n state: _ignoredState,\n ...filter\n}: PromptIndicatorProps) {\n const { prompts, pending } = usePrompts({ ...filter, basePath, ...(enabled !== undefined ? { enabled } : {}) });\n const [active, setActive] = useState<PromptSnapshot | null>(null);\n // An open prompt belongs to the API it came from; answering it on another would post its id there.\n const [activeBase, setActiveBase] = useState(basePath);\n if (activeBase !== basePath) {\n setActiveBase(basePath);\n setActive(null);\n }\n const ordered = useMemo(() => orderPrompts(prompts), [prompts]);\n const count = useMemo(() => summarizePrompts(prompts).pending, [prompts]);\n\n const autoOpened = useRef(new Set<string>());\n const unopened = autoOpen ? pending.find((prompt) => !autoOpened.current.has(prompt.id)) : undefined;\n useEffect(() => {\n if (!unopened || active) return;\n autoOpened.current.add(unopened.id);\n setActive(unopened);\n }, [unopened, active]);\n\n // A dialog's answer can land after it was closed and another opened: clear only the prompt it was for.\n const closePrompt = (id: string) => setActive((current) => (current?.id === id ? null : current));\n\n const label = count > 0 ? `${count} pending` : \"Prompts\";\n return (\n <>\n <DropdownMenu\n role=\"dialog\"\n menuLabel=\"Prompts\"\n align=\"right\"\n menuClassName=\"w-80 max-w-[calc(100vw-2rem)] p-1\"\n trigger={\n <Button\n type=\"button\"\n variant=\"ghost\"\n size=\"sm\"\n title={count > 0 ? `${label} — answer from the list` : \"No pending prompts\"}\n className={cn(\"gap-1.5\", count > 0 ? TEST_OUTCOMES.warned.className : \"text-muted-foreground\", className)}\n >\n <span className=\"relative inline-flex\">\n <Icon icon={UiQuestion} className=\"size-4\" />\n {count > 0 ? (\n <span data-prompt-pulse=\"\" aria-hidden className=\"absolute -right-0.5 -top-0.5 size-1.5 animate-pulse rounded-full bg-current\" />\n ) : null}\n </span>\n {label}\n </Button>\n }\n >\n {(close) =>\n ordered.length === 0 ? (\n <div className=\"px-2 py-1.5 text-xs text-muted-foreground\">No prompts</div>\n ) : (\n <PromptList\n prompts={ordered}\n activeId={active?.id}\n className=\"border-0\"\n onSelect={(prompt) => {\n close();\n setActive(prompt);\n }}\n />\n )\n }\n </DropdownMenu>\n {active ? (\n <PromptDialog\n key={active.id}\n prompt={active}\n basePath={basePath}\n open={true}\n onClose={() => closePrompt(active.id)}\n lookupFetcher={lookupFetcher}\n connectionApiBase={connectionApiBase}\n renderForm={renderForm}\n />\n ) : null}\n </>\n );\n}\n"],"mappings":";;;;;;;;;;;;;AAqCA,SAAgB,gBAAgB,EAC9B,WAAW,cACX,SACA,WACA,eACA,mBACA,WAAW,OACX,YACA,OAAO,eACP,GAAG,UACoB;CACvB,MAAM,EAAE,SAAS,YAAY,WAAW;EAAE,GAAG;EAAQ;EAAU,GAAI,YAAY,KAAA,IAAY,EAAE,QAAQ,IAAI,CAAC;CAAG,CAAC;CAC9G,MAAM,CAAC,QAAQ,aAAa,SAAgC,IAAI;CAEhE,MAAM,CAAC,YAAY,iBAAiB,SAAS,QAAQ;CACrD,IAAI,eAAe,UAAU;EAC3B,cAAc,QAAQ;EACtB,UAAU,IAAI;CAChB;CACA,MAAM,UAAU,cAAc,aAAa,OAAO,GAAG,CAAC,OAAO,CAAC;CAC9D,MAAM,QAAQ,cAAc,iBAAiB,OAAO,CAAC,CAAC,SAAS,CAAC,OAAO,CAAC;CAExE,MAAM,aAAa,uBAAO,IAAI,IAAY,CAAC;CAC3C,MAAM,WAAW,WAAW,QAAQ,MAAM,WAAW,CAAC,WAAW,QAAQ,IAAI,OAAO,EAAE,CAAC,IAAI,KAAA;CAC3F,gBAAgB;EACd,IAAI,CAAC,YAAY,QAAQ;EACzB,WAAW,QAAQ,IAAI,SAAS,EAAE;EAClC,UAAU,QAAQ;CACpB,GAAG,CAAC,UAAU,MAAM,CAAC;CAGrB,MAAM,eAAe,OAAe,WAAW,YAAa,SAAS,OAAO,KAAK,OAAO,OAAQ;CAEhG,MAAM,QAAQ,QAAQ,IAAI,GAAG,MAAM,YAAY;CAC/C,OACE,qBAAAA,YAAA,EAAA,UAAA,CACE,oBAAC,cAAD;EACE,MAAK;EACL,WAAU;EACV,OAAM;EACN,eAAc;EACd,SACE,qBAAC,QAAD;GACE,MAAK;GACL,SAAQ;GACR,MAAK;GACL,OAAO,QAAQ,IAAI,GAAG,MAAM,2BAA2B;GACvD,WAAW,GAAG,WAAW,QAAQ,IAAI,cAAc,OAAO,YAAY,yBAAyB,SAAS;GAL1G,UAAA,CAOE,qBAAC,QAAD;IAAM,WAAU;IAAhB,UAAA,CACE,oBAAC,MAAD;KAAM,MAAM;KAAY,WAAU;IAAU,CAAA,GAC3C,QAAQ,IACP,oBAAC,QAAD;KAAM,qBAAkB;KAAG,eAAA;KAAY,WAAU;IAA+E,CAAA,IAC9H,IACA;GACL,CAAA,GAAA,KACK;;EAGR,WAAA,UACA,QAAQ,WAAW,IACjB,oBAAC,OAAD;GAAK,WAAU;GAA4C,UAAA;EAAe,CAAA,IAE1E,oBAAC,YAAD;GACE,SAAS;GACT,UAAU,QAAQ;GAClB,WAAU;GACV,WAAW,WAAW;IACpB,MAAM;IACN,UAAU,MAAM;GAClB;EACD,CAAA;CAGO,CAAA,GACb,SACC,oBAAC,cAAD;EAEE,QAAQ;EACE;EACV,MAAM;EACN,eAAe,YAAY,OAAO,EAAE;EACrB;EACI;EACP;CACb,GARM,OAAO,EAQb,IACC,IACJ,EAAA,CAAA;AAEN"}
@@ -12,27 +12,14 @@ let react = require("react");
12
12
  let react_jsx_runtime = require("react/jsx-runtime");
13
13
  // src/data/diagnostics/ErrorDetails.tsx
14
14
  function ErrorDetails({ diagnostics, title = "Error", renderJsonContext, actions, announce = false, className }) {
15
- const [copyState, setCopyState] = (0, react.useState)("idle");
16
- const scalarContext = diagnostics.context.filter(([, value]) => !require_error_diagnostics.parseInlineJsonContextValue(value));
17
- const jsonContext = diagnostics.context.map(([label, value]) => ({
18
- label,
19
- value,
20
- data: require_error_diagnostics.parseInlineJsonContextValue(value)
21
- })).filter((entry) => entry.data !== null);
22
- const copyDiagnostics = async (event) => {
23
- event.preventDefault();
24
- event.stopPropagation();
25
- try {
26
- await require_clipboard.copyText(diagnosticReport(diagnostics, title));
27
- setCopyState("copied");
28
- } catch {
29
- setCopyState("failed");
30
- }
31
- };
32
- return /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("details", {
15
+ const expandable = hasExpandableContent(diagnostics);
16
+ const Root = expandable ? "details" : "div";
17
+ const Summary = expandable ? "summary" : "div";
18
+ return /* @__PURE__ */ (0, react_jsx_runtime.jsxs)(Root, {
33
19
  className: require_utils.cn("@container/error-details group min-w-0 rounded-md border border-destructive/30 bg-destructive/5", className),
34
- children: [/* @__PURE__ */ (0, react_jsx_runtime.jsxs)("summary", {
35
- className: "flex cursor-pointer list-none flex-wrap items-start gap-2 p-3",
20
+ "data-error-details": "",
21
+ children: [/* @__PURE__ */ (0, react_jsx_runtime.jsxs)(Summary, {
22
+ className: require_utils.cn("flex list-none flex-wrap items-start gap-2 p-3", expandable && "cursor-pointer"),
36
23
  children: [
37
24
  /* @__PURE__ */ (0, react_jsx_runtime.jsx)(require_Icon.Icon, {
38
25
  icon: require_UiWarningTriangle.UiWarningTriangle,
@@ -57,18 +44,11 @@ function ErrorDetails({ diagnostics, title = "Error", renderJsonContext, actions
57
44
  onClick: (event) => event.preventDefault(),
58
45
  children: actions
59
46
  }),
60
- /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("button", {
61
- type: "button",
62
- "aria-label": copyState === "copied" ? "Copied" : copyState === "failed" ? "Copy failed" : "Copy error details",
63
- title: "Copy message, trace, time, context, and stack trace",
64
- className: "inline-flex items-center gap-1 hover:text-foreground",
65
- onClick: (event) => void copyDiagnostics(event),
66
- children: [/* @__PURE__ */ (0, react_jsx_runtime.jsx)(require_Icon.Icon, { icon: copyState === "copied" ? require_UiCheck.UiCheck : require_UiCopy.UiCopy }), /* @__PURE__ */ (0, react_jsx_runtime.jsx)("span", {
67
- "aria-live": "polite",
68
- children: copyState === "copied" ? "Copied" : copyState === "failed" ? "Copy failed" : "Copy"
69
- })]
47
+ /* @__PURE__ */ (0, react_jsx_runtime.jsx)(CopyDiagnosticsButton, {
48
+ diagnostics,
49
+ title
70
50
  }),
71
- /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("span", {
51
+ expandable && /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("span", {
72
52
  className: "inline-flex items-center gap-1 hover:text-foreground",
73
53
  children: [
74
54
  /* @__PURE__ */ (0, react_jsx_runtime.jsx)("span", {
@@ -88,84 +68,136 @@ function ErrorDetails({ diagnostics, title = "Error", renderJsonContext, actions
88
68
  ]
89
69
  })
90
70
  ]
91
- }), /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("div", {
92
- className: "grid gap-3 border-t border-destructive/20 p-3 pt-2",
93
- children: [
94
- (diagnostics.trace || diagnostics.time) && /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("div", {
95
- className: "flex min-w-0 flex-wrap gap-2",
96
- children: [diagnostics.trace && /* @__PURE__ */ (0, react_jsx_runtime.jsx)(CopyBadge, {
97
- label: "Trace",
98
- value: diagnostics.trace,
99
- className: "max-w-full"
100
- }), diagnostics.time && /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("span", {
101
- className: "inline-flex max-w-full items-center overflow-hidden rounded-md border border-border bg-background/80 text-xs",
102
- children: [/* @__PURE__ */ (0, react_jsx_runtime.jsx)("span", {
103
- className: "shrink-0 bg-muted px-2 py-1 font-medium text-muted-foreground",
104
- children: "Time"
105
- }), /* @__PURE__ */ (0, react_jsx_runtime.jsx)("span", {
106
- className: "min-w-0 truncate px-2 py-1 font-mono text-foreground",
107
- children: diagnostics.time
108
- })]
109
- })]
110
- }),
111
- diagnostics.context.length > 0 && /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("div", {
112
- className: "min-w-0",
113
- children: [
114
- /* @__PURE__ */ (0, react_jsx_runtime.jsx)("div", {
115
- className: "mb-1.5 text-xs font-semibold uppercase tracking-wide text-muted-foreground",
116
- children: "Context"
117
- }),
118
- scalarContext.length > 0 && /* @__PURE__ */ (0, react_jsx_runtime.jsx)("div", {
119
- className: "flex flex-wrap gap-1.5",
120
- children: scalarContext.map(([label, value]) => /* @__PURE__ */ (0, react_jsx_runtime.jsx)(CopyBadge, {
121
- label,
122
- value
123
- }, `${label}:${value}`))
124
- }),
125
- jsonContext.length > 0 && /* @__PURE__ */ (0, react_jsx_runtime.jsx)("div", {
126
- className: "mt-2 grid gap-2",
127
- children: jsonContext.map((entry) => renderJsonContext ? /* @__PURE__ */ (0, react_jsx_runtime.jsx)("span", { children: renderJsonContext(entry) }, `${entry.label}:${entry.value}`) : /* @__PURE__ */ (0, react_jsx_runtime.jsx)(CopyBadge, {
128
- label: entry.label,
129
- value: entry.value
130
- }, `${entry.label}:${entry.value}`))
131
- })
132
- ]
133
- }),
134
- diagnostics.details?.map((detail) => /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("div", {
135
- className: "min-w-0",
136
- children: [/* @__PURE__ */ (0, react_jsx_runtime.jsxs)("div", {
137
- className: "mb-1.5 flex min-w-0 items-center justify-between gap-3",
138
- children: [/* @__PURE__ */ (0, react_jsx_runtime.jsx)("div", {
139
- className: "text-xs font-semibold uppercase tracking-wide text-muted-foreground",
140
- children: detail.label
141
- }), /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("button", {
142
- type: "button",
143
- onClick: () => copyText(detail.value),
144
- className: "inline-flex items-center gap-1 text-xs font-medium text-muted-foreground hover:text-foreground",
145
- children: [/* @__PURE__ */ (0, react_jsx_runtime.jsx)(require_Icon.Icon, { icon: require_UiCopy.UiCopy }), "copy"]
146
- })]
147
- }), /* @__PURE__ */ (0, react_jsx_runtime.jsx)("pre", {
148
- className: "max-h-64 overflow-auto whitespace-pre-wrap break-all rounded-md bg-muted p-2 font-mono text-xs leading-5 text-foreground",
149
- children: detail.value
71
+ }), expandable && /* @__PURE__ */ (0, react_jsx_runtime.jsx)(ErrorDetailsBody, {
72
+ diagnostics,
73
+ renderJsonContext
74
+ })]
75
+ });
76
+ }
77
+ function hasExpandableContent(d) {
78
+ return !!(d.trace || d.time || d.stacktrace || d.context.length > 0 || d.details?.length);
79
+ }
80
+ function CopyDiagnosticsButton({ diagnostics, title }) {
81
+ const [copyState, setCopyState] = (0, react.useState)("idle");
82
+ const copyDiagnostics = async (event) => {
83
+ event.preventDefault();
84
+ event.stopPropagation();
85
+ try {
86
+ await require_clipboard.copyText(diagnosticReport(diagnostics, title));
87
+ setCopyState("copied");
88
+ } catch {
89
+ setCopyState("failed");
90
+ }
91
+ };
92
+ return /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("button", {
93
+ type: "button",
94
+ "aria-label": COPY_ARIA_LABEL[copyState],
95
+ title: "Copy message, trace, time, context, and stack trace",
96
+ className: "inline-flex items-center gap-1 hover:text-foreground",
97
+ onClick: (event) => void copyDiagnostics(event),
98
+ children: [/* @__PURE__ */ (0, react_jsx_runtime.jsx)(require_Icon.Icon, { icon: copyState === "copied" ? require_UiCheck.UiCheck : require_UiCopy.UiCopy }), /* @__PURE__ */ (0, react_jsx_runtime.jsx)("span", {
99
+ "aria-live": "polite",
100
+ children: COPY_TEXT[copyState]
101
+ })]
102
+ });
103
+ }
104
+ var COPY_ARIA_LABEL = {
105
+ idle: "Copy error details",
106
+ copied: "Copied",
107
+ failed: "Copy failed"
108
+ };
109
+ var COPY_TEXT = {
110
+ idle: "Copy",
111
+ copied: "Copied",
112
+ failed: "Copy failed"
113
+ };
114
+ function ErrorDetailsBody({ diagnostics, renderJsonContext }) {
115
+ return /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("div", {
116
+ className: "grid gap-3 border-t border-destructive/20 p-3 pt-2",
117
+ children: [
118
+ (diagnostics.trace || diagnostics.time) && /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("div", {
119
+ className: "flex min-w-0 flex-wrap gap-2",
120
+ children: [diagnostics.trace && /* @__PURE__ */ (0, react_jsx_runtime.jsx)(CopyBadge, {
121
+ label: "Trace",
122
+ value: diagnostics.trace,
123
+ className: "max-w-full"
124
+ }), diagnostics.time && /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("span", {
125
+ className: "inline-flex max-w-full items-center overflow-hidden rounded-md border border-border bg-background/80 text-xs",
126
+ children: [/* @__PURE__ */ (0, react_jsx_runtime.jsx)("span", {
127
+ className: "shrink-0 bg-muted px-2 py-1 font-medium text-muted-foreground",
128
+ children: "Time"
129
+ }), /* @__PURE__ */ (0, react_jsx_runtime.jsx)("span", {
130
+ className: "min-w-0 truncate px-2 py-1 font-mono text-foreground",
131
+ children: diagnostics.time
150
132
  })]
151
- }, detail.label)),
152
- diagnostics.stacktrace && /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("div", {
153
- className: "min-w-0",
154
- children: [/* @__PURE__ */ (0, react_jsx_runtime.jsxs)("div", {
155
- className: "mb-1.5 flex min-w-0 items-center justify-between gap-3",
156
- children: [/* @__PURE__ */ (0, react_jsx_runtime.jsx)("div", {
157
- className: "text-xs font-semibold uppercase tracking-wide text-muted-foreground",
158
- children: "Stack trace"
159
- }), /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("button", {
160
- type: "button",
161
- onClick: () => copyText(diagnostics.stacktrace ?? ""),
162
- className: "inline-flex items-center gap-1 text-xs font-medium text-muted-foreground hover:text-foreground",
163
- children: [/* @__PURE__ */ (0, react_jsx_runtime.jsx)(require_Icon.Icon, { icon: require_UiCopy.UiCopy }), "copy"]
164
- })]
165
- }), /* @__PURE__ */ (0, react_jsx_runtime.jsx)(PrettyStackTrace, { stacktrace: diagnostics.stacktrace })]
133
+ })]
134
+ }),
135
+ diagnostics.context.length > 0 && /* @__PURE__ */ (0, react_jsx_runtime.jsx)(ErrorContext, {
136
+ context: diagnostics.context,
137
+ renderJsonContext
138
+ }),
139
+ diagnostics.details?.map((detail) => /* @__PURE__ */ (0, react_jsx_runtime.jsx)(DetailSection, {
140
+ label: detail.label,
141
+ copyValue: detail.value,
142
+ children: /* @__PURE__ */ (0, react_jsx_runtime.jsx)("pre", {
143
+ className: "max-h-64 overflow-auto whitespace-pre-wrap break-all rounded-md bg-muted p-2 font-mono text-xs leading-5 text-foreground",
144
+ children: detail.value
166
145
  })
167
- ]
168
- })]
146
+ }, detail.label)),
147
+ diagnostics.stacktrace && /* @__PURE__ */ (0, react_jsx_runtime.jsx)(DetailSection, {
148
+ label: "Stack trace",
149
+ copyValue: diagnostics.stacktrace,
150
+ children: /* @__PURE__ */ (0, react_jsx_runtime.jsx)(PrettyStackTrace, { stacktrace: diagnostics.stacktrace })
151
+ })
152
+ ]
153
+ });
154
+ }
155
+ function ErrorContext({ context, renderJsonContext }) {
156
+ const scalarContext = context.filter(([, value]) => !require_error_diagnostics.parseInlineJsonContextValue(value));
157
+ const jsonContext = context.map(([label, value]) => ({
158
+ label,
159
+ value,
160
+ data: require_error_diagnostics.parseInlineJsonContextValue(value)
161
+ })).filter((entry) => entry.data !== null);
162
+ return /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("div", {
163
+ className: "min-w-0",
164
+ children: [
165
+ /* @__PURE__ */ (0, react_jsx_runtime.jsx)("div", {
166
+ className: "mb-1.5 text-xs font-semibold uppercase tracking-wide text-muted-foreground",
167
+ children: "Context"
168
+ }),
169
+ scalarContext.length > 0 && /* @__PURE__ */ (0, react_jsx_runtime.jsx)("div", {
170
+ className: "flex flex-wrap gap-1.5",
171
+ children: scalarContext.map(([label, value]) => /* @__PURE__ */ (0, react_jsx_runtime.jsx)(CopyBadge, {
172
+ label,
173
+ value
174
+ }, `${label}:${value}`))
175
+ }),
176
+ jsonContext.length > 0 && /* @__PURE__ */ (0, react_jsx_runtime.jsx)("div", {
177
+ className: "mt-2 grid gap-2",
178
+ children: jsonContext.map((entry) => renderJsonContext ? /* @__PURE__ */ (0, react_jsx_runtime.jsx)("span", { children: renderJsonContext(entry) }, `${entry.label}:${entry.value}`) : /* @__PURE__ */ (0, react_jsx_runtime.jsx)(CopyBadge, {
179
+ label: entry.label,
180
+ value: entry.value
181
+ }, `${entry.label}:${entry.value}`))
182
+ })
183
+ ]
184
+ });
185
+ }
186
+ function DetailSection({ label, copyValue, children }) {
187
+ return /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("div", {
188
+ className: "min-w-0",
189
+ children: [/* @__PURE__ */ (0, react_jsx_runtime.jsxs)("div", {
190
+ className: "mb-1.5 flex min-w-0 items-center justify-between gap-3",
191
+ children: [/* @__PURE__ */ (0, react_jsx_runtime.jsx)("div", {
192
+ className: "text-xs font-semibold uppercase tracking-wide text-muted-foreground",
193
+ children: label
194
+ }), /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("button", {
195
+ type: "button",
196
+ onClick: () => copyText(copyValue),
197
+ className: "inline-flex items-center gap-1 text-xs font-medium text-muted-foreground hover:text-foreground",
198
+ children: [/* @__PURE__ */ (0, react_jsx_runtime.jsx)(require_Icon.Icon, { icon: require_UiCopy.UiCopy }), "copy"]
199
+ })]
200
+ }), children]
169
201
  });
170
202
  }
171
203
  function diagnosticReport(diagnostics, title) {
@@ -204,10 +236,10 @@ function PrettyStackTrace({ stacktrace }) {
204
236
  }),
205
237
  /* @__PURE__ */ (0, react_jsx_runtime.jsx)("div", {
206
238
  className: "space-y-0.5",
207
- children: parsed.frames.map((frame, index) => /* @__PURE__ */ (0, react_jsx_runtime.jsx)(StackFrameRow, {
239
+ children: keyStackFrames(parsed.frames).map(({ key, frame, position }) => /* @__PURE__ */ (0, react_jsx_runtime.jsx)(StackFrameRow, {
208
240
  frame,
209
- index
210
- }, `${frame.file}:${frame.line}:${index}`))
241
+ index: position
242
+ }, key))
211
243
  }),
212
244
  parsed.unparsed.length > 0 && /* @__PURE__ */ (0, react_jsx_runtime.jsx)("pre", {
213
245
  className: "mt-2 whitespace-pre-wrap rounded bg-muted p-2 font-mono text-[11px] leading-4 text-muted-foreground",
@@ -216,6 +248,19 @@ function PrettyStackTrace({ stacktrace }) {
216
248
  ]
217
249
  });
218
250
  }
251
+ function keyStackFrames(frames) {
252
+ const seen = /* @__PURE__ */ new Map();
253
+ return frames.map((frame, position) => {
254
+ const base = `${frame.file}:${frame.line}:${frame.functionName}`;
255
+ const occurrence = seen.get(base) ?? 0;
256
+ seen.set(base, occurrence + 1);
257
+ return {
258
+ key: `${base}#${occurrence}`,
259
+ frame,
260
+ position
261
+ };
262
+ });
263
+ }
219
264
  function StackFrameRow({ frame, index }) {
220
265
  const appFrame = require_error_diagnostics.isApplicationStackFrame(frame.file);
221
266
  return /* @__PURE__ */ (0, react_jsx_runtime.jsx)("button", {