@coveo/atomic 3.52.0 → 3.53.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/README.md +0 -26
- package/custom-elements.json +34 -4
- package/dist/atomic/atomic.esm.js +0 -1
- package/dist/atomic/autoloader/index.cjs.js +2 -2
- package/dist/atomic/autoloader/index.esm.js +2 -2
- package/dist/atomic/components/components/commerce/product-template-component-utils/context/fetch-product-context.js +14 -0
- package/dist/atomic/components/components/common/generated-answer/atomic-answer-content/atomic-answer-content.js +35 -9
- package/dist/atomic/components/components/common/generated-answer/feedback-button.js +2 -1
- package/dist/atomic/components/components/common/generated-answer/render-agent-generation-steps.js +34 -0
- package/dist/atomic/components/components/common/generated-answer/render-answer-content.js +7 -19
- package/dist/atomic/components/components/common/generated-answer/render-disclaimer.js +6 -7
- package/dist/atomic/components/components/common/generated-answer/styles/generated-answer.tw.css.js +1 -1
- package/dist/atomic/components/components/common/item-list/fetch-item-context.js +15 -0
- package/dist/atomic/components/components/insight/atomic-insight-generated-answer/atomic-insight-generated-answer.js +7 -4
- package/dist/atomic/components/components/search/atomic-generated-answer/atomic-generated-answer.js +18 -13
- package/dist/atomic/components/global/environment.js +1 -1
- package/dist/atomic/components/index.d.ts +2 -3
- package/dist/atomic/components/index.js +8 -2
- package/dist/atomic/lang/cs.json +1 -1
- package/dist/atomic/lang/da.json +1 -1
- package/dist/atomic/lang/de.json +1 -1
- package/dist/atomic/lang/dev.json +1 -1
- package/dist/atomic/lang/el.json +1 -1
- package/dist/atomic/lang/en.json +1 -1
- package/dist/atomic/lang/es.json +1 -1
- package/dist/atomic/lang/fi.json +1 -1
- package/dist/atomic/lang/fr.json +1 -1
- package/dist/atomic/lang/hu.json +1 -1
- package/dist/atomic/lang/id.json +1 -1
- package/dist/atomic/lang/it.json +1 -1
- package/dist/atomic/lang/ja.json +1 -1
- package/dist/atomic/lang/ko.json +1 -1
- package/dist/atomic/lang/nl.json +1 -1
- package/dist/atomic/lang/no.json +1 -1
- package/dist/atomic/lang/pl.json +1 -1
- package/dist/atomic/lang/pt-BR.json +1 -1
- package/dist/atomic/lang/pt.json +1 -1
- package/dist/atomic/lang/ru.json +1 -1
- package/dist/atomic/lang/sv.json +1 -1
- package/dist/atomic/lang/th.json +1 -1
- package/dist/atomic/lang/tr.json +1 -1
- package/dist/atomic/lang/zh-CN.json +1 -1
- package/dist/atomic/lang/zh-TW.json +1 -1
- package/dist/atomic/lang/zh.json +1 -1
- package/dist/atomic/loader/index.d.ts +4 -15
- package/dist/atomic/loader/index.js +0 -1
- package/dist/cjs/index.cjs.js +5 -2
- package/dist/cjs/loader.cjs.js +7 -4
- package/dist/cjs/version.cjs.js +2 -2
- package/dist/esm/index.js +0 -1
- package/dist/esm/loader.js +9 -5
- package/dist/esm/version.js +2 -2
- package/dist/types/components/common/generated-answer/atomic-answer-content/atomic-answer-content.d.ts +3 -1
- package/dist/types/components/common/generated-answer/atomic-generated-answers-thread/atomic-generated-answers-thread.d.ts +1 -1
- package/dist/types/components/common/generated-answer/render-agent-generation-steps.d.ts +16 -0
- package/dist/types/components/common/generated-answer/render-answer-content.d.ts +3 -4
- package/dist/types/components/common/generated-answer/render-disclaimer.d.ts +0 -1
- package/dist/types/index.d.ts +2 -1
- package/package.json +17 -31
- package/dist/atomic/_atomic.esm.js +0 -2
- package/dist/atomic/atomic.esm.js.map +0 -1
- package/dist/atomic/components/_index.d.ts +0 -36
- package/dist/atomic/components/_index.js +0 -219
- package/dist/atomic/components/index.js.map +0 -1
- package/dist/atomic/index.esm.js +0 -2
- package/dist/atomic/index.esm.js.map +0 -1
- package/dist/atomic/loader/cdn.js +0 -1
- package/dist/atomic/loader/index.cjs.js +0 -1
- package/dist/atomic/loader/index.es2017.js +0 -1
- package/dist/atomic/p-998f7983.js +0 -3
- package/dist/atomic/p-998f7983.js.map +0 -1
- package/dist/cjs/_index.cjs.js +0 -236
- package/dist/cjs/_loader.cjs.js +0 -16
- package/dist/cjs/app-globals-18f43c37.js +0 -506
- package/dist/cjs/app-globals-18f43c37.js.map +0 -1
- package/dist/cjs/atomic.cjs.js +0 -26
- package/dist/cjs/atomic.cjs.js.map +0 -1
- package/dist/cjs/index.cjs.js.map +0 -1
- package/dist/cjs/loader.cjs.js.map +0 -1
- package/dist/esm/_index.js +0 -218
- package/dist/esm/_loader.js +0 -12
- package/dist/esm/app-globals-c5b073da.js +0 -481
- package/dist/esm/app-globals-c5b073da.js.map +0 -1
- package/dist/esm/atomic.js +0 -21
- package/dist/esm/atomic.js.map +0 -1
- package/dist/esm/index.js.map +0 -1
- package/dist/esm/loader.js.map +0 -1
- package/dist/index.cjs.js +0 -1
- package/dist/index.js +0 -1
- package/dist/types/autoloader/index.d.ts +0 -1
- package/dist/types/components/common/layout/display-options.d.ts +0 -40
- package/dist/types/components/search/atomic-smart-snippet-feedback-modal/atomic-smart-snippet-feedback-modal.tw.css.d.ts +0 -2
- package/dist/types/components/search/result-template-component-utils/context/fetch-result-context.d.ts +0 -8
- package/dist/types/components.d.ts +0 -24
- package/dist/types/icons.d.ts +0 -4
- package/dist/types/lit-components.d.ts +0 -10
- package/dist/types/stencil-public-runtime.d.ts +0 -1674
- package/dist/types/types/custom-env.d.ts +0 -7
- package/dist/types/types/dayjs/locale.d.ts +0 -4
- package/dist/types/types/open-api.d.ts +0 -3
- package/dist/types/types/storybook.d.ts +0 -7
- package/docs/atomic-docs.d.ts +0 -435
- package/docs/atomic-docs.json +0 -10
package/README.md
CHANGED
|
@@ -79,32 +79,6 @@ pnpm turbo run test --filter=@coveo/atomic
|
|
|
79
79
|
|
|
80
80
|
This Storybook instance is configured with the MCP addon, which enables AI agents to programmatically interact with component stories. When Storybook is running, the MCP server is accessible at `http://localhost:4400/mcp`.
|
|
81
81
|
|
|
82
|
-
## Run Cypress for Atomic components
|
|
83
|
-
|
|
84
|
-
Ref: https://docs.cypress.io/
|
|
85
|
-
|
|
86
|
-
- All the tests will need to be under folder cypress\integration
|
|
87
|
-
|
|
88
|
-
### Open
|
|
89
|
-
|
|
90
|
-
To open cypress, run:
|
|
91
|
-
|
|
92
|
-
```sh
|
|
93
|
-
pnpm turbo run e2e:watch --filter=@coveo/atomic
|
|
94
|
-
```
|
|
95
|
-
|
|
96
|
-
To run all the test, run:
|
|
97
|
-
|
|
98
|
-
```sh
|
|
99
|
-
pnpm turbo run e2e --filter=@coveo/atomic
|
|
100
|
-
```
|
|
101
|
-
|
|
102
|
-
To run all the test in Firefox:
|
|
103
|
-
|
|
104
|
-
```sh
|
|
105
|
-
pnpm turbo run e2e:firefox --filter=@coveo/atomic
|
|
106
|
-
```
|
|
107
|
-
|
|
108
82
|
## Utilities
|
|
109
83
|
|
|
110
84
|
### Stencil decorators
|
package/custom-elements.json
CHANGED
|
@@ -6,7 +6,24 @@
|
|
|
6
6
|
"kind": "javascript-module",
|
|
7
7
|
"path": "src/index.ts",
|
|
8
8
|
"declarations": [],
|
|
9
|
-
"exports": [
|
|
9
|
+
"exports": [
|
|
10
|
+
{
|
|
11
|
+
"kind": "js",
|
|
12
|
+
"name": "Components",
|
|
13
|
+
"declaration": {
|
|
14
|
+
"name": "_Components",
|
|
15
|
+
"module": "src/index.ts"
|
|
16
|
+
}
|
|
17
|
+
},
|
|
18
|
+
{
|
|
19
|
+
"kind": "js",
|
|
20
|
+
"name": "JSX",
|
|
21
|
+
"declaration": {
|
|
22
|
+
"name": "_Components",
|
|
23
|
+
"module": "src/index.ts"
|
|
24
|
+
}
|
|
25
|
+
}
|
|
26
|
+
]
|
|
10
27
|
},
|
|
11
28
|
{
|
|
12
29
|
"kind": "javascript-module",
|
|
@@ -14124,6 +14141,12 @@
|
|
|
14124
14141
|
"declarations": [],
|
|
14125
14142
|
"exports": []
|
|
14126
14143
|
},
|
|
14144
|
+
{
|
|
14145
|
+
"kind": "javascript-module",
|
|
14146
|
+
"path": "src/components/common/generated-answer/render-agent-generation-steps.ts",
|
|
14147
|
+
"declarations": [],
|
|
14148
|
+
"exports": []
|
|
14149
|
+
},
|
|
14127
14150
|
{
|
|
14128
14151
|
"kind": "javascript-module",
|
|
14129
14152
|
"path": "src/components/common/generated-answer/render-answer-content.ts",
|
|
@@ -31547,6 +31570,13 @@
|
|
|
31547
31570
|
"type": {
|
|
31548
31571
|
"text": "GeneratedAnswerCitation[]"
|
|
31549
31572
|
}
|
|
31573
|
+
},
|
|
31574
|
+
{
|
|
31575
|
+
"name": "answerId",
|
|
31576
|
+
"optional": true,
|
|
31577
|
+
"type": {
|
|
31578
|
+
"text": "string"
|
|
31579
|
+
}
|
|
31550
31580
|
}
|
|
31551
31581
|
]
|
|
31552
31582
|
},
|
|
@@ -47866,19 +47896,19 @@
|
|
|
47866
47896
|
},
|
|
47867
47897
|
{
|
|
47868
47898
|
"kind": "javascript-module",
|
|
47869
|
-
"path": "src/components/common/facets/facet-value-
|
|
47899
|
+
"path": "src/components/common/facets/facet-value-exclude/facet-value-exclude.ts",
|
|
47870
47900
|
"declarations": [],
|
|
47871
47901
|
"exports": []
|
|
47872
47902
|
},
|
|
47873
47903
|
{
|
|
47874
47904
|
"kind": "javascript-module",
|
|
47875
|
-
"path": "src/components/common/facets/facet-value-exclude/facet-value-exclude.ts",
|
|
47905
|
+
"path": "src/components/common/facets/facet-value-exclude/facet-value-exclude.tw.css.ts",
|
|
47876
47906
|
"declarations": [],
|
|
47877
47907
|
"exports": []
|
|
47878
47908
|
},
|
|
47879
47909
|
{
|
|
47880
47910
|
"kind": "javascript-module",
|
|
47881
|
-
"path": "src/components/common/facets/facet-value-
|
|
47911
|
+
"path": "src/components/common/facets/facet-value-label-highlight/facet-value-label-highlight.ts",
|
|
47882
47912
|
"declarations": [],
|
|
47883
47913
|
"exports": []
|
|
47884
47914
|
},
|
|
@@ -57,12 +57,12 @@ function registerAutoloader(roots) {
|
|
|
57
57
|
};
|
|
58
58
|
const discover = async (root) => {
|
|
59
59
|
visitedNodes.add(root);
|
|
60
|
-
const rootTagName = root
|
|
60
|
+
const rootTagName = root instanceof Element ? root.tagName.toLowerCase() : "";
|
|
61
61
|
const rootIsCustomElement = rootTagName?.includes("-");
|
|
62
62
|
const allCustomElements = [...root.querySelectorAll("*")].filter(
|
|
63
63
|
(el) => el.tagName.toLowerCase().includes("-")
|
|
64
64
|
);
|
|
65
|
-
if (rootIsCustomElement &&
|
|
65
|
+
if (rootIsCustomElement && root instanceof Element && !customElements.get(rootTagName) && !allCustomElements.includes(root)) {
|
|
66
66
|
allCustomElements.push(root);
|
|
67
67
|
}
|
|
68
68
|
if (rootIsCustomElement) {
|
|
@@ -24,12 +24,12 @@ function registerAutoloader(roots) {
|
|
|
24
24
|
};
|
|
25
25
|
const discover = async (root) => {
|
|
26
26
|
visitedNodes.add(root);
|
|
27
|
-
const rootTagName = root
|
|
27
|
+
const rootTagName = root instanceof Element ? root.tagName.toLowerCase() : "";
|
|
28
28
|
const rootIsCustomElement = rootTagName?.includes("-");
|
|
29
29
|
const allCustomElements = [...root.querySelectorAll("*")].filter(
|
|
30
30
|
(el) => el.tagName.toLowerCase().includes("-")
|
|
31
31
|
);
|
|
32
|
-
if (rootIsCustomElement &&
|
|
32
|
+
if (rootIsCustomElement && root instanceof Element && !customElements.get(rootTagName) && !allCustomElements.includes(root)) {
|
|
33
33
|
allCustomElements.push(root);
|
|
34
34
|
}
|
|
35
35
|
if (rootIsCustomElement) {
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import { fetchItemContext } from "../../../common/item-list/fetch-item-context";
|
|
2
|
+
/**
|
|
3
|
+
* Retrieves `Product` on a rendered `atomic-product`.
|
|
4
|
+
*
|
|
5
|
+
* This utility function is useful for building custom product template elements, see [Create a Product List](https://docs.coveo.com/en/atomic/latest/cc-search/create-custom-components/native-components/#custom-product-template-component-example) for more information.
|
|
6
|
+
*
|
|
7
|
+
* You should use the utility function in the [`connectedCallback` lifecycle method](https://developer.mozilla.org/en-US/docs/Web/Web_Components/Using_custom_elements#using_the_lifecycle_callbacks).
|
|
8
|
+
*
|
|
9
|
+
* @param element - The element that the event is dispatched to, which must be the child of a rendered `atomic-product`.
|
|
10
|
+
* @returns A promise that resolves on initialization of the parent `atomic-product` element, or rejects when there is no parent `atomic-product` element.
|
|
11
|
+
*/
|
|
12
|
+
export function fetchProductContext(element) {
|
|
13
|
+
return fetchItemContext(element, 'atomic-product');
|
|
14
|
+
}
|
|
@@ -6,9 +6,11 @@ var __decorate = (this && this.__decorate) || function (decorators, target, key,
|
|
|
6
6
|
};
|
|
7
7
|
import { html, LitElement } from 'lit';
|
|
8
8
|
import { customElement, property, state } from 'lit/decorators.js';
|
|
9
|
+
import { when } from 'lit/directives/when.js';
|
|
9
10
|
import atomicGeneratedAnswerStyles from "../../../search/atomic-generated-answer/atomic-generated-answer.tw.css.js";
|
|
10
11
|
import { withTailwindStyles } from "../../../../decorators/with-tailwind-styles";
|
|
11
12
|
import { renderGeneratedContentContainer } from '../generated-content-container';
|
|
13
|
+
import { renderAgentGenerationSteps } from '../render-agent-generation-steps';
|
|
12
14
|
import { renderFeedbackAndCopyButtons } from '../render-feedback-and-copy-buttons';
|
|
13
15
|
import { renderSourceCitations } from '../source-citations';
|
|
14
16
|
const COPY_RESET_DURATION_MS = 2000;
|
|
@@ -46,15 +48,26 @@ let AtomicAnswerContent = class AtomicAnswerContent extends LitElement {
|
|
|
46
48
|
clearTimeout(this.resetCopyTimeout);
|
|
47
49
|
}
|
|
48
50
|
render() {
|
|
49
|
-
const { answer, answerContentFormat, isStreaming, citations = [], answerId, error, } = this.generatedAnswer || {};
|
|
51
|
+
const { answer, answerContentFormat, isStreaming, generationSteps, citations = [], answerId, error, cannotAnswer, } = this.generatedAnswer || {};
|
|
50
52
|
if (error) {
|
|
51
53
|
return this.renderError();
|
|
52
54
|
}
|
|
53
|
-
if (
|
|
55
|
+
if (cannotAnswer) {
|
|
56
|
+
return this.renderCannotAnswer();
|
|
57
|
+
}
|
|
58
|
+
if (!answerId) {
|
|
54
59
|
return html ``;
|
|
55
60
|
}
|
|
61
|
+
const shouldRenderFeedbackAndCopyButtons = Boolean(answer) && !isStreaming;
|
|
56
62
|
return html `
|
|
57
63
|
<div>
|
|
64
|
+
${renderAgentGenerationSteps({
|
|
65
|
+
props: {
|
|
66
|
+
i18n: this.i18n,
|
|
67
|
+
agentSteps: generationSteps ?? [],
|
|
68
|
+
isStreaming: Boolean(isStreaming),
|
|
69
|
+
},
|
|
70
|
+
})}
|
|
58
71
|
<div>
|
|
59
72
|
${renderGeneratedContentContainer({
|
|
60
73
|
props: {
|
|
@@ -63,17 +76,22 @@ let AtomicAnswerContent = class AtomicAnswerContent extends LitElement {
|
|
|
63
76
|
isStreaming: Boolean(isStreaming),
|
|
64
77
|
},
|
|
65
78
|
})(html `
|
|
66
|
-
|
|
79
|
+
${renderSourceCitations({
|
|
67
80
|
props: {
|
|
68
81
|
label: this.i18n.t('citations'),
|
|
69
82
|
isVisible: citations.length > 0,
|
|
70
83
|
},
|
|
71
|
-
})(html `${this.renderCitations(citations)}`)}
|
|
72
|
-
|
|
84
|
+
})(html `${this.renderCitations(citations, answerId)}`)}
|
|
85
|
+
`)}
|
|
73
86
|
</div>
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
87
|
+
${when(shouldRenderFeedbackAndCopyButtons, () => this.renderFeedbackAndCopyButtons(answerId))}
|
|
88
|
+
</div>
|
|
89
|
+
`;
|
|
90
|
+
}
|
|
91
|
+
renderFeedbackAndCopyButtons(answerId) {
|
|
92
|
+
return html `
|
|
93
|
+
<div class="mt-4" part="feedback-and-copy-buttons">
|
|
94
|
+
${renderFeedbackAndCopyButtons({
|
|
77
95
|
props: {
|
|
78
96
|
i18n: this.i18n,
|
|
79
97
|
generatedAnswerActionsState: {
|
|
@@ -91,7 +109,6 @@ let AtomicAnswerContent = class AtomicAnswerContent extends LitElement {
|
|
|
91
109
|
onCopyToClipboard: () => this.copyToClipboard(),
|
|
92
110
|
},
|
|
93
111
|
})}
|
|
94
|
-
</div>
|
|
95
112
|
</div>
|
|
96
113
|
`;
|
|
97
114
|
}
|
|
@@ -136,6 +153,15 @@ let AtomicAnswerContent = class AtomicAnswerContent extends LitElement {
|
|
|
136
153
|
</div>
|
|
137
154
|
`;
|
|
138
155
|
}
|
|
156
|
+
renderCannotAnswer() {
|
|
157
|
+
return html `
|
|
158
|
+
<div part="generated-answer-cannot-answer">
|
|
159
|
+
<p>
|
|
160
|
+
${this.i18n.t('generated-answer-cannot-generate-answer')}
|
|
161
|
+
</p>
|
|
162
|
+
</div>
|
|
163
|
+
`;
|
|
164
|
+
}
|
|
139
165
|
};
|
|
140
166
|
AtomicAnswerContent.styles = [atomicGeneratedAnswerStyles];
|
|
141
167
|
__decorate([
|
|
@@ -10,7 +10,8 @@ export const renderFeedbackButton = ({ props, }) => {
|
|
|
10
10
|
const baseClassName = getClassNameForButtonStyle(buttonStyle);
|
|
11
11
|
const classNames = multiClassMap(tw({
|
|
12
12
|
[baseClassName]: true,
|
|
13
|
-
'feedback-button rounded-md p-2
|
|
13
|
+
'feedback-button rounded-md p-2': true,
|
|
14
|
+
'text-neutral-dark': !props.active,
|
|
14
15
|
[props.variant]: true,
|
|
15
16
|
active: props.active,
|
|
16
17
|
'hover:text-success': props.variant === 'like',
|
package/dist/atomic/components/components/common/generated-answer/render-agent-generation-steps.js
ADDED
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
import { html } from 'lit';
|
|
2
|
+
import { keyed } from 'lit/directives/keyed.js';
|
|
3
|
+
import { when } from 'lit/directives/when.js';
|
|
4
|
+
const stepLabelKeys = {
|
|
5
|
+
searching: 'agent-generation-step-search',
|
|
6
|
+
thinking: 'agent-generation-step-think',
|
|
7
|
+
answering: 'generating-answer',
|
|
8
|
+
};
|
|
9
|
+
/**
|
|
10
|
+
* @internal
|
|
11
|
+
*/
|
|
12
|
+
export const renderAgentGenerationSteps = ({ props }) => {
|
|
13
|
+
const { i18n, agentSteps, isStreaming } = props;
|
|
14
|
+
const currentStepKey = getCurrentStepKey(agentSteps);
|
|
15
|
+
const currentStepLabel = currentStepKey ? i18n.t(currentStepKey) : undefined;
|
|
16
|
+
const canRender = isStreaming && !!currentStepLabel;
|
|
17
|
+
return html `${when(canRender, () => keyed(currentStepKey, html `
|
|
18
|
+
<div
|
|
19
|
+
part="agent-generation-status"
|
|
20
|
+
class="text-neutral-dark flex text-sm font-light"
|
|
21
|
+
>
|
|
22
|
+
<span class="generation-steps-container">
|
|
23
|
+
<span class="generation-steps-value">${currentStepLabel}</span>
|
|
24
|
+
</span>
|
|
25
|
+
</div>
|
|
26
|
+
`))}`;
|
|
27
|
+
};
|
|
28
|
+
/**
|
|
29
|
+
* Returns the current generation-step localization key.
|
|
30
|
+
*/
|
|
31
|
+
export function getCurrentStepKey(generationSteps) {
|
|
32
|
+
const activeStep = generationSteps.findLast((step) => step.status === 'active');
|
|
33
|
+
return activeStep ? stepLabelKeys[activeStep.name] : undefined;
|
|
34
|
+
}
|
|
@@ -7,31 +7,14 @@ import { renderSourceCitations } from "./source-citations";
|
|
|
7
7
|
import { renderGeneratingAnswerLabel } from './render-generating-answer-label';
|
|
8
8
|
import "../atomic-icon/atomic-icon";
|
|
9
9
|
/**
|
|
10
|
-
* Renders the answer content of a given generated answer including
|
|
10
|
+
* Renders the answer content of a given generated answer including answer text and citations.
|
|
11
11
|
*/
|
|
12
12
|
export const renderAnswerContent = ({ props }) => {
|
|
13
13
|
const { i18n, generatedAnswer, collapsible, renderFeedbackAndCopyButtonsSlot, renderCitationsSlot, onRetry, onClickShowButton, } = props;
|
|
14
|
-
const { answer,
|
|
15
|
-
const isExpanded = collapsible ? expanded : true;
|
|
16
|
-
const trimmedQuestion = question.trim();
|
|
14
|
+
const { answer, isStreaming, citations, answerContentFormat, expanded, error } = generatedAnswer;
|
|
17
15
|
const hasRetryableError = error?.isRetryable === true;
|
|
18
16
|
return html `
|
|
19
17
|
<div>
|
|
20
|
-
<div class="mt-6 flex gap-3">
|
|
21
|
-
<p
|
|
22
|
-
class="question-text min-w-0 flex-1 text-base font-semibold leading-6"
|
|
23
|
-
>
|
|
24
|
-
${trimmedQuestion}
|
|
25
|
-
</p>
|
|
26
|
-
${when(!hasRetryableError && isExpanded, () => html `
|
|
27
|
-
<div
|
|
28
|
-
part="feedback-and-copy-buttons"
|
|
29
|
-
class="flex h-9 shrink-0 items-center justify-end gap-2"
|
|
30
|
-
>
|
|
31
|
-
${renderFeedbackAndCopyButtonsSlot()}
|
|
32
|
-
</div>
|
|
33
|
-
`)}
|
|
34
|
-
</div>
|
|
35
18
|
${hasRetryableError
|
|
36
19
|
? renderRetryPrompt({
|
|
37
20
|
props: {
|
|
@@ -57,6 +40,11 @@ export const renderAnswerContent = ({ props }) => {
|
|
|
57
40
|
})(renderCitationsSlot())}
|
|
58
41
|
`)
|
|
59
42
|
: nothing}
|
|
43
|
+
${when(!hasRetryableError && (collapsible ? expanded : true), () => html `
|
|
44
|
+
<div class="mt-4" part="feedback-and-copy-buttons">
|
|
45
|
+
${renderFeedbackAndCopyButtonsSlot()}
|
|
46
|
+
</div>
|
|
47
|
+
`)}
|
|
60
48
|
${!hasRetryableError
|
|
61
49
|
? html `
|
|
62
50
|
<div part="generated-answer-footer" class="mt-6">
|
|
@@ -1,13 +1,12 @@
|
|
|
1
1
|
import { html } from 'lit';
|
|
2
|
-
import { when } from 'lit/directives/when.js';
|
|
3
2
|
/**
|
|
4
3
|
* Renders the disclaimer text for the generated answer.
|
|
5
4
|
*/
|
|
6
5
|
export const renderDisclaimer = ({ props, }) => {
|
|
7
|
-
const { i18n
|
|
8
|
-
return html
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
6
|
+
const { i18n } = props;
|
|
7
|
+
return html `
|
|
8
|
+
<div class="flex justify-end text-neutral-dark text-xs/[1rem]">
|
|
9
|
+
<slot name="disclaimer">${i18n.t('generated-answer-disclaimer')}</slot>
|
|
10
|
+
</div>
|
|
11
|
+
`;
|
|
13
12
|
};
|
package/dist/atomic/components/components/common/generated-answer/styles/generated-answer.tw.css.js
CHANGED
|
@@ -3,7 +3,7 @@ import generatedMarkdownContent from '../generated-content/generated-markdown-co
|
|
|
3
3
|
import copyButton from './copy-button.tw.css';
|
|
4
4
|
import feedbackButtons from './feedback-buttons.tw.css';
|
|
5
5
|
import generatedText from './generated-text.tw.css';
|
|
6
|
-
const baseStyle = css`/*! tailwindcss v4.1.13 | MIT License | https://tailwindcss.com */@keyframes cursor-blink{0%{opacity:0}}[part=container]{contain:layout;container-type:inline-size}.footer{display:flex}.footer .source-citations{margin-right:calc(var(--spacing, .25rem)*2)}@container (max-width: 37.5rem){.footer{flex-direction:column;gap:calc(var(--spacing, .25rem)*4)}.footer .source-citations{margin-right:calc(var(--spacing, .25rem)*0)}[part=generated-answer-footer]{flex-direction:column;gap:calc(var(--spacing, .25rem)*1)}}@media not all and (width >= 768px){.footer{flex-direction:column;gap:calc(var(--spacing, .25rem)*4)}.footer .source-citations{margin-right:calc(var(--spacing, .25rem)*0)}[part=generated-answer-footer]{flex-direction:column;gap:calc(var(--spacing, .25rem)*1)}}@container (max-width: 25rem){.footer{margin-top:calc(var(--spacing, .25rem)*4)}.footer .feedback-buttons{position:relative;right:calc(var(--spacing, .25rem)*0);top:calc(var(--spacing, .25rem)*0)}}.is-collapsible{justify-content:space-between}.is-collapsible [part=answer-show-button]{display:flex}[part=header-icon]{color:var(--atomic-primary)}[part=feedback-and-copy-buttons]{min-width:var(--atomic-generated-answer-actions-reserved-width,8rem)}[part=header-icon] svg,[part=header-icon] svg *{fill:currentColor;stroke:currentColor}.generating-label-visible [part=is-generating]{display:flex}[part=generated-container].answer-collapsed{max-height:var(--atomic-crga-collapsed-height,16rem);overflow:hidden;position:relative}[part=generated-container].answer-collapsed:before{background:linear-gradient(transparent calc(var(--atomic-crga-collapsed-height, 16rem)*.7),var(--atomic-background));content:"";height:100%;left:calc(var(--spacing, .25rem)*0);position:absolute;top:calc(var(--spacing, .25rem)*0);width:100%}[part=generated-container].answer-collapsed .feedback-buttons{display:none}[part=generated-content-container] .agent-scrollable{height:var(--atomic-generated-answer-content-fixed-height,50vh);overflow-y:auto}.query-text{display:-webkit-box;-webkit-line-clamp:3;-webkit-box-orient:vertical;overflow:hidden;text-overflow:ellipsis}`;
|
|
6
|
+
const baseStyle = css`/*! tailwindcss v4.1.13 | MIT License | https://tailwindcss.com */@keyframes cursor-blink{0%{opacity:0}}@keyframes generation-steps-rolodex{0%{opacity:.75;transform:translateY(105%) rotateX(-82deg)}to{opacity:1;transform:translateY(0) rotateX(0deg)}}[part=container]{contain:layout;container-type:inline-size}.footer{display:flex}.footer .source-citations{margin-right:calc(var(--spacing, .25rem)*2)}@container (max-width: 37.5rem){.footer{flex-direction:column;gap:calc(var(--spacing, .25rem)*4)}.footer .source-citations{margin-right:calc(var(--spacing, .25rem)*0)}[part=generated-answer-footer]{flex-direction:column;gap:calc(var(--spacing, .25rem)*1)}}@media not all and (width >= 768px){.footer{flex-direction:column;gap:calc(var(--spacing, .25rem)*4)}.footer .source-citations{margin-right:calc(var(--spacing, .25rem)*0)}[part=generated-answer-footer]{flex-direction:column;gap:calc(var(--spacing, .25rem)*1)}}@container (max-width: 25rem){.footer{margin-top:calc(var(--spacing, .25rem)*4)}.footer .feedback-buttons{position:relative;right:calc(var(--spacing, .25rem)*0);top:calc(var(--spacing, .25rem)*0)}}.is-collapsible{justify-content:space-between}.is-collapsible [part=answer-show-button]{display:flex}[part=header-icon]{color:var(--atomic-primary)}[part=feedback-and-copy-buttons]{min-width:var(--atomic-generated-answer-actions-reserved-width,8rem)}[part=header-icon] svg,[part=header-icon] svg *{fill:currentColor;stroke:currentColor}.generating-label-visible [part=is-generating]{display:flex}[part=agent-generation-status] .generation-steps-container{display:inline-flex;overflow:hidden;perspective:700px}[part=agent-generation-status] .generation-steps-value{animation:generation-steps-rolodex 1s cubic-bezier(.22,.9,.26,1) both;backface-visibility:hidden;display:inline-block;transform-origin:50% 100%;white-space:nowrap;will-change:transform}[part=generated-container].answer-collapsed{max-height:var(--atomic-crga-collapsed-height,16rem);overflow:hidden;position:relative}[part=generated-container].answer-collapsed:before{background:linear-gradient(transparent calc(var(--atomic-crga-collapsed-height, 16rem)*.7),var(--atomic-background));content:"";height:100%;left:calc(var(--spacing, .25rem)*0);position:absolute;top:calc(var(--spacing, .25rem)*0);width:100%}[part=generated-container].answer-collapsed .feedback-buttons{display:none}[part=generated-content-container] .agent-scrollable{height:var(--atomic-generated-answer-content-fixed-height,50vh);overflow-y:auto}.query-text{display:-webkit-box;-webkit-line-clamp:3;-webkit-box-orient:vertical;overflow:hidden;text-overflow:ellipsis}`;
|
|
7
7
|
export default [
|
|
8
8
|
baseStyle,
|
|
9
9
|
generatedText,
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import { closest } from '../../../utils/dom-utils.js';
|
|
2
|
+
import { buildCustomEvent } from '../../../utils/event-utils.js';
|
|
3
|
+
import { MissingParentError } from './context/item-context-controller.js';
|
|
4
|
+
const itemContextEventName = 'atomic/resolveResult';
|
|
5
|
+
export function fetchItemContext(element, parentName) {
|
|
6
|
+
return new Promise((resolve, reject) => {
|
|
7
|
+
const event = buildCustomEvent(itemContextEventName, (item) => {
|
|
8
|
+
return resolve(item);
|
|
9
|
+
});
|
|
10
|
+
element.dispatchEvent(event);
|
|
11
|
+
if (!closest(element, parentName)) {
|
|
12
|
+
reject(new MissingParentError(element.nodeName.toLowerCase(), parentName));
|
|
13
|
+
}
|
|
14
|
+
});
|
|
15
|
+
}
|
|
@@ -188,7 +188,6 @@ let AtomicInsightGeneratedAnswer = AtomicInsightGeneratedAnswer_1 = class Atomic
|
|
|
188
188
|
${renderDisclaimer({
|
|
189
189
|
props: {
|
|
190
190
|
i18n: this.bindings.i18n,
|
|
191
|
-
isStreaming: !!this.generatedAnswerState.isStreaming,
|
|
192
191
|
},
|
|
193
192
|
})}
|
|
194
193
|
</div>`)}
|
|
@@ -260,7 +259,11 @@ let AtomicInsightGeneratedAnswer = AtomicInsightGeneratedAnswer_1 = class Atomic
|
|
|
260
259
|
?.getBoundingClientRect().height;
|
|
261
260
|
if (answerHeight) {
|
|
262
261
|
const rootFontSize = parseFloat(getComputedStyle(document.documentElement).fontSize);
|
|
263
|
-
|
|
262
|
+
const nextFullAnswerHeight = answerHeight / rootFontSize;
|
|
263
|
+
if (this.fullAnswerHeight !== nextFullAnswerHeight) {
|
|
264
|
+
this.fullAnswerHeight = nextFullAnswerHeight;
|
|
265
|
+
this.requestUpdate();
|
|
266
|
+
}
|
|
264
267
|
this.updateAnswerHeight();
|
|
265
268
|
}
|
|
266
269
|
}
|
|
@@ -340,13 +343,13 @@ let AtomicInsightGeneratedAnswer = AtomicInsightGeneratedAnswer_1 = class Atomic
|
|
|
340
343
|
renderContent() {
|
|
341
344
|
const generatedAnswer = {
|
|
342
345
|
...this.generatedAnswerState,
|
|
343
|
-
question: this.bindings.engine.state.query?.q ?? '',
|
|
344
346
|
};
|
|
345
347
|
return renderAnswerContent({
|
|
346
348
|
props: {
|
|
347
349
|
i18n: this.bindings.i18n,
|
|
348
350
|
generatedAnswer: generatedAnswer,
|
|
349
|
-
collapsible: this.collapsible
|
|
351
|
+
collapsible: this.collapsible &&
|
|
352
|
+
(this.fullAnswerHeight ?? 0) > this.validateMaxCollapsedHeight(),
|
|
350
353
|
renderFeedbackAndCopyButtonsSlot: () => this.renderFeedbackAndCopyButtonsWrapper(),
|
|
351
354
|
renderCitationsSlot: () => html `${this.renderCitationsList()}`,
|
|
352
355
|
onRetry: () => this.generatedAnswer?.retry(),
|
package/dist/atomic/components/components/search/atomic-generated-answer/atomic-generated-answer.js
CHANGED
|
@@ -254,7 +254,6 @@ let AtomicGeneratedAnswer = AtomicGeneratedAnswer_1 = class AtomicGeneratedAnswe
|
|
|
254
254
|
${renderDisclaimer({
|
|
255
255
|
props: {
|
|
256
256
|
i18n: this.bindings.i18n,
|
|
257
|
-
isStreaming: !!this.generatedAnswerState.isStreaming,
|
|
258
257
|
},
|
|
259
258
|
})}
|
|
260
259
|
</div>
|
|
@@ -327,7 +326,11 @@ let AtomicGeneratedAnswer = AtomicGeneratedAnswer_1 = class AtomicGeneratedAnswe
|
|
|
327
326
|
?.getBoundingClientRect().height;
|
|
328
327
|
if (answerHeight) {
|
|
329
328
|
const rootFontSize = parseFloat(getComputedStyle(document.documentElement).fontSize);
|
|
330
|
-
|
|
329
|
+
const nextFullAnswerHeight = answerHeight / rootFontSize;
|
|
330
|
+
if (this.fullAnswerHeight !== nextFullAnswerHeight) {
|
|
331
|
+
this.fullAnswerHeight = nextFullAnswerHeight;
|
|
332
|
+
this.requestUpdate();
|
|
333
|
+
}
|
|
331
334
|
this.updateAnswerHeight();
|
|
332
335
|
}
|
|
333
336
|
}
|
|
@@ -368,16 +371,16 @@ let AtomicGeneratedAnswer = AtomicGeneratedAnswer_1 = class AtomicGeneratedAnswe
|
|
|
368
371
|
clickLike() {
|
|
369
372
|
this.controller.clickLike();
|
|
370
373
|
}
|
|
371
|
-
renderCitationsList(citations) {
|
|
374
|
+
renderCitationsList(citations, answerId) {
|
|
372
375
|
return renderCitations({
|
|
373
376
|
props: {
|
|
374
377
|
citations,
|
|
375
378
|
i18n: this.bindings.i18n,
|
|
376
379
|
buildInteractiveCitation: (citation) => buildInteractiveCitation(this.bindings.engine, {
|
|
377
|
-
options: { citation },
|
|
380
|
+
options: { citation, answerId },
|
|
378
381
|
}),
|
|
379
382
|
logCitationHover: (citationId, citationHoverTimeMs) => {
|
|
380
|
-
this.generatedAnswer?.logCitationHover(citationId, citationHoverTimeMs);
|
|
383
|
+
this.generatedAnswer?.logCitationHover(citationId, citationHoverTimeMs, answerId);
|
|
381
384
|
},
|
|
382
385
|
disableCitationAnchoring: this.disableCitationAnchoring,
|
|
383
386
|
},
|
|
@@ -404,13 +407,13 @@ let AtomicGeneratedAnswer = AtomicGeneratedAnswer_1 = class AtomicGeneratedAnswe
|
|
|
404
407
|
});
|
|
405
408
|
}
|
|
406
409
|
renderAnswerContent() {
|
|
407
|
-
const generatedAnswer = {
|
|
408
|
-
...this.generatedAnswerState,
|
|
409
|
-
question: this.bindings.engine.state.query?.q ?? '',
|
|
410
|
-
};
|
|
411
410
|
if (this.areFollowUpsEnabled) {
|
|
411
|
+
const generatedAnswerWithQuestion = {
|
|
412
|
+
...this.generatedAnswerState,
|
|
413
|
+
question: this.bindings.engine.state.query?.q ?? '',
|
|
414
|
+
};
|
|
412
415
|
const allGeneratedAnswers = [
|
|
413
|
-
|
|
416
|
+
generatedAnswerWithQuestion,
|
|
414
417
|
...(this.generatedAnswerWithFollowUps?.state.followUpAnswers
|
|
415
418
|
.followUpAnswers ?? []),
|
|
416
419
|
];
|
|
@@ -426,10 +429,10 @@ let AtomicGeneratedAnswer = AtomicGeneratedAnswer_1 = class AtomicGeneratedAnswe
|
|
|
426
429
|
return renderAnswerContent({
|
|
427
430
|
props: {
|
|
428
431
|
i18n: this.bindings.i18n,
|
|
429
|
-
generatedAnswer:
|
|
432
|
+
generatedAnswer: this.generatedAnswerState,
|
|
430
433
|
collapsible: this.isCollapsibleEnabled,
|
|
431
434
|
renderFeedbackAndCopyButtonsSlot: () => this.renderFeedbackAndCopyButtonsWrapper(),
|
|
432
|
-
renderCitationsSlot: () => html `${this.renderCitationsList(
|
|
435
|
+
renderCitationsSlot: () => html `${this.renderCitationsList(this.generatedAnswerState.citations)}`,
|
|
433
436
|
onRetry: () => this.generatedAnswer?.retry(),
|
|
434
437
|
onClickShowButton: () => this.clickOnShowButton(),
|
|
435
438
|
},
|
|
@@ -451,7 +454,9 @@ let AtomicGeneratedAnswer = AtomicGeneratedAnswer_1 = class AtomicGeneratedAnswe
|
|
|
451
454
|
true);
|
|
452
455
|
}
|
|
453
456
|
get isCollapsibleEnabled() {
|
|
454
|
-
return this.collapsible &&
|
|
457
|
+
return (this.collapsible &&
|
|
458
|
+
!this.areFollowUpsEnabled &&
|
|
459
|
+
(this.fullAnswerHeight ?? 0) > this.validateMaxCollapsedHeight());
|
|
455
460
|
}
|
|
456
461
|
resetCollapsibleStyles() {
|
|
457
462
|
const container = this.getAnswerContainer();
|
|
@@ -1,4 +1,3 @@
|
|
|
1
|
-
export * from './_index.js';
|
|
2
1
|
export * from '../../types/components/index.js';
|
|
3
|
-
|
|
4
|
-
export
|
|
2
|
+
export * as Components from '../../types/components/index.js';
|
|
3
|
+
export * as JSX from '../../types/components/index.js';
|
|
@@ -1,2 +1,8 @@
|
|
|
1
|
-
export * from '
|
|
2
|
-
|
|
1
|
+
export * from '@coveo/atomic-legacy/item-decorators';
|
|
2
|
+
import * as _Components from './components/index.js';
|
|
3
|
+
export { _Components as Components, _Components as JSX };
|
|
4
|
+
export { fetchProductContext } from './components/commerce/product-template-component-utils/context/fetch-product-context';
|
|
5
|
+
export { dispatchSearchBoxSuggestionsEvent } from './components/common/suggestions/suggestions-events';
|
|
6
|
+
export { elementHasNoQuery, elementHasQuery, } from './components/common/suggestions/suggestions-utils';
|
|
7
|
+
export { fetchBindings as initializeBindings, MissingInterfaceParentError, } from './utils/initialization-common-utils';
|
|
8
|
+
export { bindLogDocumentOpenOnResult } from './utils/result-utils';
|