@mvriu5/payload-ai 1.2.0 → 1.4.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.
Files changed (63) hide show
  1. package/README.md +118 -13
  2. package/dist/ai/providerOptions.d.ts +24 -1
  3. package/dist/ai/providerOptions.js +81 -0
  4. package/dist/ai/providerRuntime.d.ts +2 -1
  5. package/dist/ai/providerRuntime.js +5 -2
  6. package/dist/ai/tokenUsage.d.ts +38 -0
  7. package/dist/ai/tokenUsage.js +106 -0
  8. package/dist/components/Icons.d.ts +1 -8
  9. package/dist/components/Icons.js +10 -207
  10. package/dist/components/{ActionToast.d.ts → action-toast/ActionToast.d.ts} +5 -2
  11. package/dist/components/{ActionToast.js → action-toast/ActionToast.js} +81 -54
  12. package/dist/components/{ActionToast.module.css → action-toast/ActionToast.module.css} +0 -79
  13. package/dist/components/ai-input/AIInput.d.ts +5 -0
  14. package/dist/components/ai-input/AIInput.js +548 -0
  15. package/dist/components/{AIInput.module.css → ai-input/AIInput.module.css} +150 -44
  16. package/dist/components/ai-input/badge.d.ts +14 -0
  17. package/dist/components/ai-input/badge.js +85 -0
  18. package/dist/components/{AuditLogList.d.ts → audit-log-list/AuditLogList.d.ts} +4 -8
  19. package/dist/components/{AuditLogList.js → audit-log-list/AuditLogList.js} +56 -21
  20. package/dist/components/{AuditLogList.module.css → audit-log-list/AuditLogList.module.css} +11 -65
  21. package/dist/components/dashboard/Dashboard.d.ts +2 -0
  22. package/dist/components/dashboard/Dashboard.js +17 -0
  23. package/dist/components/dashboard/Dashboard.module.css +13 -0
  24. package/dist/components/{DiffDialog.d.ts → diff-dialog/DiffDialog.d.ts} +2 -2
  25. package/dist/components/{DiffDialog.js → diff-dialog/DiffDialog.js} +200 -189
  26. package/dist/components/{DiffDialog.module.css → diff-dialog/DiffDialog.module.css} +17 -35
  27. package/dist/components/hooks/useAIChatStream.d.ts +50 -0
  28. package/dist/components/hooks/useAIChatStream.js +226 -0
  29. package/dist/components/hooks/useAISettings.d.ts +6 -4
  30. package/dist/components/hooks/useAISettings.js +68 -27
  31. package/dist/components/hooks/useAuditLog.d.ts +11 -0
  32. package/dist/components/hooks/useAuditLog.js +41 -0
  33. package/dist/components/hooks/useDocumentMentionSuggestions.d.ts +1 -1
  34. package/dist/components/hooks/useDocumentMentionSuggestions.js +31 -27
  35. package/dist/components/hooks/useMentions.d.ts +58 -0
  36. package/dist/components/hooks/useMentions.js +276 -0
  37. package/dist/components/hooks/usePluginConfig.d.ts +40 -0
  38. package/dist/components/hooks/usePluginConfig.js +27 -0
  39. package/dist/components/{MentionPopover.d.ts → mention-popover/MentionPopover.d.ts} +2 -4
  40. package/dist/components/{MentionPopover.js → mention-popover/MentionPopover.js} +1 -8
  41. package/dist/components/{MentionPopover.module.css → mention-popover/MentionPopover.module.css} +1 -1
  42. package/dist/components/text-shimmer/TextShimmer.d.ts +9 -0
  43. package/dist/components/text-shimmer/TextShimmer.js +34 -0
  44. package/dist/components/text-shimmer/TextShimmer.module.css +19 -0
  45. package/dist/exports/client.d.ts +4 -2
  46. package/dist/exports/client.js +4 -2
  47. package/dist/handlers/applyActionHandler.js +27 -7
  48. package/dist/handlers/chatHandler.d.ts +4 -1
  49. package/dist/handlers/chatHandler.js +499 -74
  50. package/dist/handlers/mediaUploadHandler.d.ts +7 -0
  51. package/dist/handlers/mediaUploadHandler.js +99 -0
  52. package/dist/handlers/mentionSuggestionHandler.js +16 -14
  53. package/dist/handlers/proposalDiffHandler.js +41 -29
  54. package/dist/index.d.ts +12 -1
  55. package/dist/index.js +131 -12
  56. package/dist/payload/collectionPermissions.js +3 -1
  57. package/dist/payload/normalizeData.d.ts +0 -6
  58. package/dist/payload/normalizeData.js +25 -13
  59. package/dist/payload/proposalData.js +4 -1
  60. package/dist/payload/schemaContext.js +98 -43
  61. package/package.json +22 -20
  62. package/dist/components/AIInput.d.ts +0 -2
  63. package/dist/components/AIInput.js +0 -896
@@ -257,232 +257,35 @@ export function OpenrouterIcon(props) {
257
257
  clipPath: "url(#clip0_205_3)",
258
258
  children: [
259
259
  /*#__PURE__*/ _jsx("path", {
260
- d: "M3 248.945C18 248.945 76 236 106 219C136 202 136 202 198 158C276.497 102.293 332 120.945 423 120.945",
260
+ d: "M3 248.95C18 248.95 76 236 106 219C136 202 136 202 198 158C276.5 102.29 332 120.95 423 120.95",
261
261
  strokeWidth: "90"
262
262
  }),
263
263
  /*#__PURE__*/ _jsx("path", {
264
- d: "M511 121.5L357.25 210.268L357.25 32.7324L511 121.5Z"
264
+ d: "M511 121.5L357.25 210.27L357.25 32.73L511 121.5Z"
265
265
  }),
266
266
  /*#__PURE__*/ _jsx("path", {
267
- d: "M0 249C15 249 73 261.945 103 278.945C133 295.945 133 295.945 195 339.945C273.497 395.652 329 377 420 377",
267
+ d: "M0 249C15 249 73 261.95 103 278.95C133 295.95 133 295.95 195 339.95C273.5 395.65 329 377 420 377",
268
268
  strokeWidth: "90"
269
269
  }),
270
270
  /*#__PURE__*/ _jsx("path", {
271
- d: "M508 376.445L354.25 287.678L354.25 465.213L508 376.445Z"
271
+ d: "M508 376.45L354.25 287.68L354.25 465.21L508 376.45Z"
272
272
  })
273
273
  ]
274
274
  })
275
275
  });
276
276
  }
277
- export function FileDiff(props) {
278
- return /*#__PURE__*/ _jsxs("svg", {
279
- xmlns: "http://www.w3.org/2000/svg",
280
- viewBox: "0 0 24 24",
281
- fill: "none",
282
- stroke: "currentColor",
283
- strokeWidth: 2,
284
- strokeLinecap: "round",
285
- strokeLinejoin: "round",
286
- ...props,
287
- children: [
288
- /*#__PURE__*/ _jsx("path", {
289
- stroke: "none",
290
- d: "M0 0h24v24H0z",
291
- fill: "none"
292
- }),
293
- /*#__PURE__*/ _jsx("path", {
294
- d: "M14 3v4a1 1 0 0 0 1 1h4"
295
- }),
296
- /*#__PURE__*/ _jsx("path", {
297
- d: "M17 21h-10a2 2 0 0 1 -2 -2v-14a2 2 0 0 1 2 -2h7l5 5v11a2 2 0 0 1 -2 2"
298
- }),
299
- /*#__PURE__*/ _jsx("path", {
300
- d: "M12 10l0 4"
301
- }),
302
- /*#__PURE__*/ _jsx("path", {
303
- d: "M10 12l4 0"
304
- }),
305
- /*#__PURE__*/ _jsx("path", {
306
- d: "M10 17l4 0"
307
- })
308
- ]
309
- });
310
- }
311
- export function Send(props) {
312
- return /*#__PURE__*/ _jsxs("svg", {
313
- xmlns: "http://www.w3.org/2000/svg",
314
- viewBox: "0 0 24 24",
315
- fill: "none",
316
- stroke: "currentColor",
317
- strokeWidth: 2,
318
- strokeLinecap: "round",
319
- strokeLinejoin: "round",
320
- ...props,
321
- children: [
322
- /*#__PURE__*/ _jsx("path", {
323
- stroke: "none",
324
- d: "M0 0h24v24H0z",
325
- fill: "none"
326
- }),
327
- /*#__PURE__*/ _jsx("path", {
328
- d: "M10 14l11 -11"
329
- }),
330
- /*#__PURE__*/ _jsx("path", {
331
- d: "M21 3l-6.5 18a.55 .55 0 0 1 -1 0l-3.5 -7l-7 -3.5a.55 .55 0 0 1 0 -1l18 -6.5"
332
- })
333
- ]
334
- });
335
- }
336
- export function Apply(props) {
337
- return /*#__PURE__*/ _jsxs("svg", {
338
- xmlns: "http://www.w3.org/2000/svg",
339
- viewBox: "0 0 24 24",
340
- fill: "none",
341
- stroke: "currentColor",
342
- strokeWidth: 2,
343
- strokeLinecap: "round",
344
- strokeLinejoin: "round",
345
- ...props,
346
- children: [
347
- /*#__PURE__*/ _jsx("path", {
348
- stroke: "none",
349
- d: "M0 0h24v24H0z",
350
- fill: "none"
351
- }),
352
- /*#__PURE__*/ _jsx("path", {
353
- d: "M5 12l5 5l10 -10"
354
- })
355
- ]
356
- });
357
- }
358
- export function Reject(props) {
359
- return /*#__PURE__*/ _jsxs("svg", {
360
- xmlns: "http://www.w3.org/2000/svg",
361
- viewBox: "0 0 24 24",
362
- fill: "none",
363
- stroke: "currentColor",
364
- strokeWidth: 2,
365
- strokeLinecap: "round",
366
- strokeLinejoin: "round",
367
- ...props,
368
- children: [
369
- /*#__PURE__*/ _jsx("path", {
370
- stroke: "none",
371
- d: "M0 0h24v24H0z",
372
- fill: "none"
373
- }),
374
- /*#__PURE__*/ _jsx("path", {
375
- d: "M18 6l-12 12"
376
- }),
377
- /*#__PURE__*/ _jsx("path", {
378
- d: "M6 6l12 12"
379
- })
380
- ]
381
- });
382
- }
383
- export function Collection(props) {
384
- return /*#__PURE__*/ _jsxs("svg", {
385
- xmlns: "http://www.w3.org/2000/svg",
386
- viewBox: "0 0 24 24",
387
- fill: "none",
388
- stroke: "currentColor",
389
- strokeWidth: 2,
390
- strokeLinecap: "round",
391
- strokeLinejoin: "round",
392
- ...props,
393
- children: [
394
- /*#__PURE__*/ _jsx("path", {
395
- stroke: "none",
396
- d: "M0 0h24v24H0z",
397
- fill: "none"
398
- }),
399
- /*#__PURE__*/ _jsx("path", {
400
- d: "M5 4h4l3 3h7a2 2 0 0 1 2 2v8a2 2 0 0 1 -2 2h-14a2 2 0 0 1 -2 -2v-11a2 2 0 0 1 2 -2"
401
- })
402
- ]
403
- });
404
- }
405
- export function Document(props) {
406
- return /*#__PURE__*/ _jsxs("svg", {
407
- xmlns: "http://www.w3.org/2000/svg",
408
- viewBox: "0 0 24 24",
409
- fill: "none",
410
- stroke: "currentColor",
411
- strokeWidth: 2,
412
- strokeLinecap: "round",
413
- strokeLinejoin: "round",
414
- ...props,
415
- children: [
416
- /*#__PURE__*/ _jsx("path", {
417
- stroke: "none",
418
- d: "M0 0h24v24H0z",
419
- fill: "none"
420
- }),
421
- /*#__PURE__*/ _jsx("path", {
422
- d: "M14 3v4a1 1 0 0 0 1 1h4"
423
- }),
424
- /*#__PURE__*/ _jsx("path", {
425
- d: "M17 21h-10a2 2 0 0 1 -2 -2v-14a2 2 0 0 1 2 -2h7l5 5v11a2 2 0 0 1 -2 2"
426
- })
427
- ]
428
- });
429
- }
430
- export function Global(props) {
431
- return /*#__PURE__*/ _jsxs("svg", {
432
- xmlns: "http://www.w3.org/2000/svg",
433
- viewBox: "0 0 24 24",
434
- fill: "none",
435
- stroke: "currentColor",
436
- strokeWidth: 2,
437
- strokeLinecap: "round",
438
- strokeLinejoin: "round",
439
- ...props,
440
- children: [
441
- /*#__PURE__*/ _jsx("path", {
442
- stroke: "none",
443
- d: "M0 0h24v24H0z",
444
- fill: "none"
445
- }),
446
- /*#__PURE__*/ _jsx("path", {
447
- d: "M3 12a9 9 0 1 0 18 0a9 9 0 0 0 -18 0"
448
- }),
449
- /*#__PURE__*/ _jsx("path", {
450
- d: "M3.6 9h16.8"
451
- }),
452
- /*#__PURE__*/ _jsx("path", {
453
- d: "M3.6 15h16.8"
454
- }),
455
- /*#__PURE__*/ _jsx("path", {
456
- d: "M11.5 3a17 17 0 0 0 0 18"
457
- }),
458
- /*#__PURE__*/ _jsx("path", {
459
- d: "M12.5 3a17 17 0 0 1 0 18"
460
- })
461
- ]
462
- });
463
- }
464
- export function Block(props) {
465
- return /*#__PURE__*/ _jsxs("svg", {
277
+ export function PaperclipIcon(props) {
278
+ return /*#__PURE__*/ _jsx("svg", {
466
279
  xmlns: "http://www.w3.org/2000/svg",
467
280
  viewBox: "0 0 24 24",
468
281
  fill: "none",
469
282
  stroke: "currentColor",
470
- strokeWidth: 2,
283
+ strokeWidth: "2",
471
284
  strokeLinecap: "round",
472
285
  strokeLinejoin: "round",
473
286
  ...props,
474
- children: [
475
- /*#__PURE__*/ _jsx("path", {
476
- stroke: "none",
477
- d: "M0 0h24v24H0z",
478
- fill: "none"
479
- }),
480
- /*#__PURE__*/ _jsx("path", {
481
- d: "M14 4a1 1 0 0 1 1 -1h5a1 1 0 0 1 1 1v5a1 1 0 0 1 -1 1h-5a1 1 0 0 1 -1 -1l0 -5"
482
- }),
483
- /*#__PURE__*/ _jsx("path", {
484
- d: "M3 14h12a2 2 0 0 1 2 2v3a2 2 0 0 1 -2 2h-10a2 2 0 0 1 -2 -2v-10a2 2 0 0 1 2 -2h3a2 2 0 0 1 2 2v12"
485
- })
486
- ]
287
+ children: /*#__PURE__*/ _jsx("path", {
288
+ d: "m16 6-8.414 8.586a2 2 0 0 0 2.829 2.829l8.414-8.586a4 4 0 1 0-5.657-5.657l-8.379 8.551a6 6 0 1 0 8.485 8.485l8.379-8.551"
289
+ })
487
290
  });
488
291
  }
@@ -5,17 +5,20 @@ export type ActionProposal = {
5
5
  };
6
6
  action: "create" | "delete" | "update" | "updateGlobal";
7
7
  collection?: string;
8
+ data?: Record<string, unknown>;
8
9
  id?: string;
9
10
  label: string;
11
+ locale?: string;
12
+ localizedData?: Record<string, Record<string, unknown>>;
10
13
  slug?: string;
11
14
  };
12
15
  type ActionToastProps = {
13
16
  apiRoute: string;
14
- appliedProposalIndexes: number[];
15
17
  description?: string;
16
18
  error?: string;
17
19
  getViewURL?: (proposal: ActionProposal) => string | null;
18
20
  isApplying: boolean;
21
+ isLoading: boolean;
19
22
  onDismiss?: () => void;
20
23
  onDismissError?: () => void;
21
24
  onApply: (proposal: ActionProposal, index: number) => void;
@@ -27,5 +30,5 @@ type ActionToastProps = {
27
30
  totalTokens?: number;
28
31
  } | null;
29
32
  };
30
- export declare const ActionToast: ({ apiRoute, appliedProposalIndexes, description, error, getViewURL, isApplying, onDismiss, onDismissError, onApply, prompt, proposals, tokenUsage, }: ActionToastProps) => import("react").JSX.Element | null;
33
+ export declare const ActionToast: ({ apiRoute, description, error, getViewURL, isApplying, isLoading, onDismiss, onDismissError, onApply, prompt, proposals, tokenUsage, }: ActionToastProps) => import("react").JSX.Element | null;
31
34
  export {};
@@ -1,10 +1,31 @@
1
1
  import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
2
- import styles from "./ActionToast.module.css";
3
- import { redactSensitiveData } from "../ai/sensitiveData.js";
2
+ import { Button, CheckIcon, SwapIcon } from "@payloadcms/ui";
4
3
  import { formatAdminURL } from "payload/shared";
5
4
  import { useState } from "react";
6
- import { DiffDialog } from "./DiffDialog.js";
7
- import { Apply, FileDiff, Reject } from "./Icons.js";
5
+ import { redactSensitiveData } from "../../ai/sensitiveData.js";
6
+ import { DiffDialog } from "../diff-dialog/DiffDialog.js";
7
+ import { TextShimmer } from "../text-shimmer/TextShimmer.js";
8
+ import styles from "./ActionToast.module.css";
9
+ const ACTION_TOAST_TEXT = {
10
+ aiRequestFailed: "AI request failed",
11
+ aiResponse: "AI response",
12
+ applyProposal: "Apply proposal",
13
+ details: "Details",
14
+ diffReviewFailed: "Diff review failed",
15
+ dismiss: "Dismiss",
16
+ dismissProposals: "Dismiss proposals",
17
+ fullResponse: "Full response",
18
+ goToSource: "Go to source",
19
+ loading: "Loading",
20
+ proposalDiffError: "Could not load proposal diff.",
21
+ redacted: "[redacted]",
22
+ review: "Review",
23
+ reviewProposal: "Review proposal",
24
+ waitingForResponse: "Please wait, until the Response is received"
25
+ };
26
+ const PROPOSAL_DIFF_ENDPOINT = "/ai-proposal-diff";
27
+ const JSON_CONTENT_TYPE = "application/json";
28
+ const POST_METHOD = "POST";
8
29
  const maxDescriptionLength = 220;
9
30
  const getDescriptionPreview = (description)=>{
10
31
  if (description.length <= maxDescriptionLength) return description;
@@ -15,16 +36,16 @@ const getSafeProposalDetails = (proposal)=>{
15
36
  if (redactedProposal._aiSignature) {
16
37
  redactedProposal._aiSignature = {
17
38
  expiresAt: redactedProposal._aiSignature.expiresAt,
18
- value: "[redacted]"
39
+ value: ACTION_TOAST_TEXT.redacted
19
40
  };
20
41
  }
21
42
  return redactedProposal;
22
43
  };
23
- export const ActionToast = ({ apiRoute, appliedProposalIndexes, description, error, getViewURL, isApplying, onDismiss, onDismissError, onApply, prompt, proposals, tokenUsage })=>{
44
+ export const ActionToast = ({ apiRoute, description, error, getViewURL, isApplying, isLoading, onDismiss, onDismissError, onApply, prompt, proposals, tokenUsage })=>{
24
45
  const [activeDiff, setActiveDiff] = useState(null);
25
46
  const [diffError, setDiffError] = useState("");
26
47
  const [loadingDiffIndex, setLoadingDiffIndex] = useState(null);
27
- if (proposals.length === 0 && !error && !description) return null;
48
+ if (proposals.length === 0 && !error && !description && !isLoading) return null;
28
49
  const descriptionPreview = description ? getDescriptionPreview(description) : "";
29
50
  const isDescriptionTruncated = Boolean(description) && descriptionPreview !== description;
30
51
  const openDiff = async (proposal, index)=>{
@@ -33,20 +54,20 @@ export const ActionToast = ({ apiRoute, appliedProposalIndexes, description, err
33
54
  try {
34
55
  const res = await fetch(formatAdminURL({
35
56
  apiRoute,
36
- path: "/ai-proposal-diff"
57
+ path: PROPOSAL_DIFF_ENDPOINT
37
58
  }), {
38
59
  body: JSON.stringify({
39
60
  proposal,
40
61
  prompt
41
62
  }),
42
63
  headers: {
43
- "Content-Type": "application/json"
64
+ "Content-Type": JSON_CONTENT_TYPE
44
65
  },
45
- method: "POST"
66
+ method: POST_METHOD
46
67
  });
47
68
  const result = await res.json().catch(()=>null);
48
69
  if (!res.ok || !result) {
49
- throw new Error(result?.error || "Could not load proposal diff.");
70
+ throw new Error(result?.error || ACTION_TOAST_TEXT.proposalDiffError);
50
71
  }
51
72
  setActiveDiff({
52
73
  change: null,
@@ -57,7 +78,7 @@ export const ActionToast = ({ apiRoute, appliedProposalIndexes, description, err
57
78
  proposal
58
79
  });
59
80
  } catch (err) {
60
- setDiffError(err instanceof Error ? err.message : "Could not load proposal diff.");
81
+ setDiffError(err instanceof Error ? err.message : ACTION_TOAST_TEXT.proposalDiffError);
61
82
  } finally{
62
83
  setLoadingDiffIndex(null);
63
84
  }
@@ -65,6 +86,21 @@ export const ActionToast = ({ apiRoute, appliedProposalIndexes, description, err
65
86
  return /*#__PURE__*/ _jsxs("div", {
66
87
  className: styles.list,
67
88
  children: [
89
+ proposals.length === 0 && isLoading && /*#__PURE__*/ _jsxs("div", {
90
+ className: styles.item,
91
+ children: [
92
+ /*#__PURE__*/ _jsx("div", {
93
+ className: styles.label,
94
+ children: ACTION_TOAST_TEXT.aiResponse
95
+ }),
96
+ /*#__PURE__*/ _jsx("div", {
97
+ className: styles.description,
98
+ children: /*#__PURE__*/ _jsx(TextShimmer, {
99
+ children: ACTION_TOAST_TEXT.waitingForResponse
100
+ })
101
+ })
102
+ ]
103
+ }),
68
104
  error && /*#__PURE__*/ _jsxs("div", {
69
105
  className: `${styles.item} ${styles.errorItem}`,
70
106
  children: [
@@ -72,7 +108,7 @@ export const ActionToast = ({ apiRoute, appliedProposalIndexes, description, err
72
108
  children: [
73
109
  /*#__PURE__*/ _jsx("div", {
74
110
  className: styles.label,
75
- children: "AI request failed"
111
+ children: ACTION_TOAST_TEXT.aiRequestFailed
76
112
  }),
77
113
  /*#__PURE__*/ _jsx("div", {
78
114
  className: styles.description,
@@ -84,7 +120,7 @@ export const ActionToast = ({ apiRoute, appliedProposalIndexes, description, err
84
120
  className: styles.button,
85
121
  onClick: onDismissError,
86
122
  type: "button",
87
- children: "Dismiss"
123
+ children: ACTION_TOAST_TEXT.dismiss
88
124
  })
89
125
  ]
90
126
  }),
@@ -94,7 +130,7 @@ export const ActionToast = ({ apiRoute, appliedProposalIndexes, description, err
94
130
  children: [
95
131
  /*#__PURE__*/ _jsx("div", {
96
132
  className: styles.label,
97
- children: "AI response"
133
+ children: ACTION_TOAST_TEXT.aiResponse
98
134
  }),
99
135
  /*#__PURE__*/ _jsx("div", {
100
136
  className: styles.description,
@@ -105,7 +141,7 @@ export const ActionToast = ({ apiRoute, appliedProposalIndexes, description, err
105
141
  children: [
106
142
  /*#__PURE__*/ _jsx("summary", {
107
143
  className: styles.summary,
108
- children: "Full response"
144
+ children: ACTION_TOAST_TEXT.fullResponse
109
145
  }),
110
146
  /*#__PURE__*/ _jsx("pre", {
111
147
  className: styles.proposalDetails,
@@ -117,7 +153,6 @@ export const ActionToast = ({ apiRoute, appliedProposalIndexes, description, err
117
153
  })
118
154
  }),
119
155
  proposals.map((proposal, index)=>{
120
- const isApplied = appliedProposalIndexes.includes(index);
121
156
  const viewURL = getViewURL?.(proposal);
122
157
  return /*#__PURE__*/ _jsxs("div", {
123
158
  className: styles.item,
@@ -147,7 +182,7 @@ export const ActionToast = ({ apiRoute, appliedProposalIndexes, description, err
147
182
  children: [
148
183
  /*#__PURE__*/ _jsx("summary", {
149
184
  className: styles.summary,
150
- children: "Full response"
185
+ children: ACTION_TOAST_TEXT.fullResponse
151
186
  }),
152
187
  /*#__PURE__*/ _jsx("pre", {
153
188
  className: styles.proposalDetails,
@@ -160,7 +195,7 @@ export const ActionToast = ({ apiRoute, appliedProposalIndexes, description, err
160
195
  children: [
161
196
  /*#__PURE__*/ _jsx("summary", {
162
197
  className: styles.summary,
163
- children: "Details"
198
+ children: ACTION_TOAST_TEXT.details
164
199
  }),
165
200
  /*#__PURE__*/ _jsx("pre", {
166
201
  className: styles.proposalDetails,
@@ -176,52 +211,44 @@ export const ActionToast = ({ apiRoute, appliedProposalIndexes, description, err
176
211
  /*#__PURE__*/ _jsxs("div", {
177
212
  className: styles.viewAction,
178
213
  children: [
179
- /*#__PURE__*/ _jsxs("button", {
180
- "aria-label": `Review proposal: ${proposal.label}`,
181
- className: styles.secondaryButton,
214
+ /*#__PURE__*/ _jsxs(Button, {
215
+ "aria-label": `${ACTION_TOAST_TEXT.reviewProposal}: ${proposal.label}`,
216
+ margin: false,
217
+ buttonStyle: "subtle",
182
218
  disabled: loadingDiffIndex === index,
183
219
  onClick: ()=>void openDiff(proposal, index),
184
- type: "button",
185
220
  children: [
186
- /*#__PURE__*/ _jsx(FileDiff, {
187
- height: 16,
188
- width: 16
189
- }),
190
- loadingDiffIndex === index ? "Loading" : "Review"
221
+ /*#__PURE__*/ _jsx(SwapIcon, {}),
222
+ loadingDiffIndex === index ? ACTION_TOAST_TEXT.loading : ACTION_TOAST_TEXT.review
191
223
  ]
192
224
  }),
193
- viewURL && /*#__PURE__*/ _jsx("a", {
194
- className: styles.ghostButton,
195
- href: viewURL,
196
- rel: "noreferrer noopener",
197
- target: "_blank",
198
- children: "Go to source"
225
+ viewURL && /*#__PURE__*/ _jsx(Button, {
226
+ el: "anchor",
227
+ buttonStyle: "tab",
228
+ url: viewURL,
229
+ newTab: true,
230
+ margin: false,
231
+ children: ACTION_TOAST_TEXT.goToSource
199
232
  })
200
233
  ]
201
234
  }),
202
235
  /*#__PURE__*/ _jsxs("div", {
203
236
  className: styles.actions,
204
237
  children: [
205
- onDismiss && /*#__PURE__*/ _jsx("button", {
206
- "aria-label": "Dismiss proposals",
207
- className: styles.secondaryButton,
208
- onClick: onDismiss,
209
- type: "button",
210
- children: /*#__PURE__*/ _jsx(Reject, {
211
- height: 16,
212
- width: 16
213
- })
238
+ onDismiss && /*#__PURE__*/ _jsx(Button, {
239
+ icon: "x",
240
+ "aria-label": ACTION_TOAST_TEXT.dismissProposals,
241
+ buttonStyle: "subtle",
242
+ margin: false,
243
+ onClick: onDismiss
214
244
  }),
215
- /*#__PURE__*/ _jsx("button", {
216
- "aria-label": `Apply proposal: ${proposal.label}`,
217
- className: styles.button,
218
- disabled: isApplying || isApplied,
245
+ /*#__PURE__*/ _jsx(Button, {
246
+ "aria-label": `${ACTION_TOAST_TEXT.applyProposal}: ${proposal.label}`,
247
+ margin: false,
248
+ buttonStyle: "primary",
249
+ disabled: isApplying,
219
250
  onClick: ()=>onApply(proposal, index),
220
- type: "button",
221
- children: /*#__PURE__*/ _jsx(Apply, {
222
- height: 16,
223
- width: 16
224
- })
251
+ children: /*#__PURE__*/ _jsx(CheckIcon, {})
225
252
  })
226
253
  ]
227
254
  })
@@ -237,7 +264,7 @@ export const ActionToast = ({ apiRoute, appliedProposalIndexes, description, err
237
264
  children: [
238
265
  /*#__PURE__*/ _jsx("div", {
239
266
  className: styles.label,
240
- children: "Diff review failed"
267
+ children: ACTION_TOAST_TEXT.diffReviewFailed
241
268
  }),
242
269
  /*#__PURE__*/ _jsx("div", {
243
270
  className: styles.description,
@@ -249,7 +276,7 @@ export const ActionToast = ({ apiRoute, appliedProposalIndexes, description, err
249
276
  className: styles.button,
250
277
  onClick: ()=>setDiffError(""),
251
278
  type: "button",
252
- children: "Dismiss"
279
+ children: ACTION_TOAST_TEXT.dismiss
253
280
  })
254
281
  ]
255
282
  }),
@@ -106,79 +106,6 @@
106
106
  gap: 8px;
107
107
  }
108
108
 
109
- .button {
110
- align-items: center;
111
- background: var(--theme-text);
112
- border: 0;
113
- border-radius: 4px;
114
- color: var(--theme-bg);
115
- cursor: pointer;
116
- display: inline-flex;
117
- flex: 0 0 auto;
118
- font: inherit;
119
- gap: 6px;
120
- justify-content: center;
121
- line-height: 24px;
122
- min-height: 24px;
123
- padding: 0 14px;
124
- }
125
-
126
- .secondaryButton {
127
- align-items: center;
128
- background: transparent;
129
- border: 1px solid var(--theme-elevation-150);
130
- border-radius: 4px;
131
- color: var(--theme-text);
132
- cursor: pointer;
133
- display: inline-flex;
134
- flex: 0 0 auto;
135
- font: inherit;
136
- gap: 6px;
137
- justify-content: center;
138
- line-height: 24px;
139
- min-height: 24px;
140
- padding: 0 14px;
141
- text-decoration: none;
142
- }
143
-
144
- .secondaryButton svg {
145
- color: var(--theme-elevation-500);
146
- flex: 0 0 auto;
147
- }
148
-
149
- .button svg {
150
- flex: 0 0 auto;
151
- }
152
-
153
- .ghostButton {
154
- background: transparent;
155
- border: 0;
156
- border-radius: 4px;
157
- color: var(--theme-elevation-600);
158
- cursor: pointer;
159
- flex: 0 0 auto;
160
- font: inherit;
161
- line-height: 24px;
162
- min-height: 24px;
163
- padding: 0 10px;
164
- text-decoration: none;
165
- }
166
-
167
- .ghostButton:hover {
168
- text-decoration: underline;
169
- }
170
-
171
- .button:disabled {
172
- cursor: not-allowed;
173
- opacity: 0.45;
174
- }
175
-
176
- .secondaryButton:disabled,
177
- .ghostButton:disabled {
178
- cursor: not-allowed;
179
- opacity: 0.45;
180
- }
181
-
182
109
  @media (max-width: 768px) {
183
110
  .list {
184
111
  bottom: 16px;
@@ -210,10 +137,4 @@
210
137
  align-items: stretch;
211
138
  flex-direction: column;
212
139
  }
213
-
214
- .button,
215
- .secondaryButton,
216
- .ghostButton {
217
- width: 100%;
218
- }
219
140
  }
@@ -0,0 +1,5 @@
1
+ type AIInputProps = {
2
+ isDashboard?: boolean;
3
+ };
4
+ declare const AIInput: ({ isDashboard }: AIInputProps) => import("react").JSX.Element;
5
+ export default AIInput;