@jini-ai/chat 0.7.2 → 0.7.3-next.2

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 (202) hide show
  1. package/CHANGELOG.md +2 -2
  2. package/README.md +3 -3
  3. package/dist/contracts/chat-bubble-style.d.ts +1 -1
  4. package/dist/contracts/chat-bubble-style.js +1 -1
  5. package/dist/core/ag-ui/event-projection.d.ts +125 -0
  6. package/dist/core/ag-ui/event-projection.js +275 -0
  7. package/dist/core/ag-ui/event-reduction.d.ts +39 -0
  8. package/dist/core/ag-ui/event-reduction.js +99 -0
  9. package/dist/core/ag-ui/run-input.d.ts +53 -0
  10. package/dist/core/ag-ui/run-input.js +87 -0
  11. package/dist/core/agentic/chat-capabilities.d.ts +1 -1
  12. package/dist/core/agentic/index.d.ts +2 -4
  13. package/dist/core/agentic/index.js +2 -3
  14. package/dist/core/agents-port.d.ts +50 -0
  15. package/dist/core/agents-port.js +2 -0
  16. package/dist/core/assistant-client/ag-ui-fetch-agent.d.ts +16 -0
  17. package/dist/core/assistant-client/ag-ui-fetch-agent.js +24 -0
  18. package/dist/core/assistant-client/ag-ui-transport.d.ts +15 -1
  19. package/dist/core/assistant-client/ag-ui-transport.js +167 -145
  20. package/dist/core/assistant-client/attachment-liveness.js +13 -11
  21. package/dist/core/assistant-client/durable-run-subscription.d.ts +3 -2
  22. package/dist/core/assistant-client/durable-run-subscription.js +6 -5
  23. package/dist/core/assistant-client/messages.d.ts +7 -4
  24. package/dist/core/assistant-client/messages.js +5 -4
  25. package/dist/core/assistant-client/transport.d.ts +1 -1
  26. package/dist/core/assistant-client/transport.js +4 -4
  27. package/dist/core/index.d.ts +2 -0
  28. package/dist/core/index.js +1 -0
  29. package/dist/core/page-port.d.ts +15 -0
  30. package/dist/core/page-port.js +2 -0
  31. package/dist/core/run-activity.js +1 -1
  32. package/dist/core/run-events/entry.js +1 -0
  33. package/dist/core/user-text-redaction.d.ts +1 -3
  34. package/dist/core/user-text-redaction.js +3 -61
  35. package/dist/embed-widget/browser/agent-inventory.d.ts +37 -0
  36. package/dist/embed-widget/browser/agent-inventory.js +36 -0
  37. package/dist/embed-widget/browser/frontend-session-bridge.d.ts +2 -2
  38. package/dist/embed-widget/browser/frontend-session-bridge.js +17 -14
  39. package/dist/embed-widget/react/dialog.hooks.d.ts +16 -0
  40. package/dist/embed-widget/react/dialog.hooks.js +15 -0
  41. package/dist/embed-widget/react/embed.d.ts +7 -2
  42. package/dist/embed-widget/react/embed.js +6 -16
  43. package/dist/embed-widget/react/header.d.ts +4 -1
  44. package/dist/embed-widget/react/header.js +2 -2
  45. package/dist/embed-widget/vanilla/state.js +2 -2
  46. package/dist/embed-widget/vanilla/style.css +4 -4
  47. package/dist/react/components/A2uiSurfaceCard.d.ts +18 -4
  48. package/dist/react/components/A2uiSurfaceCard.hooks.d.ts +36 -0
  49. package/dist/react/components/A2uiSurfaceCard.hooks.js +174 -0
  50. package/dist/react/components/A2uiSurfaceCard.js +14 -227
  51. package/dist/react/components/A2uiSurfaceCard.rules.d.ts +14 -0
  52. package/dist/react/components/A2uiSurfaceCard.rules.js +24 -0
  53. package/dist/react/components/AttachmentPreviewModal.d.ts +21 -1
  54. package/dist/react/components/AttachmentPreviewModal.hooks.js +1 -3
  55. package/dist/react/components/AttachmentPreviewModal.js +11 -9
  56. package/dist/react/components/AttachmentTray.d.ts +11 -1
  57. package/dist/react/components/AttachmentTray.js +12 -8
  58. package/dist/react/components/ChatFab.d.ts +10 -1
  59. package/dist/react/components/ChatFab.js +2 -2
  60. package/dist/react/components/ChatSettingsDialog.d.ts +4 -3
  61. package/dist/react/components/ChatSettingsDialog.js +9 -6
  62. package/dist/react/components/ChatSettingsSegmented.d.ts +1 -1
  63. package/dist/react/components/ChatSettingsSegmented.js +1 -1
  64. package/dist/react/components/Composer.d.ts +9 -1
  65. package/dist/react/components/Composer.hooks.d.ts +79 -0
  66. package/dist/react/components/Composer.hooks.js +336 -0
  67. package/dist/react/components/Composer.js +40 -341
  68. package/dist/react/components/ComposerDiscovery.js +1 -1
  69. package/dist/react/components/ConversationList.d.ts +34 -1
  70. package/dist/react/components/ConversationList.hooks.d.ts +37 -0
  71. package/dist/react/components/ConversationList.hooks.js +177 -1
  72. package/dist/react/components/ConversationList.js +7 -174
  73. package/dist/react/components/ConversationTitleEditor.d.ts +17 -2
  74. package/dist/react/components/ConversationTitleEditor.hooks.d.ts +15 -0
  75. package/dist/react/components/ConversationTitleEditor.hooks.js +36 -0
  76. package/dist/react/components/ConversationTitleEditor.js +11 -34
  77. package/dist/react/components/CopyMessageButton.d.ts +6 -1
  78. package/dist/react/components/CopyMessageButton.js +4 -4
  79. package/dist/react/components/ExtEventErrorBoundary.d.ts +2 -0
  80. package/dist/react/components/ExtEventErrorBoundary.js +5 -3
  81. package/dist/react/components/FolderChips.d.ts +11 -1
  82. package/dist/react/components/FolderChips.hooks.d.ts +12 -0
  83. package/dist/react/components/FolderChips.hooks.js +10 -0
  84. package/dist/react/components/FolderChips.js +9 -9
  85. package/dist/react/components/Markdown.js +7 -5
  86. package/dist/react/components/McpUiSurfaceCard.d.ts +29 -5
  87. package/dist/react/components/McpUiSurfaceCard.js +29 -16
  88. package/dist/react/components/MessageList.d.ts +10 -1
  89. package/dist/react/components/MessageList.hooks.js +4 -2
  90. package/dist/react/components/MessageList.js +12 -8
  91. package/dist/react/components/MessageRow.d.ts +46 -2
  92. package/dist/react/components/MessageRow.hooks.d.ts +60 -0
  93. package/dist/react/components/MessageRow.hooks.js +94 -0
  94. package/dist/react/components/MessageRow.js +53 -113
  95. package/dist/react/components/MidRunUserMessage.d.ts +6 -1
  96. package/dist/react/components/MidRunUserMessage.js +5 -5
  97. package/dist/react/components/NextStepActions.d.ts +3 -1
  98. package/dist/react/components/NextStepActions.js +3 -3
  99. package/dist/react/components/QuestionForm.answers.hooks.d.ts +26 -0
  100. package/dist/react/components/QuestionForm.answers.hooks.js +89 -0
  101. package/dist/react/components/QuestionForm.d.ts +6 -0
  102. package/dist/react/components/QuestionForm.js +23 -261
  103. package/dist/react/components/QuestionForm.values.d.ts +22 -0
  104. package/dist/react/components/QuestionForm.values.js +58 -0
  105. package/dist/react/components/QuestionFormField.d.ts +17 -0
  106. package/dist/react/components/QuestionFormField.js +114 -0
  107. package/dist/react/components/QuestionsPanel.d.ts +3 -1
  108. package/dist/react/components/QuestionsPanel.js +7 -3
  109. package/dist/react/components/SentAttachment.d.ts +11 -2
  110. package/dist/react/components/SentAttachment.hooks.d.ts +1 -1
  111. package/dist/react/components/SentAttachment.hooks.js +6 -5
  112. package/dist/react/components/SentAttachment.js +5 -3
  113. package/dist/react/components/TodoCard.d.ts +3 -1
  114. package/dist/react/components/TodoCard.js +9 -4
  115. package/dist/react/components/ToolCallGroup.d.ts +11 -1
  116. package/dist/react/components/ToolCallGroup.js +10 -4
  117. package/dist/react/components/ToolCard.d.ts +6 -1
  118. package/dist/react/components/ToolCard.js +79 -69
  119. package/dist/react/components/mcp-ui-question-input.d.ts +1 -1
  120. package/dist/react/components/mcp-ui-question-input.js +3 -3
  121. package/dist/react/components/mcp-ui-surface-state.d.ts +1 -1
  122. package/dist/react/features/chat-pane/agent-tools.d.ts +1 -1
  123. package/dist/react/features/chat-pane/antigravity/model-options.d.ts +2 -0
  124. package/dist/react/features/chat-pane/antigravity/model-options.js +2 -0
  125. package/dist/react/features/chat-pane/claude/model-options.d.ts +2 -0
  126. package/dist/react/features/chat-pane/claude/model-options.js +2 -0
  127. package/dist/react/features/chat-pane/codex/model-options.d.ts +2 -0
  128. package/dist/react/features/chat-pane/codex/model-options.js +2 -0
  129. package/dist/react/features/chat-pane/components/AgentPluginUsage.d.ts +4 -1
  130. package/dist/react/features/chat-pane/components/AgentPluginUsage.js +2 -2
  131. package/dist/react/features/chat-pane/components/AgentRuntimePicker.d.ts +10 -6
  132. package/dist/react/features/chat-pane/components/AgentRuntimePicker.js +18 -132
  133. package/dist/react/features/chat-pane/components/ChatPane.d.ts +24 -2
  134. package/dist/react/features/chat-pane/components/ChatPane.js +45 -297
  135. package/dist/react/features/chat-pane/components/ChatPaneComposerArea.d.ts +33 -0
  136. package/dist/react/features/chat-pane/components/ChatPaneComposerArea.js +119 -0
  137. package/dist/react/features/chat-pane/components/ChatPaneLayout.d.ts +42 -0
  138. package/dist/react/features/chat-pane/components/ChatPaneLayout.js +54 -0
  139. package/dist/react/features/chat-pane/components/ChatPaneStatus.d.ts +27 -0
  140. package/dist/react/features/chat-pane/components/ChatPaneStatus.js +91 -0
  141. package/dist/react/features/chat-pane/components/RuntimeDropUp.d.ts +6 -1
  142. package/dist/react/features/chat-pane/components/RuntimeDropUp.js +20 -19
  143. package/dist/react/features/chat-pane/components/RuntimePickerSections.d.ts +62 -0
  144. package/dist/react/features/chat-pane/components/RuntimePickerSections.js +122 -0
  145. package/dist/react/features/chat-pane/create-mcp-ui-tool-caller.d.ts +1 -1
  146. package/dist/react/features/chat-pane/hooks/useChatPane.hooks.d.ts +5 -3
  147. package/dist/react/features/chat-pane/hooks/useChatPane.hooks.js +78 -26
  148. package/dist/react/features/chat-pane/hooks/useChatPaneAgentControl.hooks.js +6 -6
  149. package/dist/react/features/chat-pane/hooks/useChatPaneFileDrop.hooks.d.ts +5 -1
  150. package/dist/react/features/chat-pane/hooks/useChatPaneFileDrop.hooks.js +7 -7
  151. package/dist/react/features/chat-pane/hooks/useRuntimeDropUp.hooks.d.ts +7 -0
  152. package/dist/react/features/chat-pane/hooks/useRuntimeDropUp.hooks.js +5 -0
  153. package/dist/react/features/chat-pane/model-options.js +7 -4
  154. package/dist/react/features/chat-pane/styles.d.ts +1 -1
  155. package/dist/react/features/chat-pane/styles.js +14 -14
  156. package/dist/react/features/chat-pane/types.d.ts +29 -1
  157. package/dist/react/hooks/assistant-chats-contracts.d.ts +1 -1
  158. package/dist/react/hooks/attachment-preview-cache.d.ts +1 -1
  159. package/dist/react/hooks/attachment-preview-cache.js +1 -1
  160. package/dist/react/hooks/fab-position.js +16 -18
  161. package/dist/react/hooks/useConversation.d.ts +6 -1
  162. package/dist/react/hooks/useConversation.js +11 -10
  163. package/dist/react/hooks/useRunStream.d.ts +3 -0
  164. package/dist/react/hooks/useRunStream.js +12 -12
  165. package/dist/react/hooks/useSurfaceRecovery.d.ts +1 -1
  166. package/dist/react/hooks/useSurfaceRecovery.js +2 -2
  167. package/dist/react/index.d.ts +6 -3
  168. package/dist/react/index.js +5 -3
  169. package/dist/react/styles/chat-settings.css +9 -9
  170. package/dist/react/surfaces.d.ts +91 -0
  171. package/dist/react/surfaces.js +28 -0
  172. package/dist/server/durable-runs/recover.d.ts +4 -3
  173. package/dist/server/durable-runs/recover.js +4 -3
  174. package/dist/store/legacy/sqlite/conversations.d.ts +1 -2
  175. package/dist/store/legacy/sqlite/conversations.js +1 -1
  176. package/dist/store/legacy/sqlite/messages.d.ts +2 -3
  177. package/dist/store/legacy/sqlite/messages.js +6 -6
  178. package/dist/store/pglite/index.d.ts +7 -7
  179. package/dist/store/pglite/index.js +1 -1
  180. package/dist/store/ports.d.ts +5 -2
  181. package/dist/store/postgres/index.d.ts +7 -7
  182. package/dist/store/postgres/index.js +1 -1
  183. package/dist/store/runtime/chat-expiry-sweep.js +2 -4
  184. package/dist/store/runtime/chat-history-store.js +2 -3
  185. package/dist/store/runtime/durable-run-store.js +16 -2
  186. package/dist/store/runtime/history-tools.js +33 -11
  187. package/dist/store/runtime/kernel.d.ts +3 -2
  188. package/dist/store/runtime/run-ledger.js +2 -2
  189. package/dist/store/sql/boundary.d.ts +5 -5
  190. package/dist/store/sql/maintenance.d.ts +3 -2
  191. package/dist/store/sql/store.d.ts +16 -8
  192. package/dist/store/sql/store.js +31 -14
  193. package/dist/store/sqlite/index.d.ts +11 -12
  194. package/dist/store/sqlite/index.js +5 -5
  195. package/dist/store/sqlite/schema.d.ts +1 -1
  196. package/package.json +49 -27
  197. package/dist/core/ag-ui/entry.d.ts +0 -84
  198. package/dist/core/ag-ui/entry.js +0 -225
  199. package/dist/core/browser/page-actions.d.ts +0 -121
  200. package/dist/core/browser/page-actions.js +0 -113
  201. package/dist/embed-widget/browser/page-actions.d.ts +0 -2
  202. package/dist/embed-widget/browser/page-actions.js +0 -3
@@ -1,5 +1,5 @@
1
- import { jsx as _jsx, jsxs as _jsxs, Fragment as _Fragment } from "react/jsx-runtime";
2
- import { CREDENTIAL_CARD_GUIDANCE, SECRET_REDACTED_NOTICE } from '../../core/user-text-redaction.js';
1
+ import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
2
+ import { SECRET_REDACTED_NOTICE } from '../../core/user-text-redaction.js';
3
3
  import { useUserTextGuard } from '../hooks/useUserTextGuard.js';
4
4
  /**
5
5
  * @module QuestionForm
@@ -14,16 +14,17 @@ import { useUserTextGuard } from '../hooks/useUserTextGuard.js';
14
14
  * classes — unstyled semantic markup, host supplies CSS); every user-facing
15
15
  * string wrapped in `useT()`.
16
16
  */
17
- import { forwardRef, useEffect, useImperativeHandle, useMemo, useState } from 'react';
18
- import { formatFormAnswers, formOptionValueForLabel, redactQuestionAnswers, isSecretQuestion, withoutSecretQuestionDefaults, questionTextInputProps, questionTextareaProps } from '../../core/index.js';
17
+ import { forwardRef, useEffect, useImperativeHandle, useMemo } from 'react';
18
+ import { formatFormAnswers, redactQuestionAnswers, withoutSecretQuestionDefaults } from '../../core/index.js';
19
19
  import { useT } from '../hooks/context.js';
20
- import { SecretInput, SecretTextarea } from '@jini-ai/ui';
21
- export const QuestionForm = forwardRef(function QuestionForm({ form: incomingForm, interactive, submittedAnswers, hideInternalSubmit = false, draftAnswers, onReadyChange, onDraftChange, onAnswerChange, onSubmit, redactUserText, onSecretRedacted }, ref) {
22
- const t = useT();
20
+ import { useQuestionAnswers } from './QuestionForm.answers.hooks.js';
21
+ import { QuestionField } from './QuestionFormField.js';
22
+ export const QuestionForm = forwardRef(function QuestionForm({ useTHook = useT, useUserTextGuardHook = useUserTextGuard, useQuestionAnswersHook = useQuestionAnswers, form: incomingForm, interactive, submittedAnswers, hideInternalSubmit = false, draftAnswers, onReadyChange, onDraftChange, onAnswerChange, onSubmit, redactUserText, onSecretRedacted }, ref) {
23
+ const t = useTHook();
23
24
  const form = useMemo(() => withoutSecretQuestionDefaults({ form: incomingForm }), [incomingForm]);
24
- const guard = useUserTextGuard({ ...(redactUserText ? { redactUserText } : {}), ...(onSecretRedacted ? { onSecretRedacted } : {}) });
25
- const locked = !interactive || !onSubmit || submittedAnswers !== undefined;
26
- const state = useQuestionAnswers({ form, submittedAnswers, draftAnswers, locked }, { onDraftChange, onAnswerChange });
25
+ const guard = useUserTextGuardHook(definedGuardOptions({ redactUserText, onSecretRedacted }));
26
+ const locked = isQuestionFormLocked({ interactive, onSubmit, submittedAnswers });
27
+ const state = useQuestionAnswersHook({ form, submittedAnswers, draftAnswers, locked }, { onDraftChange, onAnswerChange });
27
28
  const currentAnswers = submittedAnswers ? redactQuestionAnswers({ form, answers: submittedAnswers }).answers : state.answers;
28
29
  const ready = answersReady(form, currentAnswers);
29
30
  function handleSubmit() {
@@ -48,56 +49,16 @@ export const QuestionForm = forwardRef(function QuestionForm({ form: incomingFor
48
49
  useImperativeHandle(ref, () => ({ submit: handleSubmit, skipAll: handleSkipAll }));
49
50
  useEffect(() => {
50
51
  onReadyChange?.(!locked && ready);
51
- // eslint-disable-next-line react-hooks/exhaustive-deps
52
52
  }, [onReadyChange, locked, ready]);
53
- return (_jsxs("div", { className: `question-form${locked ? ' question-form-locked' : ''}`, "data-form-id": form.id, children: [_jsx(QuestionFormHead, { form: form, locked: locked }), _jsx("div", { className: "question-form-body", children: form.questions.map((q) => (_jsx(QuestionField, { q: q, value: currentAnswers[q.id], formId: form.id, locked: locked, t: t, ...state.handlers }, q.id))) }), guard.secretRedacted ? _jsx("div", { role: "status", children: t(SECRET_REDACTED_NOTICE) }) : null, hideInternalSubmit ? null : _jsx(QuestionFormFoot, { locked: locked, answered: submittedAnswers !== undefined, ready: ready, submitLabel: form.submitLabel, onSubmit: handleSubmit })] }));
53
+ return (_jsxs("div", { className: `question-form${locked ? ' question-form-locked' : ''}`, "data-form-id": form.id, children: [_jsx(QuestionFormHead, { form: form, locked: locked, t: t }), _jsx("div", { className: "jini-question-form-body", children: form.questions.map((q) => (_jsx(QuestionField, { q: q, value: currentAnswers[q.id], formId: form.id, locked: locked, t: t, ...state.handlers }, q.id))) }), guard.secretRedacted ? _jsx("div", { role: "status", children: t(SECRET_REDACTED_NOTICE) }) : null, hideInternalSubmit ? null : _jsx(QuestionFormFoot, { locked: locked, answered: submittedAnswers !== undefined, ready: ready, submitLabel: form.submitLabel, onSubmit: handleSubmit, t: t })] }));
54
54
  });
55
- /** Owns the editable answers plus the picked files; every edit is a no-op once the form is locked. */
56
- function useQuestionAnswers({ form, submittedAnswers, draftAnswers, locked }, { onDraftChange, onAnswerChange } = {}) {
57
- const initial = useMemo(() => buildInitialState(form, submittedAnswers, draftAnswers), [form, submittedAnswers, draftAnswers]);
58
- const [answers, setAnswers] = useState(initial);
59
- const [fileAnswers, setFileAnswers] = useState({});
60
- useEffect(() => {
61
- setFileAnswers({});
62
- }, [form.id]);
63
- useEffect(() => {
64
- setAnswers((prev) => backfillAnswers(prev, form, submittedAnswers));
65
- }, [form, submittedAnswers]);
66
- function update(id, value) {
67
- if (locked)
68
- return;
69
- const next = { ...answers, [id]: value };
70
- setAnswers(next);
71
- onDraftChange?.(redactQuestionAnswers({ form, answers: draftSafeAnswers(form, next) }).answers);
72
- onAnswerChange?.(id, redactQuestionAnswers({ form, answers: { [id]: value } }).answers[id]);
73
- }
74
- function toggleCheckbox(id, option, maxSelections) {
75
- if (locked)
76
- return;
77
- const current = Array.isArray(answers[id]) ? answers[id] : [];
78
- const has = current.includes(option);
79
- if (!has && maxSelections !== undefined && current.length >= maxSelections)
80
- return;
81
- const next = has ? current.filter((v) => v !== option) : [...current, option];
82
- const nextAnswers = { ...answers, [id]: next };
83
- setAnswers(nextAnswers);
84
- onDraftChange?.(redactQuestionAnswers({ form, answers: draftSafeAnswers(form, nextAnswers) }).answers);
85
- onAnswerChange?.(id, next);
86
- }
87
- function updateCheckboxCustom(q, raw) {
88
- if (locked)
89
- return;
90
- const current = Array.isArray(answers[q.id]) ? answers[q.id] : [];
91
- const fixed = current.filter((entry) => questionValueIsKnown(q, entry));
92
- update(q.id, [...fixed, ...splitCustomEntries(raw)]);
93
- }
94
- function selectFiles(q, list) {
95
- const files = Array.from(list ?? []);
96
- const names = files.map((file) => file.name);
97
- setFileAnswers((current) => ({ ...current, [q.id]: files }));
98
- update(q.id, q.multiple ? names : (names[0] ?? ''));
99
- }
100
- return { answers, setAnswers, fileAnswers, handlers: { update, toggleCheckbox, updateCheckboxCustom, selectFiles } };
55
+ /** The guard's options without `undefined` members (split out of `QuestionForm` for its complexity budget). */
56
+ function definedGuardOptions({ redactUserText, onSecretRedacted }, _optional = {}) {
57
+ return { ...(redactUserText ? { redactUserText } : {}), ...(onSecretRedacted ? { onSecretRedacted } : {}) };
58
+ }
59
+ /** A form takes no input when it is read-only, has no submit target, or was already answered. */
60
+ function isQuestionFormLocked({ interactive, onSubmit, submittedAnswers }, _optional = {}) {
61
+ return !interactive || !onSubmit || submittedAnswers !== undefined;
101
62
  }
102
63
  function answersReady(form, answers) {
103
64
  const withinSelectionLimits = form.questions.every((q) => {
@@ -116,154 +77,11 @@ function answersReady(form, answers) {
116
77
  });
117
78
  return withinSelectionLimits && requiredAnswered;
118
79
  }
119
- function QuestionFormHead({ form, locked }) {
120
- const t = useT();
121
- return (_jsxs("div", { className: "question-form-head", children: [_jsx("span", { className: "question-form-icon", "aria-hidden": true, children: "?" }), _jsxs("div", { className: "question-form-titles", children: [_jsx("div", { className: "question-form-title", children: form.title }), form.description ? _jsx("div", { className: "question-form-desc", children: form.description }) : null] }), locked ? _jsx("span", { className: "question-form-pill", children: t('Answered') }) : null] }));
122
- }
123
- function QuestionFormFoot({ locked, answered, ready, submitLabel, onSubmit }) {
124
- const t = useT();
125
- return (_jsxs("div", { className: "question-form-foot", children: [locked ? _jsx("span", { className: "qf-locked-note", children: answered ? t('You answered this') : t('A newer message answered this') }) : _jsx("span", { className: "qf-hint", children: t('Answer above, then continue') }), !locked ? (_jsx("button", { type: "button", className: "primary", onClick: onSubmit, disabled: !ready, title: ready ? t('Submit your answers') : t('Answer the required questions first'), children: submitLabel ?? t('Continue') })) : null] }));
126
- }
127
- function QuestionField(ctx) {
128
- const { q, t } = ctx;
129
- const renderControl = QUESTION_CONTROLS[q.type];
130
- return (_jsxs("div", { className: "qf-field", children: [_jsxs("label", { className: "qf-label", children: [_jsx("span", { children: q.label }), q.required ? (_jsx("span", { className: "qf-required", "aria-label": t('required'), children: "*" })) : null] }), q.help ? _jsx("div", { className: "qf-help", children: q.help }) : null, isSecretQuestion({ question: q }) ? _jsx("div", { className: "qf-help", children: t(CREDENTIAL_CARD_GUIDANCE) }) : null, renderControl ? renderControl(ctx) : null] }));
131
- }
132
- function stringValue(value) {
133
- return typeof value === 'string' ? value : '';
134
- }
135
- /** A range with no usable answer yet (e.g. mid-stream) shows its minimum, matching `emptyQuestionValue`. */
136
- function rangeValue(q, value) {
137
- return typeof value === 'string' && value.trim() ? value : String(q.min ?? 0);
138
- }
139
- function customChoice({ q, t, locked }, value, onChange) {
140
- if (!shouldRenderCustomChoice(q))
141
- return null;
142
- return _jsx(CustomChoiceInput, { label: q.customLabel ?? t('Something else'), value: value, placeholder: q.customPlaceholder ?? t('Type your own answer'), disabled: locked, onChange: onChange });
143
- }
144
- function singleCustomChoice(ctx) {
145
- return customChoice(ctx, customSingleValue(ctx.q, ctx.value), (next) => ctx.update(ctx.q.id, next));
146
- }
147
- function RadioControl(ctx) {
148
- const { q, value, formId, locked, update } = ctx;
149
- if (!q.options)
150
- return null;
151
- return (_jsxs(_Fragment, { children: [_jsx("div", { className: "qf-options", children: q.options.map((opt) => (_jsxs("label", { className: `qf-chip${value === opt.value ? ' qf-chip-on' : ''}`, title: opt.description, children: [_jsx("input", { type: "radio", name: `${formId}-${q.id}`, value: opt.value, checked: value === opt.value, disabled: locked, "aria-label": opt.label, onChange: () => update(q.id, opt.value) }), _jsx(OptionCopy, { option: opt })] }, opt.value))) }), singleCustomChoice(ctx)] }));
152
- }
153
- function CheckboxControl(ctx) {
154
- const { q, value, locked, toggleCheckbox, updateCheckboxCustom } = ctx;
155
- if (!q.options)
156
- return null;
157
- const arr = Array.isArray(value) ? value : [];
158
- return (_jsxs(_Fragment, { children: [_jsx("div", { className: "qf-options", children: q.options.map((opt) => {
159
- const on = arr.includes(opt.value);
160
- const maxed = q.maxSelections !== undefined && !on && arr.length >= q.maxSelections;
161
- return (_jsxs("label", { title: opt.description, className: `qf-chip${on ? ' qf-chip-on' : ''}${maxed ? ' qf-chip-disabled' : ''}`, children: [_jsx("input", { type: "checkbox", value: opt.value, checked: on, disabled: locked || maxed, "aria-label": opt.label, onChange: () => toggleCheckbox(q.id, opt.value, q.maxSelections) }), _jsx(OptionCopy, { option: opt })] }, opt.value));
162
- }) }), customChoice(ctx, customCheckboxValue(q, value), (next) => updateCheckboxCustom(q, next))] }));
163
- }
164
- function SelectControl(ctx) {
165
- const { q, value, locked, t, update } = ctx;
166
- if (!q.options)
167
- return null;
168
- return (_jsxs(_Fragment, { children: [_jsxs("select", { className: "qf-select", value: typeof value === 'string' && questionValueIsKnown(q, value) ? value : '', disabled: locked, onChange: (e) => update(q.id, e.target.value), children: [_jsx("option", { value: "", disabled: true, children: q.placeholder ?? t('Choose one') }), q.options.map((opt) => (_jsx("option", { value: opt.value, title: opt.description, children: opt.label }, opt.value)))] }), singleCustomChoice(ctx)] }));
169
- }
170
- function DirectionCardsControl(ctx) {
171
- const { q, value, formId, locked, update } = ctx;
172
- if (!q.cards || q.cards.length === 0)
173
- return null;
174
- return (_jsxs(_Fragment, { children: [_jsx("div", { className: "qf-direction-cards", children: q.cards.map((card) => (_jsx(DirectionCardView, { card: card, formId: formId, questionId: q.id, selected: value === card.id || value === card.label, disabled: locked, onSelect: () => update(q.id, card.id) }, card.id))) }), singleCustomChoice(ctx)] }));
175
- }
176
- /** A credential-shaped text question gets the shared eye toggle (hidden by default). */
177
- function TextControl({ q, value, locked, update, t }) {
178
- const shared = { className: 'qf-input', value: stringValue(value), placeholder: q.placeholder, disabled: locked, onChange: (e) => update(q.id, e.target.value) };
179
- const props = questionTextInputProps({ question: q });
180
- const { type, ...secretProps } = props;
181
- if (type === 'password') {
182
- return _jsx(SecretInput, { ...secretProps, ...shared, "aria-label": q.label, label: q.label, toggleLabels: { show: `${t('Show')} ${q.label}`, hide: `${t('Hide')} ${q.label}` } });
183
- }
184
- return _jsx("input", { ...props, ...shared });
185
- }
186
- /** A credential-shaped textarea gets the same eye toggle; `SecretTextarea` owns the masking style. */
187
- function TextareaControl({ q, value, locked, update, t }) {
188
- const shared = { className: 'qf-textarea', value: stringValue(value), placeholder: q.placeholder, disabled: locked, rows: 3, onChange: (e) => update(q.id, e.target.value) };
189
- const props = questionTextareaProps({ question: q });
190
- if (isSecretQuestion({ question: q })) {
191
- return _jsx(SecretTextarea, { ...props, ...shared, "aria-label": q.label, label: q.label, toggleLabels: { show: `${t('Show')} ${q.label}`, hide: `${t('Hide')} ${q.label}` } });
192
- }
193
- return _jsx("textarea", { ...props, ...shared });
194
- }
195
- /** date/time/datetime-local and url/email/tel share one plain input whose `type` is the question type. */
196
- function TypedInputControl({ q, value, locked, update }) {
197
- return _jsx("input", { type: q.type, className: "qf-input", value: stringValue(value), placeholder: q.placeholder, disabled: locked, onChange: (e) => update(q.id, e.target.value) });
198
- }
199
- const QUESTION_CONTROLS = {
200
- radio: RadioControl,
201
- checkbox: CheckboxControl,
202
- select: SelectControl,
203
- 'direction-cards': DirectionCardsControl,
204
- text: TextControl,
205
- number: ({ q, value, locked, update }) => _jsx("input", { type: "number", className: "qf-input", value: stringValue(value), placeholder: q.placeholder, min: q.min, max: q.max, step: q.step, disabled: locked, onChange: (e) => update(q.id, e.target.value) }),
206
- range: ({ q, value, locked, update }) => (_jsxs("div", { className: "qf-range-wrap", children: [_jsx("input", { type: "range", className: "qf-range", value: rangeValue(q, value), min: q.min, max: q.max, step: q.step, disabled: locked, onChange: (e) => update(q.id, e.target.value) }), _jsx("output", { className: "qf-range-value", children: rangeValue(q, value) })] })),
207
- date: TypedInputControl,
208
- time: TypedInputControl,
209
- 'datetime-local': TypedInputControl,
210
- url: TypedInputControl,
211
- email: TypedInputControl,
212
- tel: TypedInputControl,
213
- color: ({ q, value, locked, update }) => _jsx("input", { type: "color", className: "qf-color", value: normalizeColorInputValue(value), disabled: locked, onChange: (e) => update(q.id, e.target.value) }),
214
- file: ({ q, value, locked, selectFiles }) => (_jsxs("div", { className: "qf-file-wrap", children: [_jsx("input", { type: "file", className: "qf-file", multiple: q.multiple, accept: q.accept, disabled: locked, onChange: (e) => selectFiles(q, e.target.files) }), fileValueLabel(value) ? _jsx("div", { className: "qf-file-summary", children: fileValueLabel(value) }) : null] })),
215
- switch: ({ q, value, locked, update }) => (_jsxs("label", { className: "qf-switch", children: [_jsx("input", { type: "checkbox", role: "switch", checked: value === 'true', disabled: locked, onChange: (e) => update(q.id, e.target.checked ? 'true' : 'false') }), _jsx("span", { "aria-hidden": true })] })),
216
- textarea: TextareaControl,
217
- };
218
- function OptionCopy({ option }) {
219
- return (_jsxs("span", { className: "qf-chip-copy", children: [_jsx("span", { children: option.label }), option.description ? _jsx("span", { className: "qf-chip-desc", children: option.description }) : null] }));
220
- }
221
- function CustomChoiceInput({ label, value, placeholder, disabled, onChange }) {
222
- const chars = customInputCharCount(value, placeholder);
223
- return (_jsxs("label", { className: "qf-custom", children: [_jsx("span", { children: label }), _jsx("input", { type: "text", className: "qf-input", value: value, placeholder: placeholder, disabled: disabled, style: { '--qf-custom-chars': String(chars) }, onChange: (event) => onChange(event.target.value) })] }));
224
- }
225
- function DirectionCardView({ card, formId, questionId, selected, disabled, onSelect }) {
226
- const t = useT();
227
- return (_jsxs("label", { className: `qf-card${selected ? ' qf-card-on' : ''}${disabled ? ' qf-card-disabled' : ''}`, children: [_jsx("input", { type: "radio", name: `${formId}-${questionId}`, value: card.id, checked: selected, disabled: disabled, onChange: () => onSelect() }), _jsxs("div", { className: "qf-card-head", children: [_jsx("div", { className: "qf-card-title", children: card.label }), selected ? _jsx("span", { className: "qf-card-pill", children: t('Selected') }) : null] }), card.palette.length > 0 ? (_jsx("div", { className: "qf-card-swatches", "aria-hidden": true, children: card.palette.slice(0, 6).map((c, i) => (_jsx("span", { className: "qf-card-swatch", style: { background: c }, title: c }, i))) })) : null, _jsxs("div", { className: "qf-card-types", "aria-hidden": true, children: [_jsx("span", { className: "qf-card-type-display", style: { fontFamily: card.displayFont }, children: "Aa" }), _jsx("span", { className: "qf-card-type-body", style: { fontFamily: card.bodyFont }, children: t('The quick brown fox') })] }), card.mood ? _jsx("p", { className: "qf-card-mood", children: card.mood }) : null, card.references.length > 0 ? (_jsxs("p", { className: "qf-card-refs", children: [_jsx("span", { className: "qf-card-refs-label", children: t('References:') }), " ", card.references.slice(0, 4).join(' · ')] })) : null] }));
228
- }
229
- function buildInitialState(form, submitted, draft) {
230
- const out = {};
231
- for (const q of form.questions)
232
- out[q.id] = initialQuestionValue(q, submitted, draft);
233
- return out;
234
- }
235
- /** Submitted beats draft beats default beats empty; file drafts are never restored (the File objects are gone). */
236
- function initialQuestionValue(q, submitted, draft) {
237
- if (submitted?.[q.id] !== undefined)
238
- return canonicalizeQuestionValue(q, submitted[q.id]);
239
- if (draft?.[q.id] !== undefined && q.type !== 'file')
240
- return canonicalizeQuestionValue(q, draft[q.id]);
241
- if (q.defaultValue !== undefined)
242
- return canonicalizeQuestionValue(q, q.defaultValue);
243
- return emptyQuestionValue(q);
244
- }
245
- /** Questions that stream in after mount get their initial value; answers already set are kept. */
246
- function backfillAnswers(prev, form, submitted) {
247
- let changed = false;
248
- const next = { ...prev };
249
- for (const q of form.questions) {
250
- if (next[q.id] !== undefined)
251
- continue;
252
- changed = true;
253
- next[q.id] = initialQuestionValue(q, submitted, undefined);
254
- }
255
- return changed ? next : prev;
80
+ function QuestionFormHead({ form, locked, t }) {
81
+ return (_jsxs("div", { className: "jini-question-form-head", children: [_jsx("span", { className: "jini-question-form-icon", "aria-hidden": true, children: "?" }), _jsxs("div", { className: "jini-question-form-titles", children: [_jsx("div", { className: "jini-question-form-title", children: form.title }), form.description ? _jsx("div", { className: "jini-question-form-desc", children: form.description }) : null] }), locked ? _jsx("span", { className: "jini-question-form-pill", children: t('Answered') }) : null] }));
256
82
  }
257
- function draftSafeAnswers(form, answers) {
258
- const fileQuestionIds = new Set(form.questions.filter((q) => q.type === 'file').map((q) => q.id));
259
- if (fileQuestionIds.size === 0)
260
- return answers;
261
- const out = {};
262
- for (const [id, value] of Object.entries(answers)) {
263
- if (!fileQuestionIds.has(id))
264
- out[id] = value;
265
- }
266
- return out;
83
+ function QuestionFormFoot({ locked, answered, ready, submitLabel, onSubmit, t }) {
84
+ return (_jsxs("div", { className: "jini-question-form-foot", children: [locked ? _jsx("span", { className: "jini-qf-locked-note", children: answered ? t('You answered this') : t('A newer message answered this') }) : _jsx("span", { className: "jini-qf-hint", children: t('Answer above, then continue') }), !locked ? (_jsx("button", { type: "button", className: "primary", onClick: onSubmit, disabled: !ready, title: ready ? t('Submit your answers') : t('Answer the required questions first'), children: submitLabel ?? t('Continue') })) : null] }));
267
85
  }
268
86
  function collectFileSubmissions(form, fileAnswers) {
269
87
  const out = [];
@@ -276,60 +94,4 @@ function collectFileSubmissions(form, fileAnswers) {
276
94
  }
277
95
  return out;
278
96
  }
279
- function emptyQuestionValue(q) {
280
- if (q.type === 'checkbox')
281
- return [];
282
- if (q.type === 'switch')
283
- return 'false';
284
- if (q.type === 'range')
285
- return String(q.min ?? 0);
286
- if (q.type === 'color')
287
- return normalizeColorInputValue('');
288
- return '';
289
- }
290
- function canonicalizeQuestionValue(q, value) {
291
- if (Array.isArray(value))
292
- return value.map((entry) => formOptionValueForLabel({ question: q, labelOrValue: entry }));
293
- return formOptionValueForLabel({ question: q, labelOrValue: value });
294
- }
295
- function shouldRenderCustomChoice(q) {
296
- return q.allowCustom !== false;
297
- }
298
- function questionValueIsKnown(q, value) {
299
- if (q.options?.some((option) => option.value === value || option.label === value))
300
- return true;
301
- if (q.cards?.some((card) => card.id === value || card.label === value))
302
- return true;
303
- return false;
304
- }
305
- function customSingleValue(q, value) {
306
- if (typeof value !== 'string' || value.length === 0)
307
- return '';
308
- return questionValueIsKnown(q, value) ? '' : value;
309
- }
310
- function customCheckboxValue(q, value) {
311
- if (!Array.isArray(value))
312
- return '';
313
- return value.filter((entry) => !questionValueIsKnown(q, entry)).join(', ');
314
- }
315
- function splitCustomEntries(raw) {
316
- return raw
317
- .split(/[\n,]/)
318
- .map((entry) => entry.trim())
319
- .filter(Boolean);
320
- }
321
- function customInputCharCount(value, placeholder) {
322
- const base = value.length > 0 ? value.length : Math.min(placeholder.length, 22);
323
- return Math.max(18, Math.min(base + 2, 72));
324
- }
325
- function normalizeColorInputValue(value) {
326
- if (typeof value === 'string' && /^#[0-9a-fA-F]{6}$/.test(value))
327
- return value;
328
- return '#000000';
329
- }
330
- function fileValueLabel(value) {
331
- if (Array.isArray(value))
332
- return value.join(', ');
333
- return typeof value === 'string' ? value : '';
334
- }
335
97
  //# sourceMappingURL=QuestionForm.js.map
@@ -0,0 +1,22 @@
1
+ import type { QuestionForm as QuestionFormType } from '../../core/index.js';
2
+ export type AnswerValue = string | string[] | undefined;
3
+ export declare function emptyQuestionValue(q: QuestionFormType['questions'][number]): string | string[];
4
+ export declare function canonicalizeQuestionValue({ q, value }: {
5
+ q: QuestionFormType['questions'][number];
6
+ value: string | string[];
7
+ }, _optional?: {}): string | string[];
8
+ export declare function shouldRenderCustomChoice(q: QuestionFormType['questions'][number]): boolean;
9
+ export declare function questionValueIsKnown({ q, value }: {
10
+ q: QuestionFormType['questions'][number];
11
+ value: string;
12
+ }, _optional?: {}): boolean;
13
+ export declare function customSingleValue(q: QuestionFormType['questions'][number], value: AnswerValue): string;
14
+ export declare function customCheckboxValue(q: QuestionFormType['questions'][number], value: AnswerValue): string;
15
+ export declare function splitCustomEntries(raw: string): string[];
16
+ export declare function customInputCharCount({ value, placeholder }: {
17
+ value: string;
18
+ placeholder: string;
19
+ }, _optional?: {}): number;
20
+ export declare function normalizeColorInputValue(value: AnswerValue): string;
21
+ export declare function fileValueLabel(value: AnswerValue): string;
22
+ //# sourceMappingURL=QuestionForm.values.d.ts.map
@@ -0,0 +1,58 @@
1
+ import { formOptionValueForLabel } from '../../core/index.js';
2
+ export function emptyQuestionValue(q) {
3
+ if (q.type === 'checkbox')
4
+ return [];
5
+ if (q.type === 'switch')
6
+ return 'false';
7
+ if (q.type === 'range')
8
+ return String(q.min ?? 0);
9
+ if (q.type === 'color')
10
+ return normalizeColorInputValue('');
11
+ return '';
12
+ }
13
+ export function canonicalizeQuestionValue({ q, value }, _optional = {}) {
14
+ if (Array.isArray(value))
15
+ return value.map((entry) => formOptionValueForLabel({ question: q, labelOrValue: entry }));
16
+ return formOptionValueForLabel({ question: q, labelOrValue: value });
17
+ }
18
+ export function shouldRenderCustomChoice(q) {
19
+ return q.allowCustom !== false;
20
+ }
21
+ export function questionValueIsKnown({ q, value }, _optional = {}) {
22
+ if (q.options?.some((option) => option.value === value || option.label === value))
23
+ return true;
24
+ if (q.cards?.some((card) => card.id === value || card.label === value))
25
+ return true;
26
+ return false;
27
+ }
28
+ export function customSingleValue(q, value) {
29
+ if (typeof value !== 'string' || value.length === 0)
30
+ return '';
31
+ return questionValueIsKnown({ q, value }) ? '' : value;
32
+ }
33
+ export function customCheckboxValue(q, value) {
34
+ if (!Array.isArray(value))
35
+ return '';
36
+ return value.filter((entry) => !questionValueIsKnown({ q, value: entry })).join(', ');
37
+ }
38
+ export function splitCustomEntries(raw) {
39
+ return raw
40
+ .split(/[\n,]/)
41
+ .map((entry) => entry.trim())
42
+ .filter(Boolean);
43
+ }
44
+ export function customInputCharCount({ value, placeholder }, _optional = {}) {
45
+ const base = value.length > 0 ? value.length : Math.min(placeholder.length, 22);
46
+ return Math.max(18, Math.min(base + 2, 72));
47
+ }
48
+ export function normalizeColorInputValue(value) {
49
+ if (typeof value === 'string' && /^#[0-9a-fA-F]{6}$/.test(value))
50
+ return value;
51
+ return '#000000';
52
+ }
53
+ export function fileValueLabel(value) {
54
+ if (Array.isArray(value))
55
+ return value.join(', ');
56
+ return typeof value === 'string' ? value : '';
57
+ }
58
+ //# sourceMappingURL=QuestionForm.values.js.map
@@ -0,0 +1,17 @@
1
+ import type { QuestionForm as QuestionFormType } from '../../core/index.js';
2
+ import type { useT } from '../hooks/context.js';
3
+ import type { useQuestionAnswers } from './QuestionForm.answers.hooks.js';
4
+ import { type AnswerValue } from './QuestionForm.values.js';
5
+ type Question = QuestionFormType['questions'][number];
6
+ /** Everything one question's control needs: its value plus the form-level edit handlers. */
7
+ type FieldHandlers = ReturnType<typeof useQuestionAnswers>['handlers'];
8
+ interface FieldContext extends FieldHandlers {
9
+ q: Question;
10
+ value: AnswerValue;
11
+ formId: string;
12
+ locked: boolean;
13
+ t: ReturnType<typeof useT>;
14
+ }
15
+ export declare function QuestionField(ctx: FieldContext): import("react").JSX.Element;
16
+ export {};
17
+ //# sourceMappingURL=QuestionFormField.d.ts.map
@@ -0,0 +1,114 @@
1
+ import { jsx as _jsx, jsxs as _jsxs, Fragment as _Fragment } from "react/jsx-runtime";
2
+ import { SecretInput, SecretTextarea } from '@jini-ai/ui';
3
+ import { isSecretQuestion, questionTextInputProps, questionTextareaProps } from '../../core/index.js';
4
+ import { CREDENTIAL_CARD_GUIDANCE } from '../../core/user-text-redaction.js';
5
+ import { shouldRenderCustomChoice, questionValueIsKnown, customSingleValue, customCheckboxValue, customInputCharCount, normalizeColorInputValue, fileValueLabel } from './QuestionForm.values.js';
6
+ function questionHelpId(formId, q) {
7
+ return `${formId}-${q.id}-help`;
8
+ }
9
+ /** Required state and help-text link for a control; each attribute is omitted when it does not apply. */
10
+ function fieldAria(formId, q) {
11
+ return { 'aria-required': q.required || undefined, 'aria-describedby': q.help ? questionHelpId(formId, q) : undefined };
12
+ }
13
+ export function QuestionField(ctx) {
14
+ const { q, t } = ctx;
15
+ const renderControl = QUESTION_CONTROLS[q.type];
16
+ return (_jsxs("div", { className: "qf-field", children: [_jsxs("label", { className: "qf-label", children: [_jsx("span", { children: q.label }), q.required ? (_jsx("span", { className: "qf-required", "aria-label": t('required'), children: "*" })) : null] }), q.help ? _jsx("div", { className: "qf-help", id: questionHelpId(ctx.formId, q), children: q.help }) : null, isSecretQuestion({ question: q }) ? _jsx("div", { className: "qf-help", children: t(CREDENTIAL_CARD_GUIDANCE) }) : null, renderControl ? renderControl(ctx) : null] }));
17
+ }
18
+ function stringValue(value) {
19
+ return typeof value === 'string' ? value : '';
20
+ }
21
+ /** A range with no usable answer yet (e.g. mid-stream) shows its minimum, matching `emptyQuestionValue`. */
22
+ function rangeValue(q, value) {
23
+ return typeof value === 'string' && value.trim() ? value : String(q.min ?? 0);
24
+ }
25
+ function customChoice({ q, t, locked }, value, onChange) {
26
+ if (!shouldRenderCustomChoice(q))
27
+ return null;
28
+ return _jsx(CustomChoiceInput, { label: q.customLabel ?? t('Something else'), value: value, placeholder: q.customPlaceholder ?? t('Type your own answer'), disabled: locked, onChange: onChange });
29
+ }
30
+ function singleCustomChoice(ctx) {
31
+ return customChoice(ctx, customSingleValue(ctx.q, ctx.value), (next) => ctx.update(ctx.q.id, next));
32
+ }
33
+ function RadioControl(ctx) {
34
+ const { q, value, formId, locked, update } = ctx;
35
+ if (!q.options)
36
+ return null;
37
+ return (_jsxs(_Fragment, { children: [_jsx("div", { className: "qf-options", children: q.options.map((opt) => (_jsxs("label", { className: `qf-chip${value === opt.value ? ' qf-chip-on' : ''}`, title: opt.description, children: [_jsx("input", { type: "radio", name: `${formId}-${q.id}`, value: opt.value, checked: value === opt.value, disabled: locked, "aria-label": opt.label, onChange: () => update(q.id, opt.value) }), _jsx(OptionCopy, { option: opt })] }, opt.value))) }), singleCustomChoice(ctx)] }));
38
+ }
39
+ function CheckboxControl(ctx) {
40
+ const { q, value, locked, toggleCheckbox, updateCheckboxCustom } = ctx;
41
+ if (!q.options)
42
+ return null;
43
+ const arr = Array.isArray(value) ? value : [];
44
+ return (_jsxs(_Fragment, { children: [_jsx("div", { className: "qf-options", children: q.options.map((opt) => {
45
+ const on = arr.includes(opt.value);
46
+ const maxed = q.maxSelections !== undefined && !on && arr.length >= q.maxSelections;
47
+ return (_jsxs("label", { title: opt.description, className: `qf-chip${on ? ' qf-chip-on' : ''}${maxed ? ' qf-chip-disabled' : ''}`, children: [_jsx("input", { type: "checkbox", value: opt.value, checked: on, disabled: locked || maxed, "aria-label": opt.label, onChange: () => toggleCheckbox(q.id, opt.value, q.maxSelections) }), _jsx(OptionCopy, { option: opt })] }, opt.value));
48
+ }) }), customChoice(ctx, customCheckboxValue(q, value), (next) => updateCheckboxCustom(q, next))] }));
49
+ }
50
+ function SelectControl(ctx) {
51
+ const { q, value, locked, t, update } = ctx;
52
+ if (!q.options)
53
+ return null;
54
+ return (_jsxs(_Fragment, { children: [_jsxs("select", { className: "qf-select", "aria-label": q.label, ...fieldAria(ctx.formId, q), value: typeof value === 'string' && questionValueIsKnown({ q, value }) ? value : '', disabled: locked, onChange: (e) => update(q.id, e.target.value), children: [_jsx("option", { value: "", disabled: true, children: q.placeholder ?? t('Choose one') }), q.options.map((opt) => (_jsx("option", { value: opt.value, title: opt.description, children: opt.label }, opt.value)))] }), singleCustomChoice(ctx)] }));
55
+ }
56
+ function DirectionCardsControl(ctx) {
57
+ const { q, value, formId, locked, update, t } = ctx;
58
+ if (!q.cards || q.cards.length === 0)
59
+ return null;
60
+ return (_jsxs(_Fragment, { children: [_jsx("div", { className: "qf-direction-cards", children: q.cards.map((card) => (_jsx(DirectionCardView, { card: card, formId: formId, questionId: q.id, selected: value === card.id || value === card.label, disabled: locked, onSelect: () => update(q.id, card.id), t: t }, card.id))) }), singleCustomChoice(ctx)] }));
61
+ }
62
+ /** A credential-shaped text question gets the shared eye toggle (hidden by default). */
63
+ function TextControl({ q, value, locked, update, t, formId }) {
64
+ const shared = { className: 'qf-input', value: stringValue(value), placeholder: q.placeholder, disabled: locked, onChange: (e) => update(q.id, e.target.value) };
65
+ const props = questionTextInputProps({ question: q });
66
+ const { type, ...secretProps } = props;
67
+ if (type === 'password') {
68
+ return _jsx(SecretInput, { ...secretProps, ...shared, "aria-label": q.label, label: q.label, toggleLabels: { show: `${t('Show')} ${q.label}`, hide: `${t('Hide')} ${q.label}` } });
69
+ }
70
+ return _jsx("input", { ...props, ...shared, "aria-label": q.label, ...fieldAria(formId, q) });
71
+ }
72
+ /** A credential-shaped textarea gets the same eye toggle; `SecretTextarea` owns the masking style. */
73
+ function TextareaControl({ q, value, locked, update, t, formId }) {
74
+ const shared = { className: 'qf-textarea', value: stringValue(value), placeholder: q.placeholder, disabled: locked, rows: 3, onChange: (e) => update(q.id, e.target.value) };
75
+ const props = questionTextareaProps({ question: q });
76
+ if (isSecretQuestion({ question: q })) {
77
+ return _jsx(SecretTextarea, { ...props, ...shared, "aria-label": q.label, label: q.label, toggleLabels: { show: `${t('Show')} ${q.label}`, hide: `${t('Hide')} ${q.label}` } });
78
+ }
79
+ return _jsx("textarea", { ...props, ...shared, "aria-label": q.label, ...fieldAria(formId, q) });
80
+ }
81
+ /** date/time/datetime-local and url/email/tel share one plain input whose `type` is the question type. */
82
+ function TypedInputControl({ q, value, locked, update, formId }) {
83
+ return _jsx("input", { type: q.type, className: "qf-input", "aria-label": q.label, ...fieldAria(formId, q), value: stringValue(value), placeholder: q.placeholder, disabled: locked, onChange: (e) => update(q.id, e.target.value) });
84
+ }
85
+ const QUESTION_CONTROLS = {
86
+ radio: RadioControl,
87
+ checkbox: CheckboxControl,
88
+ select: SelectControl,
89
+ 'direction-cards': DirectionCardsControl,
90
+ text: TextControl,
91
+ number: ({ q, value, locked, update, formId }) => _jsx("input", { type: "number", className: "qf-input", "aria-label": q.label, ...fieldAria(formId, q), value: stringValue(value), placeholder: q.placeholder, min: q.min, max: q.max, step: q.step, disabled: locked, onChange: (e) => update(q.id, e.target.value) }),
92
+ range: ({ q, value, locked, update, formId }) => (_jsxs("div", { className: "qf-range-wrap", children: [_jsx("input", { type: "range", className: "qf-range", "aria-label": q.label, ...fieldAria(formId, q), value: rangeValue(q, value), min: q.min, max: q.max, step: q.step, disabled: locked, onChange: (e) => update(q.id, e.target.value) }), _jsx("output", { className: "qf-range-value", children: rangeValue(q, value) })] })),
93
+ date: TypedInputControl,
94
+ time: TypedInputControl,
95
+ 'datetime-local': TypedInputControl,
96
+ url: TypedInputControl,
97
+ email: TypedInputControl,
98
+ tel: TypedInputControl,
99
+ color: ({ q, value, locked, update, formId }) => _jsx("input", { type: "color", className: "qf-color", "aria-label": q.label, ...fieldAria(formId, q), value: normalizeColorInputValue(value), disabled: locked, onChange: (e) => update(q.id, e.target.value) }),
100
+ file: ({ q, value, locked, selectFiles, formId }) => (_jsxs("div", { className: "qf-file-wrap", children: [_jsx("input", { type: "file", className: "qf-file", "aria-label": q.label, ...fieldAria(formId, q), multiple: q.multiple, accept: q.accept, disabled: locked, onChange: (e) => selectFiles(q, e.target.files) }), fileValueLabel(value) ? _jsx("div", { className: "qf-file-summary", children: fileValueLabel(value) }) : null] })),
101
+ switch: ({ q, value, locked, update, formId }) => (_jsxs("label", { className: "qf-switch", children: [_jsx("input", { type: "checkbox", role: "switch", "aria-label": q.label, ...fieldAria(formId, q), checked: value === 'true', disabled: locked, onChange: (e) => update(q.id, e.target.checked ? 'true' : 'false') }), _jsx("span", { "aria-hidden": true })] })),
102
+ textarea: TextareaControl,
103
+ };
104
+ function OptionCopy({ option }) {
105
+ return (_jsxs("span", { className: "jini-qf-chip-copy", children: [_jsx("span", { children: option.label }), option.description ? _jsx("span", { className: "jini-qf-chip-desc", children: option.description }) : null] }));
106
+ }
107
+ function CustomChoiceInput({ label, value, placeholder, disabled, onChange }) {
108
+ const chars = customInputCharCount({ value, placeholder });
109
+ return (_jsxs("label", { className: "jini-qf-custom", children: [_jsx("span", { children: label }), _jsx("input", { type: "text", className: "qf-input", value: value, placeholder: placeholder, disabled: disabled, style: { '--qf-custom-chars': String(chars) }, onChange: (event) => onChange(event.target.value) })] }));
110
+ }
111
+ function DirectionCardView({ card, formId, questionId, selected, disabled, onSelect, t }) {
112
+ return (_jsxs("label", { className: `qf-card${selected ? ' qf-card-on' : ''}${disabled ? ' qf-card-disabled' : ''}`, children: [_jsx("input", { type: "radio", name: `${formId}-${questionId}`, value: card.id, checked: selected, disabled: disabled, onChange: () => onSelect() }), _jsxs("div", { className: "jini-qf-card-head", children: [_jsx("div", { className: "jini-qf-card-title", children: card.label }), selected ? _jsx("span", { className: "jini-qf-card-pill", children: t('Selected') }) : null] }), card.palette.length > 0 ? (_jsx("div", { className: "jini-qf-card-swatches", "aria-hidden": true, children: card.palette.slice(0, 6).map((c, i) => (_jsx("span", { className: "jini-qf-card-swatch", style: { background: c }, title: c }, i))) })) : null, _jsxs("div", { className: "jini-qf-card-types", "aria-hidden": true, children: [_jsx("span", { className: "jini-qf-card-type-display", style: { fontFamily: card.displayFont }, children: "Aa" }), _jsx("span", { className: "jini-qf-card-type-body", style: { fontFamily: card.bodyFont }, children: t('The quick brown fox') })] }), card.mood ? _jsx("p", { className: "jini-qf-card-mood", children: card.mood }) : null, card.references.length > 0 ? (_jsxs("p", { className: "jini-qf-card-refs", children: [_jsx("span", { className: "jini-qf-card-refs-label", children: t('References:') }), " ", card.references.slice(0, 4).join(' · ')] })) : null] }));
113
+ }
114
+ //# sourceMappingURL=QuestionFormField.js.map
@@ -1,5 +1,6 @@
1
1
  import type { UserTextRedactionOptions } from '../../core/user-text-redaction.js';
2
2
  import type { QuestionForm as QuestionFormType } from '../../core/index.js';
3
+ import { useT } from '../hooks/context.js';
3
4
  export interface QuestionsPanelProps extends UserTextRedactionOptions {
4
5
  form: QuestionFormType | null;
5
6
  interactive: boolean;
@@ -9,6 +10,7 @@ export interface QuestionsPanelProps extends UserTextRedactionOptions {
9
10
  /** The assistant turn is still streaming the form — keeps Continue disabled and shows a generating hint. */
10
11
  generating?: boolean;
11
12
  onSubmit: (text: string, answers: Record<string, string | string[]>) => void;
13
+ useTHook?: typeof useT;
12
14
  }
13
- export declare function QuestionsPanel({ form, interactive, submitDisabled, submittedAnswers, generating, onSubmit, redactUserText, onSecretRedacted }: QuestionsPanelProps): import("react").JSX.Element | null;
15
+ export declare function QuestionsPanel({ form, interactive, submitDisabled, submittedAnswers, generating, onSubmit, redactUserText, onSecretRedacted, useTHook }: QuestionsPanelProps): import("react").JSX.Element | null;
14
16
  //# sourceMappingURL=QuestionsPanel.d.ts.map
@@ -20,14 +20,18 @@ import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
20
20
  import { useRef, useState } from 'react';
21
21
  import { useT } from '../hooks/context.js';
22
22
  import { QuestionForm } from './QuestionForm.js';
23
- export function QuestionsPanel({ form, interactive, submitDisabled, submittedAnswers, generating = false, onSubmit, redactUserText, onSecretRedacted }) {
24
- const t = useT();
23
+ export function QuestionsPanel({ form, interactive, submitDisabled, submittedAnswers, generating = false, onSubmit, redactUserText, onSecretRedacted, useTHook = useT }) {
24
+ const t = useTHook();
25
25
  const formRef = useRef(null);
26
26
  const [ready, setReady] = useState(false);
27
27
  if (!form)
28
28
  return null;
29
29
  const answered = submittedAnswers !== undefined;
30
30
  const busy = submitDisabled || generating;
31
- return (_jsxs("div", { className: "qp-panel", children: [_jsx(QuestionForm, { ref: formRef, form: form, interactive: interactive, ...(submittedAnswers !== undefined ? { submittedAnswers } : {}), hideInternalSubmit: true, ...(redactUserText ? { redactUserText } : {}), ...(onSecretRedacted ? { onSecretRedacted } : {}), onReadyChange: setReady, onSubmit: onSubmit }), !answered ? (_jsxs("div", { className: "qp-foot", children: [generating ? _jsx("span", { className: "qp-hint", children: t('Still generating…') }) : null, _jsx("button", { type: "button", className: "qp-skip", disabled: busy, onClick: () => formRef.current?.skipAll(), children: t('Skip') }), _jsx("button", { type: "button", className: "qp-continue primary", disabled: busy || !ready, onClick: () => formRef.current?.submit(), children: t('Continue') })] })) : null] }));
31
+ return (_jsxs("div", { className: "jini-qp-panel", children: [_jsx(QuestionForm, { ref: formRef, form: form, interactive: interactive, ...(submittedAnswers !== undefined ? { submittedAnswers } : {}), hideInternalSubmit: true, ...(redactUserText ? { redactUserText } : {}), ...(onSecretRedacted ? { onSecretRedacted } : {}), onReadyChange: setReady, onSubmit: onSubmit }), !answered ? _jsx(QuestionsFooter, { formRef: formRef, generating: generating, busy: busy, ready: ready, t: t }) : null] }));
32
+ }
33
+ /** Skip / Continue controls (and the still-generating hint) under an unanswered form. */
34
+ function QuestionsFooter({ formRef, generating, busy, ready, t }) {
35
+ return (_jsxs("div", { className: "jini-qp-foot", children: [generating ? _jsx("span", { className: "jini-qp-hint", children: t('Still generating…') }) : null, _jsx("button", { type: "button", className: "jini-qp-skip", disabled: busy, onClick: () => formRef.current?.skipAll(), children: t('Skip') }), _jsx("button", { type: "button", className: "jini-qp-continue primary", disabled: busy || !ready, onClick: () => formRef.current?.submit(), children: t('Continue') })] }));
32
36
  }
33
37
  //# sourceMappingURL=QuestionsPanel.js.map
@@ -1,6 +1,7 @@
1
1
  import type { ReactNode } from 'react';
2
2
  import type { ChatAttachment } from '../../core/index.js';
3
- import { type ObjectUrlPort } from './SentAttachment.hooks.js';
3
+ import { useT } from '../hooks/context.js';
4
+ import { useSentAttachmentThumbnail, type ObjectUrlPort } from './SentAttachment.hooks.js';
4
5
  export interface SentAttachmentButtonProps {
5
6
  attachment: ChatAttachment;
6
7
  /** Opens the row's preview modal for this attachment. */
@@ -10,10 +11,18 @@ export interface SentAttachmentButtonProps {
10
11
  /** Blob-URL port for the thumbnail; defaults to the platform's (see `SentAttachment.hooks.ts`). */
11
12
  objectUrls?: ObjectUrlPort | undefined;
12
13
  }
14
+ /** Hooks SentAttachmentButton calls; defaults to the real ones, a test hands in fakes. */
15
+ export declare const defaultSentAttachmentButtonHooks: {
16
+ useT: typeof useT;
17
+ useSentAttachmentThumbnail: typeof useSentAttachmentThumbnail;
18
+ };
19
+ export type SentAttachmentButtonHooks = typeof defaultSentAttachmentButtonHooks;
13
20
  /**
14
21
  * One attachment on a sent user message: a small image thumbnail when this browser still holds the
15
22
  * image's bytes, otherwise the filename chip. Either way a click opens the preview modal, and the
16
23
  * accessible name stays "Open {name}".
17
24
  */
18
- export declare function SentAttachmentButton({ attachment, onOpen, renderAttachment, objectUrls }: SentAttachmentButtonProps): import("react").JSX.Element;
25
+ export declare function SentAttachmentButton({ attachment, onOpen, renderAttachment, objectUrls, hooks }: SentAttachmentButtonProps & {
26
+ hooks?: SentAttachmentButtonHooks | undefined;
27
+ }): import("react").JSX.Element;
19
28
  //# sourceMappingURL=SentAttachment.d.ts.map
@@ -35,7 +35,7 @@ export interface SentAttachmentThumbnail {
35
35
  export declare function useSentAttachmentThumbnail({ attachment, hostRendered }: {
36
36
  attachment: ChatAttachment;
37
37
  hostRendered?: boolean;
38
- }, { objectUrls, getSource }?: {
38
+ }, { objectUrls: suppliedObjectUrls, getSource }?: {
39
39
  objectUrls?: ObjectUrlPort | undefined;
40
40
  getSource?: (required: {
41
41
  path: string;