@coveo/quantic 3.41.0 → 3.42.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/docs/out/quantic-docs.json +9 -0
- package/force-app/main/default/labels/CustomLabels.labels-meta.xml +14 -0
- package/force-app/main/default/lwc/quanticGeneratedAnswer/__tests__/quanticGeneratedAnswer.test.js +271 -22
- package/force-app/main/default/lwc/quanticGeneratedAnswer/quanticGeneratedAnswer.js +92 -31
- package/force-app/main/default/lwc/quanticGeneratedAnswer/templates/conversation.css +7 -0
- package/force-app/main/default/lwc/quanticGeneratedAnswer/templates/conversation.html +63 -0
- package/force-app/main/default/lwc/quanticGeneratedAnswer/templates/generatedAnswer.css +0 -11
- package/force-app/main/default/lwc/quanticGeneratedAnswer/templates/generatedAnswer.html +2 -2
- package/force-app/main/default/lwc/quanticGeneratedAnswerBody/__tests__/quanticGeneratedAnswerBody.test.js +39 -1
- package/force-app/main/default/lwc/quanticGeneratedAnswerBody/quanticGeneratedAnswerBody.js +8 -4
- package/force-app/main/default/lwc/quanticGeneratedAnswerBody/templates/answer.html +30 -24
- package/force-app/main/default/lwc/quanticGeneratedAnswerCopyToClipboard/__tests__/quanticGeneratedAnswerCopyToClipboard.test.js +5 -1
- package/force-app/main/default/lwc/quanticGeneratedAnswerCopyToClipboard/quanticGeneratedAnswerCopyToClipboard.js +9 -2
- package/force-app/main/default/lwc/quanticGeneratedAnswerFollowUpInput/__tests__/quanticGeneratedAnswerFollowUpInput.test.js +109 -55
- package/force-app/main/default/lwc/quanticGeneratedAnswerFollowUpInput/quanticGeneratedAnswerFollowUpInput.css +59 -11
- package/force-app/main/default/lwc/quanticGeneratedAnswerFollowUpInput/quanticGeneratedAnswerFollowUpInput.html +14 -13
- package/force-app/main/default/lwc/quanticGeneratedAnswerFollowUpInput/quanticGeneratedAnswerFollowUpInput.js +40 -2
- package/force-app/main/default/lwc/quanticSourceCitations/__tests__/quanticSourceCitations.test.js +22 -2
- package/force-app/main/default/lwc/quanticSourceCitations/quanticSourceCitations.js +7 -0
- package/force-app/main/default/staticresources/coveoheadless/case-assist/headless.js +15 -15
- package/force-app/main/default/staticresources/coveoheadless/definitions/commerce.index.d.ts +1 -1
- package/force-app/main/default/staticresources/coveoheadless/definitions/controllers/commerce/core/sub-controller/headless-sub-controller.d.ts +3 -1
- package/force-app/main/default/staticresources/coveoheadless/definitions/controllers/commerce/recent-queries-list/headless-recent-queries-list.d.ts +13 -2
- package/force-app/main/default/staticresources/coveoheadless/definitions/controllers/commerce/search/did-you-mean/headless-did-you-mean.d.ts +10 -1
- package/force-app/main/default/staticresources/coveoheadless/definitions/controllers/generated-answer/headless-generated-answer.d.ts +2 -2
- package/force-app/main/default/staticresources/coveoheadless/definitions/features/follow-up-answers/follow-up-answers-actions.d.ts +32 -1
- package/force-app/main/default/staticresources/coveoheadless/definitions/features/generated-answer/generated-answer-actions.d.ts +26 -1
- package/force-app/main/default/staticresources/coveoheadless/definitions/features/generated-answer/generated-answer-state.d.ts +19 -0
- package/force-app/main/default/staticresources/coveoheadless/definitions/index.d.ts +1 -1
- package/force-app/main/default/staticresources/coveoheadless/definitions/ssr/commerce/controllers/did-you-mean/headless-did-you-mean.ssr.d.ts +4 -3
- package/force-app/main/default/staticresources/coveoheadless/definitions/ssr-commerce-next.index.d.ts +1 -1
- package/force-app/main/default/staticresources/coveoheadless/definitions/ssr-commerce.index.d.ts +1 -1
- package/force-app/main/default/staticresources/coveoheadless/definitions/ssr-next/commerce/controllers/did-you-mean/headless-did-you-mean.ssr.d.ts +4 -3
- package/force-app/main/default/staticresources/coveoheadless/headless.js +18 -18
- package/force-app/main/default/staticresources/coveoheadless/insight/headless.js +17 -17
- package/force-app/main/default/staticresources/coveoheadless/recommendation/headless.js +15 -15
- package/package.json +2 -2
|
@@ -1,23 +1,24 @@
|
|
|
1
1
|
<template>
|
|
2
2
|
<div class={inputContainerClasses}>
|
|
3
|
-
<
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
3
|
+
<div class="follow-up-input__expander slds-grow" lwc:ref="expander">
|
|
4
|
+
<textarea
|
|
5
|
+
class="follow-up-input__textarea"
|
|
6
|
+
lwc:ref="askFollowUpInput"
|
|
7
|
+
rows="1"
|
|
8
|
+
placeholder={labels.askFollowUp}
|
|
9
|
+
aria-label={labels.askFollowUp}
|
|
10
|
+
onfocus={handleFocus}
|
|
11
|
+
onblur={handleBlur}
|
|
12
|
+
oninput={handleInput}
|
|
13
|
+
onkeydown={handleKeyDown}
|
|
14
|
+
></textarea>
|
|
15
|
+
</div>
|
|
15
16
|
<lightning-button-icon
|
|
16
17
|
disabled={submitButtonDisabled}
|
|
17
18
|
onclick={handleSubmitFollowUp}
|
|
18
19
|
icon-name="utility:arrowup"
|
|
19
20
|
variant="brand"
|
|
20
|
-
class="
|
|
21
|
+
class="follow-up-input__submit-button"
|
|
21
22
|
name="submit-follow-up"
|
|
22
23
|
title={labels.submitFollowUp}
|
|
23
24
|
aria-label={labels.submitFollowUp}
|
|
@@ -33,10 +33,16 @@ export default class QuanticGeneratedAnswerFollowUpInput extends LightningElemen
|
|
|
33
33
|
return;
|
|
34
34
|
}
|
|
35
35
|
|
|
36
|
-
if (event.key === keys.ENTER) {
|
|
36
|
+
if (event.key === keys.ENTER && !event.shiftKey) {
|
|
37
37
|
event.preventDefault();
|
|
38
38
|
this.handleSubmitFollowUp();
|
|
39
39
|
}
|
|
40
|
+
|
|
41
|
+
if (event.key === keys.ESC) {
|
|
42
|
+
event.stopPropagation();
|
|
43
|
+
event.preventDefault();
|
|
44
|
+
this.refs.askFollowUpInput.blur();
|
|
45
|
+
}
|
|
40
46
|
}
|
|
41
47
|
|
|
42
48
|
handleSubmitFollowUp() {
|
|
@@ -48,14 +54,46 @@ export default class QuanticGeneratedAnswerFollowUpInput extends LightningElemen
|
|
|
48
54
|
}
|
|
49
55
|
this.sendSubmitFollowUpEvent();
|
|
50
56
|
this.refs.askFollowUpInput.value = '';
|
|
57
|
+
this.syncTextWithReplica();
|
|
58
|
+
this.collapse();
|
|
51
59
|
}
|
|
52
60
|
|
|
53
61
|
handleFocus() {
|
|
54
62
|
this._focused = true;
|
|
63
|
+
this.syncTextWithReplica();
|
|
64
|
+
this.expand();
|
|
55
65
|
}
|
|
56
66
|
|
|
57
67
|
handleBlur() {
|
|
58
68
|
this._focused = false;
|
|
69
|
+
this.collapse();
|
|
70
|
+
}
|
|
71
|
+
|
|
72
|
+
handleInput() {
|
|
73
|
+
this.expand();
|
|
74
|
+
this.syncTextWithReplica();
|
|
75
|
+
}
|
|
76
|
+
|
|
77
|
+
/**
|
|
78
|
+
* Syncs the textarea value with the expander's replicated value for seamless CSS transitions.
|
|
79
|
+
*/
|
|
80
|
+
syncTextWithReplica() {
|
|
81
|
+
const expander = this.refs.expander;
|
|
82
|
+
if (expander) {
|
|
83
|
+
expander.dataset.replicatedValue = this.refs.askFollowUpInput.value;
|
|
84
|
+
}
|
|
85
|
+
}
|
|
86
|
+
|
|
87
|
+
expand() {
|
|
88
|
+
this.refs.expander?.classList.add('follow-up-input__expander--expanded');
|
|
89
|
+
}
|
|
90
|
+
|
|
91
|
+
collapse() {
|
|
92
|
+
const expander = this.refs.expander;
|
|
93
|
+
if (expander) {
|
|
94
|
+
expander.classList.remove('follow-up-input__expander--expanded');
|
|
95
|
+
delete expander.dataset.replicatedValue;
|
|
96
|
+
}
|
|
59
97
|
}
|
|
60
98
|
|
|
61
99
|
/**
|
|
@@ -74,6 +112,6 @@ export default class QuanticGeneratedAnswerFollowUpInput extends LightningElemen
|
|
|
74
112
|
}
|
|
75
113
|
|
|
76
114
|
get inputContainerClasses() {
|
|
77
|
-
return `follow-up-
|
|
115
|
+
return `follow-up-input__container slds-is-relative slds-grid slds-box slds-p-around_none ${this._focused ? 'follow-up-input__container--focused' : ''}`;
|
|
78
116
|
}
|
|
79
117
|
}
|
package/force-app/main/default/lwc/quanticSourceCitations/__tests__/quanticSourceCitations.test.js
CHANGED
|
@@ -7,13 +7,17 @@ import QuanticSourceCitations from '../quanticSourceCitations';
|
|
|
7
7
|
jest.mock('c/quanticHeadlessLoader');
|
|
8
8
|
|
|
9
9
|
let isInitialized = false;
|
|
10
|
+
const mockBuildInteractiveCitation = jest.fn(
|
|
11
|
+
(engine, {options}) => options.citation
|
|
12
|
+
);
|
|
13
|
+
const mockEngine = {};
|
|
10
14
|
|
|
11
15
|
// @ts-ignore
|
|
12
16
|
mockHeadlessLoader.initializeWithHeadless = (element, engineId, initialize) => {
|
|
13
17
|
if (element instanceof QuanticSourceCitations) {
|
|
14
18
|
if (!isInitialized) {
|
|
15
19
|
isInitialized = true;
|
|
16
|
-
initialize();
|
|
20
|
+
initialize(mockEngine);
|
|
17
21
|
}
|
|
18
22
|
}
|
|
19
23
|
};
|
|
@@ -21,7 +25,7 @@ mockHeadlessLoader.initializeWithHeadless = (element, engineId, initialize) => {
|
|
|
21
25
|
// @ts-ignore
|
|
22
26
|
mockHeadlessLoader.getHeadlessBundle = () => {
|
|
23
27
|
return {
|
|
24
|
-
buildInteractiveCitation:
|
|
28
|
+
buildInteractiveCitation: mockBuildInteractiveCitation,
|
|
25
29
|
};
|
|
26
30
|
};
|
|
27
31
|
|
|
@@ -43,9 +47,11 @@ const mockCitations = [
|
|
|
43
47
|
text: 'text 02',
|
|
44
48
|
},
|
|
45
49
|
];
|
|
50
|
+
const mockAnswerId = 'test-answer-id';
|
|
46
51
|
|
|
47
52
|
const defaultOptions = {
|
|
48
53
|
citations: mockCitations,
|
|
54
|
+
answerId: mockAnswerId,
|
|
49
55
|
};
|
|
50
56
|
|
|
51
57
|
const selectors = {
|
|
@@ -104,6 +110,20 @@ describe('c-quantic-source-citations', () => {
|
|
|
104
110
|
});
|
|
105
111
|
});
|
|
106
112
|
|
|
113
|
+
it('should call buildInteractiveCitation for each citation with the correct parameters', async () => {
|
|
114
|
+
createTestComponent();
|
|
115
|
+
await flushPromises();
|
|
116
|
+
|
|
117
|
+
expect(mockBuildInteractiveCitation).toHaveBeenCalledTimes(
|
|
118
|
+
mockCitations.length
|
|
119
|
+
);
|
|
120
|
+
mockCitations.forEach((citation) => {
|
|
121
|
+
expect(mockBuildInteractiveCitation).toHaveBeenCalledWith(mockEngine, {
|
|
122
|
+
options: {citation, answerId: mockAnswerId},
|
|
123
|
+
});
|
|
124
|
+
});
|
|
125
|
+
});
|
|
126
|
+
|
|
107
127
|
it('should pass the disableCitationAnchoring property to the citation component', async () => {
|
|
108
128
|
const element = createTestComponent();
|
|
109
129
|
await flushPromises();
|
|
@@ -44,6 +44,12 @@ export default class QuanticSourceCitations extends LightningElement {
|
|
|
44
44
|
* @default false
|
|
45
45
|
*/
|
|
46
46
|
@api disableCitationAnchoring = false;
|
|
47
|
+
/**
|
|
48
|
+
* The unique identifier of the generated answer.
|
|
49
|
+
* @api
|
|
50
|
+
* @type {string}
|
|
51
|
+
*/
|
|
52
|
+
@api answerId;
|
|
47
53
|
|
|
48
54
|
/** @type {AnyHeadless} */
|
|
49
55
|
headless;
|
|
@@ -79,6 +85,7 @@ export default class QuanticSourceCitations extends LightningElement {
|
|
|
79
85
|
{
|
|
80
86
|
options: {
|
|
81
87
|
citation,
|
|
88
|
+
answerId: this.answerId,
|
|
82
89
|
},
|
|
83
90
|
}
|
|
84
91
|
),
|