UNPKG

devextreme-react

Version:

DevExtreme React UI and Visualization Components

143 lines (141 loc) 4.46 kB
/*! * devextreme-react * Version: 24.2.6 * Build date: Mon Mar 17 2025 * * Copyright (c) 2012 - 2025 Developer Express Inc. ALL RIGHTS RESERVED * * This software may be modified and distributed under the terms * of the MIT license. See the LICENSE file in the root of the project for details. * * https://github.com/DevExpress/devextreme-react */ "use client"; import * as React from "react"; import { memo, forwardRef, useImperativeHandle, useRef, useMemo } from "react"; import dxChat from "devextreme/ui/chat"; import { Component as BaseComponent } from "./core/component"; import NestedOption from "./core/nested-option"; const Chat = memo(forwardRef((props, ref) => { const baseRef = useRef(null); useImperativeHandle(ref, () => ({ instance() { return baseRef.current?.getInstance(); } }), [baseRef.current]); const subscribableOptions = useMemo(() => (["items"]), []); const independentEvents = useMemo(() => (["onDisposing", "onInitialized", "onMessageEntered", "onTypingEnd", "onTypingStart"]), []); const defaults = useMemo(() => ({ defaultItems: "items", }), []); const expectedChildren = useMemo(() => ({ alert: { optionName: "alerts", isCollectionItem: true }, dayHeaderFormat: { optionName: "dayHeaderFormat", isCollectionItem: false }, item: { optionName: "items", isCollectionItem: true }, messageTimestampFormat: { optionName: "messageTimestampFormat", isCollectionItem: false }, typingUser: { optionName: "typingUsers", isCollectionItem: true }, user: { optionName: "user", isCollectionItem: false } }), []); const templateProps = useMemo(() => ([ { tmplOption: "messageTemplate", render: "messageRender", component: "messageComponent" }, ]), []); return (React.createElement((BaseComponent), { WidgetClass: dxChat, ref: baseRef, subscribableOptions, independentEvents, defaults, expectedChildren, templateProps, ...props, })); })); const _componentAlert = (props) => { return React.createElement((NestedOption), { ...props, elementDescriptor: { OptionName: "alerts", IsCollectionItem: true, }, }); }; const Alert = Object.assign(_componentAlert, { componentType: "option", }); const _componentAuthor = (props) => { return React.createElement((NestedOption), { ...props, elementDescriptor: { OptionName: "author", }, }); }; const Author = Object.assign(_componentAuthor, { componentType: "option", }); const _componentDayHeaderFormat = (props) => { return React.createElement((NestedOption), { ...props, elementDescriptor: { OptionName: "dayHeaderFormat", }, }); }; const DayHeaderFormat = Object.assign(_componentDayHeaderFormat, { componentType: "option", }); const _componentItem = (props) => { return React.createElement((NestedOption), { ...props, elementDescriptor: { OptionName: "items", IsCollectionItem: true, ExpectedChildren: { author: { optionName: "author", isCollectionItem: false } }, }, }); }; const Item = Object.assign(_componentItem, { componentType: "option", }); const _componentMessageTimestampFormat = (props) => { return React.createElement((NestedOption), { ...props, elementDescriptor: { OptionName: "messageTimestampFormat", }, }); }; const MessageTimestampFormat = Object.assign(_componentMessageTimestampFormat, { componentType: "option", }); const _componentTypingUser = (props) => { return React.createElement((NestedOption), { ...props, elementDescriptor: { OptionName: "typingUsers", IsCollectionItem: true, }, }); }; const TypingUser = Object.assign(_componentTypingUser, { componentType: "option", }); const _componentUser = (props) => { return React.createElement((NestedOption), { ...props, elementDescriptor: { OptionName: "user", }, }); }; const User = Object.assign(_componentUser, { componentType: "option", }); export default Chat; export { Chat, Alert, Author, DayHeaderFormat, Item, MessageTimestampFormat, TypingUser, User };