@optiaxiom/proteus 1.1.2 → 1.1.3
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.
|
@@ -11,7 +11,7 @@ import { InlineInput } from "@optiaxiom/react/unstable";
|
|
|
11
11
|
import { IconArrowRight, IconPen } from "@optiaxiom/icons";
|
|
12
12
|
import * as RovingFocus from "@radix-ui/react-roving-focus";
|
|
13
13
|
//#region src/proteus-question/ProteusQuestion.tsx
|
|
14
|
-
function ProteusQuestion({ questions }) {
|
|
14
|
+
function ProteusQuestion({ interaction, questions }) {
|
|
15
15
|
const { onEvent, onTrack } = useProteusDocumentContext("@optiaxiom/proteus/ProteusQuestion");
|
|
16
16
|
const [answers, setAnswers] = useState([]);
|
|
17
17
|
const [currentIndex, setCurrentIndex] = useState(0);
|
|
@@ -26,11 +26,20 @@ function ProteusQuestion({ questions }) {
|
|
|
26
26
|
}, [currentIndex, onTrack]);
|
|
27
27
|
const onDismiss = useCallback(() => {
|
|
28
28
|
onTrack?.("Ask User Question Dismissed", { questionIndex: String(currentIndex) });
|
|
29
|
-
onEvent({
|
|
29
|
+
if (interaction) onEvent({
|
|
30
|
+
interaction,
|
|
31
|
+
params: {
|
|
32
|
+
cancelled: "[User declined to answer the question]",
|
|
33
|
+
questions
|
|
34
|
+
}
|
|
35
|
+
});
|
|
36
|
+
else onEvent({ message: "[User declined to answer the question]" });
|
|
30
37
|
}, [
|
|
31
38
|
currentIndex,
|
|
39
|
+
interaction,
|
|
32
40
|
onEvent,
|
|
33
|
-
onTrack
|
|
41
|
+
onTrack,
|
|
42
|
+
questions
|
|
34
43
|
]);
|
|
35
44
|
const questionRef = useRef(null);
|
|
36
45
|
const lastIndexRef = useRef(currentIndex);
|
|
@@ -61,6 +70,13 @@ function ProteusQuestion({ questions }) {
|
|
|
61
70
|
skippedCount: String(questions.length - answeredCount),
|
|
62
71
|
totalQuestions: String(questions.length)
|
|
63
72
|
});
|
|
73
|
+
if (interaction) return onEvent({
|
|
74
|
+
interaction,
|
|
75
|
+
params: {
|
|
76
|
+
answers: Object.fromEntries(questions.map(({ question }, index) => [question, (answers[index] ?? []).join(", ")])),
|
|
77
|
+
questions
|
|
78
|
+
}
|
|
79
|
+
});
|
|
64
80
|
return onEvent({ message: answers.map((value, index) => `Q: ${questions[index].question}\nA: ${value || "[Not specified]"}`).join("\n\n") });
|
|
65
81
|
};
|
|
66
82
|
const onValueChange = (value) => {
|
|
@@ -3748,6 +3748,10 @@ var public_schema_default = {
|
|
|
3748
3748
|
"additionalProperties": false,
|
|
3749
3749
|
"properties": {
|
|
3750
3750
|
"$type": { "const": "Question" },
|
|
3751
|
+
"interaction": {
|
|
3752
|
+
"description": "Name of the interaction to fire when the user finishes or cancels. When set, submit and cancel send a structured `{ questions, answers }` payload via the named interaction so a calling tool can read the answers programmatically. When omitted, a human-readable transcript is sent via the `message` event instead.",
|
|
3753
|
+
"type": "string"
|
|
3754
|
+
},
|
|
3751
3755
|
"questions": {
|
|
3752
3756
|
"$ref": "#/definitions/ProteusExpression",
|
|
3753
3757
|
"description": "Array of questions data"
|
|
@@ -3687,6 +3687,10 @@ var definitions = {
|
|
|
3687
3687
|
"ProteusQuestion": {
|
|
3688
3688
|
"properties": {
|
|
3689
3689
|
"$type": { "const": "Question" },
|
|
3690
|
+
"interaction": {
|
|
3691
|
+
"description": "Name of the interaction to fire when the user finishes or cancels. When set, submit and cancel send a structured `{ questions, answers }` payload via the named interaction so a calling tool can read the answers programmatically. When omitted, a human-readable transcript is sent via the `message` event instead.",
|
|
3692
|
+
"type": "string"
|
|
3693
|
+
},
|
|
3690
3694
|
"questions": {
|
|
3691
3695
|
"$ref": "#/definitions/ProteusExpression",
|
|
3692
3696
|
"description": "Array of questions data"
|