@smart-cloud/ai-kit-ui 1.1.39 → 1.1.41

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.1.39",
3
+ "version": "1.1.41",
4
4
  "type": "module",
5
5
  "main": "./dist/index.cjs",
6
6
  "module": "./dist/index.js",
@@ -20,11 +20,12 @@
20
20
  "@emotion/cache": "^11.14.0",
21
21
  "@emotion/react": "^11.14.0",
22
22
  "@mantine/colors-generator": "^8.3.14",
23
- "@smart-cloud/ai-kit-core": "^1.1.18",
23
+ "@smart-cloud/ai-kit-core": "^1.1.21",
24
24
  "@smart-cloud/wpsuite-core": "^2.1.2",
25
25
  "@tabler/icons-react": "^3.36.1",
26
26
  "chroma-js": "^3.2.0",
27
27
  "react-markdown": "^10.1.0",
28
+ "rehype-raw": "^7.0.0",
28
29
  "rehype-sanitize": "^6.0.0",
29
30
  "rehype-stringify": "^10.0.1",
30
31
  "remark-gfm": "^4.0.1",
@@ -42,27 +43,27 @@
42
43
  "react-dom": "^18.3.1"
43
44
  },
44
45
  "devDependencies": {
45
- "@eslint/js": "^9.39.2",
46
+ "@eslint/js": "^10.0.1",
46
47
  "@mantine/core": "^8.3.14",
47
48
  "@mantine/hooks": "^8.3.14",
48
49
  "@mantine/modals": "^8.3.14",
49
- "@types/dom-chromium-ai": "^0.0.13",
50
+ "@types/dom-chromium-ai": "^0.0.14",
50
51
  "@types/jquery": "^3.5.33",
51
52
  "@types/react": "^18.3.23",
52
53
  "@types/react-dom": "^18.3.7",
53
- "@typescript-eslint/eslint-plugin": "^8.54.0",
54
- "@typescript-eslint/parser": "^8.54.0",
54
+ "@typescript-eslint/eslint-plugin": "^8.55.0",
55
+ "@typescript-eslint/parser": "^8.55.0",
55
56
  "@wordpress/data": "^10.39.0",
56
57
  "ajv": "^8.17.1",
57
58
  "aws-amplify": "^6.16.0",
58
- "eslint": "^9.39.2",
59
+ "eslint": "^10.0.0",
59
60
  "globals": "^17.3.0",
60
61
  "jquery": "^4.0.0",
61
62
  "react": "^18.3.1",
62
63
  "react-dom": "^18.3.1",
63
64
  "tsup": "^8.5.1",
64
65
  "typescript": "^5.9.3",
65
- "typescript-eslint": "^8.54.0"
66
+ "typescript-eslint": "^8.55.0"
66
67
  },
67
68
  "exports": {
68
69
  ".": {
@@ -1,6 +1,5 @@
1
1
  import {
2
2
  Alert,
3
- Anchor,
4
3
  Button,
5
4
  Collapse,
6
5
  Divider,
@@ -55,6 +54,7 @@ import {
55
54
  } from "@tabler/icons-react";
56
55
 
57
56
  import { translations } from "../i18n";
57
+ import { PoweredBy } from "../poweredBy";
58
58
  import {
59
59
  isBackendConfigured,
60
60
  readDefaultOutputLanguage,
@@ -184,11 +184,14 @@ async function parseImageMetadataFromPromptResult(
184
184
  typeof parsed.title === "string"
185
185
  ? outputLang && outputLang !== "en"
186
186
  ? (
187
- await translate({
188
- text: parsed.title,
189
- sourceLanguage: "en",
190
- targetLanguage: outputLang,
191
- })
187
+ await translate(
188
+ {
189
+ text: parsed.title,
190
+ sourceLanguage: "en",
191
+ targetLanguage: outputLang,
192
+ },
193
+ featureOptions,
194
+ )
192
195
  ).result
193
196
  : parsed.title
194
197
  : "",
@@ -196,11 +199,14 @@ async function parseImageMetadataFromPromptResult(
196
199
  typeof parsed.caption === "string"
197
200
  ? outputLang && outputLang !== "en"
198
201
  ? (
199
- await translate({
200
- text: parsed.caption,
201
- sourceLanguage: "en",
202
- targetLanguage: outputLang,
203
- })
202
+ await translate(
203
+ {
204
+ text: parsed.caption,
205
+ sourceLanguage: "en",
206
+ targetLanguage: outputLang,
207
+ },
208
+ featureOptions,
209
+ )
204
210
  ).result
205
211
  : parsed.caption
206
212
  : "",
@@ -208,11 +214,14 @@ async function parseImageMetadataFromPromptResult(
208
214
  typeof parsed.description === "string"
209
215
  ? outputLang && outputLang !== "en"
210
216
  ? (
211
- await translate({
212
- text: parsed.description,
213
- sourceLanguage: "en",
214
- targetLanguage: outputLang,
215
- })
217
+ await translate(
218
+ {
219
+ text: parsed.description,
220
+ sourceLanguage: "en",
221
+ targetLanguage: outputLang,
222
+ },
223
+ featureOptions,
224
+ )
216
225
  ).result
217
226
  : parsed.description
218
227
  : "",
@@ -354,7 +363,11 @@ const AiFeatureBase: FC<AiFeatureProps & AiKitShellInjectedProps> = (props) => {
354
363
  >(defaults?.outputFormat);
355
364
  const [outputLanguage, setOutputLanguage] = useState<
356
365
  AiKitLanguageCode | "auto" | undefined
357
- >(defaults?.outputLanguage);
366
+ >(
367
+ defaults?.outputLanguage ||
368
+ aiKit.settings.defaultOutputLanguage ||
369
+ (mode === "rewrite" ? "auto" : undefined),
370
+ );
358
371
  const [length, setLength] = useState<
359
372
  WriterLength | RewriterLength | SummarizerLength | undefined
360
373
  >(defaults?.length);
@@ -369,33 +382,36 @@ const AiFeatureBase: FC<AiFeatureProps & AiKitShellInjectedProps> = (props) => {
369
382
  if (language) {
370
383
  I18n.setLanguage(language || "en");
371
384
  }
372
- let title;
385
+ if (title) {
386
+ return title;
387
+ }
388
+ let t;
373
389
  switch (mode) {
374
390
  default:
375
391
  case "summarize":
376
- title = I18n.get("Summarize");
392
+ t = "Summarize";
377
393
  break;
378
394
  case "proofread":
379
- title = I18n.get("Proofread");
395
+ t = "Proofread";
380
396
  break;
381
397
  case "write":
382
- title = I18n.get("Write");
398
+ t = "Write";
383
399
  break;
384
400
  case "rewrite":
385
- title = I18n.get("Rewrite");
401
+ t = "Rewrite";
386
402
  break;
387
403
  case "translate":
388
- title = I18n.get("Translate");
404
+ t = "Translate";
389
405
  break;
390
406
  case "generatePostMetadata":
391
- title = I18n.get("Generate Post Metadata");
407
+ t = "Generate Post Metadata";
392
408
  break;
393
409
  case "generateImageMetadata":
394
- title = I18n.get("Generate Image Metadata");
410
+ t = "Generate Image Metadata";
395
411
  break;
396
412
  }
397
- return title;
398
- }, [mode, language]);
413
+ return t;
414
+ }, [title, mode, language]);
399
415
 
400
416
  const formatAiKitStatus = useCallback(
401
417
  (e: AiKitStatusEvent | null): string | null => {
@@ -461,10 +477,15 @@ const AiFeatureBase: FC<AiFeatureProps & AiKitShellInjectedProps> = (props) => {
461
477
  case "generateImageMetadata":
462
478
  return Boolean(image);
463
479
  case "translate":
480
+ console.log(
481
+ "detectedLanguage",
482
+ detectedLanguage,
483
+ "outputLanguage",
484
+ outputLanguage,
485
+ );
464
486
  return (
465
487
  Boolean(text && text.trim().length > 0) &&
466
- outputLanguage &&
467
- detectedLanguage !== outputLanguage
488
+ (!outputLanguage || detectedLanguage !== outputLanguage)
468
489
  );
469
490
  case "summarize":
470
491
  case "proofread":
@@ -580,6 +601,13 @@ const AiFeatureBase: FC<AiFeatureProps & AiKitShellInjectedProps> = (props) => {
580
601
  ? outputLanguage
581
602
  : null) || readDefaultOutputLanguage();
582
603
  if (outLang === inputLang) {
604
+ console.warn(
605
+ "AI Kit: input and output languages are the same",
606
+ {
607
+ inputLang,
608
+ outLang,
609
+ },
610
+ );
583
611
  setError(
584
612
  I18n.get("Input and output languages cannot be the same."),
585
613
  );
@@ -1160,7 +1188,7 @@ Follow these additional instructions: ${instructions}`
1160
1188
  {variation === "modal" && (
1161
1189
  <Modal.Header style={{ zIndex: 1000 }}>
1162
1190
  {getOpenButtonDefaultIcon("ai-feature-title-icon")}
1163
- <Modal.Title>{I18n.get(title || defaultTitle)}</Modal.Title>
1191
+ <Modal.Title>{I18n.get(defaultTitle)}</Modal.Title>
1164
1192
  <Modal.CloseButton />
1165
1193
  </Modal.Header>
1166
1194
  )}
@@ -1334,6 +1362,7 @@ Follow these additional instructions: ${instructions}`
1334
1362
  onChange={(value) => {
1335
1363
  const val = value as AiKitLanguageCode;
1336
1364
  setInputLanguage(val);
1365
+ setDetectedLanguage(undefined);
1337
1366
  onOptionsChanged?.({ inputLanguage: val });
1338
1367
  }}
1339
1368
  />
@@ -1388,6 +1417,7 @@ Follow these additional instructions: ${instructions}`
1388
1417
  onChange={(value) => {
1389
1418
  const val = value as AiKitLanguageCode;
1390
1419
  setOutputLanguage(val);
1420
+ setDetectedLanguage(undefined);
1391
1421
  onOptionsChanged?.({ outputLanguage: val });
1392
1422
  }}
1393
1423
  />
@@ -1633,7 +1663,7 @@ Follow these additional instructions: ${instructions}`
1633
1663
  {ai.busy && statusText && (
1634
1664
  <AiFeatureBorder
1635
1665
  enabled={variation === "modal"}
1636
- working={ai.busy}
1666
+ working={true}
1637
1667
  variation={variation}
1638
1668
  >
1639
1669
  <Group
@@ -1645,7 +1675,7 @@ Follow these additional instructions: ${instructions}`
1645
1675
  >
1646
1676
  <Loader size="sm" />
1647
1677
  <Input.Label className="ai-feature-status-text">
1648
- {statusText ?? "VALAMILYEN SZÖVEG"}
1678
+ {statusText}
1649
1679
  </Input.Label>
1650
1680
  </Group>
1651
1681
  </AiFeatureBorder>
@@ -1900,36 +1930,7 @@ Follow these additional instructions: ${instructions}`
1900
1930
  {I18n.get("Close")}
1901
1931
  </Button>
1902
1932
  </Group>
1903
- <div
1904
- style={{
1905
- display: aiKit.settings?.enablePoweredBy ? "flex" : "none",
1906
- justifyContent: aiKit.settings?.enablePoweredBy
1907
- ? "flex-end"
1908
- : undefined,
1909
- padding: 0,
1910
- marginRight: "var(--ai-kit-spacing-sm)",
1911
- marginBottom:
1912
- variation === "default"
1913
- ? "var(--ai-kit-spacing-sm)"
1914
- : undefined,
1915
- }}
1916
- className={
1917
- aiKit.settings?.enablePoweredBy ? undefined : "sr-only"
1918
- }
1919
- >
1920
- <Text c="p" ta="right" fs="italic" fz="xs">
1921
- Powered by{" "}
1922
- <Anchor
1923
- href="https://wpsuite.io/ai-kit/"
1924
- target="_blank"
1925
- td="none"
1926
- fz="xs"
1927
- fw={400}
1928
- >
1929
- WPSuite AI-Kit
1930
- </Anchor>
1931
- </Text>
1932
- </div>
1933
+ <PoweredBy variation={variation} />
1933
1934
  </AiFeatureBorder>
1934
1935
  </BodyComponent>
1935
1936
  </ContentComponent>