@smart-cloud/ai-kit-ui 1.5.14 → 1.5.15

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 (54) hide show
  1. package/dist/LocaleDirectionProvider.d.ts +5 -0
  2. package/dist/index.cjs +9 -9
  3. package/dist/index.js +9 -9
  4. package/dist/locale.d.ts +13 -0
  5. package/package.json +35 -19
  6. package/eslint.config.js +0 -18
  7. package/src/ShadowBoundary.tsx +0 -229
  8. package/src/ai-chatbot/AiChatbot.tsx +0 -2325
  9. package/src/ai-chatbot/attachmentStorage.ts +0 -238
  10. package/src/ai-chatbot/index.tsx +0 -1
  11. package/src/ai-feature/AiFeature.tsx +0 -2334
  12. package/src/ai-feature/AiFeatureBorder.tsx +0 -22
  13. package/src/ai-feature/ProofreadDiff.tsx +0 -118
  14. package/src/ai-feature/index.tsx +0 -2
  15. package/src/ai-feature/utils.tsx +0 -20
  16. package/src/doc-search/DocSearch.tsx +0 -1313
  17. package/src/doc-search/index.tsx +0 -1
  18. package/src/doc-search/initialFilters.ts +0 -10
  19. package/src/errorHandling.ts +0 -305
  20. package/src/i18n/ar.ts +0 -254
  21. package/src/i18n/de.ts +0 -257
  22. package/src/i18n/en.ts +0 -269
  23. package/src/i18n/es.ts +0 -257
  24. package/src/i18n/fr.ts +0 -258
  25. package/src/i18n/he.ts +0 -250
  26. package/src/i18n/hi.ts +0 -256
  27. package/src/i18n/hu.ts +0 -269
  28. package/src/i18n/id.ts +0 -256
  29. package/src/i18n/index.ts +0 -47
  30. package/src/i18n/it.ts +0 -259
  31. package/src/i18n/ja.ts +0 -256
  32. package/src/i18n/ko.ts +0 -254
  33. package/src/i18n/nb.ts +0 -254
  34. package/src/i18n/nl.ts +0 -255
  35. package/src/i18n/pl.ts +0 -258
  36. package/src/i18n/pt.ts +0 -254
  37. package/src/i18n/ru.ts +0 -254
  38. package/src/i18n/sv.ts +0 -253
  39. package/src/i18n/th.ts +0 -252
  40. package/src/i18n/tr.ts +0 -256
  41. package/src/i18n/ua.ts +0 -257
  42. package/src/i18n/zh.ts +0 -247
  43. package/src/index.tsx +0 -7
  44. package/src/poweredBy.tsx +0 -39
  45. package/src/styles/ai-kit-ui.css +0 -1006
  46. package/src/useAiRun.ts +0 -182
  47. package/src/withAiKitShell.tsx +0 -363
  48. package/tests/ai-disclosures.test.ts +0 -126
  49. package/tests/doc-search-initial-filters.test.ts +0 -20
  50. package/tests/error-handling.test.ts +0 -140
  51. package/tsconfig.json +0 -32
  52. package/tsconfig.node.json +0 -13
  53. package/tsconfig.types.json +0 -13
  54. package/tsup.config.ts +0 -22
@@ -1,22 +0,0 @@
1
- export function AiFeatureBorder({
2
- enabled = true,
3
- working = false,
4
- variation = "default",
5
- children,
6
- }: React.PropsWithChildren<{
7
- enabled?: boolean;
8
- working?: boolean;
9
- variation?: string;
10
- }>) {
11
- const active = Boolean(enabled && working);
12
-
13
- return (
14
- <div
15
- className="ai-kit-feature-border"
16
- data-ai-kit-active={active ? "true" : "false"}
17
- data-ai-kit-variation={variation}
18
- >
19
- <div className="ai-kit-feature-border__content">{children}</div>
20
- </div>
21
- );
22
- }
@@ -1,118 +0,0 @@
1
- import { Tooltip } from "@mantine/core";
2
- import { useMemo } from "react";
3
- import { I18n } from "aws-amplify/utils";
4
-
5
- // Minimal shape compatible with dom-chromium-ai ProofreadCorrection
6
- export type Correction = {
7
- startIndex: number;
8
- endIndex: number;
9
- correction?: string;
10
- replacement?: string;
11
- explanation?: string;
12
- type?: string;
13
- };
14
-
15
- type Segment =
16
- | { kind: "plain"; text: string }
17
- | { kind: "corr"; original: string; corr: Correction };
18
-
19
- export type ProofreadDiffProps = {
20
- original: string;
21
- corrections: Correction[];
22
- };
23
-
24
- function normalizeCorrections(corrections: Correction[]): Correction[] {
25
- const sorted = [...corrections].sort((a, b) => a.startIndex - b.startIndex);
26
- const out: Correction[] = [];
27
- let lastEnd = -1;
28
- for (const c of sorted) {
29
- if (
30
- typeof c.startIndex !== "number" ||
31
- typeof c.endIndex !== "number" ||
32
- c.startIndex < 0 ||
33
- c.endIndex <= c.startIndex
34
- ) {
35
- continue;
36
- }
37
- // Drop overlaps (best-effort)
38
- if (c.startIndex < lastEnd) continue;
39
- out.push(c);
40
- lastEnd = c.endIndex;
41
- }
42
- return out;
43
- }
44
-
45
- export function ProofreadDiff({ original, corrections }: ProofreadDiffProps) {
46
- const segments = useMemo<Segment[]>(() => {
47
- const corr = normalizeCorrections(corrections || []);
48
- const segs: Segment[] = [];
49
- let cursor = 0;
50
- for (const c of corr) {
51
- if (c.startIndex > cursor) {
52
- segs.push({
53
- kind: "plain",
54
- text: original.slice(cursor, c.startIndex),
55
- });
56
- }
57
- const orig = original.slice(c.startIndex, c.endIndex);
58
- segs.push({ kind: "corr", original: orig, corr: c });
59
- cursor = c.endIndex;
60
- }
61
- if (cursor < original.length) {
62
- segs.push({ kind: "plain", text: original.slice(cursor) });
63
- }
64
- return segs;
65
- }, [original, corrections]);
66
-
67
- return (
68
- <div
69
- style={{
70
- padding: 12,
71
- border: "1px solid rgba(0,0,0,0.1)",
72
- borderRadius: 6,
73
- background: "rgba(0,0,0,0.02)",
74
- whiteSpace: "pre-wrap",
75
- lineHeight: 1.5,
76
- }}
77
- >
78
- {segments.map((s, idx) => {
79
- if (s.kind === "plain") {
80
- return <span key={idx}>{s.text}</span>;
81
- }
82
- const replacement = (
83
- s.corr.replacement ??
84
- s.corr.correction ??
85
- ""
86
- ).trim();
87
- const explanation = (s.corr.explanation ?? "").trim();
88
- const type = (s.corr.type ?? "").trim();
89
- const tooltip = [
90
- type ? I18n.get("Type") + ": - " + I18n.get(type) : "",
91
- replacement ? I18n.get("Replace with") + ": " + replacement : "",
92
- explanation ? I18n.get("Why") + ": " + explanation : "",
93
- ]
94
- .filter(Boolean)
95
- .join("\n");
96
-
97
- return (
98
- <Tooltip
99
- key={idx}
100
- label={tooltip || I18n.get("Suggested change")}
101
- multiline={true}
102
- >
103
- <span
104
- style={{
105
- textDecoration: "underline",
106
- textDecorationStyle: "wavy",
107
- cursor: "help",
108
- padding: "0 1px",
109
- }}
110
- >
111
- {s.original}
112
- </span>
113
- </Tooltip>
114
- );
115
- })}
116
- </div>
117
- );
118
- }
@@ -1,2 +0,0 @@
1
- export { AiFeature } from "./AiFeature";
2
- export { markdownToHtml } from "./utils";
@@ -1,20 +0,0 @@
1
- import rehypeSanitize, { defaultSchema } from "rehype-sanitize";
2
- import rehypeStringify from "rehype-stringify";
3
- import remarkGfm from "remark-gfm";
4
- import remarkParse from "remark-parse";
5
- import remarkRehype from "remark-rehype";
6
- import { unified } from "unified";
7
-
8
- export const markdownToHtml = async (markdown: string): Promise<string> => {
9
- return String(
10
- await unified()
11
- .use(remarkParse)
12
- .use(remarkGfm)
13
- .use(remarkRehype, {
14
- allowDangerousHtml: false,
15
- })
16
- .use(rehypeSanitize, defaultSchema)
17
- .use(rehypeStringify)
18
- .process(markdown),
19
- );
20
- };