@astryxdesign/core 0.1.8-canary.0c4d8d7 → 0.1.8-canary.3bb5896
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/dist/Chat/ChatComposerInput.d.ts +3 -20
- package/dist/Chat/ChatComposerInput.d.ts.map +1 -1
- package/dist/Chat/ChatComposerInput.js +3 -19
- package/dist/astryx.umd.js +12 -12
- package/dist/astryx.umd.js.map +3 -3
- package/package.json +1 -1
- package/src/Chat/ChatComposerInput.doc.mjs +0 -7
- package/src/Chat/ChatComposerInput.test.tsx +0 -87
- package/src/Chat/ChatComposerInput.tsx +3 -35
|
@@ -7,10 +7,8 @@
|
|
|
7
7
|
*
|
|
8
8
|
* ContentEditable-based rich input for the chat composer.
|
|
9
9
|
* Supports trigger menus (@ mentions, / commands) via SearchSource,
|
|
10
|
-
* inline token rendering, serialization, Enter
|
|
11
|
-
*
|
|
12
|
-
* key handling, message history, paste/drop file handling, and
|
|
13
|
-
* mobile-safe touch typography.
|
|
10
|
+
* inline token rendering, serialization, Enter/Shift+Enter, message
|
|
11
|
+
* history, paste/drop file handling, and mobile-safe touch typography.
|
|
14
12
|
*
|
|
15
13
|
*
|
|
16
14
|
* SYNC: When modified, update:
|
|
@@ -18,7 +16,7 @@
|
|
|
18
16
|
* - /apps/storybook/stories/ChatComposer.stories.tsx
|
|
19
17
|
* - /packages/cli/templates/blocks/components/ChatComposerInput/ (block examples)
|
|
20
18
|
*/
|
|
21
|
-
import { type ReactNode, type
|
|
19
|
+
import { type ReactNode, type ClipboardEvent } from 'react';
|
|
22
20
|
import type { BaseProps } from '../BaseProps';
|
|
23
21
|
import type { SearchableItem, SearchSource } from '../Typeahead/types';
|
|
24
22
|
import { type UseChatPasteAsTokenReturn } from './useChatPasteAsToken';
|
|
@@ -139,21 +137,6 @@ export interface ChatComposerInputProps extends Omit<BaseProps<HTMLDivElement>,
|
|
|
139
137
|
onFiles?: (files: File[]) => void;
|
|
140
138
|
/** Submit handler (Enter without Shift) */
|
|
141
139
|
onSubmit?: (value: string) => void;
|
|
142
|
-
/**
|
|
143
|
-
* Key-down handler invoked before the built-in Enter/history behavior
|
|
144
|
-
* (but after an open trigger menu consumes the event).
|
|
145
|
-
*
|
|
146
|
-
* This is the seam for platform- or app-specific key handling:
|
|
147
|
-
* - Call `event.preventDefault()` to suppress the default submit (e.g.
|
|
148
|
-
* let Enter insert a newline on a touch keyboard).
|
|
149
|
-
* - Add behavior by acting on the event yourself (e.g. submit on
|
|
150
|
-
* Cmd/Ctrl+Enter) without calling `preventDefault()`, so the default
|
|
151
|
-
* handling still runs for other keys.
|
|
152
|
-
*
|
|
153
|
-
* IME composition is always respected regardless of this handler: Enter
|
|
154
|
-
* never submits while a composition is in progress.
|
|
155
|
-
*/
|
|
156
|
-
onKeyDown?: (event: KeyboardEvent<HTMLDivElement>) => void;
|
|
157
140
|
}
|
|
158
141
|
export declare function ChatComposerInput(props: ChatComposerInputProps): import("react").JSX.Element;
|
|
159
142
|
export declare namespace ChatComposerInput {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ChatComposerInput.d.ts","sourceRoot":"","sources":["../../src/Chat/ChatComposerInput.tsx"],"names":[],"mappings":"AAIA
|
|
1
|
+
{"version":3,"file":"ChatComposerInput.d.ts","sourceRoot":"","sources":["../../src/Chat/ChatComposerInput.tsx"],"names":[],"mappings":"AAIA;;;;;;;;;;;;;;;;;GAiBG;AAEH,OAAO,EAML,KAAK,SAAS,EAEd,KAAK,cAAc,EACpB,MAAM,OAAO,CAAC;AAEf,OAAO,KAAK,EAAC,SAAS,EAAC,MAAM,cAAc,CAAC;AAC5C,OAAO,KAAK,EAAC,cAAc,EAAE,YAAY,EAAC,MAAM,oBAAoB,CAAC;AAarE,OAAO,EAEL,KAAK,yBAAyB,EAC/B,MAAM,uBAAuB,CAAC;AAC/B,OAAO,EAAQ,KAAK,UAAU,EAAC,MAAM,UAAU,CAAC;AAShD,mEAAmE;AACnE,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;IAClC,2CAA2C;IAC3C,QAAQ,CAAC,EAAE,CAAC,KAAK,EAAE,MAAM,KAAK,IAAI,CAAC;CACpC;AA0FD,wBAAgB,iBAAiB,CAAC,KAAK,EAAE,sBAAsB,+BA4Z9D;yBA5Ze,iBAAiB;;;AAoajC,wBAAgB,wBAAwB,CAAC,EAAC,KAAK,EAAC,EAAE;IAAC,KAAK,EAAE,iBAAiB,CAAA;CAAC,+BAc3E;yBAde,wBAAwB"}
|
|
@@ -11,10 +11,8 @@
|
|
|
11
11
|
*
|
|
12
12
|
* ContentEditable-based rich input for the chat composer.
|
|
13
13
|
* Supports trigger menus (@ mentions, / commands) via SearchSource,
|
|
14
|
-
* inline token rendering, serialization, Enter
|
|
15
|
-
*
|
|
16
|
-
* key handling, message history, paste/drop file handling, and
|
|
17
|
-
* mobile-safe touch typography.
|
|
14
|
+
* inline token rendering, serialization, Enter/Shift+Enter, message
|
|
15
|
+
* history, paste/drop file handling, and mobile-safe touch typography.
|
|
18
16
|
*
|
|
19
17
|
*
|
|
20
18
|
* SYNC: When modified, update:
|
|
@@ -135,7 +133,6 @@ export function ChatComposerInput(props) {
|
|
|
135
133
|
pasteAsToken: pasteAsTokenProp,
|
|
136
134
|
onFiles,
|
|
137
135
|
onSubmit = composerCtx?.onSubmit,
|
|
138
|
-
onKeyDown: onKeyDownProp,
|
|
139
136
|
xstyle,
|
|
140
137
|
className,
|
|
141
138
|
style,
|
|
@@ -292,13 +289,6 @@ export function ChatComposerInput(props) {
|
|
|
292
289
|
return;
|
|
293
290
|
}
|
|
294
291
|
|
|
295
|
-
// Consumer passthrough — runs before built-in Enter/history handling.
|
|
296
|
-
// A consumer can preventDefault() to fully own the keystroke.
|
|
297
|
-
onKeyDownProp?.(e);
|
|
298
|
-
if (e.defaultPrevented) {
|
|
299
|
-
return;
|
|
300
|
-
}
|
|
301
|
-
|
|
302
292
|
// Handle Backspace near tokens — prevent browser from creating
|
|
303
293
|
// stray <br> elements or moving the cursor unexpectedly.
|
|
304
294
|
if (e.key === 'Backspace') {
|
|
@@ -332,12 +322,6 @@ export function ChatComposerInput(props) {
|
|
|
332
322
|
}
|
|
333
323
|
}
|
|
334
324
|
if (e.key === 'Enter' && !e.shiftKey) {
|
|
335
|
-
// Never submit mid-composition — an IME uses Enter to commit a
|
|
336
|
-
// candidate (e.g. Japanese/Chinese/Korean input), and browsers may
|
|
337
|
-
// also surface the legacy keyCode 229 for composing keystrokes.
|
|
338
|
-
if (e.nativeEvent.isComposing || e.nativeEvent.keyCode === 229) {
|
|
339
|
-
return;
|
|
340
|
-
}
|
|
341
325
|
e.preventDefault();
|
|
342
326
|
if (!editableRef.current) {
|
|
343
327
|
return;
|
|
@@ -395,7 +379,7 @@ export function ChatComposerInput(props) {
|
|
|
395
379
|
e.preventDefault();
|
|
396
380
|
}
|
|
397
381
|
}
|
|
398
|
-
}, [hasHistory, onSubmit, onChange, emitChange, triggerMenu
|
|
382
|
+
}, [hasHistory, onSubmit, onChange, emitChange, triggerMenu]);
|
|
399
383
|
const handlePaste = useCallback(e => {
|
|
400
384
|
const editable = editableRef.current;
|
|
401
385
|
if (!editable) {
|