UNPKG

@plteam/chat-ui

Version:

CUI Kit is a free and open-source library for creating AI assistant chat interfaces, built with React, Material UI, and TypeScript

20 lines (19 loc) 671 B
import { ObservableReactValue } from '../utils/observers'; import { randomInt } from '../utils/numberUtils/randomInt'; export class MessageText { /** * Text of message that supports "observation", should you need to update the component immediately upon variable modification, perfect for React.useSyncExternalStore. */ observableText = new ObservableReactValue(''); modelId; constructor(text) { this.text = text; this.modelId = 'textModel' + randomInt(100, 10000); } get text() { return this.observableText.value; } set text(value) { this.observableText.value = value; } }