@constructor-io/constructorio-ui-pia 2.1.2 → 2.2.1
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/README.md +8 -0
- package/dist/constructorio-ui-pia-bundled.js +15 -15
- package/lib/cjs/components/CioPia/CioPia.js +5 -3
- package/lib/cjs/components/ConversationHistory/ConversationHistory.js +18 -14
- package/lib/cjs/components/ConversationHistory/ConversationHistoryStyles.css +7 -0
- package/lib/cjs/components/PiaConversation/PiaConversation.js +2 -2
- package/lib/cjs/hooks/useAnswerResults.js +5 -5
- package/lib/cjs/hooks/useCioPia.js +2 -1
- package/lib/cjs/hooks/useConversation.js +6 -4
- package/lib/cjs/utils/transformers.js +12 -4
- package/lib/cjs/version.js +1 -1
- package/lib/mjs/components/CioPia/CioPia.js +5 -3
- package/lib/mjs/components/ConversationHistory/ConversationHistory.js +18 -14
- package/lib/mjs/components/ConversationHistory/ConversationHistoryStyles.css +7 -0
- package/lib/mjs/components/PiaConversation/PiaConversation.js +2 -2
- package/lib/mjs/hooks/useAnswerResults.js +5 -5
- package/lib/mjs/hooks/useCioPia.js +2 -1
- package/lib/mjs/hooks/useConversation.js +5 -3
- package/lib/mjs/utils/transformers.js +12 -2
- package/lib/mjs/version.js +1 -1
- package/lib/types/components/CioPia/CioPia.d.ts +15 -1
- package/lib/types/components/ConversationHistory/ConversationHistory.d.ts +12 -1
- package/lib/types/components/PiaConversation/PiaConversation.d.ts +1 -1
- package/lib/types/hooks/useAnswerResults.d.ts +3 -2
- package/lib/types/hooks/useCioPia.d.ts +3 -1
- package/lib/types/hooks/useConversation.d.ts +3 -2
- package/lib/types/types.d.ts +15 -0
- package/lib/types/utils/transformers.d.ts +2 -2
- package/lib/types/version.d.ts +1 -1
- package/package.json +1 -1
package/lib/types/types.d.ts
CHANGED
|
@@ -32,6 +32,11 @@ export type CioPiaDisplayConfigs = {
|
|
|
32
32
|
showFeedback?: boolean;
|
|
33
33
|
mode?: CioPiaMode;
|
|
34
34
|
type?: CioPiaType;
|
|
35
|
+
/**
|
|
36
|
+
* Show product carousels on non-last conversation entries. Defaults to true.
|
|
37
|
+
* The last entry always falls back to its own items when currentItems is not provided.
|
|
38
|
+
*/
|
|
39
|
+
showPreviousItems?: boolean;
|
|
35
40
|
};
|
|
36
41
|
/**
|
|
37
42
|
* Translations type for internationalizing UI strings.
|
|
@@ -47,9 +52,18 @@ export type Translations = {
|
|
|
47
52
|
'Ask about this product'?: string;
|
|
48
53
|
};
|
|
49
54
|
export interface Callbacks {
|
|
55
|
+
/** Called when a question is submitted (via Enter key, Send button, or suggested question click). */
|
|
56
|
+
onQuestionSubmit?: (question: string) => void;
|
|
57
|
+
/** Called when a product card in the carousel is clicked. */
|
|
50
58
|
onProductCardClick?: (item: Item) => void;
|
|
59
|
+
/** Called when the user submits positive or negative feedback on an answer. */
|
|
51
60
|
onFeedback?: (type: FeedbackType) => void;
|
|
52
61
|
}
|
|
62
|
+
/** Formatter functions for transforming data before display. */
|
|
63
|
+
export interface Formatters {
|
|
64
|
+
/** Transforms image URLs before rendering (e.g., prepend a CDN base URL). */
|
|
65
|
+
formatImageUrl?: (url: string) => string;
|
|
66
|
+
}
|
|
53
67
|
/** Extends Product type to include PIA-specific fields */
|
|
54
68
|
export interface Item extends Product, Record<string, any> {
|
|
55
69
|
url?: string;
|
|
@@ -59,6 +73,7 @@ export interface ConversationEntry {
|
|
|
59
73
|
id: number;
|
|
60
74
|
question: string;
|
|
61
75
|
answer: string;
|
|
76
|
+
items?: Item[] | null;
|
|
62
77
|
}
|
|
63
78
|
/**
|
|
64
79
|
* Render props passed to CioPia children function
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { Nullable } from '@constructor-io/constructorio-client-javascript';
|
|
2
|
-
import { Item, ApiItem } from '../types';
|
|
2
|
+
import { Formatters, Item, ApiItem } 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.
|
|
6
6
|
*/
|
|
7
|
-
export declare function transformResultItem(resultItem: ApiItem): Nullable<Item>;
|
|
7
|
+
export declare function transformResultItem(resultItem: ApiItem, formatImageUrl?: Formatters['formatImageUrl']): Nullable<Item>;
|
package/lib/types/version.d.ts
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
declare const _default: "2.1
|
|
1
|
+
declare const _default: "2.2.1";
|
|
2
2
|
export default _default;
|
package/package.json
CHANGED