@moontra/moonui-pro 2.8.7 → 2.8.9

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/index.mjs CHANGED
@@ -50403,7 +50403,7 @@ function RichTextEditor({
50403
50403
  ] }) }) });
50404
50404
  }
50405
50405
  const [aiSettings, setAiSettings] = useState(() => {
50406
- if (persistAISettings) {
50406
+ if (persistAISettings && typeof window !== "undefined") {
50407
50407
  try {
50408
50408
  const stored = localStorage.getItem("moonui-ai-settings");
50409
50409
  if (stored) {
@@ -51485,11 +51485,15 @@ function RichTextEditor({
51485
51485
  gemini: "gemini-2.0-flash",
51486
51486
  cohere: "command"
51487
51487
  };
51488
- setAiSettings({
51488
+ const newSettings = {
51489
51489
  ...aiSettings,
51490
51490
  provider: value,
51491
51491
  model: defaultModels[value] || "gpt-3.5-turbo"
51492
- });
51492
+ };
51493
+ setAiSettings(newSettings);
51494
+ if (persistAISettings) {
51495
+ localStorage.setItem("moonui-ai-settings", JSON.stringify(newSettings));
51496
+ }
51493
51497
  },
51494
51498
  children: [
51495
51499
  /* @__PURE__ */ jsx(MoonUISelectTriggerPro, { children: /* @__PURE__ */ jsx(MoonUISelectValuePro, {}) }),
@@ -51511,7 +51515,13 @@ function RichTextEditor({
51511
51515
  id: "apiKey",
51512
51516
  type: "password",
51513
51517
  value: aiSettings.apiKey,
51514
- onChange: (e) => setAiSettings({ ...aiSettings, apiKey: e.target.value }),
51518
+ onChange: (e) => {
51519
+ const newSettings = { ...aiSettings, apiKey: e.target.value };
51520
+ setAiSettings(newSettings);
51521
+ if (persistAISettings) {
51522
+ localStorage.setItem("moonui-ai-settings", JSON.stringify(newSettings));
51523
+ }
51524
+ },
51515
51525
  placeholder: "sk-..."
51516
51526
  }
51517
51527
  )
@@ -51522,7 +51532,13 @@ function RichTextEditor({
51522
51532
  MoonUISelectPro,
51523
51533
  {
51524
51534
  value: aiSettings.model,
51525
- onValueChange: (value) => setAiSettings({ ...aiSettings, model: value }),
51535
+ onValueChange: (value) => {
51536
+ const newSettings = { ...aiSettings, model: value };
51537
+ setAiSettings(newSettings);
51538
+ if (persistAISettings) {
51539
+ localStorage.setItem("moonui-ai-settings", JSON.stringify(newSettings));
51540
+ }
51541
+ },
51526
51542
  children: [
51527
51543
  /* @__PURE__ */ jsx(MoonUISelectTriggerPro, { children: /* @__PURE__ */ jsx(MoonUISelectValuePro, {}) }),
51528
51544
  /* @__PURE__ */ jsxs(MoonUISelectContentPro, { children: [
@@ -51561,7 +51577,13 @@ function RichTextEditor({
51561
51577
  max: "2",
51562
51578
  step: "0.1",
51563
51579
  value: aiSettings.temperature,
51564
- onChange: (e) => setAiSettings({ ...aiSettings, temperature: parseFloat(e.target.value) })
51580
+ onChange: (e) => {
51581
+ const newSettings = { ...aiSettings, temperature: parseFloat(e.target.value) };
51582
+ setAiSettings(newSettings);
51583
+ if (persistAISettings) {
51584
+ localStorage.setItem("moonui-ai-settings", JSON.stringify(newSettings));
51585
+ }
51586
+ }
51565
51587
  }
51566
51588
  )
51567
51589
  ] }),
@@ -51575,7 +51597,13 @@ function RichTextEditor({
51575
51597
  min: "1",
51576
51598
  max: "4000",
51577
51599
  value: aiSettings.maxTokens,
51578
- onChange: (e) => setAiSettings({ ...aiSettings, maxTokens: parseInt(e.target.value) })
51600
+ onChange: (e) => {
51601
+ const newSettings = { ...aiSettings, maxTokens: parseInt(e.target.value) };
51602
+ setAiSettings(newSettings);
51603
+ if (persistAISettings) {
51604
+ localStorage.setItem("moonui-ai-settings", JSON.stringify(newSettings));
51605
+ }
51606
+ }
51579
51607
  }
51580
51608
  )
51581
51609
  ] })
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@moontra/moonui-pro",
3
- "version": "2.8.7",
3
+ "version": "2.8.9",
4
4
  "description": "Premium React components for MoonUI - Advanced UI library with 50+ pro components including performance, interactive, and gesture components",
5
5
  "type": "module",
6
6
  "main": "dist/index.mjs",
@@ -111,11 +111,11 @@ import { createAIProvider, type AIProvider as AIProviderInterface } from '../../
111
111
  type AIProvider = 'openai' | 'anthropic' | 'gemini' | 'claude' | 'cohere'
112
112
 
113
113
  interface AISettingsType {
114
- provider: AIProvider
115
- apiKey?: string
116
- model?: string
117
- temperature?: number
118
- maxTokens?: number
114
+ provider: 'openai' | 'claude' | 'gemini' | 'cohere'
115
+ apiKey: string
116
+ model: string
117
+ temperature: number
118
+ maxTokens: number
119
119
  }
120
120
 
121
121
  // Supported languages for translation
@@ -345,14 +345,14 @@ export function RichTextEditor({
345
345
 
346
346
  const [aiSettings, setAiSettings] = useState<AISettingsType>(() => {
347
347
  // Öncelik sırası: Props > LocalStorage > Varsayılan
348
- if (persistAISettings) {
348
+ if (persistAISettings && typeof window !== 'undefined') {
349
349
  try {
350
350
  const stored = localStorage.getItem('moonui-ai-settings');
351
351
  if (stored) {
352
352
  const parsed = JSON.parse(stored);
353
353
  // Props'tan gelen değerler her zaman öncelikli
354
354
  return {
355
- provider: aiConfig.provider || parsed.provider || 'openai',
355
+ provider: (aiConfig.provider || parsed.provider || 'openai') as 'openai' | 'claude' | 'gemini' | 'cohere',
356
356
  apiKey: aiConfig.apiKey || parsed.apiKey || '',
357
357
  model: aiConfig.model || parsed.model || 'gpt-3.5-turbo',
358
358
  temperature: aiConfig.temperature ?? parsed.temperature ?? 0.7,
@@ -366,7 +366,7 @@ export function RichTextEditor({
366
366
 
367
367
  // LocalStorage yoksa veya persist kapalıysa props/varsayılan değerleri kullan
368
368
  return {
369
- provider: aiConfig.provider || 'openai',
369
+ provider: (aiConfig.provider || 'openai') as 'openai' | 'claude' | 'gemini' | 'cohere',
370
370
  apiKey: aiConfig.apiKey || '',
371
371
  model: aiConfig.model || 'gpt-3.5-turbo',
372
372
  temperature: aiConfig.temperature ?? 0.7,
@@ -1512,11 +1512,16 @@ export function RichTextEditor({
1512
1512
  gemini: 'gemini-2.0-flash',
1513
1513
  cohere: 'command'
1514
1514
  };
1515
- setAiSettings({
1515
+ const newSettings = {
1516
1516
  ...aiSettings,
1517
1517
  provider: value,
1518
1518
  model: defaultModels[value] || 'gpt-3.5-turbo'
1519
- });
1519
+ };
1520
+ setAiSettings(newSettings);
1521
+ // LocalStorage'a hemen kaydet
1522
+ if (persistAISettings) {
1523
+ localStorage.setItem('moonui-ai-settings', JSON.stringify(newSettings));
1524
+ }
1520
1525
  }}
1521
1526
  >
1522
1527
  <SelectTrigger>
@@ -1536,7 +1541,14 @@ export function RichTextEditor({
1536
1541
  id="apiKey"
1537
1542
  type="password"
1538
1543
  value={aiSettings.apiKey}
1539
- onChange={(e) => setAiSettings({ ...aiSettings, apiKey: e.target.value })}
1544
+ onChange={(e) => {
1545
+ const newSettings = { ...aiSettings, apiKey: e.target.value };
1546
+ setAiSettings(newSettings);
1547
+ // Save to localStorage immediately
1548
+ if (persistAISettings) {
1549
+ localStorage.setItem('moonui-ai-settings', JSON.stringify(newSettings));
1550
+ }
1551
+ }}
1540
1552
  placeholder="sk-..."
1541
1553
  />
1542
1554
  </div>
@@ -1544,7 +1556,14 @@ export function RichTextEditor({
1544
1556
  <Label htmlFor="model">Model</Label>
1545
1557
  <Select
1546
1558
  value={aiSettings.model}
1547
- onValueChange={(value) => setAiSettings({ ...aiSettings, model: value })}
1559
+ onValueChange={(value) => {
1560
+ const newSettings = { ...aiSettings, model: value };
1561
+ setAiSettings(newSettings);
1562
+ // Save to localStorage immediately
1563
+ if (persistAISettings) {
1564
+ localStorage.setItem('moonui-ai-settings', JSON.stringify(newSettings));
1565
+ }
1566
+ }}
1548
1567
  >
1549
1568
  <SelectTrigger>
1550
1569
  <SelectValue />
@@ -1589,7 +1608,14 @@ export function RichTextEditor({
1589
1608
  max="2"
1590
1609
  step="0.1"
1591
1610
  value={aiSettings.temperature}
1592
- onChange={(e) => setAiSettings({ ...aiSettings, temperature: parseFloat(e.target.value) })}
1611
+ onChange={(e) => {
1612
+ const newSettings = { ...aiSettings, temperature: parseFloat(e.target.value) };
1613
+ setAiSettings(newSettings);
1614
+ // Save to localStorage immediately
1615
+ if (persistAISettings) {
1616
+ localStorage.setItem('moonui-ai-settings', JSON.stringify(newSettings));
1617
+ }
1618
+ }}
1593
1619
  />
1594
1620
  </div>
1595
1621
  <div className="grid gap-2">
@@ -1600,7 +1626,14 @@ export function RichTextEditor({
1600
1626
  min="1"
1601
1627
  max="4000"
1602
1628
  value={aiSettings.maxTokens}
1603
- onChange={(e) => setAiSettings({ ...aiSettings, maxTokens: parseInt(e.target.value) })}
1629
+ onChange={(e) => {
1630
+ const newSettings = { ...aiSettings, maxTokens: parseInt(e.target.value) };
1631
+ setAiSettings(newSettings);
1632
+ // Save to localStorage immediately
1633
+ if (persistAISettings) {
1634
+ localStorage.setItem('moonui-ai-settings', JSON.stringify(newSettings));
1635
+ }
1636
+ }}
1604
1637
  />
1605
1638
  </div>
1606
1639
  </div>