@smart-cloud/ai-kit-ui 1.1.35 → 1.1.37

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.35",
3
+ "version": "1.1.37",
4
4
  "type": "module",
5
5
  "main": "./dist/index.cjs",
6
6
  "module": "./dist/index.js",
@@ -20,7 +20,7 @@
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.17",
23
+ "@smart-cloud/ai-kit-core": "^1.1.18",
24
24
  "@smart-cloud/wpsuite-core": "^2.1.2",
25
25
  "@tabler/icons-react": "^3.36.1",
26
26
  "chroma-js": "^3.2.0",
@@ -303,6 +303,7 @@ const AiFeatureBase: FC<AiFeatureProps & AiKitShellInjectedProps> = (props) => {
303
303
  default: defaults,
304
304
  onClose,
305
305
  onAccept,
306
+ onOptionsChanged,
306
307
  language,
307
308
  rootElement,
308
309
  } = props;
@@ -335,7 +336,7 @@ const AiFeatureBase: FC<AiFeatureProps & AiKitShellInjectedProps> = (props) => {
335
336
 
336
337
  const [state, setState] = useState<string>();
337
338
  const [featureOpen, setFeatureOpen] = useState<boolean>(!showOpenButton);
338
- const [optionsOpen, setOptionsOpen] = useState<boolean>(false);
339
+ const [optionsOpen, setOptionsOpen] = useState<boolean>();
339
340
  const [backendConfigured, setBackendConfigured] = useState(false);
340
341
  const [error, setError] = useState<string | null>(null);
341
342
  const [generated, setGenerated] = useState<never | null>(null);
@@ -969,6 +970,7 @@ Follow these additional instructions: ${instructions}`
969
970
 
970
971
  useEffect(() => {
971
972
  if (
973
+ optionsOpen !== false ||
972
974
  !featureOpen ||
973
975
  !autoRun ||
974
976
  !canGenerate ||
@@ -1218,7 +1220,7 @@ Follow these additional instructions: ${instructions}`
1218
1220
  )}
1219
1221
  </Group>
1220
1222
 
1221
- <CollapseComponent in={optionsOpen}>
1223
+ <CollapseComponent in={optionsOpen === true}>
1222
1224
  {optionsDisplay === "collapse" && <Divider my="sm" />}
1223
1225
  <OptionsComponent gap="xs" justify="space-between">
1224
1226
  {/* TOPIC */}
@@ -1246,7 +1248,11 @@ Follow these additional instructions: ${instructions}`
1246
1248
  value={text || ""}
1247
1249
  onChange={(
1248
1250
  e: React.ChangeEvent<HTMLInputElement>,
1249
- ) => setText(e.target.value)}
1251
+ ) => {
1252
+ const value = e.target.value;
1253
+ setText(value);
1254
+ onOptionsChanged?.({ text: value });
1255
+ }}
1250
1256
  />
1251
1257
  </Tooltip>
1252
1258
  )}
@@ -1279,7 +1285,11 @@ Follow these additional instructions: ${instructions}`
1279
1285
  value={instructions || ""}
1280
1286
  onChange={(
1281
1287
  e: React.ChangeEvent<HTMLInputElement>,
1282
- ) => setInstructions(e.target.value)}
1288
+ ) => {
1289
+ const value = e.target.value;
1290
+ setInstructions(value);
1291
+ onOptionsChanged?.({ instructions: value });
1292
+ }}
1283
1293
  />
1284
1294
  </Tooltip>
1285
1295
  )}
@@ -1318,9 +1328,11 @@ Follow these additional instructions: ${instructions}`
1318
1328
  ),
1319
1329
  ]}
1320
1330
  value={inputLanguage || "auto"}
1321
- onChange={(value) =>
1322
- setInputLanguage(value as AiKitLanguageCode)
1323
- }
1331
+ onChange={(value) => {
1332
+ const val = value as AiKitLanguageCode;
1333
+ setInputLanguage(val);
1334
+ onOptionsChanged?.({ inputLanguage: val });
1335
+ }}
1324
1336
  />
1325
1337
  </Tooltip>
1326
1338
  )}
@@ -1370,9 +1382,11 @@ Follow these additional instructions: ${instructions}`
1370
1382
  aiKit.settings.defaultOutputLanguage ||
1371
1383
  (mode === "rewrite" ? "auto" : "")
1372
1384
  }
1373
- onChange={(value) =>
1374
- setOutputLanguage(value as AiKitLanguageCode)
1375
- }
1385
+ onChange={(value) => {
1386
+ const val = value as AiKitLanguageCode;
1387
+ setOutputLanguage(val);
1388
+ onOptionsChanged?.({ outputLanguage: val });
1389
+ }}
1376
1390
  />
1377
1391
  </Tooltip>
1378
1392
  )}
@@ -1413,9 +1427,11 @@ Follow these additional instructions: ${instructions}`
1413
1427
  },
1414
1428
  ]}
1415
1429
  value={type || "key-points"}
1416
- onChange={(value) =>
1417
- setType(value as SummarizerType)
1418
- }
1430
+ onChange={(value) => {
1431
+ const val = value as SummarizerType;
1432
+ setType(val);
1433
+ onOptionsChanged?.({ type: val });
1434
+ }}
1419
1435
  />
1420
1436
  </Tooltip>
1421
1437
  )}
@@ -1477,9 +1493,13 @@ Follow these additional instructions: ${instructions}`
1477
1493
  tone ||
1478
1494
  (mode === "write" ? "neutral" : "as-is")
1479
1495
  }
1480
- onChange={(value) =>
1481
- setTone(value as WriterTone | RewriterTone)
1482
- }
1496
+ onChange={(value) => {
1497
+ const val = value as
1498
+ | WriterTone
1499
+ | RewriterTone;
1500
+ setTone(val);
1501
+ onOptionsChanged?.({ tone: val });
1502
+ }}
1483
1503
  />
1484
1504
  </Tooltip>
1485
1505
  )}
@@ -1539,14 +1559,14 @@ Follow these additional instructions: ${instructions}`
1539
1559
  length ||
1540
1560
  (mode === "rewrite" ? "as-is" : "short")
1541
1561
  }
1542
- onChange={(value) =>
1543
- setLength(
1544
- value as
1545
- | WriterLength
1546
- | RewriterLength
1547
- | SummarizerLength,
1548
- )
1549
- }
1562
+ onChange={(value) => {
1563
+ const val = value as
1564
+ | WriterLength
1565
+ | RewriterLength
1566
+ | SummarizerLength;
1567
+ setLength(val);
1568
+ onOptionsChanged?.({ length: val });
1569
+ }}
1550
1570
  />
1551
1571
  </Tooltip>
1552
1572
  )}
@@ -1590,14 +1610,14 @@ Follow these additional instructions: ${instructions}`
1590
1610
  },
1591
1611
  ]}
1592
1612
  value={outputFormat || "markdown"}
1593
- onChange={(value) =>
1594
- setOutputFormat(
1595
- value as
1596
- | "plain-text"
1597
- | "markdown"
1598
- | "html",
1599
- )
1600
- }
1613
+ onChange={(value) => {
1614
+ const val = value as
1615
+ | "plain-text"
1616
+ | "markdown"
1617
+ | "html";
1618
+ setOutputFormat(val);
1619
+ onOptionsChanged?.({ outputFormat: val });
1620
+ }}
1601
1621
  />
1602
1622
  </Tooltip>
1603
1623
  ))}