@optiaxiom/proteus 0.1.27-next.2 → 0.2.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,5 +1,5 @@
1
- @layer optiaxiom._2m54yp;
2
- @layer optiaxiom._2m54yp {
1
+ @layer optiaxiom._155jno1;
2
+ @layer optiaxiom._155jno1 {
3
3
  .ProteusChart__jmlqij1 {
4
4
  border-radius: 16px;
5
5
  }
@@ -1,5 +1,5 @@
1
- @layer optiaxiom._2m54yp;
2
- @layer optiaxiom._2m54yp {
1
+ @layer optiaxiom._155jno1;
2
+ @layer optiaxiom._155jno1 {
3
3
  .ProteusChartTooltipContent__1gsvq810 {
4
4
  min-width: 128px;
5
5
  }
@@ -1,5 +1,5 @@
1
- @layer optiaxiom._2m54yp;
2
- @layer optiaxiom._2m54yp {
1
+ @layer optiaxiom._155jno1;
2
+ @layer optiaxiom._155jno1 {
3
3
  .ProteusDocumentShell__vpuvfj1 {
4
4
  margin: -4px;
5
5
  }
@@ -1,5 +1,5 @@
1
- @layer optiaxiom._2m54yp;
2
- @layer optiaxiom._2m54yp {
1
+ @layer optiaxiom._155jno1;
2
+ @layer optiaxiom._155jno1 {
3
3
  .ProteusImageCarousel__1t6qej70 {
4
4
  outline: none;
5
5
  user-select: none;
@@ -1,5 +1,5 @@
1
- @layer optiaxiom._2m54yp;
2
- @layer optiaxiom._2m54yp {
1
+ @layer optiaxiom._155jno1;
2
+ @layer optiaxiom._155jno1 {
3
3
  .ProteusQuestion__8f590p0 {
4
4
  outline: none;
5
5
  }
@@ -1,4 +1,4 @@
1
- import './../assets/src/proteus-chart/ProteusChart.css.ts.vanilla-BjD9gTQa.css';
1
+ import './../assets/src/proteus-chart/ProteusChart.css.ts.vanilla-BLxzbWut.css';
2
2
  import { recipe } from '@optiaxiom/react/css-runtime';
3
3
 
4
4
  var chart = recipe({base:[{border:'1',borderColor:'border.tertiary',fontSize:'sm',p:'16'},'ProteusChart__jmlqij1','ProteusChart__jmlqij0']});
@@ -1,4 +1,4 @@
1
- import './../assets/src/proteus-chart/ProteusChartTooltipContent.css.ts.vanilla-CiBO2VBA.css';
1
+ import './../assets/src/proteus-chart/ProteusChartTooltipContent.css.ts.vanilla-BxCxymWg.css';
2
2
  import { recipe } from '@optiaxiom/react/css-runtime';
3
3
 
4
4
  var tooltip = recipe({base:[{bg:'bg.default',border:'1',borderColor:'border.secondary',display:'grid',fontSize:'sm',gap:'6',px:'8',py:'10',rounded:'lg',shadow:'lg'},'ProteusChartTooltipContent__1gsvq810']});
@@ -1,4 +1,4 @@
1
- import './../assets/src/proteus-document/ProteusDocumentShell.css.ts.vanilla-CONvLXzv.css';
1
+ import './../assets/src/proteus-document/ProteusDocumentShell.css.ts.vanilla-BZNGG_wN.css';
2
2
  import { recipe } from '@optiaxiom/react/css-runtime';
3
3
 
4
4
  var body = recipe({base:[{flexDirection:'column',gap:'16'},'ProteusDocumentShell__vpuvfj0'],variants:{truncate:{false:{},true:[{maxH:'sm',overflow:'auto',p:'4'},'ProteusDocumentShell__vpuvfj1']}}});
@@ -20,6 +20,7 @@ function ProteusDocumentShell({
20
20
  onInteraction,
21
21
  onMessage,
22
22
  onOpenChange,
23
+ onTrack,
23
24
  open: openProp,
24
25
  readOnly = false,
25
26
  strict,
@@ -95,6 +96,11 @@ function ProteusDocumentShell({
95
96
  }
96
97
  return;
97
98
  }),
99
+ onTrack: useEffectEvent(
100
+ (event, properties) => {
101
+ onTrack?.(event, properties);
102
+ }
103
+ ),
98
104
  readOnly,
99
105
  strict,
100
106
  useResource,
@@ -1,4 +1,4 @@
1
- import './../assets/src/proteus-image-carousel/ProteusImageCarousel.css.ts.vanilla-BR0bm1gm.css';
1
+ import './../assets/src/proteus-image-carousel/ProteusImageCarousel.css.ts.vanilla-f4zcbZW_.css';
2
2
  import { recipe } from '@optiaxiom/react/css-runtime';
3
3
 
4
4
  var carousel = recipe({base:[{flexDirection:'column',gap:'12'},'ProteusImageCarousel__1t6qej70']});
@@ -1,4 +1,4 @@
1
- import './../assets/src/proteus-question/ProteusQuestion.css.ts.vanilla-B6KKoYKy.css';
1
+ import './../assets/src/proteus-question/ProteusQuestion.css.ts.vanilla-D7Zi6Bwi.css';
2
2
  import { recipe } from '@optiaxiom/react/css-runtime';
3
3
 
4
4
  var addon = recipe({base:[{display:'grid',fontWeight:'500',placeItems:'center',rounded:'lg',size:'md',transition:'colors'},'ProteusQuestion__8f590p3'],variants:{cursor:{pointer:{cursor:'pointer'}}}});
@@ -12,18 +12,28 @@ import { useProteusDocumentContext } from '../proteus-document/ProteusDocumentCo
12
12
  import { addon, choice, choiceGroup, question } from './ProteusQuestion-css.js';
13
13
 
14
14
  function ProteusQuestion({ questions }) {
15
- const { onEvent } = useProteusDocumentContext(
15
+ const { onEvent, onTrack } = useProteusDocumentContext(
16
16
  "@optiaxiom/proteus/ProteusQuestion"
17
17
  );
18
18
  const [answers, setAnswers] = useState([]);
19
19
  const [currentIndex, setCurrentIndex] = useState(0);
20
20
  const value = answers[currentIndex];
21
21
  const valid = Array.isArray(value) && value.length > 0 && value.every(Boolean);
22
+ const goBack = useCallback(() => {
23
+ onTrack?.("Ask User Question Back", {
24
+ fromIndex: String(currentIndex),
25
+ toIndex: String(currentIndex - 1)
26
+ });
27
+ setCurrentIndex((i) => i - 1);
28
+ }, [currentIndex, onTrack]);
22
29
  const onDismiss = useCallback(() => {
30
+ onTrack?.("Ask User Question Dismissed", {
31
+ questionIndex: String(currentIndex)
32
+ });
23
33
  void onEvent({
24
34
  message: "[User declined to answer the question]"
25
35
  });
26
- }, [onEvent]);
36
+ }, [currentIndex, onEvent, onTrack]);
27
37
  const questionRef = useRef(null);
28
38
  const lastIndexRef = useRef(currentIndex);
29
39
  useEffect(() => {
@@ -57,17 +67,30 @@ function ProteusQuestion({ questions }) {
57
67
  const isLast = currentIndex === questions.length - 1;
58
68
  const otherValue = value?.find((v) => !options.includes(v));
59
69
  const otherChecked = otherValue !== void 0;
60
- const onComplete = () => onEvent({
61
- message: answers.map(
62
- (value2, index) => `Q: ${questions[index].question}
70
+ const onComplete = () => {
71
+ const answeredCount = answers.filter(
72
+ (answer) => Array.isArray(answer) && answer.length > 0
73
+ ).length;
74
+ onTrack?.("Ask User Question Submitted", {
75
+ answeredCount: String(answeredCount),
76
+ skippedCount: String(questions.length - answeredCount),
77
+ totalQuestions: String(questions.length)
78
+ });
79
+ return onEvent({
80
+ message: answers.map(
81
+ (value2, index) => `Q: ${questions[index].question}
63
82
  A: ${value2 || "[Not specified]"}`
64
- ).join("\n\n")
65
- });
83
+ ).join("\n\n")
84
+ });
85
+ };
66
86
  const onValueChange = (value2) => {
67
87
  answers[currentIndex] = value2;
68
88
  setAnswers([...answers]);
69
89
  };
70
90
  const onSkip = () => {
91
+ onTrack?.("Ask User Question Skipped", {
92
+ questionIndex: String(currentIndex)
93
+ });
71
94
  answers[currentIndex] = null;
72
95
  setAnswers([...answers]);
73
96
  if (isLast) {
@@ -77,6 +100,15 @@ A: ${value2 || "[Not specified]"}`
77
100
  }
78
101
  };
79
102
  const onSubmit = () => {
103
+ const currentValue = answers[currentIndex];
104
+ if (currentValue) {
105
+ const firstIndex = options.indexOf(currentValue[0]);
106
+ onTrack?.("Ask User Question Option Selected", {
107
+ isCustomText: String(currentValue.some((v) => !options.includes(v))),
108
+ optionIndex: String(firstIndex),
109
+ questionIndex: String(currentIndex)
110
+ });
111
+ }
80
112
  if (isLast) {
81
113
  void onComplete();
82
114
  } else {
@@ -98,7 +130,7 @@ A: ${value2 || "[Not specified]"}`
98
130
  if ((event.key === "ArrowLeft" || event.key === "ArrowRight") && !(event.target instanceof HTMLInputElement) && !event.target.isContentEditable) {
99
131
  event.preventDefault();
100
132
  if (event.key === "ArrowLeft" && currentIndex > 0) {
101
- setCurrentIndex((i) => i - 1);
133
+ goBack();
102
134
  } else if (event.key === "ArrowRight" && !isLast) {
103
135
  setCurrentIndex((i) => i + 1);
104
136
  }
@@ -121,7 +153,7 @@ A: ${value2 || "[Not specified]"}`
121
153
  icon: /* @__PURE__ */ jsx(IconAngleLeft, {}),
122
154
  onClick: (event) => {
123
155
  event.preventDefault();
124
- setCurrentIndex((i) => i - 1);
156
+ goBack();
125
157
  },
126
158
  size: "sm"
127
159
  }