@smart-cloud/ai-kit-ui 1.0.2 → 1.1.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.
- package/dist/ai-kit-ui.css +693 -36
- package/dist/index.cjs +25 -8
- package/dist/index.d.cts +16 -5
- package/dist/index.d.ts +16 -5
- package/dist/index.js +25 -8
- package/package.json +2 -2
- package/src/ShadowBoundary.tsx +23 -21
- package/src/ai-chatbot/AiChatbot.tsx +1398 -0
- package/src/ai-chatbot/index.tsx +1 -0
- package/src/ai-feature/AiFeature.tsx +61 -11
- package/src/i18n/ar.ts +45 -1
- package/src/i18n/de.ts +173 -128
- package/src/i18n/en.ts +46 -1
- package/src/i18n/es.ts +45 -1
- package/src/i18n/fr.ts +45 -1
- package/src/i18n/he.ts +45 -1
- package/src/i18n/hi.ts +45 -1
- package/src/i18n/hu.ts +52 -8
- package/src/i18n/id.ts +45 -1
- package/src/i18n/it.ts +45 -1
- package/src/i18n/ja.ts +45 -1
- package/src/i18n/ko.ts +45 -1
- package/src/i18n/nb.ts +46 -1
- package/src/i18n/nl.ts +46 -1
- package/src/i18n/pl.ts +45 -1
- package/src/i18n/pt.ts +45 -1
- package/src/i18n/ru.ts +45 -1
- package/src/i18n/sv.ts +45 -1
- package/src/i18n/th.ts +45 -1
- package/src/i18n/tr.ts +45 -1
- package/src/i18n/ua.ts +45 -1
- package/src/i18n/zh.ts +44 -1
- package/src/index.tsx +1 -0
- package/src/styles/ai-kit-ui.css +693 -36
- package/src/withAiKitShell.tsx +2 -2
- package/.gitattributes +0 -8
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@smart-cloud/ai-kit-ui",
|
|
3
|
-
"version": "1.0
|
|
3
|
+
"version": "1.1.0",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"main": "./dist/index.cjs",
|
|
6
6
|
"module": "./dist/index.js",
|
|
@@ -19,7 +19,7 @@
|
|
|
19
19
|
"dependencies": {
|
|
20
20
|
"@emotion/cache": "^11.14.0",
|
|
21
21
|
"@emotion/react": "^11.14.0",
|
|
22
|
-
"@smart-cloud/ai-kit-core": "^1.
|
|
22
|
+
"@smart-cloud/ai-kit-core": "^1.1.1",
|
|
23
23
|
"@smart-cloud/wpsuite-core": "^2.0.5",
|
|
24
24
|
"@tabler/icons-react": "^3.36.1",
|
|
25
25
|
"react-markdown": "^10.1.0",
|
package/src/ShadowBoundary.tsx
CHANGED
|
@@ -13,7 +13,7 @@ export type ShadowBoundaryProps = {
|
|
|
13
13
|
className?: string;
|
|
14
14
|
|
|
15
15
|
/** Optional raw CSS text injected into the shadow root (as <style>). */
|
|
16
|
-
|
|
16
|
+
innerCSS?: string;
|
|
17
17
|
|
|
18
18
|
/** ID of the element inside the shadow root used as the portal target. */
|
|
19
19
|
rootElementId: string;
|
|
@@ -87,7 +87,7 @@ function installAiKitPropertyRegistry() {
|
|
|
87
87
|
doc.head.appendChild(style);
|
|
88
88
|
}
|
|
89
89
|
|
|
90
|
-
// tiny stable hash to detect
|
|
90
|
+
// tiny stable hash to detect innerCSS changes without forcing huge deps churn
|
|
91
91
|
function hashStringDjb2(str: string): string {
|
|
92
92
|
let hash = 5381;
|
|
93
93
|
for (let i = 0; i < str.length; i++) {
|
|
@@ -102,7 +102,7 @@ const STYLE_TEXT_ID = "ai-kit-style-text";
|
|
|
102
102
|
export function ShadowBoundary({
|
|
103
103
|
stylesheets,
|
|
104
104
|
className,
|
|
105
|
-
|
|
105
|
+
innerCSS,
|
|
106
106
|
children,
|
|
107
107
|
rootElementId,
|
|
108
108
|
mode = "local",
|
|
@@ -119,9 +119,9 @@ export function ShadowBoundary({
|
|
|
119
119
|
return all.join("|");
|
|
120
120
|
}, [stylesheets]);
|
|
121
121
|
|
|
122
|
-
const
|
|
123
|
-
return
|
|
124
|
-
}, [
|
|
122
|
+
const innerCSSHash = useMemo(() => {
|
|
123
|
+
return innerCSS ? hashStringDjb2(innerCSS) : "";
|
|
124
|
+
}, [innerCSS]);
|
|
125
125
|
|
|
126
126
|
useLayoutEffect(() => {
|
|
127
127
|
if (!hostRef.current) return;
|
|
@@ -179,17 +179,11 @@ export function ShadowBoundary({
|
|
|
179
179
|
const applyScheme = () => {
|
|
180
180
|
host.setAttribute("data-ai-kit-variation", readVariation() || "default");
|
|
181
181
|
host.setAttribute("data-mantine-color-scheme", readScheme() || "auto");
|
|
182
|
-
if (className) {
|
|
183
|
-
host.className = className;
|
|
184
|
-
}
|
|
185
|
-
host.style.setProperty("outline", "none");
|
|
186
|
-
host.style.setProperty("box-shadow", "none");
|
|
187
|
-
host.style.setProperty("--mantine-color-body", "transparent");
|
|
188
182
|
};
|
|
189
183
|
|
|
190
184
|
applyScheme();
|
|
191
185
|
|
|
192
|
-
//
|
|
186
|
+
// 4) Watch for scheme/variation changes
|
|
193
187
|
const mo = new MutationObserver(applyScheme);
|
|
194
188
|
mo.observe(rootEl, {
|
|
195
189
|
attributes: true,
|
|
@@ -215,18 +209,18 @@ export function ShadowBoundary({
|
|
|
215
209
|
STYLE_TEXT_ID,
|
|
216
210
|
) as HTMLStyleElement | null;
|
|
217
211
|
|
|
218
|
-
if (
|
|
212
|
+
if (innerCSS) {
|
|
219
213
|
if (!existingStyle) {
|
|
220
214
|
const s = doc.createElement("style");
|
|
221
215
|
s.id = STYLE_TEXT_ID;
|
|
222
|
-
s.setAttribute("data-hash",
|
|
223
|
-
s.textContent =
|
|
216
|
+
s.setAttribute("data-hash", innerCSSHash);
|
|
217
|
+
s.textContent = innerCSS;
|
|
224
218
|
rootEl.appendChild(s);
|
|
225
219
|
} else {
|
|
226
220
|
const prevHash = existingStyle.getAttribute("data-hash") || "";
|
|
227
|
-
if (prevHash !==
|
|
228
|
-
existingStyle.setAttribute("data-hash",
|
|
229
|
-
existingStyle.textContent =
|
|
221
|
+
if (prevHash !== innerCSSHash) {
|
|
222
|
+
existingStyle.setAttribute("data-hash", innerCSSHash);
|
|
223
|
+
existingStyle.textContent = innerCSS;
|
|
230
224
|
}
|
|
231
225
|
}
|
|
232
226
|
} else if (existingStyle) {
|
|
@@ -240,7 +234,7 @@ export function ShadowBoundary({
|
|
|
240
234
|
mo.disconnect();
|
|
241
235
|
mq?.removeEventListener?.("change", onMq);
|
|
242
236
|
};
|
|
243
|
-
}, [mode, overlayRootId, rootElementId, stylesKey,
|
|
237
|
+
}, [mode, overlayRootId, rootElementId, stylesKey, innerCSS, innerCSSHash]);
|
|
244
238
|
|
|
245
239
|
const emotionCache = useMemo(() => {
|
|
246
240
|
if (!portalTarget) return null;
|
|
@@ -252,7 +246,15 @@ export function ShadowBoundary({
|
|
|
252
246
|
}, [portalTarget, mode]);
|
|
253
247
|
|
|
254
248
|
return (
|
|
255
|
-
<div
|
|
249
|
+
<div
|
|
250
|
+
ref={hostRef}
|
|
251
|
+
className={className}
|
|
252
|
+
style={{
|
|
253
|
+
outline: "none",
|
|
254
|
+
boxShadow: "none",
|
|
255
|
+
backgroundColor: "transparent",
|
|
256
|
+
}}
|
|
257
|
+
>
|
|
256
258
|
{portalTarget && shadowRoot && emotionCache
|
|
257
259
|
? createPortal(
|
|
258
260
|
<CacheProvider value={emotionCache}>
|