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

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 (55) hide show
  1. package/dist/LocaleDirectionProvider.d.ts +5 -0
  2. package/dist/ai-feature/AiFeature.d.ts +1 -0
  3. package/dist/index.cjs +9 -9
  4. package/dist/index.js +9 -9
  5. package/dist/locale.d.ts +13 -0
  6. package/package.json +35 -19
  7. package/eslint.config.js +0 -18
  8. package/src/ShadowBoundary.tsx +0 -229
  9. package/src/ai-chatbot/AiChatbot.tsx +0 -2325
  10. package/src/ai-chatbot/attachmentStorage.ts +0 -238
  11. package/src/ai-chatbot/index.tsx +0 -1
  12. package/src/ai-feature/AiFeature.tsx +0 -2334
  13. package/src/ai-feature/AiFeatureBorder.tsx +0 -22
  14. package/src/ai-feature/ProofreadDiff.tsx +0 -118
  15. package/src/ai-feature/index.tsx +0 -2
  16. package/src/ai-feature/utils.tsx +0 -20
  17. package/src/doc-search/DocSearch.tsx +0 -1313
  18. package/src/doc-search/index.tsx +0 -1
  19. package/src/doc-search/initialFilters.ts +0 -10
  20. package/src/errorHandling.ts +0 -305
  21. package/src/i18n/ar.ts +0 -254
  22. package/src/i18n/de.ts +0 -257
  23. package/src/i18n/en.ts +0 -269
  24. package/src/i18n/es.ts +0 -257
  25. package/src/i18n/fr.ts +0 -258
  26. package/src/i18n/he.ts +0 -250
  27. package/src/i18n/hi.ts +0 -256
  28. package/src/i18n/hu.ts +0 -269
  29. package/src/i18n/id.ts +0 -256
  30. package/src/i18n/index.ts +0 -47
  31. package/src/i18n/it.ts +0 -259
  32. package/src/i18n/ja.ts +0 -256
  33. package/src/i18n/ko.ts +0 -254
  34. package/src/i18n/nb.ts +0 -254
  35. package/src/i18n/nl.ts +0 -255
  36. package/src/i18n/pl.ts +0 -258
  37. package/src/i18n/pt.ts +0 -254
  38. package/src/i18n/ru.ts +0 -254
  39. package/src/i18n/sv.ts +0 -253
  40. package/src/i18n/th.ts +0 -252
  41. package/src/i18n/tr.ts +0 -256
  42. package/src/i18n/ua.ts +0 -257
  43. package/src/i18n/zh.ts +0 -247
  44. package/src/index.tsx +0 -7
  45. package/src/poweredBy.tsx +0 -39
  46. package/src/styles/ai-kit-ui.css +0 -1006
  47. package/src/useAiRun.ts +0 -182
  48. package/src/withAiKitShell.tsx +0 -363
  49. package/tests/ai-disclosures.test.ts +0 -126
  50. package/tests/doc-search-initial-filters.test.ts +0 -20
  51. package/tests/error-handling.test.ts +0 -140
  52. package/tsconfig.json +0 -32
  53. package/tsconfig.node.json +0 -13
  54. package/tsconfig.types.json +0 -13
  55. package/tsup.config.ts +0 -22
@@ -0,0 +1,13 @@
1
+ import { type PropsWithChildren } from "react";
2
+ import { type TranslationCatalogs } from "@smart-cloud/wpsuite-core";
3
+ export interface AiKitTranslator {
4
+ language: string;
5
+ customTranslations?: TranslationCatalogs | null;
6
+ get(key: string, fallback?: string): string;
7
+ }
8
+ export declare function useSiteLocale(): import("@smart-cloud/wpsuite-core").SiteLocaleSnapshot;
9
+ export declare function AiKitLocaleProvider({ language, customTranslations, children }: PropsWithChildren<{
10
+ language: string;
11
+ customTranslations?: TranslationCatalogs | null;
12
+ }>): import("react").JSX.Element;
13
+ export declare function useAiKitI18n(): AiKitTranslator;
package/package.json CHANGED
@@ -1,11 +1,14 @@
1
1
  {
2
2
  "name": "@smart-cloud/ai-kit-ui",
3
- "version": "1.5.14",
3
+ "version": "1.5.16",
4
4
  "type": "module",
5
5
  "main": "./dist/index.cjs",
6
6
  "module": "./dist/index.js",
7
7
  "types": "./dist/index.d.ts",
8
8
  "license": "ISC",
9
+ "files": [
10
+ "dist"
11
+ ],
9
12
  "scripts": {
10
13
  "build": "yarn build:js && yarn build:types",
11
14
  "build:js": "tsup --minify",
@@ -22,8 +25,8 @@
22
25
  "@emotion/cache": "^11.14.0",
23
26
  "@emotion/react": "^11.14.0",
24
27
  "@mantine/colors-generator": "^8.3.18",
25
- "@smart-cloud/ai-kit-core": "^1.5.7",
26
- "@smart-cloud/wpsuite-core": "^2.3.2",
28
+ "@smart-cloud/ai-kit-core": "^1.5.9",
29
+ "@smart-cloud/wpsuite-core": "^2.4.1",
27
30
  "@tabler/icons-react": "^3.46.0",
28
31
  "chroma-js": "^3.2.0",
29
32
  "country-flag-icons": "^1.6.20",
@@ -44,12 +47,12 @@
44
47
  "@mantine/core": "^8.3.18",
45
48
  "@mantine/hooks": "^8.3.18",
46
49
  "@mantine/modals": "^8.3.18",
47
- "@smart-cloud/aws-amplify-ui": "6.15.5",
48
- "@smart-cloud/aws-amplify-ui-react": "6.15.5",
49
- "@wordpress/data": "^10.52.0",
50
- "@wordpress/i18n": "^6.25.0",
50
+ "@smart-cloud/aws-amplify-ui": "6.15.7-preview.1",
51
+ "@smart-cloud/aws-amplify-ui-react": "6.15.7-preview.1",
52
+ "@wordpress/data": "^10.54.0",
53
+ "@wordpress/i18n": "^6.27.0",
51
54
  "aws-amplify": "^6.20.0",
52
- "jose": "^6.2.5",
55
+ "jose": "^6.2.12",
53
56
  "react": "^18.3.1",
54
57
  "react-dom": "^18.3.1"
55
58
  },
@@ -59,39 +62,52 @@
59
62
  "@mantine/core": "^8.3.18",
60
63
  "@mantine/hooks": "^8.3.18",
61
64
  "@mantine/modals": "^8.3.18",
62
- "@smart-cloud/aws-amplify-ui": "6.15.5",
63
- "@smart-cloud/aws-amplify-ui-react": "6.15.5",
65
+ "@smart-cloud/aws-amplify-ui": "6.15.7-preview.1",
66
+ "@smart-cloud/aws-amplify-ui-react": "6.15.7-preview.1",
64
67
  "@types/dom-chromium-ai": "^0.0.17",
65
68
  "@types/jquery": "^4.0.1",
66
69
  "@types/react": "^18.3.31",
67
70
  "@types/react-dom": "^18.3.7",
68
- "@typescript-eslint/eslint-plugin": "^8.65.0",
69
- "@typescript-eslint/parser": "^8.65.0",
70
- "@wordpress/data": "^10.52.0",
71
- "@wordpress/i18n": "^6.25.0",
71
+ "@typescript-eslint/eslint-plugin": "^8.69.0",
72
+ "@typescript-eslint/parser": "^8.69.0",
73
+ "@wordpress/data": "^10.54.0",
74
+ "@wordpress/i18n": "^6.27.0",
72
75
  "ajv": "^8.20.0",
73
76
  "aws-amplify": "^6.20.0",
74
- "eslint": "^10.8.0",
75
- "globals": "^17.8.0",
77
+ "eslint": "^10.10.0",
78
+ "globals": "^17.12.0",
76
79
  "jquery": "^4.0.0",
77
- "jose": "^6.2.5",
80
+ "jose": "^6.2.12",
78
81
  "react": "^18.3.1",
79
82
  "react-dom": "^18.3.1",
80
83
  "tsup": "^8.5.1",
81
84
  "typescript": "^6.0.3",
82
- "typescript-eslint": "^8.65.0"
85
+ "typescript-eslint": "^8.69.0",
86
+ "yaml": "^2.8.3"
83
87
  },
84
88
  "resolutions": {
89
+ "@humanfs/node": "^0.16.8",
85
90
  "brace-expansion": "^5.0.9",
86
91
  "esbuild": "^0.28.1",
87
92
  "fast-xml-builder": "^1.3.0",
88
93
  "fast-xml-parser": "^5.10.1",
89
- "fast-uri": "^3.1.4",
94
+ "fast-uri": "^3.1.6",
90
95
  "flatted": "^3.4.4",
91
96
  "picomatch": "^4.0.5",
92
97
  "rollup": "^4.62.3",
93
98
  "@emotion/react/**/yaml": "^1.10.3"
94
99
  },
100
+ "overrides": {
101
+ "@humanfs/node": "^0.16.8",
102
+ "brace-expansion": "^5.0.9",
103
+ "esbuild": "^0.28.1",
104
+ "fast-xml-builder": "^1.3.0",
105
+ "fast-xml-parser": "^5.10.1",
106
+ "fast-uri": "^3.1.6",
107
+ "flatted": "^3.4.4",
108
+ "picomatch": "^4.0.5",
109
+ "rollup": "^4.62.3"
110
+ },
95
111
  "exports": {
96
112
  ".": {
97
113
  "types": "./dist/index.d.ts",
package/eslint.config.js DELETED
@@ -1,18 +0,0 @@
1
- import jseslint from "@eslint/js";
2
- import { defineConfig } from 'eslint/config';
3
- import globals from "globals";
4
- import tseslint from 'typescript-eslint';
5
-
6
- export default defineConfig(
7
- { ignores: ['**/build/**', '**/dist/**', '**/webpack.config.cjs'] },
8
- jseslint.configs.recommended,
9
- ...tseslint.configs.recommended,
10
- {
11
- files: ["**/*.tsx", "**/*.ts"],
12
- languageOptions: {
13
- parser: tseslint.parser,
14
- ecmaVersion: 2020,
15
- globals: globals.browser,
16
- },
17
- }
18
- );
@@ -1,229 +0,0 @@
1
- import createCache from "@emotion/cache";
2
- import { CacheProvider } from "@emotion/react";
3
- import {
4
- SetStateAction,
5
- useLayoutEffect,
6
- useMemo,
7
- useRef,
8
- useState,
9
- } from "react";
10
- import { createPortal } from "react-dom";
11
-
12
- export type ShadowBoundaryMode = "local" | "overlay";
13
-
14
- export type ShadowBoundaryProps = {
15
- /** Stylesheets to inject into the shadow root (as <link rel="stylesheet">). */
16
- stylesheets: string[];
17
-
18
- /** ID of the element inside the shadow root used as the portal target. */
19
- rootElementId: string;
20
-
21
- /** Variation of the shadow boundary behavior. */
22
- variation?: "default" | "modal";
23
- /**
24
- * Where to create the shadow root:
25
- * - "local": attach shadow to this component's host element (keeps layout positioning).
26
- * - "overlay": attach shadow to a singleton element in top (or self) document (always on top).
27
- */
28
- mode?: ShadowBoundaryMode;
29
-
30
- /**
31
- * For mode="overlay": host id in the top (or self) document.
32
- * Same id everywhere => singleton overlay host.
33
- */
34
- overlayRootId?: string;
35
-
36
- setHost: React.Dispatch<SetStateAction<HTMLElement | null>>;
37
- /** Optional notification for consumers that need a distinct modal portal. */
38
- setRootElement?: React.Dispatch<SetStateAction<HTMLDivElement | null>>;
39
- children: (api: {
40
- /** Portal target element inside the shadow root. */
41
- rootElement: HTMLDivElement;
42
- /** Shadow root instance. */
43
- shadowRoot: ShadowRoot;
44
- }) => React.ReactNode;
45
- };
46
-
47
- function getTopDocumentSafe(): Document {
48
- try {
49
- return window.top?.document ?? window.document;
50
- } catch {
51
- return window.document;
52
- }
53
- }
54
-
55
- function ensureStylesheets(
56
- doc: Document,
57
- container: HTMLElement,
58
- shadow: ShadowRoot,
59
- hrefs: string[],
60
- ) {
61
- for (const href of hrefs) {
62
- const id = `ai-kit-style-${btoa(href).replace(/=+$/g, "")}`;
63
- if (shadow.getElementById(id)) continue;
64
- const link = doc.createElement("link");
65
- link.id = id;
66
- link.rel = "stylesheet";
67
- link.href = href;
68
- container.appendChild(link);
69
- }
70
- }
71
-
72
- const REGISTRY_ID = "ai-kit-property-registry";
73
-
74
- function installAiKitPropertyRegistry(doc: Document) {
75
- if (doc.getElementById(REGISTRY_ID)) return;
76
-
77
- const style = doc.createElement("style");
78
- style.id = REGISTRY_ID;
79
- style.textContent = `
80
- @property --ai-kit-border-angle {
81
- syntax: "<angle>";
82
- inherits: true;
83
- initial-value: 0deg;
84
- }
85
- `;
86
- (doc.head ?? doc.documentElement).appendChild(style);
87
- }
88
-
89
- export function ShadowBoundary({
90
- stylesheets,
91
- children,
92
- rootElementId,
93
- mode = "local",
94
- overlayRootId = "ai-kit-overlay-root",
95
- setHost,
96
- setRootElement,
97
- }: ShadowBoundaryProps) {
98
- const hostRef = useRef<HTMLDivElement | null>(null);
99
-
100
- const [shadowRoot, setShadowRoot] = useState<ShadowRoot | null>(null);
101
- const [portalTarget, setPortalTarget] = useState<HTMLDivElement | null>(null);
102
-
103
- // Combine built-in + external stylesheets; stable key so callers don't need to memoize arrays.
104
- const stylesKey = useMemo(() => {
105
- const all = [...stylesheets];
106
- return all.join("|");
107
- }, [stylesheets]);
108
-
109
- useLayoutEffect(() => {
110
- if (!hostRef.current) return;
111
-
112
- const doc =
113
- mode === "overlay" ? getTopDocumentSafe() : hostRef.current.ownerDocument;
114
-
115
- // 1) Decide overlay host vs local host
116
- let host: HTMLElement;
117
- if (mode === "overlay") {
118
- let overlayHost = doc.getElementById(
119
- overlayRootId,
120
- ) as HTMLDivElement | null;
121
- if (!overlayHost) {
122
- overlayHost = doc.createElement("div");
123
- overlayHost.id = overlayRootId;
124
-
125
- // Do not affect layout; allow overlays to sit above everything.
126
- overlayHost.style.position = "fixed";
127
- overlayHost.style.inset = "0";
128
- overlayHost.style.width = "0";
129
- overlayHost.style.height = "0";
130
- overlayHost.style.zIndex = "2147483647"; // max z-index
131
- overlayHost.style.pointerEvents = "none";
132
-
133
- doc.body.appendChild(overlayHost);
134
- }
135
- host = overlayHost;
136
- } else {
137
- host = hostRef.current;
138
- }
139
- setHost(host);
140
-
141
- // 2) Ensure shadow root
142
- const shadow = host.shadowRoot ?? host.attachShadow({ mode: "open" });
143
-
144
- // 3) Ensure portal target div
145
- let rootEl = shadow.querySelector(
146
- `#${CSS.escape(rootElementId)}`,
147
- ) as HTMLDivElement | null;
148
- if (!rootEl) {
149
- rootEl = doc.createElement("div");
150
- rootEl.id = rootElementId;
151
- rootEl.style.margin = "0";
152
-
153
- // Overlay host itself has pointerEvents:none; allow content to receive events.
154
- if (mode === "overlay") {
155
- rootEl.style.pointerEvents = "auto";
156
- }
157
- shadow.appendChild(rootEl);
158
- }
159
-
160
- const readScheme = () => rootEl.getAttribute("data-mantine-color-scheme");
161
- const readVariation = () => rootEl.getAttribute("data-ai-kit-variation");
162
-
163
- const applyScheme = () => {
164
- host.setAttribute("data-ai-kit-variation", readVariation() || "default");
165
- host.setAttribute("data-mantine-color-scheme", readScheme() || "auto");
166
- };
167
-
168
- applyScheme();
169
-
170
- // 4) Watch for scheme/variation changes
171
- const mo = new MutationObserver(applyScheme);
172
- mo.observe(rootEl, {
173
- attributes: true,
174
- attributeFilter: ["data-mantine-color-scheme"],
175
- });
176
-
177
- const mq = window.matchMedia?.("(prefers-color-scheme: dark)");
178
- const onMq = () => applyScheme();
179
- mq?.addEventListener?.("change", onMq);
180
-
181
- installAiKitPropertyRegistry(doc);
182
-
183
- // 5) Inject styles into shadow body (dedup per shadow root)
184
- ensureStylesheets(
185
- doc,
186
- rootEl,
187
- shadow,
188
- stylesKey ? stylesKey.split("|") : [],
189
- );
190
-
191
- setShadowRoot(shadow);
192
- setPortalTarget(rootEl);
193
- setRootElement?.(rootEl);
194
-
195
- return () => {
196
- mo.disconnect();
197
- mq?.removeEventListener?.("change", onMq);
198
- };
199
- }, [mode, overlayRootId, rootElementId, stylesKey]);
200
-
201
- const emotionCache = useMemo(() => {
202
- if (!portalTarget) return null;
203
- // IMPORTANT: container must be an HTMLElement inside the shadow tree.
204
- return createCache({
205
- key: mode === "overlay" ? "ai-kit-ov" : "ai-kit-local",
206
- container: portalTarget,
207
- });
208
- }, [portalTarget, mode]);
209
-
210
- return (
211
- <div
212
- ref={hostRef}
213
- style={{
214
- outline: "none",
215
- boxShadow: "none",
216
- backgroundColor: "transparent",
217
- }}
218
- >
219
- {portalTarget && shadowRoot && emotionCache
220
- ? createPortal(
221
- <CacheProvider value={emotionCache}>
222
- {children({ rootElement: portalTarget, shadowRoot })}
223
- </CacheProvider>,
224
- portalTarget,
225
- )
226
- : null}
227
- </div>
228
- );
229
- }