@box/box-ai-content-answers 0.78.2 → 0.79.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.
@@ -0,0 +1,44 @@
1
+ import "../../../../styles/contextual-items-message.css";
2
+ import f from "clsx";
3
+ import { FormattedMessage as x } from "react-intl";
4
+ import { ItemsDropdown as u } from "./items-dropdown.js";
5
+ import b from "./messages.js";
6
+ import { jsx as o, jsxs as a } from "react/jsx-runtime";
7
+ const _ = "_askQuestionText_cd7at_1", k = "_sidebar_cd7at_5", m = {
8
+ askQuestionText: _,
9
+ sidebar: k
10
+ }, j = ({
11
+ contentName: r,
12
+ isUsedInsideSidebar: c = !1,
13
+ supportedItems: e,
14
+ onItemClick: n,
15
+ parentItem: s
16
+ }) => {
17
+ var t;
18
+ const d = e.length || 1, l = ((t = e[0]) == null ? void 0 : t.name) || r, i = (s == null ? void 0 : s.id) !== "0" ? s == null ? void 0 : s.name : void 0;
19
+ return /* @__PURE__ */ o("div", {
20
+ className: f(m.askQuestionText, {
21
+ [m.sidebar]: c
22
+ }),
23
+ children: /* @__PURE__ */ o(x, {
24
+ ...b.welcomeAskQuestionText,
25
+ values: {
26
+ firstItemName: /* @__PURE__ */ a("b", {
27
+ children: ["“", l, "”"]
28
+ }),
29
+ parentItem: i && /* @__PURE__ */ a("b", {
30
+ children: ["“", i, "”"]
31
+ }),
32
+ numberOfItems: d,
33
+ files: /* @__PURE__ */ o(u, {
34
+ items: e,
35
+ onItemClick: n
36
+ })
37
+ }
38
+ })
39
+ });
40
+ };
41
+ export {
42
+ j as ContextualItemsMessage,
43
+ j as default
44
+ };
@@ -2,7 +2,7 @@ import { defineMessages as e } from "react-intl";
2
2
  const t = e({
3
3
  welcomeAskQuestionText: {
4
4
  id: "boxAI.contentAnswers.welcomeAskQuestionText",
5
- defaultMessage: "Ask questions about {name}"
5
+ defaultMessage: "Ask questions about {numberOfItems, plural, one {{firstItemName}} other {{files}}}{parentItem, select, undefined {} other { in {parentItem}}}"
6
6
  },
7
7
  welcomeMessageFilesLink: {
8
8
  id: "boxAI.contentAnswers.welcomeMessageFilesLink",
@@ -1,83 +1,80 @@
1
1
  import "../../../../styles/welcome-message.css";
2
- import { InlineNotice as N, Text as a } from "@box/blueprint-web";
3
- import { BoxAiLogo as v } from "@box/blueprint-web-assets/icons/Logo";
2
+ import { InlineNotice as C, Text as n } from "@box/blueprint-web";
3
+ import { BoxAiLogo as S } from "@box/blueprint-web-assets/icons/Logo";
4
4
  import { Size6 as u } from "@box/blueprint-web-assets/tokens/tokens";
5
- import I from "clsx";
6
- import { useMemo as r } from "react";
7
- import { useIntl as C } from "react-intl";
8
- import { MediaContainer as c } from "../common/media-container.js";
9
- import m from "./messages.js";
10
- import { UnsupportedItemsNotice as A } from "./unsupported-items-notice.js";
11
- import { jsx as e, jsxs as l } from "react/jsx-runtime";
12
- const q = "_welcomeMessage_1wm3q_1", S = "_askQuestionText_1wm3q_4", k = "_sidebar_1wm3q_8", Q = "_clearChatText_1wm3q_11", y = "_warningNotice_1wm3q_15", U = "_iconAvatar_1wm3q_18", t = {
13
- welcomeMessage: q,
14
- askQuestionText: S,
15
- sidebar: k,
16
- clearChatText: Q,
17
- warningNotice: y,
18
- iconAvatar: U
19
- }, H = ({
20
- contentName: _,
21
- contentType: x,
22
- items: s = [],
23
- onItemClick: f,
24
- variant: d = "modal",
25
- warningNotice: p,
26
- warningNoticeAriaLabel: T,
5
+ import { useMemo as o } from "react";
6
+ import { useIntl as T } from "react-intl";
7
+ import { MediaContainer as i } from "../common/media-container.js";
8
+ import { ContextualItemsMessage as A } from "./contextual-items-message.js";
9
+ import w from "./messages.js";
10
+ import { UnsupportedItemsNotice as U } from "./unsupported-items-notice.js";
11
+ import { jsx as e, jsxs as f } from "react/jsx-runtime";
12
+ const k = "_welcomeMessage_14bvk_1", y = "_clearChatText_14bvk_4", j = "_warningNotice_14bvk_8", B = "_iconAvatar_14bvk_11", a = {
13
+ welcomeMessage: k,
14
+ clearChatText: y,
15
+ warningNotice: j,
16
+ iconAvatar: B
17
+ }, J = ({
18
+ contentName: v,
19
+ contentType: _,
20
+ items: t = [],
21
+ parentItem: I,
22
+ onItemClick: c,
23
+ variant: l = "modal",
24
+ warningNotice: m,
25
+ warningNoticeAriaLabel: M,
27
26
  welcomeMessageClearText: b
28
27
  }) => {
29
- const o = d === "sidebar", {
30
- formatMessage: n
31
- } = C(), w = r(() => s.filter((i) => i.status === "unsupported"), [s]), h = r(() => s.filter((i) => i.status === "no_permission"), [s]), g = r(() => w.concat(h), [w, h]), M = p && /* @__PURE__ */ e(N, {
32
- className: t.warningNotice,
28
+ const r = l === "sidebar", {
29
+ formatMessage: d
30
+ } = T(), x = o(() => t.filter((s) => s.status === "supported"), [t]), p = o(() => t.filter((s) => s.status === "unsupported"), [t]), g = o(() => t.filter((s) => s.status === "no_permission"), [t]), h = o(() => p.concat(g), [p, g]), N = m && /* @__PURE__ */ e(C, {
31
+ className: a.warningNotice,
33
32
  "data-testid": "content-answers-warning-notice",
34
33
  variant: "warning",
35
- variantIconAriaLabel: T,
36
- children: /* @__PURE__ */ e(a, {
34
+ variantIconAriaLabel: M,
35
+ children: /* @__PURE__ */ e(n, {
37
36
  as: "p",
38
37
  variant: "bodyDefaultBold",
39
- children: p
38
+ children: m
40
39
  })
41
40
  });
42
41
  return /* @__PURE__ */ e("div", {
43
- className: t.welcomeMessage,
42
+ className: a.welcomeMessage,
44
43
  "data-testid": "content-answers-welcome-message",
45
- children: /* @__PURE__ */ l(c, {
46
- variant: d,
47
- children: [/* @__PURE__ */ e(c.Figure, {
48
- isUsedInsideSidebar: o,
44
+ children: /* @__PURE__ */ f(i, {
45
+ variant: l,
46
+ children: [/* @__PURE__ */ e(i.Figure, {
47
+ isUsedInsideSidebar: r,
49
48
  children: /* @__PURE__ */ e("div", {
50
- className: t.iconAvatar,
51
- children: /* @__PURE__ */ e(v, {
49
+ className: a.iconAvatar,
50
+ children: /* @__PURE__ */ e(S, {
52
51
  height: u,
53
52
  role: "presentation",
54
53
  width: u
55
54
  })
56
55
  })
57
- }), /* @__PURE__ */ l(c.Content, {
58
- isUsedInsideSidebar: o,
56
+ }), /* @__PURE__ */ f(i.Content, {
57
+ isUsedInsideSidebar: r,
59
58
  variant: "welcomeMessage",
60
- children: [M, g.length > 0 && /* @__PURE__ */ e(A, {
61
- onItemClick: f,
62
- unsupportedItems: g
63
- }), /* @__PURE__ */ e(a, {
59
+ children: [N, h.length > 0 && /* @__PURE__ */ e(U, {
60
+ onItemClick: c,
61
+ unsupportedItems: h
62
+ }), /* @__PURE__ */ e(n, {
64
63
  as: "h1",
65
- className: t.title,
64
+ className: a.title,
66
65
  variant: "titleSmall",
67
- children: n(m.welcomeMessageTitle)
68
- }), /* @__PURE__ */ e(a, {
66
+ children: d(w.welcomeMessageTitle)
67
+ }), /* @__PURE__ */ e(A, {
68
+ contentName: v,
69
+ isUsedInsideSidebar: r,
70
+ onItemClick: c,
71
+ parentItem: I,
72
+ supportedItems: x
73
+ }), /* @__PURE__ */ e(n, {
69
74
  as: "p",
70
- className: I(t.askQuestionText, o && t.sidebar),
71
- children: n(m.welcomeAskQuestionText, {
72
- name: /* @__PURE__ */ l("b", {
73
- children: ["“", _, "”"]
74
- })
75
- })
76
- }), /* @__PURE__ */ e(a, {
77
- as: "p",
78
- className: t.clearChatText,
79
- children: b || n(m.welcomeClearChatText, {
80
- type: x
75
+ className: a.clearChatText,
76
+ children: b || d(w.welcomeClearChatText, {
77
+ type: _
81
78
  })
82
79
  })]
83
80
  })]
@@ -85,6 +82,6 @@ const q = "_welcomeMessage_1wm3q_1", S = "_askQuestionText_1wm3q_4", k = "_sideb
85
82
  });
86
83
  };
87
84
  export {
88
- H as WelcomeMessage,
89
- H as default
85
+ J as WelcomeMessage,
86
+ J as default
90
87
  };
package/i18n/en-US.js CHANGED
@@ -47,7 +47,7 @@ export default {
47
47
  "boxAI.contentAnswers.suggestedQuestions": "Suggested Questions:",
48
48
  "boxAI.contentAnswers.unsupportedItems": "{numberOfFiles, plural, one {{files} is not supported by Box AI} other {{files} are not supported by Box AI} }",
49
49
  "boxAI.contentAnswers.userAvatar": "User avatar",
50
- "boxAI.contentAnswers.welcomeAskQuestionText": "Ask questions about {name}",
50
+ "boxAI.contentAnswers.welcomeAskQuestionText": "Ask questions about {numberOfItems, plural, one {{firstItemName}} other {{files}}}{parentItem, select, undefined {} other { in {parentItem}}}",
51
51
  "boxAI.contentAnswers.welcomeClearChatText": "This chat will be cleared when you close this {type}",
52
52
  "boxAI.contentAnswers.welcomeMessageFilesLink": "{numberOfItems, plural, one {# file} other {# files} }",
53
53
  "boxAI.contentAnswers.welcomeMessageTitle": "Welcome to Box AI",
@@ -94,8 +94,8 @@ boxAI.contentAnswers.suggestedQuestions = Suggested Questions:
94
94
  boxAI.contentAnswers.unsupportedItems = {numberOfFiles, plural, one {{files} is not supported by Box AI} other {{files} are not supported by Box AI} }
95
95
  # Alt text for user avatar image
96
96
  boxAI.contentAnswers.userAvatar = User avatar
97
- # Content Answers welcome message for asking questions {Name} is the name of the content
98
- boxAI.contentAnswers.welcomeAskQuestionText = Ask questions about {name}
97
+ # Content Answers welcome message for asking questions. {firstItemName} is the name of the content, {files} is a list of items, and {parentItem} is the name of the parent item.
98
+ boxAI.contentAnswers.welcomeAskQuestionText = Ask questions about {numberOfItems, plural, one {{firstItemName}} other {{files}}}{parentItem, select, undefined {} other { in {parentItem}}}
99
99
  # Content Answers welcome message for clearing the chat. {type} is the type of content that we are going to query
100
100
  boxAI.contentAnswers.welcomeClearChatText = This chat will be cleared when you close this {type}
101
101
  # Link that show the number of files that are going to be displayed within the modal
@@ -1 +1 @@
1
- [{"id":"boxAI.contentAnswers.welcomeAskQuestionText","description":"Content Answers welcome message for asking questions {Name} is the name of the content","defaultMessage":"Ask questions about {name}"},{"id":"boxAI.contentAnswers.welcomeMessageFilesLink","description":"Link that show the number of files that are going to be displayed within the modal","defaultMessage":"{numberOfItems, plural,\n one {# file}\n other {# files}\n }"},{"id":"boxAI.contentAnswers.welcomeClearChatText","description":"Content Answers welcome message for clearing the chat. {type} is the type of content that we are going to query","defaultMessage":"This chat will be cleared when you close this {type}"},{"id":"boxAI.contentAnswers.welcomeMessageTitle","description":"Content Answers welcome message title","defaultMessage":"Welcome to Box AI"},{"id":"boxAI.contentAnswers.unsupportedItems","description":"Warning message that shows how many files are not supported by Box AI","defaultMessage":"{numberOfFiles, plural,\n one {{files} is not supported by Box AI}\n other {{files} are not supported by Box AI}\n }"}]
1
+ [{"id":"boxAI.contentAnswers.welcomeAskQuestionText","description":"Content Answers welcome message for asking questions. {firstItemName} is the name of the content, {files} is a list of items, and {parentItem} is the name of the parent item.","defaultMessage":"Ask questions about {numberOfItems, plural, one {{firstItemName}} other {{files}}}{parentItem, select, undefined {} other { in {parentItem}}}"},{"id":"boxAI.contentAnswers.welcomeMessageFilesLink","description":"Link that show the number of files that are going to be displayed within the modal","defaultMessage":"{numberOfItems, plural,\n one {# file}\n other {# files}\n }"},{"id":"boxAI.contentAnswers.welcomeClearChatText","description":"Content Answers welcome message for clearing the chat. {type} is the type of content that we are going to query","defaultMessage":"This chat will be cleared when you close this {type}"},{"id":"boxAI.contentAnswers.welcomeMessageTitle","description":"Content Answers welcome message title","defaultMessage":"Welcome to Box AI"},{"id":"boxAI.contentAnswers.unsupportedItems","description":"Warning message that shows how many files are not supported by Box AI","defaultMessage":"{numberOfFiles, plural,\n one {{files} is not supported by Box AI}\n other {{files} are not supported by Box AI}\n }"}]
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@box/box-ai-content-answers",
3
- "version": "0.78.2",
3
+ "version": "0.79.0",
4
4
  "peerDependencies": {
5
5
  "@box/blueprint-web": "^7.8.0",
6
6
  "@box/blueprint-web-assets": "^4.16.0",
@@ -56,5 +56,5 @@
56
56
  "**/*.css"
57
57
  ],
58
58
  "license": "SEE LICENSE IN LICENSE",
59
- "gitHead": "11c8390fbd9edf91abd52bee5c250e40331d2c30"
59
+ "gitHead": "489819b1fe49c8ef7374dbeeeab69fe2231d22c0"
60
60
  }
@@ -0,0 +1 @@
1
+ ._askQuestionText_cd7at_1{margin:.75rem 0;font-size:.9375rem}._askQuestionText_cd7at_1._sidebar_cd7at_5{font-size:.875rem}
@@ -1 +1 @@
1
- ._welcomeMessage_1wm3q_1{margin-top:1.25rem}._welcomeMessage_1wm3q_1 ._askQuestionText_1wm3q_4{margin:.75rem 0;font-size:.9375rem}._welcomeMessage_1wm3q_1 ._askQuestionText_1wm3q_4._sidebar_1wm3q_8{font-size:.875rem}._welcomeMessage_1wm3q_1 ._clearChatText_1wm3q_11{color:#6f6f6f;font-size:.8125rem}._welcomeMessage_1wm3q_1 ._warningNotice_1wm3q_15{margin-bottom:.75rem}._welcomeMessage_1wm3q_1 ._iconAvatar_1wm3q_18{display:flex;align-items:center;justify-content:center;width:var(--size-8);height:var(--size-8);border-radius:50%;border:.0625rem solid #e8e8e8}@media (max-width: 374px){._welcomeMessage_1wm3q_1 ._iconAvatar_1wm3q_18{width:var(--size-6);height:var(--size-6)}}@media (max-width: 374px){._welcomeMessage_1wm3q_1{margin-top:0}}
1
+ ._welcomeMessage_14bvk_1{margin-top:1.25rem}._welcomeMessage_14bvk_1 ._clearChatText_14bvk_4{color:#6f6f6f;font-size:.8125rem}._welcomeMessage_14bvk_1 ._warningNotice_14bvk_8{margin-bottom:.75rem}._welcomeMessage_14bvk_1 ._iconAvatar_14bvk_11{display:flex;align-items:center;justify-content:center;width:var(--size-8);height:var(--size-8);border-radius:50%;border:.0625rem solid #e8e8e8}@media (max-width: 374px){._welcomeMessage_14bvk_1 ._iconAvatar_14bvk_11{width:var(--size-6);height:var(--size-6)}}@media (max-width: 374px){._welcomeMessage_14bvk_1{margin-top:0}}
@@ -0,0 +1,10 @@
1
+ import { type ItemClickHandler, type ItemType } from '../../types';
2
+ export interface Props {
3
+ contentName: string;
4
+ isUsedInsideSidebar?: boolean;
5
+ parentItem: ItemType;
6
+ supportedItems: Array<ItemType>;
7
+ onItemClick?: ItemClickHandler;
8
+ }
9
+ export declare const ContextualItemsMessage: ({ contentName, isUsedInsideSidebar, supportedItems, onItemClick, parentItem, }: Props) => import("react/jsx-runtime").JSX.Element;
10
+ export default ContextualItemsMessage;
@@ -1,3 +1,3 @@
1
1
  import { type WelcomeMessageProps } from '../../types';
2
- export declare const WelcomeMessage: ({ contentName, contentType, items, onItemClick, variant, warningNotice, warningNoticeAriaLabel, welcomeMessageClearText, }: WelcomeMessageProps) => import("react/jsx-runtime").JSX.Element;
2
+ export declare const WelcomeMessage: ({ contentName, contentType, items, parentItem, onItemClick, variant, warningNotice, warningNoticeAriaLabel, welcomeMessageClearText, }: WelcomeMessageProps) => import("react/jsx-runtime").JSX.Element;
3
3
  export default WelcomeMessage;
@@ -33,6 +33,8 @@ export type WelcomeMessageProps = {
33
33
  contentType: string;
34
34
  /** Items that are going to be shown within a dropdowm to indicate whether which files are supported and which ones won't */
35
35
  items?: Array<ItemType>;
36
+ /** Represents the parent item indicating the source of the files */
37
+ parentItem?: ItemType;
36
38
  /** Callback action passed from the host application to do an action when the user clicks an item within the dropdown */
37
39
  onItemClick?: ItemClickHandler;
38
40
  /** If keyframe animation should be applied to chat elements; defaults to true */
@@ -144,7 +146,7 @@ export type ItemType = {
144
146
  type: 'file' | 'hub' | 'folder' | 'collection';
145
147
  fileType?: string;
146
148
  name: string;
147
- status: 'supported' | 'unsupported' | 'no_permission';
149
+ status?: 'supported' | 'unsupported' | 'no_permission';
148
150
  };
149
151
  export type SuggestedQuestionType = {
150
152
  label?: string;