@box/box-ai-content-answers 0.61.0 → 0.62.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.
@@ -1,105 +1,107 @@
1
1
  import "../../../../styles/answer.css";
2
- import { useBreakpoint as P, Breakpoint as T, Text as j } from "@box/blueprint-web";
3
- import { BoxAi as L, AlertTriangle as x } from "@box/blueprint-web-assets/icons/Line";
4
- import { Size5 as D, Size6 as F, Gray65 as M, Size4 as f } from "@box/blueprint-web-assets/tokens/tokens";
5
- import U from "clsx";
6
- import * as m from "react";
7
- import { useIntl as k } from "react-intl";
8
- import { A as t } from "../../../../chunks/types.js";
9
- import { MediaContainer as l } from "../common/media-container.js";
2
+ import { useBreakpoint as k, Breakpoint as z, Text as b } from "@box/blueprint-web";
3
+ import { BoxAi as M, AlertTriangle as H } from "@box/blueprint-web-assets/icons/Line";
4
+ import { Size5 as L, Size6 as x, Gray65 as D, Size4 as f } from "@box/blueprint-web-assets/tokens/tokens";
5
+ import F from "clsx";
6
+ import * as c from "react";
7
+ import { useIntl as U } from "react-intl";
8
+ import { A as o } from "../../../../chunks/types.js";
9
+ import { MediaContainer as m } from "../common/media-container.js";
10
10
  import { AnswerContent as y } from "./answer-content.js";
11
- import { CopyButton as z } from "./copy-button.js";
12
- import { InlineError as B } from "./inline-error.js";
13
- import { LoadingElement as H } from "./loading-element.js";
11
+ import { CopyButton as B } from "./copy-button.js";
12
+ import { InlineError as C } from "./inline-error.js";
13
+ import { LoadingElement as G } from "./loading-element.js";
14
14
  import d from "./messages.js";
15
- import { References as C } from "./references.js";
16
- import { jsxs as n, jsx as e } from "react/jsx-runtime";
17
- const G = "_answer_17ojr_1", b = "_alertIcon_17ojr_4", W = "_error_17ojr_7", q = "_footer_17ojr_11", J = "_shouldUseAnimation_17ojr_16", K = "_shouldAnimateHeight_17ojr_20", Q = "_iconAvatar_17ojr_24", r = {
18
- answer: G,
19
- alertIcon: b,
20
- error: W,
21
- footer: q,
22
- shouldUseAnimation: J,
23
- shouldAnimateHeight: K,
24
- iconAvatar: Q
25
- }, V = /* @__PURE__ */ new Set([t.RATE_LIMITING, t.NO_CONTENT, t.PRECONDITION_FAILED, t.GENERAL]), _o = /* @__PURE__ */ m.memo(({
26
- answer: a,
27
- citations: h,
28
- error: o,
15
+ import { References as j } from "./references.js";
16
+ import { jsxs as s, jsx as t } from "react/jsx-runtime";
17
+ const W = "_answer_5bwzk_1", q = "_alertIcon_5bwzk_4", J = "_error_5bwzk_7", K = "_footer_5bwzk_11", Q = "_shouldHaveMarginTop_5bwzk_17", V = "_shouldUseAnimation_5bwzk_20", X = "_shouldAnimateHeight_5bwzk_24", Y = "_iconAvatar_5bwzk_28", r = {
18
+ answer: W,
19
+ alertIcon: q,
20
+ error: J,
21
+ footer: K,
22
+ shouldHaveMarginTop: Q,
23
+ shouldUseAnimation: V,
24
+ shouldAnimateHeight: X,
25
+ iconAvatar: Y
26
+ }, Z = /* @__PURE__ */ new Set([o.RATE_LIMITING, o.NO_CONTENT, o.PRECONDITION_FAILED, o.GENERAL]), fe = /* @__PURE__ */ c.memo(({
27
+ answer: n,
28
+ citations: u,
29
+ error: e,
29
30
  contentType: S,
30
- isCitationsEnabled: u = !1,
31
- isCompleted: s = !1,
32
- isLoading: A = !1,
31
+ isCitationsEnabled: A = !1,
32
+ isCompleted: a = !1,
33
+ isLoading: w = !1,
33
34
  isMarkdownEnabled: I = !1,
34
35
  onCitationClick: N,
35
36
  onAnswerCopy: R,
36
37
  recordAction: i,
37
- useAnimation: w = !0
38
+ useAnimation: g = !0
38
39
  }) => {
39
- const E = V.has(o), p = A && !a && !o, [g, O] = m.useState(s), {
40
- formatMessage: c
41
- } = k(), _ = P() === T.Small ? D : F;
42
- m.useEffect(() => {
43
- setTimeout(() => O(s), 0);
44
- }, [s]);
45
- const v = () => /* @__PURE__ */ n(j, {
40
+ const p = Z.has(e), E = w && !n && !e, [T, v] = c.useState(a), {
41
+ formatMessage: l
42
+ } = U(), _ = k() === z.Small ? L : x;
43
+ c.useEffect(() => {
44
+ setTimeout(() => v(a), 0);
45
+ }, [a]);
46
+ const h = () => /* @__PURE__ */ t(H, {
47
+ className: r.alertIcon,
48
+ color: D,
49
+ "data-testid": "content-answers-error-alert-icon",
50
+ height: f,
51
+ role: "presentation",
52
+ width: f
53
+ }), O = () => /* @__PURE__ */ s(b, {
46
54
  as: "p",
47
55
  className: r.error,
48
56
  color: "textOnLightSecondary",
49
57
  "data-testid": "content-answers-error",
50
58
  variant: "caption",
51
- children: [o === t.RESPONSE_INTERRUPTED && c(d.responseInterruptedError), o === t.RESPONSE_FAILED && c(d.responseFailedError), o === t.RESPONSE_STOPPED && c(d.responseStoppedError), o !== t.RESPONSE_STOPPED && /* @__PURE__ */ e(x, {
52
- className: r.alertIcon,
53
- color: M,
54
- "data-testid": "content-answers-error-alert-icon",
55
- height: f,
56
- role: "presentation",
57
- width: f
58
- })]
59
- });
60
- return /* @__PURE__ */ n("div", {
59
+ children: [e === o.RESPONSE_INTERRUPTED && l(d.responseInterruptedError), e === o.RESPONSE_FAILED && l(d.responseFailedError), e === o.RESPONSE_STOPPED && l(d.responseStoppedError), e !== o.RESPONSE_STOPPED && h()]
60
+ }), P = () => e !== o.RESPONSE_STOPPED ? /* @__PURE__ */ t(B, {
61
+ answer: n,
62
+ onAnswerCopy: R,
63
+ recordAction: i
64
+ }) : n ? null : h();
65
+ return /* @__PURE__ */ s("div", {
61
66
  "aria-live": "polite",
62
67
  className: r.answer,
63
68
  "data-testid": "content-answers-answer",
64
- children: [!E && !p && /* @__PURE__ */ n(l, {
65
- children: [/* @__PURE__ */ e(l.Figure, {
66
- children: /* @__PURE__ */ e("div", {
69
+ children: [!p && !E && /* @__PURE__ */ s(m, {
70
+ children: [/* @__PURE__ */ t(m.Figure, {
71
+ children: /* @__PURE__ */ t("div", {
67
72
  className: r.iconAvatar,
68
- children: /* @__PURE__ */ e(L, {
73
+ children: /* @__PURE__ */ t(M, {
69
74
  height: _,
70
75
  role: "presentation",
71
76
  width: _
72
77
  })
73
78
  })
74
- }), /* @__PURE__ */ n(l.Content, {
75
- children: [/* @__PURE__ */ e(y, {
76
- answer: a,
79
+ }), /* @__PURE__ */ s(m.Content, {
80
+ children: [/* @__PURE__ */ t(y, {
81
+ answer: n,
77
82
  isMarkdownEnabled: I
78
- }), s && /* @__PURE__ */ n("div", {
79
- className: U(r.footer, {
80
- [r.shouldUseAnimation]: w,
81
- [r.shouldAnimateHeight]: g
83
+ }), a && /* @__PURE__ */ s("div", {
84
+ className: F(r.footer, {
85
+ [r.shouldHaveMarginTop]: n,
86
+ [r.shouldAnimateHeight]: T,
87
+ [r.shouldUseAnimation]: g
82
88
  }),
83
89
  "data-testid": "content-answers-answer-footer",
84
- children: [o && v(), u && !o && /* @__PURE__ */ e(C, {
85
- citations: h,
90
+ children: [e && O(), A && !e && /* @__PURE__ */ t(j, {
91
+ citations: u,
86
92
  onCitationClick: N,
87
93
  recordAction: i
88
- }), /* @__PURE__ */ e(z, {
89
- answer: a,
90
- onAnswerCopy: R,
91
- recordAction: i
92
- })]
94
+ }), P()]
93
95
  })]
94
96
  })]
95
- }), E && /* @__PURE__ */ e(B, {
97
+ }), p && /* @__PURE__ */ t(C, {
96
98
  contentType: S,
97
- error: o,
99
+ error: e,
98
100
  recordAction: i
99
- }), p && /* @__PURE__ */ e(H, {})]
101
+ }), E && /* @__PURE__ */ t(G, {})]
100
102
  });
101
103
  });
102
104
  export {
103
- _o as Answer,
104
- _o as default
105
+ fe as Answer,
106
+ fe as default
105
107
  };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@box/box-ai-content-answers",
3
- "version": "0.61.0",
3
+ "version": "0.62.0",
4
4
  "peerDependencies": {
5
5
  "@box/blueprint-web": "^7.8.0",
6
6
  "@box/blueprint-web-assets": "^4.16.0",
@@ -13,7 +13,7 @@
13
13
  "remarkable": "^2.0.1"
14
14
  },
15
15
  "devDependencies": {
16
- "@box/blueprint-web": "^8.1.0",
16
+ "@box/blueprint-web": "^8.1.1",
17
17
  "@box/blueprint-web-assets": "^4.28.0",
18
18
  "@box/storybook-utils": "^0.7.0",
19
19
  "@testing-library/react": "^15.0.6",
@@ -52,5 +52,5 @@
52
52
  "**/*.css"
53
53
  ],
54
54
  "license": "SEE LICENSE IN LICENSE",
55
- "gitHead": "c7134dc6556b45dee546a7106f9dd2768f11a4eb"
55
+ "gitHead": "04ed35c59eefe989e527ecd06e3107144d332781"
56
56
  }
package/styles/answer.css CHANGED
@@ -1 +1 @@
1
- ._answer_17ojr_1{white-space:pre-wrap}._answer_17ojr_1 ._alertIcon_17ojr_4{margin-left:.5rem}._answer_17ojr_1 ._error_17ojr_7{display:flex;align-items:center}._answer_17ojr_1 ._footer_17ojr_11{display:flex;justify-content:space-between;margin-top:.75rem}._answer_17ojr_1 ._footer_17ojr_11._shouldUseAnimation_17ojr_16{max-height:0;overflow-y:hidden}._answer_17ojr_1 ._footer_17ojr_11._shouldUseAnimation_17ojr_16._shouldAnimateHeight_17ojr_20{max-height:200px;transition:max-height 1s ease-in}._answer_17ojr_1 ._iconAvatar_17ojr_24{display:flex;align-items:center;justify-content:center;width:var(--size-8);height:var(--size-8);border-radius:50%}@media (max-width: 374px){._answer_17ojr_1 ._iconAvatar_17ojr_24{width:var(--size-6);height:var(--size-6)}}
1
+ ._answer_5bwzk_1{white-space:pre-wrap}._answer_5bwzk_1 ._alertIcon_5bwzk_4{margin-left:.5rem}._answer_5bwzk_1 ._error_5bwzk_7{display:flex;align-items:center}._answer_5bwzk_1 ._footer_5bwzk_11{height:1.5rem;display:flex;justify-content:space-between;align-items:center}._answer_5bwzk_1 ._footer_5bwzk_11._shouldHaveMarginTop_5bwzk_17{margin-top:.75rem}._answer_5bwzk_1 ._footer_5bwzk_11._shouldUseAnimation_5bwzk_20{max-height:0;overflow-y:hidden}._answer_5bwzk_1 ._footer_5bwzk_11._shouldUseAnimation_5bwzk_20._shouldAnimateHeight_5bwzk_24{max-height:200px;transition:max-height 1s ease-in}._answer_5bwzk_1 ._iconAvatar_5bwzk_28{display:flex;align-items:center;justify-content:center;width:var(--size-8);height:var(--size-8);border-radius:50%}@media (max-width: 374px){._answer_5bwzk_1 ._iconAvatar_5bwzk_28{width:var(--size-6);height:var(--size-6)}}
@@ -22,4 +22,5 @@ export declare const answerWithLargeTable = "\n| English | Spanish |
22
22
  export declare const answerWithTable = "\n| English | Spanish | Color |\n|---------------|---------------|-------------|\n| Apple | Manzana | Red |\n| Banana | Pl\u00E1tano | Yellow |\n| Orange | Naranja | Orange |\n| Grape | Uva | Purple |\n| Strawberry | Fresa | Red |\n| Blueberry | Ar\u00E1ndano | Blue |\n| Lemon | Lim\u00F3n | Yellow |\n| Pineapple | Pi\u00F1a | Brown/Yellow|\n| Watermelon | Sand\u00EDa | Green/Red |\n| Cherry | Cereza | Red |\n";
23
23
  export declare const answerWithCodeBlocks = "\nCode Blocks\n```html\n<div>\n <p>This is a paragraph inside a &lt;div&gt; block.</p>\n</div>\n```\n\n```\nfunction greet(name) {\n console.log('Hello, ' + name + '!');\n}\n\ngreet('World');\n```\n\n```c++\n#include <iostream>\n\nint main() {\n std::cout << \"Hello, world! This is a long line that will cause overflow in the code block when displayed on a narrow screen or container.\" << std::endl;\n return 0;\n}\n```\n";
24
24
  export declare const DefaultAnswer: (props: AnswerProps) => import("react/jsx-runtime").JSX.Element;
25
+ export declare const StoppedAnswer: (props: AnswerProps) => import("react/jsx-runtime").JSX.Element;
25
26
  export declare const WithUpdatedAnswer: (props: AnswerProps) => import("react/jsx-runtime").JSX.Element;