@duskmoon-dev/components 0.6.2 → 0.6.4
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.
- package/README.md +33 -0
- package/dist/components/chat/Chat.types.d.ts +9 -0
- package/dist/components/chat/ChatComposerContext.d.ts +27 -0
- package/dist/components/chat/ChatRequest.d.ts +22 -0
- package/dist/components/chat/ChatSessionComposer.types.d.ts +2 -0
- package/dist/components/chat/ComposerQueue.types.d.ts +17 -0
- package/dist/components/chat/ComposerSettingsMenus.d.ts +10 -0
- package/dist/components/chat/composer/ComposerShell.d.ts +1 -0
- package/dist/components/chat/index.d.ts +2 -0
- package/dist/components/chat/index.js +874 -408
- package/dist/components/chat/rich/index.js +6 -2
- package/dist/components/markdown/index.js +68 -1
- package/dist/components/markdown/remarkCjkAutolink.d.ts +24 -0
- package/dist/generated/version.d.ts +1 -1
- package/dist/index.js +2364 -1833
- package/dist/infrastructure.js +1 -1
- package/dist/styles.css +348 -40
- package/package.json +3 -3
package/README.md
CHANGED
|
@@ -210,6 +210,39 @@ idempotency, persistence and execution policy. The Chat documentation includes
|
|
|
210
210
|
interactive fake-host examples with real local state transitions; their memory
|
|
211
211
|
storage survives editor remounts only and makes no durable delivery claim.
|
|
212
212
|
|
|
213
|
+
### Settings menus, context and timeline approvals
|
|
214
|
+
|
|
215
|
+
Core **1.21.5 or newer** is required. Import these APIs from the package root or
|
|
216
|
+
`@duskmoon-dev/components/chat`; import `@duskmoon-dev/components/styles.css`
|
|
217
|
+
for the complete Core and React stylesheet.
|
|
218
|
+
|
|
219
|
+
`ComposerSettings variant="menu"` uses the same serialized request, revision,
|
|
220
|
+
abort and acknowledgment protocol as the default select presentation. Choice
|
|
221
|
+
metadata accepts `description`, `tone="warning"` and `icon`. An `ordered` setting
|
|
222
|
+
renders its choices as a range and requests a change on pointer/key release;
|
|
223
|
+
`defaultValue` enables reset. `groups` combines `settingIds` under a trigger,
|
|
224
|
+
with optional `nestedSettingIds` and `appearance="access" | "model"`. Values
|
|
225
|
+
remain controlled by the host, including rejected or stale acknowledgments.
|
|
226
|
+
The menus close after choosing; status feedback remains announced outside them.
|
|
227
|
+
|
|
228
|
+
Both `Chat.Composer` and `ChatSessionComposer` accept `context`, rendered first
|
|
229
|
+
inside the composer. Compose `Chat.ComposerContext`, `Chat.ComposerContextItem`,
|
|
230
|
+
`Chat.ComposerContextEnd` and `Chat.ComposerConnection` there. Items accept an
|
|
231
|
+
`icon` and an optional `action` with a required accessible `label` and `onClick`.
|
|
232
|
+
Connection `state` is `connected`, `connecting` or `disconnected`; `label`
|
|
233
|
+
customizes its visible status. Core joins the bar to default, compact and ghost
|
|
234
|
+
composer surfaces using the shared inset; no additional consumer CSS is needed.
|
|
235
|
+
|
|
236
|
+
Place `Chat.Request` next to `Chat.Tool` inside `Chat.Agent`. Supply a `title`,
|
|
237
|
+
detail children and ordered `actions` (`id`, `label`, `onSelect`, optional
|
|
238
|
+
`tone="primary" | "danger"`). The host owns `pending` while deciding and `state`:
|
|
239
|
+
`pending`, `approved`, `approved-for-session`, `declined`, `expired` or
|
|
240
|
+
`answer-elsewhere`. Only the pending state renders actions; `pending` disables
|
|
241
|
+
them while a decision is in flight. `explanation` and `statusLabel` provide host
|
|
242
|
+
context and localized status. Status updates are polite; incoming updates never
|
|
243
|
+
move focus out of the composer. If resolution removes a focused decision, focus
|
|
244
|
+
stays on that request without scrolling.
|
|
245
|
+
|
|
213
246
|
Core 1.21.1 still has a known Moonlight contrast gap for neutral outlined/ghost
|
|
214
247
|
labels ([duskmoonui#78](https://github.com/duskmoon-dev/duskmoonui/issues/78)).
|
|
215
248
|
The upstream fix is required before claiming complete palette accessibility.
|
|
@@ -1,3 +1,5 @@
|
|
|
1
|
+
import type { ChatRequestProps } from "./ChatRequest";
|
|
2
|
+
import type { ChatComposerContextProps, ChatComposerContextItemProps, ChatComposerContextEndProps, ChatComposerConnectionProps } from "./ChatComposerContext";
|
|
1
3
|
import type { ComponentProps, ForwardRefExoticComponent, RefAttributes, ReactNode } from "react";
|
|
2
4
|
import type { TextAreaProps } from "../input";
|
|
3
5
|
import type { ComposerScope } from "./Composer.types";
|
|
@@ -155,6 +157,8 @@ export interface ChatComposerProps extends Omit<ComponentProps<"div">, "children
|
|
|
155
157
|
compact?: boolean;
|
|
156
158
|
/** Additional actions in the compact Add menu. */
|
|
157
159
|
addMenu?: ReactNode;
|
|
160
|
+
/** Attached context bar, rendered first inside the composer. */
|
|
161
|
+
context?: ReactNode;
|
|
158
162
|
disabled?: boolean;
|
|
159
163
|
/** Gates submission while keeping the draft editable. */
|
|
160
164
|
busy?: boolean;
|
|
@@ -183,6 +187,11 @@ export interface ChatComposerProps extends Omit<ComponentProps<"div">, "children
|
|
|
183
187
|
type ChatPartComponent<T extends HTMLElement, P> = ForwardRefExoticComponent<P & RefAttributes<T>>;
|
|
184
188
|
export type ChatComponent = ChatPartComponent<HTMLDivElement, ChatProps> & {
|
|
185
189
|
Composer: ChatPartComponent<HTMLDivElement, ChatComposerProps>;
|
|
190
|
+
ComposerContext: ChatPartComponent<HTMLDivElement, ChatComposerContextProps>;
|
|
191
|
+
ComposerContextItem: ChatPartComponent<HTMLSpanElement, ChatComposerContextItemProps>;
|
|
192
|
+
ComposerContextEnd: ChatPartComponent<HTMLSpanElement, ChatComposerContextEndProps>;
|
|
193
|
+
ComposerConnection: ChatPartComponent<HTMLSpanElement, ChatComposerConnectionProps>;
|
|
194
|
+
Request: ChatPartComponent<HTMLDivElement, ChatRequestProps>;
|
|
186
195
|
Agent: ChatPartComponent<HTMLDivElement, ChatAgentProps>;
|
|
187
196
|
Content: ChatPartComponent<HTMLDivElement, ChatContentProps>;
|
|
188
197
|
Work: ChatPartComponent<HTMLDetailsElement, ChatWorkProps>;
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
import React from "react";
|
|
2
|
+
import type { ComponentProps, MouseEventHandler, ReactNode } from "react";
|
|
3
|
+
export type ChatComposerContextProps = ComponentProps<"div">;
|
|
4
|
+
/** Place first inside the composer, or pass through its context slot. */
|
|
5
|
+
export declare const ChatComposerContext: React.ForwardRefExoticComponent<Omit<React.DetailedHTMLProps<React.HTMLAttributes<HTMLDivElement>, HTMLDivElement>, "ref"> & React.RefAttributes<HTMLDivElement>>;
|
|
6
|
+
export interface ChatComposerContextItemAction {
|
|
7
|
+
/** Accessible name for the native button, including icon-only actions. */
|
|
8
|
+
label: string;
|
|
9
|
+
onClick: MouseEventHandler<HTMLButtonElement>;
|
|
10
|
+
disabled?: boolean;
|
|
11
|
+
children?: ReactNode;
|
|
12
|
+
}
|
|
13
|
+
export interface ChatComposerContextItemProps extends ComponentProps<"span"> {
|
|
14
|
+
/** Decorative icon; the item's children supply its readable label. */
|
|
15
|
+
icon?: ReactNode;
|
|
16
|
+
action?: ChatComposerContextItemAction;
|
|
17
|
+
}
|
|
18
|
+
export declare const ChatComposerContextItem: React.ForwardRefExoticComponent<Omit<ChatComposerContextItemProps, "ref"> & React.RefAttributes<HTMLSpanElement>>;
|
|
19
|
+
export type ChatComposerContextEndProps = ComponentProps<"span">;
|
|
20
|
+
export declare const ChatComposerContextEnd: React.ForwardRefExoticComponent<Omit<React.DetailedHTMLProps<React.HTMLAttributes<HTMLSpanElement>, HTMLSpanElement>, "ref"> & React.RefAttributes<HTMLSpanElement>>;
|
|
21
|
+
export type ChatComposerConnectionState = "connected" | "connecting" | "disconnected";
|
|
22
|
+
export interface ChatComposerConnectionProps extends Omit<ComponentProps<"span">, "children"> {
|
|
23
|
+
state: ChatComposerConnectionState;
|
|
24
|
+
/** Localized visible text, also used as the accessible status name. */
|
|
25
|
+
label?: string;
|
|
26
|
+
}
|
|
27
|
+
export declare const ChatComposerConnection: React.ForwardRefExoticComponent<Omit<ChatComposerConnectionProps, "ref"> & React.RefAttributes<HTMLSpanElement>>;
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
import React from "react";
|
|
2
|
+
export type ChatRequestState = "pending" | "approved" | "approved-for-session" | "declined" | "expired" | "answer-elsewhere";
|
|
3
|
+
export interface ChatRequestAction {
|
|
4
|
+
readonly id: string;
|
|
5
|
+
readonly label: React.ReactNode;
|
|
6
|
+
readonly ariaLabel?: string;
|
|
7
|
+
readonly tone?: "primary" | "danger";
|
|
8
|
+
readonly disabled?: boolean;
|
|
9
|
+
readonly onSelect: () => void;
|
|
10
|
+
}
|
|
11
|
+
export interface ChatRequestProps extends Omit<React.HTMLAttributes<HTMLDivElement>, "title"> {
|
|
12
|
+
readonly title: React.ReactNode;
|
|
13
|
+
readonly state?: ChatRequestState;
|
|
14
|
+
/** Host-owned decision in flight; does not resolve the request. */
|
|
15
|
+
readonly pending?: boolean;
|
|
16
|
+
readonly statusLabel?: string;
|
|
17
|
+
readonly actions?: readonly ChatRequestAction[];
|
|
18
|
+
/** Host explanation, including where an unanswerable request can be answered. */
|
|
19
|
+
readonly explanation?: React.ReactNode;
|
|
20
|
+
}
|
|
21
|
+
/** Timeline presentation only. The host owns decisions, pending state and results. */
|
|
22
|
+
export declare const ChatRequest: React.ForwardRefExoticComponent<ChatRequestProps & React.RefAttributes<HTMLDivElement>>;
|
|
@@ -30,6 +30,8 @@ export interface ChatSessionComposerProps extends Omit<ComponentProps<"div">, "c
|
|
|
30
30
|
readonly compact?: boolean;
|
|
31
31
|
/** Additional actions in the compact Add menu. */
|
|
32
32
|
readonly addMenu?: ReactNode;
|
|
33
|
+
/** Attached context bar, rendered first inside the composer. */
|
|
34
|
+
readonly context?: ReactNode;
|
|
33
35
|
readonly onStop?: () => void;
|
|
34
36
|
readonly label?: string;
|
|
35
37
|
readonly attachLabel?: string;
|
|
@@ -23,6 +23,9 @@ export interface ChatAuthoritativeQueueProps {
|
|
|
23
23
|
export interface ComposerSettingChoice {
|
|
24
24
|
readonly value: string;
|
|
25
25
|
readonly label: string;
|
|
26
|
+
readonly description?: string;
|
|
27
|
+
readonly tone?: "warning";
|
|
28
|
+
readonly icon?: React.ReactNode;
|
|
26
29
|
readonly unavailableReason?: string;
|
|
27
30
|
}
|
|
28
31
|
export interface ComposerSetting {
|
|
@@ -30,8 +33,20 @@ export interface ComposerSetting {
|
|
|
30
33
|
readonly label: string;
|
|
31
34
|
readonly value: string;
|
|
32
35
|
readonly choices: readonly ComposerSettingChoice[];
|
|
36
|
+
/** Ordered choices render as a slider in the menu presentation. */
|
|
37
|
+
readonly ordered?: boolean;
|
|
38
|
+
readonly defaultValue?: string;
|
|
33
39
|
readonly unavailableReason?: string;
|
|
34
40
|
}
|
|
41
|
+
/** Settings grouped under one trigger, in host-supplied order. */
|
|
42
|
+
export interface ComposerSettingsGroup {
|
|
43
|
+
readonly id: string;
|
|
44
|
+
readonly label: string;
|
|
45
|
+
readonly settingIds: readonly string[];
|
|
46
|
+
readonly nestedSettingIds?: readonly string[];
|
|
47
|
+
readonly appearance?: "access" | "model";
|
|
48
|
+
readonly icon?: React.ReactNode;
|
|
49
|
+
}
|
|
35
50
|
export interface ComposerSettingRequest {
|
|
36
51
|
readonly requestId: string;
|
|
37
52
|
readonly scopeKey: string;
|
|
@@ -52,6 +67,8 @@ export type ComposerSettingResult = {
|
|
|
52
67
|
readonly message: string;
|
|
53
68
|
});
|
|
54
69
|
export interface ComposerSettingsProps {
|
|
70
|
+
readonly variant?: "select" | "menu";
|
|
71
|
+
readonly groups?: readonly ComposerSettingsGroup[];
|
|
55
72
|
readonly scopeKey: string;
|
|
56
73
|
readonly revision: number;
|
|
57
74
|
readonly settings: readonly ComposerSetting[];
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import React from "react";
|
|
2
|
+
import type { ComposerSettingsProps } from "./ComposerQueue.types";
|
|
3
|
+
type MenuProps = ComposerSettingsProps & {
|
|
4
|
+
busy: boolean;
|
|
5
|
+
feedback: Readonly<Record<string, string>>;
|
|
6
|
+
request: (id: string, value: string) => Promise<void>;
|
|
7
|
+
};
|
|
8
|
+
/** Presentation only: both settings variants use the same request/acknowledgment owner. */
|
|
9
|
+
export declare function ComposerSettingsMenus(props: MenuProps): React.JSX.Element;
|
|
10
|
+
export {};
|
|
@@ -17,6 +17,7 @@ interface ComposerShellProps extends Omit<React.ComponentProps<"div">, "children
|
|
|
17
17
|
composerId: string;
|
|
18
18
|
compact?: boolean;
|
|
19
19
|
addMenu?: React.ReactNode;
|
|
20
|
+
context?: React.ReactNode;
|
|
20
21
|
entries: readonly ComposerShellAttachment[];
|
|
21
22
|
renderAttachment?: ChatComposerProps["renderAttachment"];
|
|
22
23
|
removeAttachment: (id: number | string) => void;
|
|
@@ -22,3 +22,5 @@ export { useComposerSession } from "./composer/useComposerSession";
|
|
|
22
22
|
export { createComposerSessionController, createComposerRecoveryOwner, composerActionEligibility, ComposerUncertainTransportError, snapshotComposerReceipt, } from "./composer/session";
|
|
23
23
|
export { readComposerDocument, readComposerDraft, snapshotComposerDocument, snapshotComposerSubmission, exportComposerText, exportComposerMarkdown, } from "./composer/document";
|
|
24
24
|
export type { ComposerReadResult } from "./composer/document";
|
|
25
|
+
export * from "./ChatComposerContext";
|
|
26
|
+
export * from "./ChatRequest";
|