@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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@smart-cloud/ai-kit-ui",
3
- "version": "1.0.2",
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.0.0",
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",
@@ -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
- styleText?: string;
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 styleText changes without forcing huge deps churn
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
- styleText,
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 styleTextHash = useMemo(() => {
123
- return styleText ? hashStringDjb2(styleText) : "";
124
- }, [styleText]);
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
- // Kövesd, ha a host dokumentumban változik a séma
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 (styleText) {
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", styleTextHash);
223
- s.textContent = styleText;
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 !== styleTextHash) {
228
- existingStyle.setAttribute("data-hash", styleTextHash);
229
- existingStyle.textContent = styleText;
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, styleText, styleTextHash]);
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 ref={hostRef}>
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}>