@box/box-ai-content-answers 0.150.0 → 0.151.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.
Files changed (46) hide show
  1. package/dist/chunks/markdown.module.js +19 -0
  2. package/dist/esm/lib/components/answer/answer.js +123 -127
  3. package/dist/esm/lib/components/answer/messages.js +4 -0
  4. package/dist/esm/lib/components/answer/thumb-buttons.js +31 -31
  5. package/dist/esm/lib/components/common/inline-citation.js +47 -0
  6. package/dist/esm/lib/components/common/markdown-react.js +81 -59
  7. package/dist/esm/lib/components/common/markdown.js +723 -721
  8. package/dist/esm/lib/utils/inlineCitationsUtils.js +36 -0
  9. package/dist/i18n/bn-IN.js +1 -0
  10. package/dist/i18n/da-DK.js +1 -0
  11. package/dist/i18n/de-DE.js +1 -0
  12. package/dist/i18n/en-AU.js +1 -0
  13. package/dist/i18n/en-CA.js +1 -0
  14. package/dist/i18n/en-GB.js +1 -0
  15. package/dist/i18n/en-US.js +1 -0
  16. package/dist/i18n/en-US.properties +2 -0
  17. package/dist/i18n/en-x-pseudo.js +1 -0
  18. package/dist/i18n/es-419.js +1 -0
  19. package/dist/i18n/es-ES.js +1 -0
  20. package/dist/i18n/fi-FI.js +1 -0
  21. package/dist/i18n/fr-CA.js +1 -0
  22. package/dist/i18n/fr-FR.js +1 -0
  23. package/dist/i18n/hi-IN.js +1 -0
  24. package/dist/i18n/it-IT.js +1 -0
  25. package/dist/i18n/ja-JP.js +1 -0
  26. package/dist/i18n/json/src/lib/components/answer/messages.json +1 -1
  27. package/dist/i18n/ko-KR.js +1 -0
  28. package/dist/i18n/nb-NO.js +1 -0
  29. package/dist/i18n/nl-NL.js +1 -0
  30. package/dist/i18n/pl-PL.js +1 -0
  31. package/dist/i18n/pt-BR.js +1 -0
  32. package/dist/i18n/ru-RU.js +1 -0
  33. package/dist/i18n/sv-SE.js +1 -0
  34. package/dist/i18n/tr-TR.js +1 -0
  35. package/dist/i18n/zh-CN.js +1 -0
  36. package/dist/i18n/zh-TW.js +1 -0
  37. package/dist/styles/markdown.css +1 -7
  38. package/dist/styles/markdown2.css +7 -0
  39. package/dist/types/lib/components/answer/answer.d.ts +1 -2
  40. package/dist/types/lib/components/answer/messages.d.ts +5 -0
  41. package/dist/types/lib/components/answer/stories/shared.d.ts +15 -3
  42. package/dist/types/lib/components/common/inline-citation.d.ts +7 -0
  43. package/dist/types/lib/utils/inlineCitationsUtils.d.ts +17 -0
  44. package/package.json +1 -1
  45. package/dist/esm/lib/utils/getBoxLinks.js +0 -13
  46. package/dist/types/lib/utils/getBoxLinks.d.ts +0 -15
@@ -1,99 +1,121 @@
1
- import i from "react-markdown";
2
- import d from "remark-gfm";
3
- import { jsxs as a, jsx as n } from "react/jsx-runtime";
4
- const m = ({
1
+ import d from "react-markdown";
2
+ import h from "remark-gfm";
3
+ import { isBoxCitation as f } from "../../utils/inlineCitationsUtils.js";
4
+ import u from "./inline-citation.js";
5
+ import { s as t } from "../../../../chunks/markdown.module.js";
6
+ import { jsxs as c, jsx as n } from "react/jsx-runtime";
7
+ const N = ({
5
8
  children: e,
6
- className: t
9
+ className: o
7
10
  }) => {
8
- const o = t ? t.replace("language-", "") : "";
9
- return /* @__PURE__ */ a("div", {
10
- className: "hljs",
11
+ const r = o ? o.replace("language-", "") : "", s = (i) => i.trim().split(/\r?\n/).map((a, m) => /* @__PURE__ */ c("div", {
12
+ className: "hljs-line",
11
13
  children: [/* @__PURE__ */ n("span", {
12
- className: "hljs-language",
13
- children: o || "auto"
14
+ className: "hljs-line-number",
15
+ children: m + 1
16
+ }), /* @__PURE__ */ n("span", {
17
+ className: "hljs-line-content",
18
+ children: a
19
+ })]
20
+ }, `line-${a.substring(0, 20)}-${Date.now()}`));
21
+ return /* @__PURE__ */ c("div", {
22
+ className: t.hljs,
23
+ children: [/* @__PURE__ */ n("span", {
24
+ className: t.hljsLanguage,
25
+ children: r || "auto"
14
26
  }), /* @__PURE__ */ n("code", {
15
- children: ((s) => s.trim().split(/\r?\n/).map((c, l) => /* @__PURE__ */ a("div", {
16
- className: "hljs-line",
17
- children: [/* @__PURE__ */ n("span", {
18
- className: "hljs-line-number",
19
- children: l + 1
20
- }), /* @__PURE__ */ n("span", {
21
- className: "hljs-line-content",
22
- children: c
23
- })]
24
- }, `line-${c.substring(0, 20)}-${Date.now()}`)))(e)
27
+ children: s(e)
25
28
  })]
26
29
  });
27
- }, u = ({
30
+ }, k = ({
28
31
  children: e
29
32
  }) => /* @__PURE__ */ n("div", {
30
- className: "table-wrapper",
33
+ className: t.tableWrapper,
31
34
  children: /* @__PURE__ */ n("table", {
32
35
  children: e
33
36
  })
34
- }), h = ({
37
+ }), b = ({
35
38
  href: e,
36
- children: t
37
- }) => /* @__PURE__ */ a("span", {
38
- children: [t, " (", e, ")"]
39
- }), f = ({
39
+ children: o
40
+ }) => /* @__PURE__ */ c("span", {
41
+ children: [o, " (", e, ")"]
42
+ }), g = ({
40
43
  children: e
41
44
  }) => /* @__PURE__ */ n("blockquote", {
42
- className: "blockquote",
45
+ className: t.blockquote,
43
46
  children: e
44
- }), N = ({
47
+ }), j = ({
45
48
  children: e
46
49
  }) => /* @__PURE__ */ n("ol", {
47
- className: "orderedList",
50
+ className: t.orderedList,
48
51
  children: e
49
- }), b = ({
52
+ }), x = ({
50
53
  children: e
51
54
  }) => {
52
- var o;
53
- const t = ((o = e == null ? void 0 : e.toString().match(/^(\d+)/)) == null ? void 0 : o[1]) || e;
55
+ var r;
56
+ const o = ((r = e == null ? void 0 : e.toString().match(/^(\d+)/)) == null ? void 0 : r[1]) || e;
54
57
  return /* @__PURE__ */ n("span", {
55
- className: "footnote",
56
- children: t
58
+ className: t.footnote,
59
+ children: o
57
60
  });
58
- }, k = {
59
- code: m,
60
- table: u,
61
- blockquote: f,
62
- ol: N,
63
- sup: b,
61
+ }, C = {
62
+ code: N,
63
+ table: k,
64
+ blockquote: g,
65
+ ol: j,
66
+ sup: x,
64
67
  // Handle footnote references
68
+ // Custom paragraph component to handle inline elements properly
69
+ p: ({
70
+ children: e
71
+ }) => /* @__PURE__ */ n("div", {
72
+ className: t.inlineParagraph,
73
+ children: e
74
+ }),
65
75
  // Handle footnote references that might be rendered as links
66
76
  a: (e) => {
67
- var t, o, r;
68
- if ((t = e.href) != null && t.startsWith("#user-content-fn")) {
69
- const s = ((r = (o = e.children) == null ? void 0 : o.toString().match(/^(\d+)/)) == null ? void 0 : r[1]) || e.children;
77
+ var r, s, i, l;
78
+ if ((r = e.href) != null && r.startsWith("#user-content-fn")) {
79
+ const a = ((i = (s = e.children) == null ? void 0 : s.toString().match(/^(\d+)/)) == null ? void 0 : i[1]) || e.children;
70
80
  return /* @__PURE__ */ n("a", {
71
- className: "footnote-reference",
81
+ className: t.footnoteReference,
72
82
  href: e.href,
73
- children: s
83
+ children: a
84
+ });
85
+ }
86
+ if (e.href && f(e.href)) {
87
+ const a = ((l = e.children) == null ? void 0 : l.toString()) || "";
88
+ return /* @__PURE__ */ n("span", {
89
+ style: {
90
+ display: "inline-block"
91
+ },
92
+ children: /* @__PURE__ */ n(u, {
93
+ fileName: a,
94
+ href: e.href
95
+ })
74
96
  });
75
97
  }
76
- return /* @__PURE__ */ n(h, {
98
+ return /* @__PURE__ */ n(b, {
77
99
  href: e.href,
78
100
  children: e.children
79
101
  });
80
102
  }
81
- }, q = ({
103
+ }, y = ({
82
104
  children: e
83
105
  }) => /* @__PURE__ */ n("div", {
84
- className: "markdown-content",
85
- children: /* @__PURE__ */ n(i, {
86
- components: k,
87
- remarkPlugins: [d],
106
+ className: t.markdownContent,
107
+ children: /* @__PURE__ */ n(d, {
108
+ components: C,
109
+ remarkPlugins: [h],
88
110
  children: e
89
111
  })
90
112
  });
91
113
  export {
92
- f as Blockquote,
93
- m as CodeBlock,
94
- b as Footnote,
95
- h as Link,
96
- N as Ol,
97
- u as Table,
98
- q as default
114
+ g as Blockquote,
115
+ N as CodeBlock,
116
+ x as Footnote,
117
+ b as Link,
118
+ j as Ol,
119
+ k as Table,
120
+ y as default
99
121
  };