@optiaxiom/proteus 0.1.26 → 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.
- package/dist/esm/assets/src/proteus-chart/{ProteusChart.css.ts.vanilla-B-FJ2e1F.css → ProteusChart.css.ts.vanilla-BLxzbWut.css} +2 -2
- package/dist/esm/assets/src/proteus-chart/{ProteusChartTooltipContent.css.ts.vanilla-B7GlVdiy.css → ProteusChartTooltipContent.css.ts.vanilla-BxCxymWg.css} +2 -2
- package/dist/esm/assets/src/proteus-document/{ProteusDocumentShell.css.ts.vanilla-GbLC1fdW.css → ProteusDocumentShell.css.ts.vanilla-BZNGG_wN.css} +2 -2
- package/dist/esm/assets/src/proteus-image-carousel/{ProteusImageCarousel.css.ts.vanilla-B21Y_xyv.css → ProteusImageCarousel.css.ts.vanilla-f4zcbZW_.css} +2 -2
- package/dist/esm/assets/src/proteus-question/{ProteusQuestion.css.ts.vanilla--FkursVc.css → ProteusQuestion.css.ts.vanilla-D7Zi6Bwi.css} +2 -2
- package/dist/esm/proteus-chart/ProteusChart-css.js +1 -1
- package/dist/esm/proteus-chart/ProteusChartTooltipContent-css.js +1 -1
- package/dist/esm/proteus-document/ProteusDocumentShell-css.js +1 -1
- package/dist/esm/proteus-document/ProteusDocumentShell.js +6 -0
- package/dist/esm/proteus-image-carousel/ProteusImageCarousel-css.js +1 -1
- package/dist/esm/proteus-question/ProteusQuestion-css.js +1 -1
- package/dist/esm/proteus-question/ProteusQuestion.js +41 -9
- package/dist/index.d.ts +5 -1
- package/package.json +3 -3
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import './../assets/src/proteus-chart/ProteusChart.css.ts.vanilla-
|
|
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-
|
|
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-
|
|
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-
|
|
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
|
|
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 = () =>
|
|
61
|
-
|
|
62
|
-
(
|
|
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
|
-
|
|
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
|
-
|
|
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
|
-
|
|
156
|
+
goBack();
|
|
125
157
|
},
|
|
126
158
|
size: "sm"
|
|
127
159
|
}
|
package/dist/index.d.ts
CHANGED
|
@@ -252,6 +252,10 @@ type ProteusDocumentShellProps = Pick<ComponentPropsWithoutRef<typeof Disclosure
|
|
|
252
252
|
* Callback when user sends a message action
|
|
253
253
|
*/
|
|
254
254
|
onMessage?: (message: string) => Promise<void> | void;
|
|
255
|
+
/**
|
|
256
|
+
* Callback when an analytics event is fired
|
|
257
|
+
*/
|
|
258
|
+
onTrack?: (event: string, properties: Record<string, string>) => void;
|
|
255
259
|
/**
|
|
256
260
|
* Whether form is readonly
|
|
257
261
|
*/
|
|
@@ -276,7 +280,7 @@ type ProteusDocument$2 = {
|
|
|
276
280
|
title?: ReactNode;
|
|
277
281
|
titleIcon?: string;
|
|
278
282
|
};
|
|
279
|
-
declare function ProteusDocumentShell({ collapsible: collapsibleProp, data, defaultOpen, element, onDataChange, onDownload, onInteraction, onMessage, onOpenChange, open: openProp, readOnly, strict, useResource, }: ProteusDocumentShellProps): react_jsx_runtime.JSX.Element;
|
|
283
|
+
declare function ProteusDocumentShell({ collapsible: collapsibleProp, data, defaultOpen, element, onDataChange, onDownload, onInteraction, onMessage, onOpenChange, onTrack, open: openProp, readOnly, strict, useResource, }: ProteusDocumentShellProps): react_jsx_runtime.JSX.Element;
|
|
280
284
|
declare namespace ProteusDocumentShell {
|
|
281
285
|
var displayName: string;
|
|
282
286
|
}
|
package/package.json
CHANGED
|
@@ -7,7 +7,7 @@
|
|
|
7
7
|
"url": "git+https://github.com/optimizely-axiom/optiaxiom.git"
|
|
8
8
|
},
|
|
9
9
|
"type": "module",
|
|
10
|
-
"version": "0.
|
|
10
|
+
"version": "0.2.0",
|
|
11
11
|
"files": [
|
|
12
12
|
"dist/**",
|
|
13
13
|
"LICENSE"
|
|
@@ -38,8 +38,8 @@
|
|
|
38
38
|
"embla-carousel-react": "^8.6.0",
|
|
39
39
|
"jsonpointer": "^5.0.1",
|
|
40
40
|
"recharts": "^3.8.1",
|
|
41
|
-
"@optiaxiom/
|
|
42
|
-
"@optiaxiom/
|
|
41
|
+
"@optiaxiom/react": "1.9.28",
|
|
42
|
+
"@optiaxiom/icons": "1.1.1"
|
|
43
43
|
},
|
|
44
44
|
"devDependencies": {
|
|
45
45
|
"@emotion/hash": "^0.9.2",
|