interface.ts 3.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120
  1. import { ReactNode } from "react";
  2. import { OnChangeProps, UploadProps } from "../upload";
  3. import { TooltipProps } from "../tooltip";
  4. import { BaseSkill, Reference, Suggestion, Attachment, Content, Setup, LeftMenuChangeProps, RichTextJSON, MessageContent } from "@douyinfe/semi-foundation/aiChatInput/interface";
  5. import { Extension } from "@tiptap/core";
  6. import { Content as TiptapContent } from "@tiptap/core";
  7. import { PopoverProps } from "../popover";
  8. export interface AIChatInputState {
  9. templateVisible: boolean;
  10. skillVisible: boolean;
  11. suggestionVisible: boolean;
  12. attachments?: Attachment[];
  13. skill?: Skill;
  14. popupWidth?: number;
  15. activeSkillIndex?: number;
  16. activeSuggestionIndex?: number;
  17. popupKey?: number;
  18. content?: RichTextJSON;
  19. richTextInit?: boolean
  20. }
  21. export interface AIChatInputProps {
  22. dropdownMatchTriggerWidth?: boolean;
  23. className?: string;
  24. style?: React.CSSProperties;
  25. // Rich text editor related
  26. placeholder?: string;
  27. extensions?: Extension[];
  28. onContentChange?: (contents: Content[]) => void;
  29. defaultContent?: TiptapContent[];
  30. onFocus?: (event: React.FocusEvent) => void;
  31. onBlur?: (event: React.FocusEvent) => void;
  32. // Reference related
  33. references?: Reference[];
  34. renderReference?: (reference: Reference) => ReactNode;
  35. onReferenceDelete?: (reference: Reference) => void;
  36. onReferenceClick?: (reference: Reference) => void;
  37. // Upload related
  38. uploadProps?: UploadProps;
  39. onUploadChange?: (props: OnChangeProps) => void;
  40. // TopSlot related
  41. renderTopSlot?: (props: RenderTopSlotProps) => ReactNode;
  42. topSlotPosition?: 'top' | 'middle' | 'bottom';
  43. showUploadFile?: boolean;
  44. showReference?: boolean;
  45. // Operate area related
  46. round?: boolean; // full round for footer operate/configure button
  47. canSend?: boolean; // custom can send
  48. onMessageSend?: (props: MessageContent) => void;
  49. onStopGenerate?: () => void;
  50. uploadTipProps?: TooltipProps;
  51. generating: boolean;
  52. // Configure area related
  53. renderConfigureArea?: (className?: string) => ReactNode;
  54. onConfigureChange?: (value: LeftMenuChangeProps, changedValue: LeftMenuChangeProps) => void;
  55. // Action area related
  56. renderActionArea?: (props: ActionAreaProps) => ReactNode;
  57. // Suggestion related
  58. suggestions?: Suggestion[];
  59. renderSuggestionItem?: (props: RenderSuggestionItemProps) => ReactNode;
  60. onSuggestClick?: (suggestion: Suggestion) => void;
  61. // Skill related
  62. skills: Skill[];
  63. skillHotKey?: string;
  64. templatesStyle?: React.CSSProperties;
  65. templatesCls?: string;
  66. onSkillChange?: (skill: Skill) => void;
  67. renderSkillItem?: (props: RenderSkillItemProps) => ReactNode;
  68. // Template related
  69. renderTemplate?: (skill: Skill, onTemplateClick: (content: string) => void) => ReactNode;
  70. onTemplateVisibleChange?: (visible: boolean) => void;
  71. showTemplateButton?: boolean;
  72. // transformer
  73. transformer?: Map<string, (obj: any) => any>;
  74. // Popover related
  75. popoverProps?: PopoverProps
  76. }
  77. export interface RenderSuggestionItemProps {
  78. suggestion: Suggestion;
  79. className: string;
  80. onClick: () => void;
  81. onMouseEnter: () => void
  82. }
  83. export interface RenderSkillItemProps {
  84. skill: Skill;
  85. className: string;
  86. onClick: () => void;
  87. onMouseEnter: () => void
  88. }
  89. export interface Skill extends BaseSkill {
  90. icon: ReactNode
  91. }
  92. interface ActionAreaProps {
  93. // menuItem: by order,upload button, send(stopGenerate) button
  94. menuItem: ReactNode[];
  95. className: string
  96. }
  97. interface RenderTopSlotProps {
  98. references: Reference[];
  99. attachments: Attachment[];
  100. content: Content[];
  101. handleUploadFileDelete: (attachment: Attachment) => void;
  102. handleReferenceDelete: (reference: Reference) => void
  103. }
  104. export {
  105. BaseSkill,
  106. Reference,
  107. Suggestion,
  108. Content,
  109. Setup,
  110. Attachment,
  111. LeftMenuChangeProps
  112. };