@polymorfa/react 0.1.0-dev.20260922094209

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.
@@ -0,0 +1,109 @@
1
+ import { type ConversationController, type ConversationMessage, type MessageAttachment, type MessageComposerController, type RenderedTemplate, type TemplateBuilderController } from "@polymorfa/browser";
2
+ import { type QuickReplyOption, type ChatIconName, type ComponentSlot, type MessageKey, type SlotClassNames } from "@polymorfa/ui";
3
+ import { type CSSProperties, type ReactNode } from "react";
4
+ import { usePolymorfa } from "./context.js";
5
+ type ControllerProps<T> = {
6
+ readonly controller?: T;
7
+ readonly createController?: () => T;
8
+ };
9
+ type Configuration = ReturnType<typeof usePolymorfa>;
10
+ interface SlotProps {
11
+ readonly className: string;
12
+ readonly style?: CSSProperties;
13
+ readonly "data-slot": ComponentSlot;
14
+ }
15
+ export type Slots = (slot: ComponentSlot, base: string) => SlotProps;
16
+ /** Slot resolver that keeps its identity while the inputs are unchanged. */
17
+ export declare function useSlots(classNames: SlotClassNames | undefined): Slots;
18
+ /** Root props: theme classes, direction, CSS variables, and the slot. */
19
+ export declare function useShell(slots: Slots, slot: ComponentSlot, base: string, className: string | undefined): {
20
+ readonly dir: "ltr" | "rtl";
21
+ readonly className: string;
22
+ readonly style: CSSProperties;
23
+ readonly "data-slot": ComponentSlot;
24
+ };
25
+ export declare function text(configuration: Configuration, key: MessageKey, values?: Readonly<Record<string, string>>): string;
26
+ export declare function Icon({ name, className, }: {
27
+ readonly name: ChatIconName;
28
+ readonly className?: string;
29
+ }): import("react").JSX.Element;
30
+ export type RenderAttachment = (attachment: MessageAttachment, message: ConversationMessage) => ReactNode;
31
+ interface ConversationViewProps {
32
+ readonly renderMessage?: (message: ConversationMessage) => ReactNode;
33
+ readonly renderAttachment?: RenderAttachment;
34
+ /** Show a Reply action on each message. */
35
+ readonly onReply?: (message: ConversationMessage) => void;
36
+ }
37
+ export interface MessageListProps extends ControllerProps<ConversationController>, ConversationViewProps {
38
+ readonly className?: string;
39
+ readonly classNames?: SlotClassNames;
40
+ }
41
+ export declare function MessageList({ controller, createController, className, classNames, ...viewProps }: MessageListProps): import("react").JSX.Element;
42
+ export interface ComposeBoxProps extends ControllerProps<MessageComposerController> {
43
+ readonly onSent?: () => void;
44
+ readonly className?: string;
45
+ readonly classNames?: SlotClassNames;
46
+ /**
47
+ * Offer file attachments: the attach button, drop and paste. Defaults to
48
+ * `true`. Turn it off when the composer's actions have no upload adapter.
49
+ */
50
+ readonly attachments?: boolean;
51
+ /** File types the attach button offers, as for `<input accept>`. */
52
+ readonly accept?: string;
53
+ /** Allow picking several files at once. Defaults to `true`. */
54
+ readonly multiple?: boolean;
55
+ /** Resolves the reply banner's quoted message. */
56
+ readonly conversation?: ConversationController;
57
+ /** Resolves the reply banner's quoted message without a controller. */
58
+ readonly messages?: readonly ConversationMessage[];
59
+ /** Replaces the locale's `composer.placeholder`. */
60
+ readonly placeholder?: string;
61
+ /** Rendered in the toolbar before the built-in buttons. */
62
+ readonly startActions?: ReactNode;
63
+ /** Rendered after the message field, before the send or mic button. */
64
+ readonly endActions?: ReactNode;
65
+ /** Show the emoji picker button. Defaults to `true`. */
66
+ readonly emoji?: boolean;
67
+ /**
68
+ * Show the voice note button. Defaults to `true` where the browser has
69
+ * `MediaRecorder` and `getUserMedia`.
70
+ */
71
+ readonly voiceNotes?: boolean;
72
+ /** Send a voice note as soon as it finishes uploading. Defaults to `true`. */
73
+ readonly voiceNoteAutoSend?: boolean;
74
+ /** Options for the "/" quick reply menu. */
75
+ readonly quickReplies?: readonly QuickReplyOption[];
76
+ /** Called after a quick reply's text is inserted. */
77
+ readonly onQuickReply?: (option: QuickReplyOption) => void;
78
+ /** Rows the message field grows to before it scrolls. Defaults to 8. */
79
+ readonly maxRows?: number;
80
+ }
81
+ export declare function ComposeBox({ controller, createController, onSent, className, classNames, attachments, accept, multiple, conversation, messages, placeholder, startActions, endActions, emoji, voiceNotes, voiceNoteAutoSend, quickReplies, onQuickReply, maxRows, }: ComposeBoxProps): import("react").JSX.Element;
82
+ export interface ChatDrawerProps extends MessageListProps {
83
+ readonly open?: boolean;
84
+ readonly onClose?: () => void;
85
+ /** Custom footer; takes precedence over the built-in composer. */
86
+ readonly composer?: ReactNode;
87
+ readonly title?: string;
88
+ /** Alias of `controller`. */
89
+ readonly conversation?: ConversationController;
90
+ /** Renders the built-in composer and wires message Reply to it. */
91
+ readonly composerController?: MessageComposerController;
92
+ readonly createComposerController?: () => MessageComposerController;
93
+ /**
94
+ * Move focus into the drawer when it first mounts open. Defaults to
95
+ * `false`; focus always moves when `open` changes to `true`.
96
+ */
97
+ readonly autoFocus?: boolean;
98
+ /** Props for the built-in composer. */
99
+ readonly composerProps?: Omit<ComposeBoxProps, "controller" | "createController" | "conversation">;
100
+ }
101
+ export declare function ChatDrawer({ open, onClose, composer, title, className, classNames, conversation, controller, createController, composerController, createComposerController, composerProps, onReply, autoFocus, ...viewProps }: ChatDrawerProps): import("react").JSX.Element | null;
102
+ export interface TemplateBuilderProps extends ControllerProps<TemplateBuilderController> {
103
+ readonly renderPreview?: (preview: RenderedTemplate) => ReactNode;
104
+ readonly className?: string;
105
+ readonly classNames?: SlotClassNames;
106
+ }
107
+ export declare function TemplateBuilder({ controller, createController, renderPreview, className, classNames, }: TemplateBuilderProps): import("react").JSX.Element;
108
+ export {};
109
+ //# sourceMappingURL=components.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"components.d.ts","sourceRoot":"","sources":["../src/components.tsx"],"names":[],"mappings":"AAAA,OAAO,EAIL,KAAK,sBAAsB,EAC3B,KAAK,mBAAmB,EAGxB,KAAK,iBAAiB,EACtB,KAAK,yBAAyB,EAE9B,KAAK,gBAAgB,EACrB,KAAK,yBAAyB,EAG/B,MAAM,oBAAoB,CAAC;AAC5B,OAAO,EAiBL,KAAK,gBAAgB,EAarB,KAAK,YAAY,EACjB,KAAK,aAAa,EAClB,KAAK,UAAU,EACf,KAAK,cAAc,EACpB,MAAM,eA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