@cratis/components 4.42.0 → 4.42.1
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/compat-manifest.json +11 -11
- package/dist/esm/Chat/ChatSidebar.d.ts +2 -2
- package/dist/esm/Chat/ChatSidebar.d.ts.map +1 -1
- package/dist/esm/Chat/ChatSidebar.js +21 -101
- package/dist/esm/Chat/ChatSidebar.js.map +1 -1
- package/dist/esm/Chat/ChatSidebarContent.d.ts +25 -0
- package/dist/esm/Chat/ChatSidebarContent.d.ts.map +1 -0
- package/dist/esm/Chat/ChatSidebarContent.js +12 -0
- package/dist/esm/Chat/ChatSidebarContent.js.map +1 -0
- package/dist/esm/Chat/ChatSidebarHeader.d.ts +16 -0
- package/dist/esm/Chat/ChatSidebarHeader.d.ts.map +1 -0
- package/dist/esm/Chat/ChatSidebarHeader.js +26 -0
- package/dist/esm/Chat/ChatSidebarHeader.js.map +1 -0
- package/dist/esm/Chat/ChatSidebarShells.d.ts +31 -0
- package/dist/esm/Chat/ChatSidebarShells.d.ts.map +1 -0
- package/dist/esm/Chat/ChatSidebarShells.js +43 -0
- package/dist/esm/Chat/ChatSidebarShells.js.map +1 -0
- package/dist/esm/Chat/useNonModalPhase.d.ts +16 -0
- package/dist/esm/Chat/useNonModalPhase.d.ts.map +1 -0
- package/dist/esm/Chat/useNonModalPhase.js +38 -0
- package/dist/esm/Chat/useNonModalPhase.js.map +1 -0
- package/dist/esm/Chat/useTopicSelection.d.ts +31 -0
- package/dist/esm/Chat/useTopicSelection.d.ts.map +1 -0
- package/dist/esm/Chat/useTopicSelection.js +45 -0
- package/dist/esm/Chat/useTopicSelection.js.map +1 -0
- package/dist/esm/DataTables/ColumnFilterActions.d.ts +11 -0
- package/dist/esm/DataTables/ColumnFilterActions.d.ts.map +1 -0
- package/dist/esm/DataTables/ColumnFilterActions.js +8 -0
- package/dist/esm/DataTables/ColumnFilterActions.js.map +1 -0
- package/dist/esm/DataTables/ColumnFilterMenu.d.ts +1 -1
- package/dist/esm/DataTables/ColumnFilterMenu.d.ts.map +1 -1
- package/dist/esm/DataTables/ColumnFilterMenu.js +16 -148
- package/dist/esm/DataTables/ColumnFilterMenu.js.map +1 -1
- package/dist/esm/DataTables/ColumnFilterTrigger.d.ts +12 -0
- package/dist/esm/DataTables/ColumnFilterTrigger.d.ts.map +1 -0
- package/dist/esm/DataTables/ColumnFilterTrigger.js +9 -0
- package/dist/esm/DataTables/ColumnFilterTrigger.js.map +1 -0
- package/dist/esm/DataTables/ColumnFilterValueInput.d.ts +24 -0
- package/dist/esm/DataTables/ColumnFilterValueInput.d.ts.map +1 -0
- package/dist/esm/DataTables/ColumnFilterValueInput.js +39 -0
- package/dist/esm/DataTables/ColumnFilterValueInput.js.map +1 -0
- package/dist/esm/DataTables/columnFilterMatchModes.d.ts +10 -0
- package/dist/esm/DataTables/columnFilterMatchModes.d.ts.map +1 -0
- package/dist/esm/DataTables/columnFilterMatchModes.js +52 -0
- package/dist/esm/DataTables/columnFilterMatchModes.js.map +1 -0
- package/dist/esm/DataTables/resolveColumnFilterLabels.d.ts +4 -0
- package/dist/esm/DataTables/resolveColumnFilterLabels.d.ts.map +1 -0
- package/dist/esm/DataTables/resolveColumnFilterLabels.js +20 -0
- package/dist/esm/DataTables/resolveColumnFilterLabels.js.map +1 -0
- package/dist/esm/DataTables/useColumnFilterDraft.d.ts +13 -0
- package/dist/esm/DataTables/useColumnFilterDraft.d.ts.map +1 -0
- package/dist/esm/DataTables/useColumnFilterDraft.js +24 -0
- package/dist/esm/DataTables/useColumnFilterDraft.js.map +1 -0
- package/dist/esm/DataTables/useRestoreFocusOnClose.d.ts +7 -0
- package/dist/esm/DataTables/useRestoreFocusOnClose.d.ts.map +1 -0
- package/dist/esm/DataTables/useRestoreFocusOnClose.js +30 -0
- package/dist/esm/DataTables/useRestoreFocusOnClose.js.map +1 -0
- package/dist/esm/Dialogs/DialogDocument.d.ts +22 -0
- package/dist/esm/Dialogs/DialogDocument.d.ts.map +1 -0
- package/dist/esm/Dialogs/DialogDocument.js +24 -0
- package/dist/esm/Dialogs/DialogDocument.js.map +1 -0
- package/dist/esm/Dialogs/DialogFooter.d.ts +24 -0
- package/dist/esm/Dialogs/DialogFooter.d.ts.map +1 -0
- package/dist/esm/Dialogs/DialogFooter.js +65 -0
- package/dist/esm/Dialogs/DialogFooter.js.map +1 -0
- package/dist/esm/Dialogs/DialogHeader.d.ts +31 -0
- package/dist/esm/Dialogs/DialogHeader.d.ts.map +1 -0
- package/dist/esm/Dialogs/DialogHeader.js +28 -0
- package/dist/esm/Dialogs/DialogHeader.js.map +1 -0
- package/dist/esm/Dialogs/DialogImplementation.d.ts +1 -2
- package/dist/esm/Dialogs/DialogImplementation.d.ts.map +1 -1
- package/dist/esm/Dialogs/DialogImplementation.js +88 -189
- package/dist/esm/Dialogs/DialogImplementation.js.map +1 -1
- package/dist/esm/Dialogs/DialogShells.d.ts +29 -0
- package/dist/esm/Dialogs/DialogShells.d.ts.map +1 -0
- package/dist/esm/Dialogs/DialogShells.js +36 -0
- package/dist/esm/Dialogs/DialogShells.js.map +1 -0
- package/dist/esm/Dialogs/dialogPartAttributes.d.ts +19 -0
- package/dist/esm/Dialogs/dialogPartAttributes.d.ts.map +1 -0
- package/dist/esm/Dialogs/dialogPartAttributes.js +10 -0
- package/dist/esm/Dialogs/dialogPartAttributes.js.map +1 -0
- package/dist/esm/Dialogs/resolveDialogLabels.d.ts +29 -0
- package/dist/esm/Dialogs/resolveDialogLabels.d.ts.map +1 -0
- package/dist/esm/Dialogs/resolveDialogLabels.js +11 -0
- package/dist/esm/Dialogs/resolveDialogLabels.js.map +1 -0
- package/dist/esm/Dialogs/useDialogClose.d.ts +13 -0
- package/dist/esm/Dialogs/useDialogClose.d.ts.map +1 -0
- package/dist/esm/Dialogs/useDialogClose.js +32 -0
- package/dist/esm/Dialogs/useDialogClose.js.map +1 -0
- package/dist/esm/Dialogs/useDialogFocus.d.ts +26 -0
- package/dist/esm/Dialogs/useDialogFocus.d.ts.map +1 -0
- package/dist/esm/Dialogs/useDialogFocus.js +56 -0
- package/dist/esm/Dialogs/useDialogFocus.js.map +1 -0
- package/dist/esm/Dialogs/useDialogZIndex.d.ts +9 -0
- package/dist/esm/Dialogs/useDialogZIndex.d.ts.map +1 -0
- package/dist/esm/Dialogs/useDialogZIndex.js +19 -0
- package/dist/esm/Dialogs/useDialogZIndex.js.map +1 -0
- package/dist/esm/SchemaEditor/ReadOnlyTypeCell.d.ts +6 -0
- package/dist/esm/SchemaEditor/ReadOnlyTypeCell.d.ts.map +1 -0
- package/dist/esm/SchemaEditor/ReadOnlyTypeCell.js +19 -0
- package/dist/esm/SchemaEditor/ReadOnlyTypeCell.js.map +1 -0
- package/dist/esm/SchemaEditor/SchemaEditor.d.ts.map +1 -1
- package/dist/esm/SchemaEditor/SchemaEditor.js +44 -514
- package/dist/esm/SchemaEditor/SchemaEditor.js.map +1 -1
- package/dist/esm/SchemaEditor/SchemaEditorNavigation.d.ts +13 -0
- package/dist/esm/SchemaEditor/SchemaEditorNavigation.d.ts.map +1 -0
- package/dist/esm/SchemaEditor/SchemaEditorNavigation.js +36 -0
- package/dist/esm/SchemaEditor/SchemaEditorNavigation.js.map +1 -0
- package/dist/esm/SchemaEditor/SchemaEditorTable.d.ts +34 -0
- package/dist/esm/SchemaEditor/SchemaEditorTable.d.ts.map +1 -0
- package/dist/esm/SchemaEditor/SchemaEditorTable.js +54 -0
- package/dist/esm/SchemaEditor/SchemaEditorTable.js.map +1 -0
- package/dist/esm/SchemaEditor/TypeCell.d.ts.map +1 -1
- package/dist/esm/SchemaEditor/TypeCell.js +14 -80
- package/dist/esm/SchemaEditor/TypeCell.js.map +1 -1
- package/dist/esm/SchemaEditor/TypeCellActions.d.ts +13 -0
- package/dist/esm/SchemaEditor/TypeCellActions.d.ts.map +1 -0
- package/dist/esm/SchemaEditor/TypeCellActions.js +19 -0
- package/dist/esm/SchemaEditor/TypeCellActions.js.map +1 -0
- package/dist/esm/SchemaEditor/resolveTypeChange.d.ts +12 -0
- package/dist/esm/SchemaEditor/resolveTypeChange.d.ts.map +1 -0
- package/dist/esm/SchemaEditor/resolveTypeChange.js +19 -0
- package/dist/esm/SchemaEditor/resolveTypeChange.js.map +1 -0
- package/dist/esm/SchemaEditor/schemaDocument.d.ts +20 -0
- package/dist/esm/SchemaEditor/schemaDocument.d.ts.map +1 -0
- package/dist/esm/SchemaEditor/schemaDocument.js +70 -0
- package/dist/esm/SchemaEditor/schemaDocument.js.map +1 -0
- package/dist/esm/SchemaEditor/schemaEditorMenu.d.ts +30 -0
- package/dist/esm/SchemaEditor/schemaEditorMenu.d.ts.map +1 -0
- package/dist/esm/SchemaEditor/schemaEditorMenu.js +51 -0
- package/dist/esm/SchemaEditor/schemaEditorMenu.js.map +1 -0
- package/dist/esm/SchemaEditor/schemaPropertyEdits.d.ts +33 -0
- package/dist/esm/SchemaEditor/schemaPropertyEdits.d.ts.map +1 -0
- package/dist/esm/SchemaEditor/schemaPropertyEdits.js +134 -0
- package/dist/esm/SchemaEditor/schemaPropertyEdits.js.map +1 -0
- package/dist/esm/SchemaEditor/typeOptions.d.ts +11 -0
- package/dist/esm/SchemaEditor/typeOptions.d.ts.map +1 -0
- package/dist/esm/SchemaEditor/typeOptions.js +20 -0
- package/dist/esm/SchemaEditor/typeOptions.js.map +1 -0
- package/dist/esm/SchemaEditor/useSchemaDocument.d.ts +26 -0
- package/dist/esm/SchemaEditor/useSchemaDocument.d.ts.map +1 -0
- package/dist/esm/SchemaEditor/useSchemaDocument.js +65 -0
- package/dist/esm/SchemaEditor/useSchemaDocument.js.map +1 -0
- package/dist/esm/SchemaEditor/useSchemaEdits.d.ts +29 -0
- package/dist/esm/SchemaEditor/useSchemaEdits.d.ts.map +1 -0
- package/dist/esm/SchemaEditor/useSchemaEdits.js +50 -0
- package/dist/esm/SchemaEditor/useSchemaEdits.js.map +1 -0
- package/dist/esm/SchemaEditor/useSchemaNavigation.d.ts +15 -0
- package/dist/esm/SchemaEditor/useSchemaNavigation.d.ts.map +1 -0
- package/dist/esm/SchemaEditor/useSchemaNavigation.js +24 -0
- package/dist/esm/SchemaEditor/useSchemaNavigation.js.map +1 -0
- package/dist/esm/SchemaEditor/useSchemaRows.d.ts +17 -0
- package/dist/esm/SchemaEditor/useSchemaRows.d.ts.map +1 -0
- package/dist/esm/SchemaEditor/useSchemaRows.js +49 -0
- package/dist/esm/SchemaEditor/useSchemaRows.js.map +1 -0
- package/package.json +1 -1
package/compat-manifest.json
CHANGED
|
@@ -68,7 +68,7 @@
|
|
|
68
68
|
{
|
|
69
69
|
"name": "@cratis/components",
|
|
70
70
|
"role": "core",
|
|
71
|
-
"version": "4.42.
|
|
71
|
+
"version": "4.42.1",
|
|
72
72
|
"releaseMajorRange": ">=4 <5",
|
|
73
73
|
"independentRelease": false,
|
|
74
74
|
"private": false,
|
|
@@ -92,7 +92,7 @@
|
|
|
92
92
|
{
|
|
93
93
|
"name": "@cratis/eslint-plugin-components",
|
|
94
94
|
"role": "eslint",
|
|
95
|
-
"version": "4.42.
|
|
95
|
+
"version": "4.42.1",
|
|
96
96
|
"releaseMajorRange": ">=4 <5",
|
|
97
97
|
"independentRelease": false,
|
|
98
98
|
"private": false,
|
|
@@ -105,7 +105,7 @@
|
|
|
105
105
|
{
|
|
106
106
|
"name": "@cratis/components.migrator",
|
|
107
107
|
"role": "migrator",
|
|
108
|
-
"version": "4.42.
|
|
108
|
+
"version": "4.42.1",
|
|
109
109
|
"releaseMajorRange": ">=4 <5",
|
|
110
110
|
"independentRelease": false,
|
|
111
111
|
"private": false,
|
|
@@ -116,13 +116,13 @@
|
|
|
116
116
|
{
|
|
117
117
|
"name": "@cratis/components.conformance",
|
|
118
118
|
"role": "conformance",
|
|
119
|
-
"version": "4.42.
|
|
119
|
+
"version": "4.42.1",
|
|
120
120
|
"releaseMajorRange": ">=4 <5",
|
|
121
121
|
"independentRelease": false,
|
|
122
122
|
"private": false,
|
|
123
123
|
"packageAccess": "public",
|
|
124
124
|
"peerDependencies": {
|
|
125
|
-
"@cratis/components": "4.42.
|
|
125
|
+
"@cratis/components": "4.42.1",
|
|
126
126
|
"react": "^19.0.0",
|
|
127
127
|
"react-dom": "^19.0.0"
|
|
128
128
|
},
|
|
@@ -132,13 +132,13 @@
|
|
|
132
132
|
{
|
|
133
133
|
"name": "@cratis/components.mui",
|
|
134
134
|
"role": "renderer-adapter",
|
|
135
|
-
"version": "4.42.
|
|
135
|
+
"version": "4.42.1",
|
|
136
136
|
"releaseMajorRange": ">=4 <5",
|
|
137
137
|
"independentRelease": false,
|
|
138
138
|
"private": false,
|
|
139
139
|
"packageAccess": "public",
|
|
140
140
|
"peerDependencies": {
|
|
141
|
-
"@cratis/components": "4.42.
|
|
141
|
+
"@cratis/components": "4.42.1",
|
|
142
142
|
"@emotion/react": ">=11.5 <12",
|
|
143
143
|
"@emotion/styled": ">=11.11 <12",
|
|
144
144
|
"@mui/material": ">=9 <10",
|
|
@@ -188,13 +188,13 @@
|
|
|
188
188
|
{
|
|
189
189
|
"name": "@cratis/components.primereact",
|
|
190
190
|
"role": "renderer-adapter",
|
|
191
|
-
"version": "4.42.
|
|
191
|
+
"version": "4.42.1",
|
|
192
192
|
"releaseMajorRange": ">=4 <5",
|
|
193
193
|
"independentRelease": false,
|
|
194
194
|
"private": false,
|
|
195
195
|
"packageAccess": "public",
|
|
196
196
|
"peerDependencies": {
|
|
197
|
-
"@cratis/components": "4.42.
|
|
197
|
+
"@cratis/components": "4.42.1",
|
|
198
198
|
"@primereact/core": ">=11 <12",
|
|
199
199
|
"@primereact/ui": ">=11 <12",
|
|
200
200
|
"@primeuix/themes": ">=3 <4",
|
|
@@ -256,13 +256,13 @@
|
|
|
256
256
|
{
|
|
257
257
|
"name": "@cratis/components.primereact10",
|
|
258
258
|
"role": "renderer-adapter",
|
|
259
|
-
"version": "4.42.
|
|
259
|
+
"version": "4.42.1",
|
|
260
260
|
"releaseMajorRange": ">=4 <5",
|
|
261
261
|
"independentRelease": false,
|
|
262
262
|
"private": false,
|
|
263
263
|
"packageAccess": "public",
|
|
264
264
|
"peerDependencies": {
|
|
265
|
-
"@cratis/components": "4.42.
|
|
265
|
+
"@cratis/components": "4.42.1",
|
|
266
266
|
"primereact": ">=10.9.9 <11",
|
|
267
267
|
"react": "^19.0.0",
|
|
268
268
|
"react-dom": "^19.0.0"
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import type { ButtonHTMLAttributes, HTMLAttributes, ReactNode } from 'react';
|
|
2
2
|
import type { ChatConversationLabels, ChatConversationProps } from './ChatConversation.js';
|
|
3
|
-
import {
|
|
3
|
+
import type { ChatIdentifier } from './ChatIdentifier.js';
|
|
4
4
|
import type { ChatMention } from './ChatMention.js';
|
|
5
5
|
import type { ChatMessage } from './ChatMessage.js';
|
|
6
6
|
import type { ChatTopic } from './ChatTopic.js';
|
|
@@ -148,6 +148,6 @@ export interface ChatSidebarProps<TMessage extends ChatMessage = ChatMessage, TT
|
|
|
148
148
|
* a name through {@link ChatSidebarProps.onRequestTopicName | onRequestTopicName} — rendering a
|
|
149
149
|
* pending placeholder until the name arrives.
|
|
150
150
|
*/
|
|
151
|
-
export declare const ChatSidebar: <TMessage extends ChatMessage = ChatMessage, TTopic extends ChatTopic = ChatTopic>({ open, onClose, topics, messages, topicActions, renderHeaderActions, topicsStatus, messagesStatus, selectedTopicId, onTopicSelected, onStartTopic, onSendMessage, onRequestTopicName, isTopicUnnamed, position, width, modal, labels, className, pt, ...conversation }: ChatSidebarProps<TMessage, TTopic>) =>
|
|
151
|
+
export declare const ChatSidebar: <TMessage extends ChatMessage = ChatMessage, TTopic extends ChatTopic = ChatTopic>({ open, onClose, topics, messages, topicActions, renderHeaderActions, topicsStatus, messagesStatus, selectedTopicId, onTopicSelected, onStartTopic, onSendMessage, onRequestTopicName, isTopicUnnamed, position, width, modal, labels, className, pt, ...conversation }: ChatSidebarProps<TMessage, TTopic>) => import("react").JSX.Element;
|
|
152
152
|
export {};
|
|
153
153
|
//# sourceMappingURL=ChatSidebar.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ChatSidebar.d.ts","sourceRoot":"","sources":["../../../Chat/ChatSidebar.tsx"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"ChatSidebar.d.ts","sourceRoot":"","sources":["../../../Chat/ChatSidebar.tsx"],"names":[],"mappings":"AAGA,OAAO,KAAK,EAAE,oBAAoB,EAAE,cAAc,EAAE,SAAS,EAAE,MAAM,OAAO,CAAC;AAC7E,OAAO,KAAK,EAAE,sBAAsB,EAAE,qBAAqB,EAAE,MAAM,uBAAoB,CAAC;AACxF,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,qBAAkB,CAAC;AACvD,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,kBAAe,CAAC;AACjD,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,kBAAe,CAAC;AACjD,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,gBAAa,CAAC;AAC7C,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,sBAAmB,CAAC;AACzD,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,iBAAc,CAAC;AAC/C,OAAO,KAAK,EAAE,mBAAmB,EAAE,MAAM,oBAAiB,CAAC;AAS3D,KAAK,yBAAyB,CAAC,QAAQ,IAAI,cAAc,CAAC,QAAQ,CAAC,GAAG;IAClE,CAAC,SAAS,EAAE,QAAQ,MAAM,EAAE,GAAG,MAAM,GAAG,MAAM,GAAG,OAAO,GAAG,SAAS,CAAC;CACxE,CAAC;AAEF,KAAK,2BAA2B,GAAG,IAAI,CACnC,oBAAoB,CAAC,iBAAiB,CAAC,EACvC,SAAS,GAAG,MAAM,CACrB,CAAC;AAEF,mEAAmE;AACnE,MAAM,WAAW,gBAAgB;IAC7B,wHAAwH;IACxH,QAAQ,CAAC,EAAE,yBAAyB,CAAC,cAAc,CAAC,CAAC;IACrD,gCAAgC;IAChC,IAAI,CAAC,EAAE,yBAAyB,CA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,EAC1C,MAAM,SAAS,SAAS,GAAG,SAAS,2QAuBrC,gBAAgB,CAAC,QAAQ,EAAE,MAAM,CAAC,gCA6DpC,CAAC"}
|
|
@@ -1,106 +1,26 @@
|
|
|
1
1
|
import { jsxs, Fragment, jsx } from 'react/jsx-runtime';
|
|
2
|
-
import {
|
|
3
|
-
import {
|
|
4
|
-
import {
|
|
5
|
-
import {
|
|
6
|
-
import {
|
|
7
|
-
import { ChatTopicList } from './ChatTopicList.js';
|
|
8
|
-
import { isTopicUnnamed } from './isTopicUnnamed.js';
|
|
9
|
-
import { shouldRequestTopicName } from './shouldRequestTopicName.js';
|
|
10
|
-
import { useCratisIcon } from '../configuration/useCratisIcon.js';
|
|
11
|
-
import { unstable_useOverlayEnvironment } from '../renderer/RendererContext.js';
|
|
12
|
-
import { classNames } from '../ClassNames/classNames.js';
|
|
2
|
+
import { ChatSidebarContent } from './ChatSidebarContent.js';
|
|
3
|
+
import { ChatSidebarHeader } from './ChatSidebarHeader.js';
|
|
4
|
+
import { ModalChatSidebar, NonModalChatSidebar } from './ChatSidebarShells.js';
|
|
5
|
+
import { useNonModalPhase } from './useNonModalPhase.js';
|
|
6
|
+
import { useTopicSelection } from './useTopicSelection.js';
|
|
13
7
|
|
|
14
|
-
const
|
|
15
|
-
const
|
|
16
|
-
const
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
return;
|
|
31
|
-
if (!modal && (window.matchMedia?.('(prefers-reduced-motion: reduce)').matches ||
|
|
32
|
-
nonModalPanel.current?.getAnimations?.().length === 0)) {
|
|
33
|
-
setNonModalPhase(nonModalPhase === 'entering' ? 'open' : 'closed');
|
|
34
|
-
return;
|
|
35
|
-
}
|
|
36
|
-
const timeout = setTimeout(() => {
|
|
37
|
-
setNonModalPhase(nonModalPhase === 'entering' ? 'open' : 'closed');
|
|
38
|
-
}, 250);
|
|
39
|
-
return () => clearTimeout(timeout);
|
|
40
|
-
}, [modal, nonModalPhase, portalContainer]);
|
|
41
|
-
const [internalSelectedId, setInternalSelectedId] = useState();
|
|
42
|
-
const isControlled = selectedTopicId !== undefined;
|
|
43
|
-
const openTopicId = isControlled
|
|
44
|
-
? (selectedTopicId ?? undefined)
|
|
45
|
-
: internalSelectedId;
|
|
46
|
-
const openTopic = openTopicId === undefined
|
|
47
|
-
? undefined
|
|
48
|
-
: topics.find((topic) => sameChatIdentifier(topic.id, openTopicId));
|
|
49
|
-
const unnamed = isTopicUnnamed$1 ?? isTopicUnnamed;
|
|
50
|
-
const select = (topicId, topic) => {
|
|
51
|
-
if (!isControlled) {
|
|
52
|
-
setInternalSelectedId(topicId);
|
|
53
|
-
}
|
|
54
|
-
onTopicSelected?.(topicId, topic ??
|
|
55
|
-
(topicId === undefined
|
|
56
|
-
? undefined
|
|
57
|
-
: topics.find((candidate) => sameChatIdentifier(candidate.id, topicId))));
|
|
58
|
-
};
|
|
59
|
-
const startTopic = async () => {
|
|
60
|
-
const topicId = await onStartTopic?.();
|
|
61
|
-
if (topicId !== undefined) {
|
|
62
|
-
select(topicId);
|
|
63
|
-
}
|
|
64
|
-
};
|
|
65
|
-
const openMessages = openTopicId === undefined
|
|
66
|
-
? []
|
|
67
|
-
: messages.filter((message) => sameChatIdentifier(message.topicId, openTopicId));
|
|
68
|
-
const send = (body, mentions) => {
|
|
69
|
-
if (openTopicId === undefined)
|
|
70
|
-
return;
|
|
71
|
-
onSendMessage(openTopicId, body, mentions);
|
|
72
|
-
if (openTopic &&
|
|
73
|
-
shouldRequestTopicName(unnamed(openTopic), openMessages.length)) {
|
|
74
|
-
onRequestTopicName?.(openTopic, body);
|
|
75
|
-
}
|
|
76
|
-
};
|
|
77
|
-
const title = openTopicId === undefined
|
|
78
|
-
? (labels?.topics ?? 'Topics')
|
|
79
|
-
: openTopic && !unnamed(openTopic)
|
|
80
|
-
? openTopic.name
|
|
81
|
-
: (labels?.unnamedTopic ?? 'New topic');
|
|
82
|
-
const titleIsPending = openTopicId !== undefined && (!openTopic || unnamed(openTopic));
|
|
83
|
-
const panel = (jsxs(Fragment, { children: [jsxs("header", { ...pt?.header, className: classNames('cratis-chat-sidebar__header', pt?.header?.className), "data-cratis-part": 'header', children: [openTopicId !== undefined && (jsx("button", { ...pt?.back, type: 'button', className: classNames('cratis-chat-sidebar__back', pt?.back?.className), "data-cratis-part": 'back', title: labels?.back ?? 'Back to topics', "aria-label": labels?.back ?? 'Back to topics', onClick: () => select(undefined), children: jsx(BackIcon, {}) })), jsx("h2", { ...pt?.title, className: classNames('cratis-chat-sidebar__title', titleIsPending
|
|
84
|
-
? 'cratis-chat-sidebar__title--pending'
|
|
85
|
-
: undefined, pt?.title?.className), "data-cratis-part": 'title', children: title }), renderHeaderActions?.(openTopic), jsx("button", { ...pt?.close, type: 'button', className: classNames('cratis-chat-sidebar__close', pt?.close?.className), "data-cratis-part": 'close', "aria-label": labels?.close ?? 'Close chat', onClick: onClose, children: jsx("span", { "aria-hidden": 'true', children: icon('close', '×') }) })] }), jsx("div", { ...pt?.content, className: classNames('cratis-chat-sidebar__content', pt?.content?.className), "data-cratis-part": 'content', children: openTopicId === undefined ? (jsx(ChatTopicList, { topics: topics, topicActions: topicActions, status: topicsStatus, onOpen: (topic) => select(topic.id, topic), onStart: onStartTopic
|
|
86
|
-
? () => {
|
|
87
|
-
void startTopic();
|
|
88
|
-
}
|
|
89
|
-
: undefined, authorOf: conversation.authorOf, renderAvatar: conversation.renderAvatar, isTopicUnnamed: isTopicUnnamed$1, buildAvatarUrl: conversation.buildAvatarUrl, labels: {
|
|
90
|
-
unnamedTopic: labels?.unnamedTopic,
|
|
91
|
-
...labels?.topicList,
|
|
92
|
-
} })) : (jsx(ChatConversation, { ...conversation, messages: openMessages, status: messagesStatus, onSendMessage: send, labels: labels?.conversation })) })] }));
|
|
93
|
-
return modal ? (jsx(ModalOverlay, { ...pt?.backdrop, isOpen: open, onOpenChange: (openState) => {
|
|
94
|
-
if (!openState)
|
|
95
|
-
onClose();
|
|
96
|
-
}, isDismissable: modal, isKeyboardDismissDisabled: !modal, className: classNames('cratis-chat-sidebar__backdrop', pt?.backdrop?.className), "data-cratis-part": 'backdrop', "data-modal": modal, "data-open": open || undefined, "data-selected": openTopicId !== undefined || undefined, children: jsx(Modal, { ...pt?.root, className: classNames('cratis-chat-sidebar', pt?.root?.className, className), style: { width, ...pt?.root?.style }, "data-cratis-part": 'root', "data-cratis-component": 'ChatSidebar', "data-position": position, "data-open": open || undefined, "data-selected": openTopicId !== undefined || undefined, children: panel }) })) : (nonModalPhase !== 'closed' &&
|
|
97
|
-
portalContainer &&
|
|
98
|
-
createPortal(jsx("div", { ...pt?.backdrop, className: classNames('cratis-chat-sidebar__backdrop', pt?.backdrop?.className), "data-cratis-part": 'backdrop', "data-modal": false, "data-open": open || undefined, "data-selected": openTopicId !== undefined || undefined, "data-entering": nonModalPhase === 'entering' || undefined, "data-exiting": nonModalPhase === 'exiting' || undefined, children: jsx("div", { ...pt?.root, ref: nonModalPanel, className: classNames('cratis-chat-sidebar', pt?.root?.className, className), style: { width, ...pt?.root?.style }, "data-cratis-part": 'root', "data-cratis-component": 'ChatSidebar', "data-position": position, "data-open": open || undefined, "data-selected": openTopicId !== undefined || undefined, "data-entering": nonModalPhase === 'entering' || undefined, "data-exiting": nonModalPhase === 'exiting' || undefined, onAnimationEnd: (event) => {
|
|
99
|
-
pt?.root?.onAnimationEnd?.(event);
|
|
100
|
-
if (event.target !== event.currentTarget)
|
|
101
|
-
return;
|
|
102
|
-
setNonModalPhase((phase) => phase === 'entering' ? 'open' : phase === 'exiting' ? 'closed' : phase);
|
|
103
|
-
}, children: panel }) }), portalContainer));
|
|
8
|
+
const ChatSidebar = ({ open, onClose, topics, messages, topicActions, renderHeaderActions, topicsStatus, messagesStatus, selectedTopicId, onTopicSelected, onStartTopic, onSendMessage, onRequestTopicName, isTopicUnnamed, position = 'right', width = '24rem', modal = false, labels, className, pt, ...conversation }) => {
|
|
9
|
+
const nonModal = useNonModalPhase(open, modal);
|
|
10
|
+
const selection = useTopicSelection({
|
|
11
|
+
topics,
|
|
12
|
+
messages,
|
|
13
|
+
selectedTopicId,
|
|
14
|
+
onTopicSelected,
|
|
15
|
+
onStartTopic,
|
|
16
|
+
onSendMessage,
|
|
17
|
+
onRequestTopicName,
|
|
18
|
+
isTopicUnnamed,
|
|
19
|
+
});
|
|
20
|
+
const { openTopicId, openTopic, select } = selection;
|
|
21
|
+
const panel = (jsxs(Fragment, { children: [jsx(ChatSidebarHeader, { openTopicId: openTopicId, openTopic: openTopic, unnamed: selection.unnamed, headerActions: renderHeaderActions?.(openTopic), labels: labels, pt: pt, onBack: () => select(undefined), onClose: onClose }), jsx(ChatSidebarContent, { openTopicId: openTopicId, openMessages: selection.openMessages, topics: topics, topicActions: topicActions, topicsStatus: topicsStatus, messagesStatus: messagesStatus, isTopicUnnamed: isTopicUnnamed, conversation: conversation, labels: labels, pt: pt, onOpenTopic: (topic) => select(topic.id, topic), onStart: selection.onStart, onSend: selection.send })] }));
|
|
22
|
+
const shell = { open, hasOpenTopic: openTopicId !== undefined, position, width, className, pt };
|
|
23
|
+
return modal ? (jsx(ModalChatSidebar, { ...shell, onClose: onClose, children: panel })) : (jsx(NonModalChatSidebar, { ...shell, phase: nonModal.phase, panelRef: nonModal.panelRef, portalContainer: nonModal.portalContainer, onPhaseSettled: nonModal.setPhase, children: panel }));
|
|
104
24
|
};
|
|
105
25
|
|
|
106
26
|
export { ChatSidebar };
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ChatSidebar.js","sources":["../../../Chat/ChatSidebar.tsx"],"sourcesContent":["// Copyright (c) Cratis. All rights reserved.\n// Licensed under the MIT license. See LICENSE file in the project root for full license information.\n\nimport { useEffect, useRef, useState } from 'react';\nimport type { ButtonHTMLAttributes, HTMLAttributes, ReactNode } from 'react';\nimport { createPortal } from 'react-dom';\nimport { Modal, ModalOverlay } from 'react-aria-components';\nimport type { ChatConversationLabels, ChatConversationProps } from './ChatConversation';\nimport { ChatConversation } from './ChatConversation';\nimport { sameChatIdentifier, type ChatIdentifier } from './ChatIdentifier';\nimport type { ChatMention } from './ChatMention';\nimport type { ChatMessage } from './ChatMessage';\nimport type { ChatTopic } from './ChatTopic';\nimport type { ChatTopicAction } from './ChatTopicAction';\nimport type { ChatStatus } from './ChatStatus';\nimport type { ChatTopicListLabels } from './ChatTopicList';\nimport { ChatTopicList } from './ChatTopicList';\nimport { isTopicUnnamed as defaultIsTopicUnnamed } from './isTopicUnnamed';\nimport { shouldRequestTopicName } from './shouldRequestTopicName';\nimport { useCratisIcon } from '../configuration/useCratisIcon';\nimport { unstable_useOverlayEnvironment } from '../renderer/RendererContext';\nimport type { ExactPartKeys } from '../types/ExactPartKeys';\nimport type { PartsOf } from '../types/parts';\nimport { classNames } from '../ClassNames/classNames';\n\ntype ChatSidebarPartAttributes<TElement> = HTMLAttributes<TElement> & {\n [attribute: `data-${string}`]: string | number | boolean | undefined;\n};\n\ntype ChatSidebarButtonAttributes = Omit<\n ButtonHTMLAttributes<HTMLButtonElement>,\n 'onClick' | 'type'\n>;\n\n/** Stable Cratis-owned parts for styling a {@link ChatSidebar}. */\nexport interface ChatSidebarParts {\n /** Viewport overlay layer the sidebar portals into — only paints/blocks when {@link ChatSidebarProps.modal} is true. */\n backdrop?: ChatSidebarPartAttributes<HTMLDivElement>;\n /** The sidebar panel itself. */\n root?: ChatSidebarPartAttributes<HTMLDivElement>;\n /** Header containing the back affordance, title, and close button. */\n header?: ChatSidebarPartAttributes<HTMLElement>;\n /** The topic list title, or the open topic's name. */\n title?: ChatSidebarPartAttributes<HTMLHeadingElement>;\n /** Back-to-topics button, present only while a topic is open. */\n back?: ChatSidebarButtonAttributes;\n /** Close button. */\n close?: ChatSidebarButtonAttributes;\n /** The topic list / conversation content region. */\n content?: ChatSidebarPartAttributes<HTMLDivElement>;\n}\n\nconst chatSidebarPartsMatchManifest: ExactPartKeys<\n ChatSidebarParts,\n PartsOf<'ChatSidebar'>\n> = true;\nvoid chatSidebarPartsMatchManifest;\n\n/** Overrides for every label the {@link ChatSidebar} and its children render. Any field left\n * unset falls back to a literal English default. */\nexport interface ChatSidebarLabels {\n /** The sidebar's title while the topic list is showing. Defaults to `'Topics'`. */\n topics?: string;\n\n /** Placeholder title for a topic that has not been named yet. Defaults to `'New topic'`. */\n unnamedTopic?: string;\n\n /** Tooltip/accessible label for the back-to-topics button. Defaults to `'Back to topics'`. */\n back?: string;\n\n /** Accessible label for the close button. Defaults to `'Close chat'`. */\n close?: string;\n\n /** Labels forwarded to the {@link ChatTopicList}. */\n topicList?: ChatTopicListLabels;\n\n /** Labels forwarded to the {@link ChatConversation}. */\n conversation?: ChatConversationLabels;\n}\n\n/**\n * Props for {@link ChatSidebar}.\n * @typeParam TMessage The host's message type — anything extending {@link ChatMessage}.\n * @typeParam TTopic The host's topic type — anything extending {@link ChatTopic}.\n */\nexport interface ChatSidebarProps<\n TMessage extends ChatMessage = ChatMessage,\n TTopic extends ChatTopic = ChatTopic,\n> extends Omit<\n ChatConversationProps<TMessage>,\n 'messages' | 'onSendMessage' | 'labels' | 'className' | 'status'\n> {\n /**\n * Renders host content in the header, between the title and the close button, for example a\n * rename control for the open topic. Nothing is rendered when it returns null or undefined.\n * @param openTopic The open topic, or undefined while the topic list is shown.\n * @returns What to render in the header.\n */\n renderHeaderActions?: (openTopic: TTopic | undefined) => ReactNode;\n\n /** Whether the sidebar is open. */\n open: boolean;\n\n /** Invoked when the sidebar asks to close — the host owns {@link open}, so closing means the host flips it. */\n onClose: () => void;\n\n /**\n * The topics, in any order. Hand this the array a live (observable) query delivers and the\n * sidebar re-renders as it changes.\n */\n topics: TTopic[];\n\n /**\n * The messages — either the whole chat or just the open topic's; the sidebar shows those of\n * the open topic by matching on `topicId` either way. Hand this the array a live\n * (observable) query delivers and the conversation re-renders as it changes.\n */\n messages: TMessage[];\n\n /** The host's actions to offer on each topic where they are available. The inherited `actions` prop applies only to messages. */\n topicActions?: ChatTopicAction<TTopic>[];\n\n /** Topic-list query display state. Defaults to ready when omitted. */\n topicsStatus?: ChatStatus;\n\n /** Conversation query display state. Defaults to ready when omitted. */\n messagesStatus?: ChatStatus;\n\n /**\n * The open topic, for hosts that own the selection themselves: an identifier opens that\n * topic's conversation, `null` shows the topic list, and leaving the prop unset lets the\n * sidebar keep the selection internally.\n */\n selectedTopicId?: ChatIdentifier | null;\n\n /**\n * Invoked when the open topic changes — a topic was opened (or just started), or the person\n * went back to the list.\n * @param topicId The identifier of the topic now open, or undefined for the list.\n * @param topic The topic itself, when it is known in {@link topics}.\n */\n onTopicSelected?: (topicId: ChatIdentifier | undefined, topic?: TTopic) => void;\n\n /**\n * Invoked when a new topic is asked for. Creating the topic is the host's business; answer\n * with its identifier (directly or through a promise) and the sidebar opens it, ready for\n * the first message. Omit to leave the new-topic affordance off.\n * @returns The identifier of the topic that was started, when the host created one.\n */\n onStartTopic?: () => ChatIdentifier | undefined | Promise<ChatIdentifier | undefined>;\n\n /**\n * Invoked when a message is sent, with the topic it belongs to, the trimmed body and who it\n * mentions. Everything else about persisting the message is the host's business.\n * @param topicId The identifier of the topic the message was sent in.\n * @param body The message text, mentions written into it as plain `@Name`.\n * @param mentions Who the body mentions.\n */\n onSendMessage: (\n topicId: ChatIdentifier,\n body: string,\n mentions: ChatMention[],\n ) => void;\n\n /**\n * Invoked when the very first message is sent in a topic that has no name yet — the host\n * asks its LLM (or whatever it prefers) for a good name and supplies it through the topic\n * data; until then the topic renders its pending placeholder. Not invoked again for later\n * messages, and never for a topic that already has a name.\n * @param topic The topic that needs a name.\n * @param firstMessageBody The message to derive the name from.\n */\n onRequestTopicName?: (topic: TTopic, firstMessageBody: string) => void;\n\n /**\n * Decides whether a topic counts as unnamed — see {@link ChatTopicListProps.isTopicUnnamed}.\n * @param topic The topic to check.\n * @returns True when the topic has no usable name yet.\n */\n isTopicUnnamed?: (topic: TTopic) => boolean;\n\n /** Which edge the sidebar opens from. Defaults to `'right'`. */\n position?: 'left' | 'right';\n\n /** The sidebar's width, any CSS length. Defaults to `'24rem'`. */\n width?: string;\n\n /**\n * Whether the sidebar is modal — a backdrop behind it, and dismissing by Escape or clicking\n * outside. Defaults to false: a chat lives *next to* the work, so it should not block it —\n * the background stays visible and interactive, and only the close/back affordances dismiss it.\n */\n modal?: boolean;\n\n /** Overrides for every label rendered. Unset fields fall back to literal English defaults. */\n labels?: ChatSidebarLabels;\n\n /** Additional class name for the sidebar's panel element. */\n className?: string;\n\n /** Cratis-owned per-part attributes. */\n pt?: ChatSidebarParts;\n}\n\nconst BackIcon = () => (\n <svg\n width='14'\n height='14'\n viewBox='0 0 24 24'\n fill='none'\n stroke='currentColor'\n strokeWidth='2.5'\n aria-hidden='true'\n >\n <line x1='19' y1='12' x2='5' y2='12' />\n <polyline points='12 19 5 12 12 5' />\n </svg>\n);\n\n/**\n * A topic-based chat in a sidebar next to the view, built on Components' own overlay primitives\n * (React Aria internally, for accessible dismissal and focus handling). It opens on the topic\n * list; picking a topic (or starting a new one) slides into that conversation, with a back\n * affordance to the list. Everything about *data* is the host's: topics and messages come in as\n * arrays (hand it live query data and it stays current), sends and new topics go out as\n * callbacks, and when the first message lands in an unnamed topic the sidebar asks the host for\n * a name through {@link ChatSidebarProps.onRequestTopicName | onRequestTopicName} — rendering a\n * pending placeholder until the name arrives.\n */\nexport const ChatSidebar = <\n TMessage extends ChatMessage = ChatMessage,\n TTopic extends ChatTopic = ChatTopic,\n>({\n open,\n onClose,\n topics,\n messages,\n topicActions,\n renderHeaderActions,\n topicsStatus,\n messagesStatus,\n selectedTopicId,\n onTopicSelected,\n onStartTopic,\n onSendMessage,\n onRequestTopicName,\n isTopicUnnamed,\n position = 'right',\n width = '24rem',\n modal = false,\n labels,\n className,\n pt,\n ...conversation\n}: ChatSidebarProps<TMessage, TTopic>) => {\n const icon = useCratisIcon();\n const overlayEnvironment = unstable_useOverlayEnvironment();\n const [mounted, setMounted] = useState(false);\n const nonModalPanel = useRef<HTMLDivElement>(null);\n const [nonModalPhase, setNonModalPhase] = useState<\n 'closed' | 'entering' | 'open' | 'exiting'\n >('closed');\n\n useEffect(() => setMounted(true), []);\n useEffect(() => {\n setNonModalPhase((phase) =>\n open ? 'entering' : phase === 'closed' ? 'closed' : 'exiting',\n );\n }, [open]);\n const portalContainer = !modal && mounted && nonModalPhase !== 'closed'\n ? overlayEnvironment.getContainer()\n : null;\n useEffect(() => {\n if (nonModalPhase !== 'entering' && nonModalPhase !== 'exiting') return;\n if (!modal && (\n window.matchMedia?.('(prefers-reduced-motion: reduce)').matches ||\n nonModalPanel.current?.getAnimations?.().length === 0\n )) {\n setNonModalPhase(nonModalPhase === 'entering' ? 'open' : 'closed');\n return;\n }\n const timeout = setTimeout(() => {\n setNonModalPhase(nonModalPhase === 'entering' ? 'open' : 'closed');\n }, 250);\n return () => clearTimeout(timeout);\n }, [modal, nonModalPhase, portalContainer]);\n\n const [internalSelectedId, setInternalSelectedId] = useState<\n ChatIdentifier | undefined\n >();\n const isControlled = selectedTopicId !== undefined;\n const openTopicId = isControlled\n ? (selectedTopicId ?? undefined)\n : internalSelectedId;\n const openTopic =\n openTopicId === undefined\n ? undefined\n : topics.find((topic) => sameChatIdentifier(topic.id, openTopicId));\n const unnamed = isTopicUnnamed ?? defaultIsTopicUnnamed;\n\n const select = (topicId: ChatIdentifier | undefined, topic?: TTopic) => {\n if (!isControlled) {\n setInternalSelectedId(topicId);\n }\n onTopicSelected?.(\n topicId,\n topic ??\n (topicId === undefined\n ? undefined\n : topics.find((candidate) =>\n sameChatIdentifier(candidate.id, topicId),\n )),\n );\n };\n\n const startTopic = async () => {\n const topicId = await onStartTopic?.();\n if (topicId !== undefined) {\n select(topicId);\n }\n };\n\n const openMessages =\n openTopicId === undefined\n ? []\n : messages.filter((message) =>\n sameChatIdentifier(message.topicId, openTopicId),\n );\n\n const send = (body: string, mentions: ChatMention[]) => {\n if (openTopicId === undefined) return;\n onSendMessage(openTopicId, body, mentions);\n if (\n openTopic &&\n shouldRequestTopicName(unnamed(openTopic), openMessages.length)\n ) {\n onRequestTopicName?.(openTopic, body);\n }\n };\n\n const title =\n openTopicId === undefined\n ? (labels?.topics ?? 'Topics')\n : openTopic && !unnamed(openTopic)\n ? openTopic.name\n : (labels?.unnamedTopic ?? 'New topic');\n const titleIsPending =\n openTopicId !== undefined && (!openTopic || unnamed(openTopic));\n\n const panel = (\n <>\n <header\n {...pt?.header}\n className={classNames(\n 'cratis-chat-sidebar__header',\n pt?.header?.className,\n )}\n data-cratis-part='header'\n >\n {openTopicId !== undefined && (\n <button\n {...pt?.back}\n type='button'\n className={classNames(\n 'cratis-chat-sidebar__back',\n pt?.back?.className,\n )}\n data-cratis-part='back'\n title={labels?.back ?? 'Back to topics'}\n aria-label={labels?.back ?? 'Back to topics'}\n onClick={() => select(undefined)}\n >\n <BackIcon />\n </button>\n )}\n <h2\n {...pt?.title}\n className={classNames(\n 'cratis-chat-sidebar__title',\n titleIsPending\n ? 'cratis-chat-sidebar__title--pending'\n : undefined,\n pt?.title?.className,\n )}\n data-cratis-part='title'\n >\n {title}\n </h2>\n {renderHeaderActions?.(openTopic)}\n <button\n {...pt?.close}\n type='button'\n className={classNames(\n 'cratis-chat-sidebar__close',\n pt?.close?.className,\n )}\n data-cratis-part='close'\n aria-label={labels?.close ?? 'Close chat'}\n onClick={onClose}\n >\n <span aria-hidden='true'>{icon('close', '×')}</span>\n </button>\n </header>\n <div\n {...pt?.content}\n className={classNames(\n 'cratis-chat-sidebar__content',\n pt?.content?.className,\n )}\n data-cratis-part='content'\n >\n {openTopicId === undefined ? (\n <ChatTopicList<TTopic>\n topics={topics}\n topicActions={topicActions}\n status={topicsStatus}\n onOpen={(topic) => select(topic.id, topic)}\n onStart={\n onStartTopic\n ? () => {\n void startTopic();\n }\n : undefined\n }\n authorOf={conversation.authorOf}\n renderAvatar={conversation.renderAvatar}\n isTopicUnnamed={isTopicUnnamed}\n buildAvatarUrl={conversation.buildAvatarUrl}\n labels={{\n unnamedTopic: labels?.unnamedTopic,\n ...labels?.topicList,\n }}\n />\n ) : (\n <ChatConversation<TMessage>\n {...conversation}\n messages={openMessages}\n status={messagesStatus}\n onSendMessage={send}\n labels={labels?.conversation}\n />\n )}\n </div>\n </>\n );\n\n return modal ? (\n <ModalOverlay\n {...pt?.backdrop}\n isOpen={open}\n onOpenChange={(openState) => {\n if (!openState) onClose();\n }}\n isDismissable={modal}\n isKeyboardDismissDisabled={!modal}\n className={classNames(\n 'cratis-chat-sidebar__backdrop',\n pt?.backdrop?.className,\n )}\n data-cratis-part='backdrop'\n data-modal={modal}\n data-open={open || undefined}\n data-selected={openTopicId !== undefined || undefined}\n >\n <Modal\n {...pt?.root}\n className={classNames(\n 'cratis-chat-sidebar',\n pt?.root?.className,\n className,\n )}\n style={{ width, ...pt?.root?.style }}\n data-cratis-part='root'\n data-cratis-component='ChatSidebar'\n data-position={position}\n data-open={open || undefined}\n data-selected={openTopicId !== undefined || undefined}\n >\n {panel}\n </Modal>\n </ModalOverlay>\n ) : (\n // Non-modal: a chat lives *next to* the work, so the background must stay visible and\n // interactive. React Aria's Modal blocks its backdrop by design (its dismissal props only\n // gate how it closes, never whether it intercepts), so the default is a plain portaled\n // layer with no dismissal behavior at all — only the close/back affordances dismiss it.\n nonModalPhase !== 'closed' &&\n portalContainer &&\n createPortal(\n <div\n {...pt?.backdrop}\n className={classNames(\n 'cratis-chat-sidebar__backdrop',\n pt?.backdrop?.className,\n )}\n data-cratis-part='backdrop'\n data-modal={false}\n data-open={open || undefined}\n data-selected={openTopicId !== undefined || undefined}\n data-entering={nonModalPhase === 'entering' || undefined}\n data-exiting={nonModalPhase === 'exiting' || undefined}\n >\n <div\n {...pt?.root}\n ref={nonModalPanel}\n className={classNames(\n 'cratis-chat-sidebar',\n pt?.root?.className,\n className,\n )}\n style={{ width, ...pt?.root?.style }}\n data-cratis-part='root'\n data-cratis-component='ChatSidebar'\n data-position={position}\n data-open={open || undefined}\n data-selected={openTopicId !== undefined || undefined}\n data-entering={nonModalPhase === 'entering' || undefined}\n data-exiting={nonModalPhase === 'exiting' || undefined}\n onAnimationEnd={(event) => {\n pt?.root?.onAnimationEnd?.(event);\n if (event.target !== event.currentTarget) return;\n setNonModalPhase((phase) =>\n phase === 'entering' ? 'open' : phase === 'exiting' ? 'closed' : phase,\n );\n }}\n >\n {panel}\n </div>\n </div>,\n portalContainer,\n )\n );\n};\n"],"names":["_jsxs","_jsx","isTopicUnnamed","defaultIsTopicUnnamed","_Fragment"],"mappings":";;;;;;;;;;;;;AA4MA,MAAM,QAAQ,GAAG,OACbA,IAAA,CAAA,KAAA,EAAA,EACI,KAAK,EAAC,IAAI,EACV,MAAM,EAAC,IAAI,EACX,OAAO,EAAC,WAAW,EACnB,IAAI,EAAC,MAAM,EACX,MAAM,EAAC,cAAc,EACrB,WAAW,EAAC,KAAK,EAAA,aAAA,EACL,MAAM,EAAA,QAAA,EAAA,CAElBC,GAAA,CAAA,MAAA,EAAA,EAAM,EAAE,EAAC,IAAI,EAAC,EAAE,EAAC,IAAI,EAAC,EAAE,EAAC,GAAG,EAAC,EAAE,EAAC,IAAI,EAAA,CAAG,EACvCA,GAAA,CAAA,UAAA,EAAA,EAAU,MAAM,EAAC,iBAAiB,EAAA,CAAG,CAAA,EAAA,CACnC,CACT;AAYM,MAAM,WAAW,GAAG,CAGzB,EACE,IAAI,EACJ,OAAO,EACP,MAAM,EACN,QAAQ,EACR,YAAY,EACZ,mBAAmB,EACnB,YAAY,EACZ,cAAc,EACd,eAAe,EACf,eAAe,EACf,YAAY,EACZ,aAAa,EACb,kBAAkB,kBAClBC,gBAAc,EACd,QAAQ,GAAG,OAAO,EAClB,KAAK,GAAG,OAAO,EACf,KAAK,GAAG,KAAK,EACb,MAAM,EACN,SAAS,EACT,EAAE,EACF,GAAG,YAAY,EACkB,KAAI;AACrC,IAAA,MAAM,IAAI,GAAG,aAAa,EAAE;AAC5B,IA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tsx"],"sourcesContent":["// Copyright (c) Cratis. All rights reserved.\n// Licensed under the MIT license. See LICENSE file in the project root for full license information.\n\nimport type { ButtonHTMLAttributes, HTMLAttributes, ReactNode } from 'react';\nimport type { ChatConversationLabels, ChatConversationProps } from './ChatConversation';\nimport type { ChatIdentifier } from './ChatIdentifier';\nimport type { ChatMention } from './ChatMention';\nimport type { ChatMessage } from './ChatMessage';\nimport type { ChatTopic } from './ChatTopic';\nimport type { ChatTopicAction } from './ChatTopicAction';\nimport type { ChatStatus } from './ChatStatus';\nimport type { ChatTopicListLabels } from './ChatTopicList';\nimport { ChatSidebarContent } from './ChatSidebarContent';\nimport { ChatSidebarHeader } from './ChatSidebarHeader';\nimport { ModalChatSidebar, NonModalChatSidebar } from './ChatSidebarShells';\nimport { useNonModalPhase } from './useNonModalPhase';\nimport { useTopicSelection } from './useTopicSelection';\nimport type { ExactPartKeys } from '../types/ExactPartKeys';\nimport type { PartsOf } from '../types/parts';\n\ntype ChatSidebarPartAttributes<TElement> = HTMLAttributes<TElement> & {\n [attribute: `data-${string}`]: string | number | boolean | undefined;\n};\n\ntype ChatSidebarButtonAttributes = Omit<\n ButtonHTMLAttributes<HTMLButtonElement>,\n 'onClick' | 'type'\n>;\n\n/** Stable Cratis-owned parts for styling a {@link ChatSidebar}. */\nexport interface ChatSidebarParts {\n /** Viewport overlay layer the sidebar portals into — only paints/blocks when {@link ChatSidebarProps.modal} is true. */\n backdrop?: ChatSidebarPartAttributes<HTMLDivElement>;\n /** The sidebar panel itself. */\n root?: ChatSidebarPartAttributes<HTMLDivElement>;\n /** Header containing the back affordance, title, and close button. */\n header?: ChatSidebarPartAttributes<HTMLElement>;\n /** The topic list title, or the open topic's name. */\n title?: ChatSidebarPartAttributes<HTMLHeadingElement>;\n /** Back-to-topics button, present only while a topic is open. */\n back?: ChatSidebarButtonAttributes;\n /** Close button. */\n close?: ChatSidebarButtonAttributes;\n /** The topic list / conversation content region. */\n content?: ChatSidebarPartAttributes<HTMLDivElement>;\n}\n\nconst chatSidebarPartsMatchManifest: ExactPartKeys<\n ChatSidebarParts,\n PartsOf<'ChatSidebar'>\n> = true;\nvoid chatSidebarPartsMatchManifest;\n\n/** Overrides for every label the {@link ChatSidebar} and its children render. Any field left\n * unset falls back to a literal English default. */\nexport interface ChatSidebarLabels {\n /** The sidebar's title while the topic list is showing. Defaults to `'Topics'`. */\n topics?: string;\n\n /** Placeholder title for a topic that has not been named yet. Defaults to `'New topic'`. */\n unnamedTopic?: string;\n\n /** Tooltip/accessible label for the back-to-topics button. Defaults to `'Back to topics'`. */\n back?: string;\n\n /** Accessible label for the close button. Defaults to `'Close chat'`. */\n close?: string;\n\n /** Labels forwarded to the {@link ChatTopicList}. */\n topicList?: ChatTopicListLabels;\n\n /** Labels forwarded to the {@link ChatConversation}. */\n conversation?: ChatConversationLabels;\n}\n\n/**\n * Props for {@link ChatSidebar}.\n * @typeParam TMessage The host's message type — anything extending {@link ChatMessage}.\n * @typeParam TTopic The host's topic type — anything extending {@link ChatTopic}.\n */\nexport interface ChatSidebarProps<\n TMessage extends ChatMessage = ChatMessage,\n TTopic extends ChatTopic = ChatTopic,\n> extends Omit<\n ChatConversationProps<TMessage>,\n 'messages' | 'onSendMessage' | 'labels' | 'className' | 'status'\n> {\n /**\n * Renders host content in the header, between the title and the close button, for example a\n * rename control for the open topic. Nothing is rendered when it returns null or undefined.\n * @param openTopic The open topic, or undefined while the topic list is shown.\n * @returns What to render in the header.\n */\n renderHeaderActions?: (openTopic: TTopic | undefined) => ReactNode;\n\n /** Whether the sidebar is open. */\n open: boolean;\n\n /** Invoked when the sidebar asks to close — the host owns {@link open}, so closing means the host flips it. */\n onClose: () => void;\n\n /**\n * The topics, in any order. Hand this the array a live (observable) query delivers and the\n * sidebar re-renders as it changes.\n */\n topics: TTopic[];\n\n /**\n * The messages — either the whole chat or just the open topic's; the sidebar shows those of\n * the open topic by matching on `topicId` either way. Hand this the array a live\n * (observable) query delivers and the conversation re-renders as it changes.\n */\n messages: TMessage[];\n\n /** The host's actions to offer on each topic where they are available. The inherited `actions` prop applies only to messages. */\n topicActions?: ChatTopicAction<TTopic>[];\n\n /** Topic-list query display state. Defaults to ready when omitted. */\n topicsStatus?: ChatStatus;\n\n /** Conversation query display state. Defaults to ready when omitted. */\n messagesStatus?: ChatStatus;\n\n /**\n * The open topic, for hosts that own the selection themselves: an identifier opens that\n * topic's conversation, `null` shows the topic list, and leaving the prop unset lets the\n * sidebar keep the selection internally.\n */\n selectedTopicId?: ChatIdentifier | null;\n\n /**\n * Invoked when the open topic changes — a topic was opened (or just started), or the person\n * went back to the list.\n * @param topicId The identifier of the topic now open, or undefined for the list.\n * @param topic The topic itself, when it is known in {@link topics}.\n */\n onTopicSelected?: (topicId: ChatIdentifier | undefined, topic?: TTopic) => void;\n\n /**\n * Invoked when a new topic is asked for. Creating the topic is the host's business; answer\n * with its identifier (directly or through a promise) and the sidebar opens it, ready for\n * the first message. Omit to leave the new-topic affordance off.\n * @returns The identifier of the topic that was started, when the host created one.\n */\n onStartTopic?: () => ChatIdentifier | undefined | Promise<ChatIdentifier | undefined>;\n\n /**\n * Invoked when a message is sent, with the topic it belongs to, the trimmed body and who it\n * mentions. Everything else about persisting the message is the host's business.\n * @param topicId The identifier of the topic the message was sent in.\n * @param body The message text, mentions written into it as plain `@Name`.\n * @param mentions Who the body mentions.\n */\n onSendMessage: (\n topicId: ChatIdentifier,\n body: string,\n mentions: ChatMention[],\n ) => void;\n\n /**\n * Invoked when the very first message is sent in a topic that has no name yet — the host\n * asks its LLM (or whatever it prefers) for a good name and supplies it through the topic\n * data; until then the topic renders its pending placeholder. Not invoked again for later\n * messages, and never for a topic that already has a name.\n * @param topic The topic that needs a name.\n * @param firstMessageBody The message to derive the name from.\n */\n onRequestTopicName?: (topic: TTopic, firstMessageBody: string) => void;\n\n /**\n * Decides whether a topic counts as unnamed — see {@link ChatTopicListProps.isTopicUnnamed}.\n * @param topic The topic to check.\n * @returns True when the topic has no usable name yet.\n */\n isTopicUnnamed?: (topic: TTopic) => boolean;\n\n /** Which edge the sidebar opens from. Defaults to `'right'`. */\n position?: 'left' | 'right';\n\n /** The sidebar's width, any CSS length. Defaults to `'24rem'`. */\n width?: string;\n\n /**\n * Whether the sidebar is modal — a backdrop behind it, and dismissing by Escape or clicking\n * outside. Defaults to false: a chat lives *next to* the work, so it should not block it —\n * the background stays visible and interactive, and only the close/back affordances dismiss it.\n */\n modal?: boolean;\n\n /** Overrides for every label rendered. Unset fields fall back to literal English defaults. */\n labels?: ChatSidebarLabels;\n\n /** Additional class name for the sidebar's panel element. */\n className?: string;\n\n /** Cratis-owned per-part attributes. */\n pt?: ChatSidebarParts;\n}\n\n/**\n * A topic-based chat in a sidebar next to the view, built on Components' own overlay primitives\n * (React Aria internally, for accessible dismissal and focus handling). It opens on the topic\n * list; picking a topic (or starting a new one) slides into that conversation, with a back\n * affordance to the list. Everything about *data* is the host's: topics and messages come in as\n * arrays (hand it live query data and it stays current), sends and new topics go out as\n * callbacks, and when the first message lands in an unnamed topic the sidebar asks the host for\n * a name through {@link ChatSidebarProps.onRequestTopicName | onRequestTopicName} — rendering a\n * pending placeholder until the name arrives.\n */\nexport const ChatSidebar = <\n TMessage extends ChatMessage = ChatMessage,\n TTopic extends ChatTopic = ChatTopic,\n>({\n open,\n onClose,\n topics,\n messages,\n topicActions,\n renderHeaderActions,\n topicsStatus,\n messagesStatus,\n selectedTopicId,\n onTopicSelected,\n onStartTopic,\n onSendMessage,\n onRequestTopicName,\n isTopicUnnamed,\n position = 'right',\n width = '24rem',\n modal = false,\n labels,\n className,\n pt,\n ...conversation\n}: ChatSidebarProps<TMessage, TTopic>) => {\n const nonModal = useNonModalPhase(open, modal);\n const selection = useTopicSelection<TMessage, TTopic>({\n topics,\n messages,\n selectedTopicId,\n onTopicSelected,\n onStartTopic,\n onSendMessage,\n onRequestTopicName,\n isTopicUnnamed,\n });\n const { openTopicId, openTopic, select } = selection;\n\n const panel = (\n <>\n <ChatSidebarHeader<TTopic>\n openTopicId={openTopicId}\n openTopic={openTopic}\n unnamed={selection.unnamed}\n headerActions={renderHeaderActions?.(openTopic)}\n labels={labels}\n pt={pt}\n onBack={() => select(undefined)}\n onClose={onClose}\n />\n <ChatSidebarContent<TMessage, TTopic>\n openTopicId={openTopicId}\n openMessages={selection.openMessages}\n topics={topics}\n topicActions={topicActions}\n topicsStatus={topicsStatus}\n messagesStatus={messagesStatus}\n isTopicUnnamed={isTopicUnnamed}\n conversation={conversation}\n labels={labels}\n pt={pt}\n onOpenTopic={(topic) => select(topic.id, topic)}\n onStart={selection.onStart}\n onSend={selection.send}\n />\n </>\n );\n\n const shell = { open, hasOpenTopic: openTopicId !== undefined, position, width, className, pt };\n\n return modal ? (\n <ModalChatSidebar {...shell} onClose={onClose}>\n {panel}\n </ModalChatSidebar>\n ) : (\n <NonModalChatSidebar\n {...shell}\n phase={nonModal.phase}\n panelRef={nonModal.panelRef}\n portalContainer={nonModal.portalContainer}\n onPhaseSettled={nonModal.setPhase}\n >\n {panel}\n </NonModalChatSidebar>\n );\n};\n"],"names":["_jsxs","_Fragment","_jsx"],"mappings":";;;;;;;AAiNO,MAAM,WAAW,GAAG,CAGzB,EACE,IAAI,EACJ,OAAO,EACP,MAAM,EACN,QAAQ,EACR,YAAY,EACZ,mBAAmB,EACnB,YAAY,EACZ,cAAc,EACd,eAAe,EACf,eAAe,EACf,YAAY,EACZ,aAAa,EACb,kBAAkB,EAClB,cAAc,EACd,QAAQ,GAAG,OAAO,EAClB,KAAK,GAAG,OAAO,EACf,KAAK,GAAG,KAAK,EACb,MAAM,EACN,SAAS,EACT,EAAE,EACF,GAAG,YAAY,EACkB,KAAI;IACrC,MAAM,QAAQ,GAAG,gBAAgB,CAAC,IAAI,EAAE,KAAK,CAAC;IAC9C,MAAM,SAAS,GAAG,iBAAiB,CAAmB;QAClD,MAAM;QACN,QAAQ;QACR,eAAe;QACf,eAAe;QACf,YAAY;QACZ,aAAa;QACb,kBAAkB;QAClB,cAAc;AACjB,KAAA,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AAK,EAAE,QAAQ,CAAC,KAAK,EACrB,QAAQ,EAAE,QAAQ,CAAC,QAAQ,EAC3B,eAAe,EAAE,QAAQ,CAAC,eAAe,EACzC,cAAc,EAAE,QAAQ,CAAC,QAAQ,EAAA,QAAA,EAEhC,KAAK,EAAA,CACY,CACzB;AACL;;"}
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
import type { ChatSidebarLabels, ChatSidebarParts, ChatSidebarProps } from './ChatSidebar.js';
|
|
2
|
+
import { type ChatConversationProps } from './ChatConversation.js';
|
|
3
|
+
import type { ChatIdentifier } from './ChatIdentifier.js';
|
|
4
|
+
import type { ChatMention } from './ChatMention.js';
|
|
5
|
+
import type { ChatMessage } from './ChatMessage.js';
|
|
6
|
+
import type { ChatTopic } from './ChatTopic.js';
|
|
7
|
+
type ConversationPassThrough<TMessage extends ChatMessage> = Omit<ChatConversationProps<TMessage>, 'messages' | 'onSendMessage' | 'labels' | 'className' | 'status'>;
|
|
8
|
+
interface ChatSidebarContentProps<TMessage extends ChatMessage, TTopic extends ChatTopic> {
|
|
9
|
+
openTopicId: ChatIdentifier | undefined;
|
|
10
|
+
openMessages: TMessage[];
|
|
11
|
+
topics: TTopic[];
|
|
12
|
+
topicActions: ChatSidebarProps<TMessage, TTopic>['topicActions'];
|
|
13
|
+
topicsStatus: ChatSidebarProps<TMessage, TTopic>['topicsStatus'];
|
|
14
|
+
messagesStatus: ChatSidebarProps<TMessage, TTopic>['messagesStatus'];
|
|
15
|
+
isTopicUnnamed: ChatSidebarProps<TMessage, TTopic>['isTopicUnnamed'];
|
|
16
|
+
conversation: ConversationPassThrough<TMessage>;
|
|
17
|
+
labels?: ChatSidebarLabels;
|
|
18
|
+
pt?: ChatSidebarParts;
|
|
19
|
+
onOpenTopic: (topic: TTopic) => void;
|
|
20
|
+
onStart?: () => void;
|
|
21
|
+
onSend: (body: string, mentions: ChatMention[]) => void;
|
|
22
|
+
}
|
|
23
|
+
export declare const ChatSidebarContent: <TMessage extends ChatMessage, TTopic extends ChatTopic>({ openTopicId, openMessages, topics, topicActions, topicsStatus, messagesStatus, isTopicUnnamed, conversation, labels, pt, onOpenTopic, onStart, onSend, }: ChatSidebarContentProps<TMessage, TTopic>) => import("react").JSX.Element;
|
|
24
|
+
export {};
|
|
25
|
+
//# sourceMappingURL=ChatSidebarContent.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"ChatSidebarContent.d.ts","sourceRoot":"","sources":["../../../Chat/ChatSidebarContent.tsx"],"names":[],"mappings":"AAIA,OAAO,KAAK,EAAE,iBAAiB,EAAE,gBAAgB,EAAE,gBAAgB,EAAE,MAAM,kBAAe,CAAC;AAC3F,OAAO,EAAoB,KAAK,qBAAqB,EAAE,MAAM,uBAAoB,CAAC;AAClF,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,qBAAkB,CAAC;AACvD,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,kBAAe,CAAC;AACjD,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,kBAAe,CAAC;AACjD,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,gBAAa,CAAC;AAG7C,KAAK,uBAAuB,CAAC,QAAQ,SAAS,WAAW,IAAI,IAAI,CAC7D,qBAAqB,CAAC,QAAQ,CAAC,EAC/B,UAAU,GAAG,eAAe,GAAG,QAAQ,GAAG,WAAW,GAAG,QAAQ,CACnE,CAAC;AAEF,UAAU,uBAAuB,CAAC,QAAQ,SAAS,WAAW,EAAE,MAAM,SAAS,SAAS;IACpF,WAAW,EAAE,cAAc,GAAG,SAAS,CAAC;IACxC,YAAY,EAAE,QAAQ,EAAE,CAAC;IACzB,MAAM,EAAE,MAAM,EAAE,CAAC;IACjB,YAAY,EAAE,gBAAgB,CAAC,QAAQ,EAAE,MAAM,CAAC,CAAC,cAAc,CAAC,CAAC;IACjE,YAAY,EAAE,gBAAgB,CAAC,QAAQ,EAAE,MAAM,CAAC,CAAC,cAAc,CAAC,CAAC;IACjE,cAAc,EAAE,gBAAgB,CAAC,QAAQ,EAAE,MAAM,CAAC,CAAC,gBAAgB,CAAC,CAAC;IACrE,cAAc,EAAE,gBAAgB,CAAC,QAAQ,EAAE,MAAM,CAAC,CAAC,gBAAgB,CAAC,CAAC;IACrE,YAAY,EAAE,uBAAuB,CAAC,QAAQ,CAAC,CAAC;IAChD,MAAM,CAAC,EAAE,iBAAiB,CAAC;IAC3B,EAAE,CAAC,EAAE,gBAAgB,CAAC;IACtB,WAAW,EAAE,CAAC,KAAK,EAAE,MAAM,KAAK,IAAI,CAAC;IACrC,OAAO,CAAC,EAAE,MAAM,IAAI,CAAC;IACrB,MAAM,EAAE,CAAC,IAAI,EAAE,MAAM,EAAE,QAAQ,EAAE,WAAW,EAAE,KAAK,IAAI,CAAC;CAC3D;AAED,eAAO,MAAM,kBAAkB,GAAI,QAAQ,SAAS,WAAW,EAAE,MAAM,SAAS,SAAS,8JActF,uBAAuB,CAAC,QAAQ,EAAE,MAAM,CAAC,gCAgC3C,CAAC"}
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import { jsx } from 'react/jsx-runtime';
|
|
2
|
+
import { classNames } from '../ClassNames/classNames.js';
|
|
3
|
+
import { ChatConversation } from './ChatConversation.js';
|
|
4
|
+
import { ChatTopicList } from './ChatTopicList.js';
|
|
5
|
+
|
|
6
|
+
const ChatSidebarContent = ({ openTopicId, openMessages, topics, topicActions, topicsStatus, messagesStatus, isTopicUnnamed, conversation, labels, pt, onOpenTopic, onStart, onSend, }) => (jsx("div", { ...pt?.content, className: classNames('cratis-chat-sidebar__content', pt?.content?.className), "data-cratis-part": 'content', children: openTopicId === undefined ? (jsx(ChatTopicList, { topics: topics, topicActions: topicActions, status: topicsStatus, onOpen: onOpenTopic, onStart: onStart, authorOf: conversation.authorOf, renderAvatar: conversation.renderAvatar, isTopicUnnamed: isTopicUnnamed, buildAvatarUrl: conversation.buildAvatarUrl, labels: {
|
|
7
|
+
unnamedTopic: labels?.unnamedTopic,
|
|
8
|
+
...labels?.topicList,
|
|
9
|
+
} })) : (jsx(ChatConversation, { ...conversation, messages: openMessages, status: messagesStatus, onSendMessage: onSend, labels: labels?.conversation })) }));
|
|
10
|
+
|
|
11
|
+
export { ChatSidebarContent };
|
|
12
|
+
//# sourceMappingURL=ChatSidebarContent.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"ChatSidebarContent.js","sources":["../../../Chat/ChatSidebarContent.tsx"],"sourcesContent":["// Copyright (c) Cratis. All rights reserved.\n// Licensed under the MIT license. See LICENSE file in the project root for full license information.\n\nimport { classNames } from '../ClassNames/classNames';\nimport type { ChatSidebarLabels, ChatSidebarParts, ChatSidebarProps } from './ChatSidebar';\nimport { ChatConversation, type ChatConversationProps } from './ChatConversation';\nimport type { ChatIdentifier } from './ChatIdentifier';\nimport type { ChatMention } from './ChatMention';\nimport type { ChatMessage } from './ChatMessage';\nimport type { ChatTopic } from './ChatTopic';\nimport { ChatTopicList } from './ChatTopicList';\n\ntype ConversationPassThrough<TMessage extends ChatMessage> = Omit<\n ChatConversationProps<TMessage>,\n 'messages' | 'onSendMessage' | 'labels' | 'className' | 'status'\n>;\n\ninterface ChatSidebarContentProps<TMessage extends ChatMessage, TTopic extends ChatTopic> {\n openTopicId: ChatIdentifier | undefined;\n openMessages: TMessage[];\n topics: TTopic[];\n topicActions: ChatSidebarProps<TMessage, TTopic>['topicActions'];\n topicsStatus: ChatSidebarProps<TMessage, TTopic>['topicsStatus'];\n messagesStatus: ChatSidebarProps<TMessage, TTopic>['messagesStatus'];\n isTopicUnnamed: ChatSidebarProps<TMessage, TTopic>['isTopicUnnamed'];\n conversation: ConversationPassThrough<TMessage>;\n labels?: ChatSidebarLabels;\n pt?: ChatSidebarParts;\n onOpenTopic: (topic: TTopic) => void;\n onStart?: () => void;\n onSend: (body: string, mentions: ChatMention[]) => void;\n}\n\nexport const ChatSidebarContent = <TMessage extends ChatMessage, TTopic extends ChatTopic>({\n openTopicId,\n openMessages,\n topics,\n topicActions,\n topicsStatus,\n messagesStatus,\n isTopicUnnamed,\n conversation,\n labels,\n pt,\n onOpenTopic,\n onStart,\n onSend,\n}: ChatSidebarContentProps<TMessage, TTopic>) => (\n <div\n {...pt?.content}\n className={classNames('cratis-chat-sidebar__content', pt?.content?.className)}\n data-cratis-part='content'\n >\n {openTopicId === undefined ? (\n <ChatTopicList<TTopic>\n topics={topics}\n topicActions={topicActions}\n status={topicsStatus}\n onOpen={onOpenTopic}\n onStart={onStart}\n authorOf={conversation.authorOf}\n renderAvatar={conversation.renderAvatar}\n isTopicUnnamed={isTopicUnnamed}\n buildAvatarUrl={conversation.buildAvatarUrl}\n labels={{\n unnamedTopic: labels?.unnamedTopic,\n ...labels?.topicList,\n }}\n />\n ) : (\n <ChatConversation<TMessage>\n {...conversation}\n messages={openMessages}\n status={messagesStatus}\n onSendMessage={onSend}\n labels={labels?.conversation}\n />\n )}\n </div>\n);\n"],"names":["_jsx"],"mappings":";;;;;AAiCO,MAAM,kBAAkB,GAAG,CAAyD,EACvF,WAAW,EACX,YAAY,EACZ,MAAM,EACN,YAAY,EACZ,YAAY,EACZ,cAAc,EACd,cAAc,EACd,YAAY,EACZ,MAAM,EACN,EAAE,EACF,WAAW,EACX,OAAO,EACP,MAAM,GACkC,MACxCA,GAAA,CAAA,KAAA,EAAA,EAAA,GACQ,EAAE,EAAE,OAAO,EACf,SAAS,EAAE,UAAU,CAAC,8BAA8B,EAAE,EAAE,EAAE,OAAO,EAAE,SAAS,CAAC,EAAA,kBAAA,EAC5D,SAAS,EAAA,QAAA,EAEzB,WAAW,KAAK,SAAS,IACtBA,GAAA,CAAC,aAAa,EAAA,EACV,MAAM,EAAE,MAAM,EACd,YAAY,EAAE,YAAY,EAC1B,MAAM,EAAE,YAAY,EACpB,MAAM,EAAE,WAAW,EACnB,OAAO,EAAE,OAAO,EAChB,QAAQ,EAAE,YAAY,CAAC,QAAQ,EAC/B,YAAY,EAAE,YAAY,CAAC,YAAY,EACvC,cAAc,EAAE,cAAc,EAC9B,cAAc,EAAE,YAAY,CAAC,cAAc,EAC3C,MAAM,EAAE;YACJ,YAAY,EAAE,MAAM,EAAE,YAAY;YAClC,GAAG,MAAM,EAAE,SAAS;AACvB,SAAA,EAAA,CACH,KAEFA,GAAA,CAAC,gBAAgB,EAAA,EAAA,GACT,YAAY,EAChB,QAAQ,EAAE,YAAY,EACtB,MAAM,EAAE,cAAc,EACtB,aAAa,EAAE,MAAM,EACrB,MAAM,EAAE,MAAM,EAAE,YAAY,EAAA,CAC9B,CACL,EAAA,CACC;;"}
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import type { ReactNode } from 'react';
|
|
2
|
+
import type { ChatSidebarLabels, ChatSidebarParts } from './ChatSidebar.js';
|
|
3
|
+
import type { ChatTopic } from './ChatTopic.js';
|
|
4
|
+
interface ChatSidebarHeaderProps<TTopic extends ChatTopic> {
|
|
5
|
+
openTopicId: unknown;
|
|
6
|
+
openTopic: TTopic | undefined;
|
|
7
|
+
unnamed: (topic: TTopic) => boolean;
|
|
8
|
+
headerActions: ReactNode;
|
|
9
|
+
labels?: ChatSidebarLabels;
|
|
10
|
+
pt?: ChatSidebarParts;
|
|
11
|
+
onBack: () => void;
|
|
12
|
+
onClose: () => void;
|
|
13
|
+
}
|
|
14
|
+
export declare const ChatSidebarHeader: <TTopic extends ChatTopic>({ openTopicId, openTopic, unnamed, headerActions, labels, pt, onBack, onClose, }: ChatSidebarHeaderProps<TTopic>) => import("react").JSX.Element;
|
|
15
|
+
export {};
|
|
16
|
+
//# sourceMappingURL=ChatSidebarHeader.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"ChatSidebarHeader.d.ts","sourceRoot":"","sources":["../../../Chat/ChatSidebarHeader.tsx"],"names":[],"mappings":"AAGA,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,OAAO,CAAC;AAGvC,OAAO,KAAK,EAAE,iBAAiB,EAAE,gBAAgB,EAAE,MAAM,kBAAe,CAAC;AACzE,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,gBAAa,CAAC;AAE7C,UAAU,sBAAsB,CAAC,MAAM,SAAS,SAAS;IACrD,WAAW,EAAE,OAAO,CAAC;IACrB,SAAS,EAAE,MAAM,GAAG,SAAS,CAAC;IAC9B,OAAO,EAAE,CAAC,KAAK,EAAE,MAAM,KAAK,OAAO,CAAC;IACpC,aAAa,EAAE,SAAS,CAAC;IACzB,MAAM,CAAC,EAAE,iBAAiB,CAAC;IAC3B,EAAE,CAAC,EAAE,gBAAgB,CAAC;IACtB,MAAM,EAAE,MAAM,IAAI,CAAC;IACnB,OAAO,EAAE,MAAM,IAAI,CAAC;CACvB;AAoFD,eAAO,MAAM,iBAAiB,GAAI,MAAM,SAAS,SAAS,oFASvD,sBAAsB,CAAC,MAAM,CAAC,gCAkBhC,CAAC"}
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
import { jsxs, jsx } from 'react/jsx-runtime';
|
|
2
|
+
import { classNames } from '../ClassNames/classNames.js';
|
|
3
|
+
import { useCratisIcon } from '../configuration/useCratisIcon.js';
|
|
4
|
+
|
|
5
|
+
const BackIcon = () => (jsxs("svg", { width: '14', height: '14', viewBox: '0 0 24 24', fill: 'none', stroke: 'currentColor', strokeWidth: '2.5', "aria-hidden": 'true', children: [jsx("line", { x1: '19', y1: '12', x2: '5', y2: '12' }), jsx("polyline", { points: '12 19 5 12 12 5' })] }));
|
|
6
|
+
const resolveTitle = (isListShown, openTopic, unnamed, labels) => {
|
|
7
|
+
if (isListShown)
|
|
8
|
+
return labels?.topics ?? 'Topics';
|
|
9
|
+
if (openTopic && !unnamed(openTopic))
|
|
10
|
+
return openTopic.name;
|
|
11
|
+
return labels?.unnamedTopic ?? 'New topic';
|
|
12
|
+
};
|
|
13
|
+
const BackButton = ({ label, pt, onClick }) => (jsx("button", { ...pt?.back, type: 'button', className: classNames('cratis-chat-sidebar__back', pt?.back?.className), "data-cratis-part": 'back', title: label ?? 'Back to topics', "aria-label": label ?? 'Back to topics', onClick: onClick, children: jsx(BackIcon, {}) }));
|
|
14
|
+
const CloseButton = ({ label, pt, onClick }) => {
|
|
15
|
+
const icon = useCratisIcon();
|
|
16
|
+
return (jsx("button", { ...pt?.close, type: 'button', className: classNames('cratis-chat-sidebar__close', pt?.close?.className), "data-cratis-part": 'close', "aria-label": label ?? 'Close chat', onClick: onClick, children: jsx("span", { "aria-hidden": 'true', children: icon('close', '×') }) }));
|
|
17
|
+
};
|
|
18
|
+
const Title = ({ isPending, pt, children }) => (jsx("h2", { ...pt?.title, className: classNames('cratis-chat-sidebar__title', isPending ? 'cratis-chat-sidebar__title--pending' : undefined, pt?.title?.className), "data-cratis-part": 'title', children: children }));
|
|
19
|
+
const ChatSidebarHeader = ({ openTopicId, openTopic, unnamed, headerActions, labels, pt, onBack, onClose, }) => {
|
|
20
|
+
const isListShown = openTopicId === undefined;
|
|
21
|
+
const titleIsPending = !isListShown && (!openTopic || unnamed(openTopic));
|
|
22
|
+
return (jsxs("header", { ...pt?.header, className: classNames('cratis-chat-sidebar__header', pt?.header?.className), "data-cratis-part": 'header', children: [!isListShown && jsx(BackButton, { label: labels?.back, pt: pt, onClick: onBack }), jsx(Title, { isPending: titleIsPending, pt: pt, children: resolveTitle(isListShown, openTopic, unnamed, labels) }), headerActions, jsx(CloseButton, { label: labels?.close, pt: pt, onClick: onClose })] }));
|
|
23
|
+
};
|
|
24
|
+
|
|
25
|
+
export { ChatSidebarHeader };
|
|
26
|
+
//# sourceMappingURL=ChatSidebarHeader.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"ChatSidebarHeader.js","sources":["../../../Chat/ChatSidebarHeader.tsx"],"sourcesContent":["// Copyright (c) Cratis. All rights reserved.\n// Licensed under the MIT license. See LICENSE file in the project root for full license information.\n\nimport type { ReactNode } from 'react';\nimport { classNames } from '../ClassNames/classNames';\nimport { useCratisIcon } from '../configuration/useCratisIcon';\nimport type { ChatSidebarLabels, ChatSidebarParts } from './ChatSidebar';\nimport type { ChatTopic } from './ChatTopic';\n\ninterface ChatSidebarHeaderProps<TTopic extends ChatTopic> {\n openTopicId: unknown;\n openTopic: TTopic | undefined;\n unnamed: (topic: TTopic) => boolean;\n headerActions: ReactNode;\n labels?: ChatSidebarLabels;\n pt?: ChatSidebarParts;\n onBack: () => void;\n onClose: () => void;\n}\n\nconst BackIcon = () => (\n <svg\n width='14'\n height='14'\n viewBox='0 0 24 24'\n fill='none'\n stroke='currentColor'\n strokeWidth='2.5'\n aria-hidden='true'\n >\n <line x1='19' y1='12' x2='5' y2='12' />\n <polyline points='12 19 5 12 12 5' />\n </svg>\n);\n\nconst resolveTitle = <TTopic extends ChatTopic>(\n isListShown: boolean,\n openTopic: TTopic | undefined,\n unnamed: (topic: TTopic) => boolean,\n labels?: ChatSidebarLabels,\n) => {\n if (isListShown) return labels?.topics ?? 'Topics';\n if (openTopic && !unnamed(openTopic)) return openTopic.name;\n return labels?.unnamedTopic ?? 'New topic';\n};\n\ninterface HeaderButtonProps {\n label?: string;\n pt?: ChatSidebarParts;\n onClick: () => void;\n}\n\nconst BackButton = ({ label, pt, onClick }: HeaderButtonProps) => (\n <button\n {...pt?.back}\n type='button'\n className={classNames('cratis-chat-sidebar__back', pt?.back?.className)}\n data-cratis-part='back'\n title={label ?? 'Back to topics'}\n aria-label={label ?? 'Back to topics'}\n onClick={onClick}\n >\n <BackIcon />\n </button>\n);\n\nconst CloseButton = ({ label, pt, onClick }: HeaderButtonProps) => {\n const icon = useCratisIcon();\n return (\n <button\n {...pt?.close}\n type='button'\n className={classNames('cratis-chat-sidebar__close', pt?.close?.className)}\n data-cratis-part='close'\n aria-label={label ?? 'Close chat'}\n onClick={onClick}\n >\n <span aria-hidden='true'>{icon('close', '×')}</span>\n </button>\n );\n};\n\ninterface TitleProps {\n isPending: boolean;\n pt?: ChatSidebarParts;\n children: ReactNode;\n}\n\nconst Title = ({ isPending, pt, children }: TitleProps) => (\n <h2\n {...pt?.title}\n className={classNames(\n 'cratis-chat-sidebar__title',\n isPending ? 'cratis-chat-sidebar__title--pending' : undefined,\n pt?.title?.className,\n )}\n data-cratis-part='title'\n >\n {children}\n </h2>\n);\n\nexport const ChatSidebarHeader = <TTopic extends ChatTopic>({\n openTopicId,\n openTopic,\n unnamed,\n headerActions,\n labels,\n pt,\n onBack,\n onClose,\n}: ChatSidebarHeaderProps<TTopic>) => {\n const isListShown = openTopicId === undefined;\n const titleIsPending = !isListShown && (!openTopic || unnamed(openTopic));\n\n return (\n <header\n {...pt?.header}\n className={classNames('cratis-chat-sidebar__header', pt?.header?.className)}\n data-cratis-part='header'\n >\n {!isListShown && <BackButton label={labels?.back} pt={pt} onClick={onBack} />}\n <Title isPending={titleIsPending} pt={pt}>\n {resolveTitle(isListShown, openTopic, unnamed, labels)}\n </Title>\n {headerActions}\n <CloseButton label={labels?.close} pt={pt} onClick={onClose} />\n </header>\n );\n};\n"],"names":["_jsxs","_jsx"],"mappings":";;;;AAoBA,MAAM,QAAQ,GAAG,OACbA,IAAA,CAAA,KAAA,EAAA,EACI,KAAK,EAAC,IAAI,EACV,MAAM,EAAC,IAAI,EACX,OAAO,EAAC,WAAW,EACnB,IAAI,EAAC,MAAM,EACX,MAAM,EAAC,cAAc,EACrB,WAAW,EAAC,KAAK,EAAA,aAAA,EACL,MAAM,EAAA,QAAA,EAAA,CAElBC,GAAA,CAAA,MAAA,EAAA,EAAM,EAAE,EAAC,IAAI,EAAC,EAAE,EAAC,IAAI,EAAC,EAAE,EAAC,GAAG,EAAC,EAAE,EAAC,IAAI,EAAA,CAAG,EACvCA,GAAA,CAAA,UAAA,EAAA,EAAU,MAAM,EAAC,iBAAiB,EAAA,CAAG,CAAA,EAAA,CACnC,CACT;AAED,MAAM,YAAY,GAAG,CACjB,WAAoB,EACpB,SAA6B,EAC7B,OAAmC,EACnC,MAA0B,KAC1B;AACA,IAAA,IAAI,WAAW;AAAE,QAAA,OAAO,MAAM,EAAE,MAAM,IAAI,QAAQ;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
|
|
3
|
+
import type { NonModalPhase } from './useNonModalPhase.js';
|
|
4
|
+
interface ChatSidebarShellProps {
|
|
5
|
+
open: boolean;
|
|
6
|
+
hasOpenTopic: boolean;
|
|
7
|
+
position: 'left' | 'right';
|
|
8
|
+
width: string;
|
|
9
|
+
className?: string;
|
|
10
|
+
pt?: ChatSidebarParts;
|
|
11
|
+
children: ReactNode;
|
|
12
|
+
}
|
|
13
|
+
interface ModalChatSidebarProps extends ChatSidebarShellProps {
|
|
14
|
+
onClose: () => void;
|
|
15
|
+
}
|
|
16
|
+
interface NonModalChatSidebarProps extends ChatSidebarShellProps {
|
|
17
|
+
phase: NonModalPhase;
|
|
18
|
+
panelRef: RefObject<HTMLDivElement | null>;
|
|
19
|
+
portalContainer: Element | null;
|
|
20
|
+
onPhaseSettled: (update: (phase: NonModalPhase) => NonModalPhase) => void;
|
|
21
|
+
}
|
|
22
|
+
export declare const ModalChatSidebar: ({ onClose, ...shell }: ModalChatSidebarProps) => import("react").JSX.Element;
|
|
23
|
+
/**
|
|
24
|
+
* Non-modal: a chat lives *next to* the work, so the background must stay visible and
|
|
25
|
+
* interactive. React Aria's Modal blocks its backdrop by design (its dismissal props only
|
|
26
|
+
* gate how it closes, never whether it intercepts), so this is a plain portaled layer with
|
|
27
|
+
* no dismissal behavior at all — only the close/back affordances dismiss it.
|
|
28
|
+
*/
|
|
29
|
+
export declare const NonModalChatSidebar: ({ portalContainer, ...panel }: NonModalChatSidebarProps) => import("react").ReactPortal | null;
|
|
30
|
+
export {};
|
|
31
|
+
//# sourceMappingURL=ChatSidebarShells.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"ChatSidebarShells.d.ts","sourceRoot":"","sources":["../../../Chat/ChatSidebarShells.tsx"],"names":[],"mappings":"AAGA,OAAO,KAAK,EAAE,SAAS,EAAE,SAAS,EAAE,MAAM,OAAO,CAAC;AAIlD,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,kBAAe,CAAC;AACtD,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,uBAAoB,CAAC;AAExD,UAAU,qBAAqB;IAC3B,IAAI,EAAE,OAAO,CAAC;IACd,YAAY,EAAE,OAAO,CAAC;IACtB,QAAQ,EAAE,MAAM,GAAG,OAAO,CAAC;IAC3B,KAAK,EAAE,MAAM,CAAC;IACd,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,EAAE,CAAC,EAAE,gBAAgB,CAAC;IACtB,QAAQ,EAAE,SAAS,CAAC;CACvB;AAED,UAAU,qBAAsB,SAAQ,qBAAqB;IACzD,OAAO,EAAE,MAAM,IAAI,CAAC;CACvB;AAED,UAAU,wBAAyB,SAAQ,qBAAqB;IAC5D,KAAK,EAAE,aAAa,CAAC;IACrB,QAAQ,EAAE,SAAS,CAAC,cAAc,GAAG,IAAI,CAAC,CAAC;IAC3C,eAAe,EAAE,OAAO,GAAG,IAAI,CAAC;IAChC,cAAc,EAAE,CAAC,MAAM,EAAE,CAAC,KAAK,EAAE,aAAa,KAAK,aAAa,KAAK,IAAI,CAAC;CAC7E;AAoCD,eAAO,MAAM,gBAAgB,0BAA2B,qBAAqB,gCAgB5E,CAAC;AA2BF;;;;;GAKG;AACH,eAAO,MAAM,mBAAmB,kCAAmC,wBAAwB,uCAgB1F,CAAC"}
|
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
import { jsx } from 'react/jsx-runtime';
|
|
2
|
+
import { createPortal } from 'react-dom';
|
|
3
|
+
import { ModalOverlay, Modal } from 'react-aria-components';
|
|
4
|
+
import { classNames } from '../ClassNames/classNames.js';
|
|
5
|
+
|
|
6
|
+
const settleAnimation = (phase) => {
|
|
7
|
+
if (phase === 'entering')
|
|
8
|
+
return 'open';
|
|
9
|
+
return phase === 'exiting' ? 'closed' : phase;
|
|
10
|
+
};
|
|
11
|
+
const panelAttributes = (shell) => ({
|
|
12
|
+
...shell.pt?.root,
|
|
13
|
+
className: classNames('cratis-chat-sidebar', shell.pt?.root?.className, shell.className),
|
|
14
|
+
style: { width: shell.width, ...shell.pt?.root?.style },
|
|
15
|
+
'data-position': shell.position,
|
|
16
|
+
});
|
|
17
|
+
const backdropAttributes = (pt) => ({
|
|
18
|
+
...pt?.backdrop,
|
|
19
|
+
className: classNames('cratis-chat-sidebar__backdrop', pt?.backdrop?.className),
|
|
20
|
+
});
|
|
21
|
+
const phaseAttributes = (phase) => ({
|
|
22
|
+
'data-entering': phase === 'entering' || undefined,
|
|
23
|
+
'data-exiting': phase === 'exiting' || undefined,
|
|
24
|
+
});
|
|
25
|
+
const ModalPanel = (shell) => (jsx(Modal, { ...panelAttributes(shell), "data-cratis-part": 'root', "data-cratis-component": 'ChatSidebar', "data-open": shell.open || undefined, "data-selected": shell.hasOpenTopic || undefined, children: shell.children }));
|
|
26
|
+
const ModalChatSidebar = ({ onClose, ...shell }) => (jsx(ModalOverlay, { ...backdropAttributes(shell.pt), isOpen: shell.open, onOpenChange: (openState) => {
|
|
27
|
+
if (!openState)
|
|
28
|
+
onClose();
|
|
29
|
+
}, isDismissable: true, isKeyboardDismissDisabled: false, "data-cratis-part": 'backdrop', "data-modal": true, "data-open": shell.open || undefined, "data-selected": shell.hasOpenTopic || undefined, children: jsx(ModalPanel, { ...shell }) }));
|
|
30
|
+
const NonModalPanel = ({ panelRef, onPhaseSettled, ...shell }) => (jsx("div", { ...panelAttributes(shell), ...phaseAttributes(shell.phase), ref: panelRef, "data-cratis-part": 'root', "data-cratis-component": 'ChatSidebar', "data-open": shell.open || undefined, "data-selected": shell.hasOpenTopic || undefined, onAnimationEnd: (event) => {
|
|
31
|
+
shell.pt?.root?.onAnimationEnd?.(event);
|
|
32
|
+
if (event.target !== event.currentTarget)
|
|
33
|
+
return;
|
|
34
|
+
onPhaseSettled(settleAnimation);
|
|
35
|
+
}, children: shell.children }));
|
|
36
|
+
const NonModalChatSidebar = ({ portalContainer, ...panel }) => {
|
|
37
|
+
if (panel.phase === 'closed' || !portalContainer)
|
|
38
|
+
return null;
|
|
39
|
+
return createPortal(jsx("div", { ...backdropAttributes(panel.pt), ...phaseAttributes(panel.phase), "data-cratis-part": 'backdrop', "data-modal": false, "data-open": panel.open || undefined, "data-selected": panel.hasOpenTopic || undefined, children: jsx(NonModalPanel, { ...panel }) }), portalContainer);
|
|
40
|
+
};
|
|
41
|
+
|
|
42
|
+
export { ModalChatSidebar, NonModalChatSidebar };
|
|
43
|
+
//# sourceMappingURL=ChatSidebarShells.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"ChatSidebarShells.js","sources":["../../../Chat/ChatSidebarShells.tsx"],"sourcesContent":["// Copyright (c) Cratis. All rights reserved.\n// Licensed under the MIT license. See LICENSE file in the project root for full license information.\n\nimport type { ReactNode, RefObject } from 'react';\nimport { createPortal } from 'react-dom';\nimport { Modal, ModalOverlay } from 'react-aria-components';\nimport { classNames } from '../ClassNames/classNames';\nimport type { ChatSidebarParts } from './ChatSidebar';\nimport type { NonModalPhase } from './useNonModalPhase';\n\ninterface ChatSidebarShellProps {\n open: boolean;\n hasOpenTopic: boolean;\n position: 'left' | 'right';\n width: string;\n className?: string;\n pt?: ChatSidebarParts;\n children: ReactNode;\n}\n\ninterface ModalChatSidebarProps extends ChatSidebarShellProps {\n onClose: () => void;\n}\n\ninterface NonModalChatSidebarProps extends ChatSidebarShellProps {\n phase: NonModalPhase;\n panelRef: RefObject<HTMLDivElement | null>;\n portalContainer: Element | null;\n onPhaseSettled: (update: (phase: NonModalPhase) => NonModalPhase) => void;\n}\n\nconst settleAnimation = (phase: NonModalPhase): NonModalPhase => {\n if (phase === 'entering') return 'open';\n return phase === 'exiting' ? 'closed' : phase;\n};\n\nconst panelAttributes = (shell: ChatSidebarShellProps) => ({\n ...shell.pt?.root,\n className: classNames('cratis-chat-sidebar', shell.pt?.root?.className, shell.className),\n style: { width: shell.width, ...shell.pt?.root?.style },\n 'data-position': shell.position,\n});\n\nconst backdropAttributes = (pt?: ChatSidebarParts) => ({\n ...pt?.backdrop,\n className: classNames('cratis-chat-sidebar__backdrop', pt?.backdrop?.className),\n});\n\nconst phaseAttributes = (phase: NonModalPhase) => ({\n 'data-entering': phase === 'entering' || undefined,\n 'data-exiting': phase === 'exiting' || undefined,\n});\n\nconst ModalPanel = (shell: ChatSidebarShellProps) => (\n <Modal\n {...panelAttributes(shell)}\n data-cratis-part='root'\n data-cratis-component='ChatSidebar'\n data-open={shell.open || undefined}\n data-selected={shell.hasOpenTopic || undefined}\n >\n {shell.children}\n </Modal>\n);\n\nexport const ModalChatSidebar = ({ onClose, ...shell }: ModalChatSidebarProps) => (\n <ModalOverlay\n {...backdropAttributes(shell.pt)}\n isOpen={shell.open}\n onOpenChange={(openState) => {\n if (!openState) onClose();\n }}\n isDismissable\n isKeyboardDismissDisabled={false}\n data-cratis-part='backdrop'\n data-modal\n data-open={shell.open || undefined}\n data-selected={shell.hasOpenTopic || undefined}\n >\n <ModalPanel {...shell} />\n </ModalOverlay>\n);\n\ninterface NonModalPanelProps extends ChatSidebarShellProps {\n phase: NonModalPhase;\n panelRef: RefObject<HTMLDivElement | null>;\n onPhaseSettled: (update: (phase: NonModalPhase) => NonModalPhase) => void;\n}\n\nconst NonModalPanel = ({ panelRef, onPhaseSettled, ...shell }: NonModalPanelProps) => (\n <div\n {...panelAttributes(shell)}\n {...phaseAttributes(shell.phase)}\n ref={panelRef}\n data-cratis-part='root'\n data-cratis-component='ChatSidebar'\n data-open={shell.open || undefined}\n data-selected={shell.hasOpenTopic || undefined}\n onAnimationEnd={(event) => {\n shell.pt?.root?.onAnimationEnd?.(event);\n if (event.target !== event.currentTarget) return;\n onPhaseSettled(settleAnimation);\n }}\n >\n {shell.children}\n </div>\n);\n\n/**\n * Non-modal: a chat lives *next to* the work, so the background must stay visible and\n * interactive. React Aria's Modal blocks its backdrop by design (its dismissal props only\n * gate how it closes, never whether it intercepts), so this is a plain portaled layer with\n * no dismissal behavior at all — only the close/back affordances dismiss it.\n */\nexport const NonModalChatSidebar = ({ portalContainer, ...panel }: NonModalChatSidebarProps) => {\n if (panel.phase === 'closed' || !portalContainer) return null;\n\n return createPortal(\n <div\n {...backdropAttributes(panel.pt)}\n {...phaseAttributes(panel.phase)}\n data-cratis-part='backdrop'\n data-modal={false}\n data-open={panel.open || undefined}\n data-selected={panel.hasOpenTopic || undefined}\n >\n <NonModalPanel {...panel} />\n </div>,\n portalContainer,\n );\n};\n"],"names":["_jsx"],"mappings":";;;;;AA+BA,MAAM,eAAe,GAAG,CAAC,KAAoB,KAAmB;IAC5D,IAAI,KAAK,KAAK,UAAU;AAAE,QAAA,OAAO,MAAM;IACvC,OAAO,KAAK,KAAK,SAAS,GAAG,QAAQ,GAAG,KAAK;AACjD,CAAC;AAED,MAAM,eAAe,GAAG,CAAC,KAA4B,MAAM;AACvD,IAAA,GAAG,KAAK,CAAC,EAAE,EAAE,IAAI;AACjB,IAAA,SAAS,EAAE,UAAU,CAAC,qBAAqB,EAAE,KAAK,CAAC,EAAE,EAAE,IAAI,EAAE,SAAS,EAAE,KAAK,CAAC,SAAS,CAAC;AACxF,IAAA,KAAK,EAAE,EAAE,KAAK,EAAE,KAAK,CAAC,KAAK,EAAE,GAAG,KAAK,CAAC,EAAE,EAAE,IAAI,EAAE,KAAK,EAAE;IACvD,eAAe,EAAE,KAAK,CAAC,QAAQ;AAClC,CAAA,CAAC;AAEF,MAAM,kBAAkB,GAAG,CAAC,EAAqB,MAAM;IACnD,GAAG,EAAE,EAAE,QAAQ;IACf,SAAS,EAAE,UAAU,CAAC,+BAA+B,EAAE,EAAE,EAAE,QAAQ,EAAE,SAAS,CAAC;AAClF,CAAA,CAAC;AAEF,MAAM,eAAe,GAAG,CAAC,KAAoB,MAAM;AAC/C,IAAA,eAAe,EAAE,KAAK,KAAK,UAAU,IAAI,SAAS;AAClD,IAAA,cAAc,EAAE,KAAK,KAAK,SAAS,IAAI,SAAS;AACnD,CAAA,CAAC;AAEF,MAAM,UAAU,GAAG,CAAC,KAA4B,MAC5CA,GAAA,CAAC,KAAK,OACE,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