@constructor-io/constructorio-ui-pia 2.8.0 → 2.10.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/constructorio-ui-pia-bundled.js +75 -72
- package/lib/cjs/components/CioPia/CioPia.js +29 -5
- package/lib/cjs/components/CioPia/PiaCustomCarousel.js +42 -9
- package/lib/cjs/components/ConversationHistory/ConversationHistory.js +3 -3
- package/lib/cjs/components/PiaConversation/PiaConversation.js +2 -2
- package/lib/cjs/components/PiaInlineAnswer/PiaInlineAnswer.js +3 -3
- package/lib/cjs/constants.js +2 -1
- package/lib/cjs/hooks/useCioClient.js +2 -2
- package/lib/cjs/hooks/useCioPia.js +12 -3
- package/lib/cjs/hooks/useConversation.js +32 -9
- package/lib/cjs/hooks/useTracking.js +71 -0
- package/lib/cjs/hooks/useViewportTracking.js +92 -0
- package/lib/cjs/version.js +1 -1
- package/lib/mjs/components/CioPia/CioPia.js +28 -5
- package/lib/mjs/components/CioPia/PiaCustomCarousel.js +54 -20
- package/lib/mjs/components/ConversationHistory/ConversationHistory.js +3 -3
- package/lib/mjs/components/PiaConversation/PiaConversation.js +2 -2
- package/lib/mjs/components/PiaInlineAnswer/PiaInlineAnswer.js +3 -3
- package/lib/mjs/constants.js +1 -0
- package/lib/mjs/hooks/useCioClient.js +2 -2
- package/lib/mjs/hooks/useCioPia.js +13 -4
- package/lib/mjs/hooks/useConversation.js +24 -2
- package/lib/mjs/hooks/useTracking.js +107 -0
- package/lib/mjs/hooks/useViewportTracking.js +89 -0
- package/lib/mjs/version.js +1 -1
- package/lib/types/components/CioPia/CioPia.d.ts +5 -1
- package/lib/types/components/CioPia/PiaCustomCarousel.d.ts +5 -1
- package/lib/types/components/ConversationHistory/ConversationHistory.d.ts +6 -2
- package/lib/types/components/PiaConversation/PiaConversation.d.ts +5 -2
- package/lib/types/components/PiaInlineAnswer/PiaInlineAnswer.d.ts +7 -2
- package/lib/types/constants.d.ts +1 -0
- package/lib/types/hooks/useCioClient.d.ts +3 -7
- package/lib/types/hooks/useCioPia.d.ts +4 -0
- package/lib/types/hooks/useConversation.d.ts +5 -2
- package/lib/types/hooks/useTracking.d.ts +27 -0
- package/lib/types/hooks/useViewportTracking.d.ts +10 -0
- package/lib/types/types.d.ts +8 -0
- package/lib/types/utils/transformers.d.ts +1 -1
- package/lib/types/version.d.ts +1 -1
- package/package.json +6 -3
|
@@ -1,10 +1,12 @@
|
|
|
1
|
-
import { Callbacks, ConversationEntry, PiaCallbackContext, Question, Item } from '../types';
|
|
1
|
+
import { Callbacks, ConversationEntry, FeedbackType, PiaCallbackContext, Question, Item } from '../types';
|
|
2
2
|
import { UseCioPiaReturn } from './useCioPia';
|
|
3
|
+
import { UseTrackingReturn } from './useTracking';
|
|
3
4
|
export interface UseConversationProps {
|
|
4
5
|
pia: UseCioPiaReturn;
|
|
5
6
|
itemId: string;
|
|
6
7
|
isConversation: boolean;
|
|
7
8
|
callbacks?: Callbacks;
|
|
9
|
+
tracking?: UseTrackingReturn;
|
|
8
10
|
}
|
|
9
11
|
export interface UseConversationReturn {
|
|
10
12
|
currentQuestion: string;
|
|
@@ -18,6 +20,7 @@ export interface UseConversationReturn {
|
|
|
18
20
|
handleSubmitQuestion: (question: string) => void;
|
|
19
21
|
handleQuestionClick: (question: string) => void;
|
|
20
22
|
handleInputFocus: () => void;
|
|
23
|
+
handleFeedback: (type: FeedbackType) => void;
|
|
21
24
|
resetState: () => void;
|
|
22
25
|
}
|
|
23
|
-
export default function useConversation({ pia, itemId, isConversation, callbacks, }: UseConversationProps): UseConversationReturn;
|
|
26
|
+
export default function useConversation({ pia, itemId, isConversation, callbacks, tracking, }: UseConversationProps): UseConversationReturn;
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
import { Tracker } from '@constructor-io/constructorio-client-javascript/lib/types/constructorio';
|
|
2
|
+
import { FeedbackType, Item, Question, GetAnswerResultsResponse } from '../types';
|
|
3
|
+
export interface TimeSpan {
|
|
4
|
+
start: string;
|
|
5
|
+
end: string;
|
|
6
|
+
}
|
|
7
|
+
export interface UseTrackingProps {
|
|
8
|
+
cioClient?: {
|
|
9
|
+
tracker: Tracker;
|
|
10
|
+
};
|
|
11
|
+
itemId: string;
|
|
12
|
+
itemName: string;
|
|
13
|
+
variationId?: string;
|
|
14
|
+
threadId?: string;
|
|
15
|
+
}
|
|
16
|
+
export interface UseTrackingReturn {
|
|
17
|
+
trackViews: (questions: Question[], viewTimespans: TimeSpan[]) => void;
|
|
18
|
+
trackView: (questions: Question[]) => void;
|
|
19
|
+
trackOutOfView: () => void;
|
|
20
|
+
trackFocus: () => void;
|
|
21
|
+
trackQuestionClick: (question: string) => void;
|
|
22
|
+
trackQuestionSubmit: (question: string) => void;
|
|
23
|
+
trackAnswerView: (question: string, answerData: GetAnswerResultsResponse, items?: Item[] | null) => void;
|
|
24
|
+
trackAnswerFeedback: (feedbackType: FeedbackType, qnaResultId?: string) => void;
|
|
25
|
+
trackResultClick: (clickedItem: Item, position: number, question: string, qnaResultId?: string) => void;
|
|
26
|
+
}
|
|
27
|
+
export default function useTracking({ cioClient, itemId, itemName, variationId, threadId, }: UseTrackingProps): UseTrackingReturn;
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import { Question } from '../types';
|
|
2
|
+
import { UseTrackingReturn } from './useTracking';
|
|
3
|
+
export interface UseViewportTrackingProps {
|
|
4
|
+
tracking: UseTrackingReturn;
|
|
5
|
+
questions: Question[];
|
|
6
|
+
}
|
|
7
|
+
export interface UseViewportTrackingReturn {
|
|
8
|
+
containerRef: (node: HTMLDivElement | null) => void;
|
|
9
|
+
}
|
|
10
|
+
export default function useViewportTracking({ tracking, questions, }: UseViewportTrackingProps): UseViewportTrackingReturn;
|
package/lib/types/types.d.ts
CHANGED
|
@@ -86,6 +86,14 @@ export interface Formatters {
|
|
|
86
86
|
/** Transforms image URLs before rendering (e.g., prepend a CDN base URL). */
|
|
87
87
|
formatImageUrl?: (url: string) => string;
|
|
88
88
|
}
|
|
89
|
+
/** Props forwarded to the ProductCard rendered inside the carousel. */
|
|
90
|
+
export interface ProductCardDisplayProps {
|
|
91
|
+
/**
|
|
92
|
+
* Currency symbol to display next to product prices (e.g., "€", "£").
|
|
93
|
+
* When omitted, the default ProductCard price rendering is used.
|
|
94
|
+
*/
|
|
95
|
+
priceCurrency?: string;
|
|
96
|
+
}
|
|
89
97
|
/** Extends Product type to include PIA-specific fields */
|
|
90
98
|
export interface Item extends Product, Record<string, any> {
|
|
91
99
|
url?: string;
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { Nullable } from '@constructor-io/constructorio-client-javascript';
|
|
2
|
-
import { Formatters, Item
|
|
2
|
+
import { ApiItem, Formatters, Item } from '../types';
|
|
3
3
|
/**
|
|
4
4
|
* Converts a raw ApiItem from the Get Answers API response into an Item object
|
|
5
5
|
* that can be used in the Carousel component.
|
package/lib/types/version.d.ts
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
declare const _default: "2.
|
|
1
|
+
declare const _default: "2.10.0";
|
|
2
2
|
export default _default;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@constructor-io/constructorio-ui-pia",
|
|
3
|
-
"version": "2.
|
|
3
|
+
"version": "2.10.0",
|
|
4
4
|
"description": "Constructor.io AI Product Insights Agent UI library for web applications",
|
|
5
5
|
"author": "Constructor.io Corporation",
|
|
6
6
|
"license": "MIT",
|
|
@@ -68,7 +68,7 @@
|
|
|
68
68
|
"prepare": "husky"
|
|
69
69
|
},
|
|
70
70
|
"peerDependencies": {
|
|
71
|
-
"@constructor-io/constructorio-client-javascript": "^2.
|
|
71
|
+
"@constructor-io/constructorio-client-javascript": "^2.89.0",
|
|
72
72
|
"@constructor-io/constructorio-ui-components": "^1.5.0",
|
|
73
73
|
"react": ">=16.12.0",
|
|
74
74
|
"react-dom": ">=16.12.0",
|
|
@@ -123,7 +123,7 @@
|
|
|
123
123
|
"storybook": "^8.6.4",
|
|
124
124
|
"typescript": "^4.9.4",
|
|
125
125
|
"typescript-eslint": "^8.59.2",
|
|
126
|
-
"vite": "^6.3
|
|
126
|
+
"vite": "^6.4.3",
|
|
127
127
|
"vite-plugin-css-injected-by-js": "^3.5.2",
|
|
128
128
|
"webpack": "^5.98.0"
|
|
129
129
|
},
|
|
@@ -134,5 +134,8 @@
|
|
|
134
134
|
"dependencies": {
|
|
135
135
|
"dompurify": "^3.4.2",
|
|
136
136
|
"marked": "^15.0.12"
|
|
137
|
+
},
|
|
138
|
+
"overrides": {
|
|
139
|
+
"uuid": "^11.1.1"
|
|
137
140
|
}
|
|
138
141
|
}
|