@cratis/components 3.5.1 → 3.6.0

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.
Files changed (153) hide show
  1. package/README.md +1 -0
  2. package/dist/esm/Canvas/Canvas.d.ts +2 -0
  3. package/dist/esm/Canvas/Canvas.d.ts.map +1 -1
  4. package/dist/esm/Canvas/Canvas.js +25 -5
  5. package/dist/esm/Canvas/Canvas.js.map +1 -1
  6. package/dist/esm/Canvas/CanvasItem.d.ts +1 -0
  7. package/dist/esm/Canvas/CanvasItem.d.ts.map +1 -1
  8. package/dist/esm/Canvas/CanvasItem.js +7 -2
  9. package/dist/esm/Canvas/CanvasItem.js.map +1 -1
  10. package/dist/esm/Canvas/index.js +8 -0
  11. package/dist/esm/Canvas/index.js.map +1 -1
  12. package/dist/esm/Canvas/messaging/useOptionalMessenger.d.ts +3 -0
  13. package/dist/esm/Canvas/messaging/useOptionalMessenger.d.ts.map +1 -0
  14. package/dist/esm/Canvas/messaging/useOptionalMessenger.js +41 -0
  15. package/dist/esm/Canvas/messaging/useOptionalMessenger.js.map +1 -0
  16. package/dist/esm/Canvas/shapes/ChatBubble/Chat.d.ts +3 -1
  17. package/dist/esm/Canvas/shapes/ChatBubble/Chat.d.ts.map +1 -1
  18. package/dist/esm/Canvas/shapes/ChatBubble/Chat.js +13 -3
  19. package/dist/esm/Canvas/shapes/ChatBubble/Chat.js.map +1 -1
  20. package/dist/esm/Canvas/shapes/ChatBubble/ChatComposer.d.ts +2 -1
  21. package/dist/esm/Canvas/shapes/ChatBubble/ChatComposer.d.ts.map +1 -1
  22. package/dist/esm/Canvas/shapes/ChatBubble/ChatComposer.js +52 -4
  23. package/dist/esm/Canvas/shapes/ChatBubble/ChatComposer.js.map +1 -1
  24. package/dist/esm/Canvas/shapes/ChatBubble/ChatMessageAdded.d.ts +6 -0
  25. package/dist/esm/Canvas/shapes/ChatBubble/ChatMessageAdded.d.ts.map +1 -0
  26. package/dist/esm/Canvas/shapes/ChatBubble/ChatMessageAdded.js +18 -0
  27. package/dist/esm/Canvas/shapes/ChatBubble/ChatMessageAdded.js.map +1 -0
  28. package/dist/esm/Canvas/shapes/ChatBubble/Mentions/extractMentions.d.ts +4 -0
  29. package/dist/esm/Canvas/shapes/ChatBubble/Mentions/extractMentions.d.ts.map +1 -0
  30. package/dist/esm/Canvas/shapes/ChatBubble/Mentions/extractMentions.js +24 -0
  31. package/dist/esm/Canvas/shapes/ChatBubble/Mentions/extractMentions.js.map +1 -0
  32. package/dist/esm/Canvas/shapes/ChatBubble/Mentions/findMentionRanges.d.ts +11 -0
  33. package/dist/esm/Canvas/shapes/ChatBubble/Mentions/findMentionRanges.d.ts.map +1 -0
  34. package/dist/esm/Canvas/shapes/ChatBubble/Mentions/findMentionRanges.js +40 -0
  35. package/dist/esm/Canvas/shapes/ChatBubble/Mentions/findMentionRanges.js.map +1 -0
  36. package/dist/esm/Canvas/shapes/ChatBubble/Mentions/index.d.ts +3 -0
  37. package/dist/esm/Canvas/shapes/ChatBubble/Mentions/index.d.ts.map +1 -1
  38. package/dist/esm/Canvas/shapes/ChatBubble/Mentions/index.js +3 -0
  39. package/dist/esm/Canvas/shapes/ChatBubble/Mentions/index.js.map +1 -1
  40. package/dist/esm/Canvas/shapes/ChatBubble/Mentions/mentionSegments.d.ts +10 -0
  41. package/dist/esm/Canvas/shapes/ChatBubble/Mentions/mentionSegments.d.ts.map +1 -0
  42. package/dist/esm/Canvas/shapes/ChatBubble/Mentions/mentionSegments.js +29 -0
  43. package/dist/esm/Canvas/shapes/ChatBubble/Mentions/mentionSegments.js.map +1 -0
  44. package/dist/esm/Canvas/shapes/ChatBubble/index.d.ts +1 -0
  45. package/dist/esm/Canvas/shapes/ChatBubble/index.d.ts.map +1 -1
  46. package/dist/esm/Canvas/shapes/ChatBubble/index.js +1 -0
  47. package/dist/esm/Canvas/shapes/ChatBubble/index.js.map +1 -1
  48. package/dist/esm/Canvas/shapes/Note/Note.d.ts.map +1 -1
  49. package/dist/esm/Canvas/shapes/Note/Note.js +11 -2
  50. package/dist/esm/Canvas/shapes/Note/Note.js.map +1 -1
  51. package/dist/esm/Canvas/shapes/Note/NoteTextChanged.d.ts +6 -0
  52. package/dist/esm/Canvas/shapes/Note/NoteTextChanged.d.ts.map +1 -0
  53. package/dist/esm/Canvas/shapes/Note/NoteTextChanged.js +18 -0
  54. package/dist/esm/Canvas/shapes/Note/NoteTextChanged.js.map +1 -0
  55. package/dist/esm/Canvas/shapes/Note/index.d.ts +1 -0
  56. package/dist/esm/Canvas/shapes/Note/index.d.ts.map +1 -1
  57. package/dist/esm/Canvas/shapes/Note/index.js +1 -0
  58. package/dist/esm/Canvas/shapes/Note/index.js.map +1 -1
  59. package/dist/esm/Canvas/shapes/Region/ItemAddedToRegion.d.ts +6 -0
  60. package/dist/esm/Canvas/shapes/Region/ItemAddedToRegion.d.ts.map +1 -0
  61. package/dist/esm/Canvas/shapes/Region/ItemAddedToRegion.js +20 -0
  62. package/dist/esm/Canvas/shapes/Region/ItemAddedToRegion.js.map +1 -0
  63. package/dist/esm/Canvas/shapes/Region/ItemRemovedFromRegion.d.ts +6 -0
  64. package/dist/esm/Canvas/shapes/Region/ItemRemovedFromRegion.d.ts.map +1 -0
  65. package/dist/esm/Canvas/shapes/Region/ItemRemovedFromRegion.js +19 -0
  66. package/dist/esm/Canvas/shapes/Region/ItemRemovedFromRegion.js.map +1 -0
  67. package/dist/esm/Canvas/shapes/Region/Region.d.ts.map +1 -1
  68. package/dist/esm/Canvas/shapes/Region/Region.js +51 -1
  69. package/dist/esm/Canvas/shapes/Region/Region.js.map +1 -1
  70. package/dist/esm/Canvas/shapes/Region/index.d.ts +4 -0
  71. package/dist/esm/Canvas/shapes/Region/index.d.ts.map +1 -1
  72. package/dist/esm/Canvas/shapes/Region/index.js +3 -0
  73. package/dist/esm/Canvas/shapes/Region/index.js.map +1 -1
  74. package/dist/esm/Canvas/shapes/Region/regionContainment.d.ts +8 -0
  75. package/dist/esm/Canvas/shapes/Region/regionContainment.d.ts.map +1 -0
  76. package/dist/esm/Canvas/shapes/Region/regionContainment.js +35 -0
  77. package/dist/esm/Canvas/shapes/Region/regionContainment.js.map +1 -0
  78. package/dist/esm/Chat/ChatAuthor.d.ts +9 -0
  79. package/dist/esm/Chat/ChatAuthor.d.ts.map +1 -0
  80. package/dist/esm/Chat/ChatAuthor.js +2 -0
  81. package/dist/esm/Chat/ChatAuthor.js.map +1 -0
  82. package/dist/esm/Chat/ChatConversation.d.ts +38 -0
  83. package/dist/esm/Chat/ChatConversation.d.ts.map +1 -0
  84. package/dist/esm/Chat/ChatConversation.js +73 -0
  85. package/dist/esm/Chat/ChatConversation.js.map +1 -0
  86. package/dist/esm/Chat/ChatIdentifier.d.ts +6 -0
  87. package/dist/esm/Chat/ChatIdentifier.d.ts.map +1 -0
  88. package/dist/esm/Chat/ChatIdentifier.js +19 -0
  89. package/dist/esm/Chat/ChatIdentifier.js.map +1 -0
  90. package/dist/esm/Chat/ChatMention.d.ts +8 -0
  91. package/dist/esm/Chat/ChatMention.d.ts.map +1 -0
  92. package/dist/esm/Chat/ChatMention.js +2 -0
  93. package/dist/esm/Chat/ChatMention.js.map +1 -0
  94. package/dist/esm/Chat/ChatMessage.d.ts +12 -0
  95. package/dist/esm/Chat/ChatMessage.d.ts.map +1 -0
  96. package/dist/esm/Chat/ChatMessage.js +2 -0
  97. package/dist/esm/Chat/ChatMessage.js.map +1 -0
  98. package/dist/esm/Chat/ChatMessageAction.d.ts +10 -0
  99. package/dist/esm/Chat/ChatMessageAction.d.ts.map +1 -0
  100. package/dist/esm/Chat/ChatMessageAction.js +2 -0
  101. package/dist/esm/Chat/ChatMessageAction.js.map +1 -0
  102. package/dist/esm/Chat/ChatMessageBody.d.ts +8 -0
  103. package/dist/esm/Chat/ChatMessageBody.d.ts.map +1 -0
  104. package/dist/esm/Chat/ChatMessageBody.js +17 -0
  105. package/dist/esm/Chat/ChatMessageBody.js.map +1 -0
  106. package/dist/esm/Chat/ChatSidebar.d.ts +38 -0
  107. package/dist/esm/Chat/ChatSidebar.d.ts.map +1 -0
  108. package/dist/esm/Chat/ChatSidebar.js +65 -0
  109. package/dist/esm/Chat/ChatSidebar.js.map +1 -0
  110. package/dist/esm/Chat/ChatSidebarForObservableQueries.d.ts +15 -0
  111. package/dist/esm/Chat/ChatSidebarForObservableQueries.d.ts.map +1 -0
  112. package/dist/esm/Chat/ChatSidebarForObservableQueries.js +27 -0
  113. package/dist/esm/Chat/ChatSidebarForObservableQueries.js.map +1 -0
  114. package/dist/esm/Chat/ChatTopic.d.ts +10 -0
  115. package/dist/esm/Chat/ChatTopic.d.ts.map +1 -0
  116. package/dist/esm/Chat/ChatTopic.js +2 -0
  117. package/dist/esm/Chat/ChatTopic.js.map +1 -0
  118. package/dist/esm/Chat/ChatTopicList.d.ts +26 -0
  119. package/dist/esm/Chat/ChatTopicList.d.ts.map +1 -0
  120. package/dist/esm/Chat/ChatTopicList.js +29 -0
  121. package/dist/esm/Chat/ChatTopicList.js.map +1 -0
  122. package/dist/esm/Chat/index.d.ts +29 -0
  123. package/dist/esm/Chat/index.d.ts.map +1 -0
  124. package/dist/esm/Chat/index.js +20 -0
  125. package/dist/esm/Chat/index.js.map +1 -0
  126. package/dist/esm/Chat/isTopicUnnamed.d.ts +3 -0
  127. package/dist/esm/Chat/isTopicUnnamed.d.ts.map +1 -0
  128. package/dist/esm/Chat/isTopicUnnamed.js +14 -0
  129. package/dist/esm/Chat/isTopicUnnamed.js.map +1 -0
  130. package/dist/esm/Chat/relativeTimestamp.d.ts +7 -0
  131. package/dist/esm/Chat/relativeTimestamp.d.ts.map +1 -0
  132. package/dist/esm/Chat/relativeTimestamp.js +25 -0
  133. package/dist/esm/Chat/relativeTimestamp.js.map +1 -0
  134. package/dist/esm/Chat/shouldRequestTopicName.d.ts +2 -0
  135. package/dist/esm/Chat/shouldRequestTopicName.d.ts.map +1 -0
  136. package/dist/esm/Chat/shouldRequestTopicName.js +15 -0
  137. package/dist/esm/Chat/shouldRequestTopicName.js.map +1 -0
  138. package/dist/esm/Chat/topicsByActivity.d.ts +3 -0
  139. package/dist/esm/Chat/topicsByActivity.d.ts.map +1 -0
  140. package/dist/esm/Chat/topicsByActivity.js +25 -0
  141. package/dist/esm/Chat/topicsByActivity.js.map +1 -0
  142. package/dist/esm/Dialogs/BusyIndicatorDialog.js +2 -2
  143. package/dist/esm/Dialogs/BusyIndicatorDialog.js.map +1 -1
  144. package/dist/esm/PivotViewer/components/pivot/colorResolver.d.ts.map +1 -1
  145. package/dist/esm/PivotViewer/components/pivot/colorResolver.js +16 -26
  146. package/dist/esm/PivotViewer/components/pivot/colorResolver.js.map +1 -1
  147. package/dist/esm/index.d.ts +2 -1
  148. package/dist/esm/index.d.ts.map +1 -1
  149. package/dist/esm/index.js +39 -37
  150. package/dist/esm/index.js.map +1 -1
  151. package/dist/esm/styles.css +498 -95
  152. package/dist/esm/theme.css +75 -14
  153. package/package.json +6 -2
@@ -1,2 +1,5 @@
1
1
  export { Region } from './Region';
2
+ export { ItemAddedToRegion } from './ItemAddedToRegion';
3
+ export { ItemRemovedFromRegion } from './ItemRemovedFromRegion';
4
+ export { itemsWithinRegion } from './regionContainment';
2
5
  //# sourceMappingURL=index.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../../Canvas/shapes/Region/index.ts"],"names":[],"mappings":"AAGA,OAAO,EAAE,MAAM,EAAE,MAAM,UAAU,CAAC"}
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../../Canvas/shapes/Region/index.ts"],"names":[],"mappings":"AAGA,OAAO,EAAE,MAAM,EAAE,MAAM,UAAU,CAAC;AAElC,OAAO,EAAE,iBAAiB,EAAE,MAAM,qBAAqB,CAAC;AACxD,OAAO,EAAE,qBAAqB,EAAE,MAAM,yBAAyB,CAAC;AAChE,OAAO,EAAE,iBAAiB,EAAE,MAAM,qBAAqB,CAAC"}
@@ -0,0 +1,8 @@
1
+ export interface RegionContainmentBounds {
2
+ x: number;
3
+ y: number;
4
+ width: number;
5
+ height: number;
6
+ }
7
+ export declare function itemsWithinRegion(regionBounds: RegionContainmentBounds, items: Iterable<[string, RegionContainmentBounds]>, excludeId?: string): string[];
8
+ //# sourceMappingURL=regionContainment.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"regionContainment.d.ts","sourceRoot":"","sources":["../../../../../Canvas/shapes/Region/regionContainment.ts"],"names":[],"mappings":"AAQA,MAAM,WAAW,uBAAuB;IAGpC,CAAC,EAAE,MAAM,CAAC;IAGV,CAAC,EAAE,MAAM,CAAC;IAGV,KAAK,EAAE,MAAM,CAAC;IAGd,MAAM,EAAE,MAAM,CAAC;CAClB;AAeD,wBAAgB,iBAAiB,CAC7B,YAAY,EAAE,uBAAuB,EACrC,KAAK,EAAE,QAAQ,CAAC,CAAC,MAAM,EAAE,uBAAuB,CAAC,CAAC,EAClD,SAAS,CAAC,EAAE,MAAM,GAAG,MAAM,EAAE,CAgBhC"}
@@ -0,0 +1,35 @@
1
+ // Copyright (c) Cratis. All rights reserved.
2
+ // Licensed under the MIT license. See LICENSE file in the project root for full license information.
3
+ /**
4
+ * Determines which items lie within a region, by center point: an item is "within" when its center
5
+ * point lies inside the region's bounds. The test is inclusive on all four edges — a center sitting
6
+ * exactly on the region's edge counts as within, so an item nudged flush against the boundary reads
7
+ * as inside rather than flickering out on the last pixel.
8
+ * @param regionBounds The region's world-space bounds.
9
+ * @param items The candidate items as `[id, bounds]` pairs — a `ReadonlyMap`'s entries iterate as
10
+ * exactly this shape, so a Canvas item registry snapshot can be passed straight in.
11
+ * @param excludeId An id never to report, no matter where it sits — a region passes its own id here
12
+ * so the `CanvasItem` the region itself is wrapped in (registered under the same id by convention)
13
+ * is not reported as its own member.
14
+ * @returns The ids of the items whose center lies within the region, in the order the items iterate.
15
+ */
16
+ function itemsWithinRegion(regionBounds, items, excludeId) {
17
+ const left = regionBounds.x;
18
+ const top = regionBounds.y;
19
+ const right = regionBounds.x + regionBounds.width;
20
+ const bottom = regionBounds.y + regionBounds.height;
21
+ const result = [];
22
+ for (const [id, bounds] of items) {
23
+ if (id === excludeId)
24
+ continue;
25
+ const centerX = bounds.x + bounds.width / 2;
26
+ const centerY = bounds.y + bounds.height / 2;
27
+ if (centerX >= left && centerX <= right && centerY >= top && centerY <= bottom) {
28
+ result.push(id);
29
+ }
30
+ }
31
+ return result;
32
+ }
33
+
34
+ export { itemsWithinRegion };
35
+ //# sourceMappingURL=regionContainment.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"regionContainment.js","sources":["../../../../../Canvas/shapes/Region/regionContainment.ts"],"sourcesContent":[null],"names":[],"mappings":"AAAA;AACA;AAsBA;;;;;;;;;;;;AAYG;SACa,iBAAiB,CAC7B,YAAqC,EACrC,KAAkD,EAClD,SAAkB,EAAA;AAClB,IAAA,MAAM,IAAI,GAAG,YAAY,CAAC,CAAC;AAC3B,IAAA,MAAM,GAAG,GAAG,YAAY,CAAC,CAAC;IAC1B,MAAM,KAAK,GAAG,YAAY,CAAC,CAAC,GAAG,YAAY,CAAC,KAAK;IACjD,MAAM,MAAM,GAAG,YAAY,CAAC,CAAC,GAAG,YAAY,CAAC,MAAM;IAEnD,MAAM,MAAM,GAAa,EAAE;IAC3B,KAAK,MAAM,CAAC,EAAE,EAAE,MAAM,CAAC,IAAI,KAAK,EAAE;QAC9B,IAAI,EAAE,KAAK,SAAS;YAAE;QACtB,MAAM,OAAO,GAAG,MAAM,CAAC,CAAC,GAAG,MAAM,CAAC,KAAK,GAAG,CAAC;QAC3C,MAAM,OAAO,GAAG,MAAM,CAAC,CAAC,GAAG,MAAM,CAAC,MAAM,GAAG,CAAC;AAC5C,QAAA,IAAI,OAAO,IAAI,IAAI,IAAI,OAAO,IAAI,KAAK,IAAI,OAAO,IAAI,GAAG,IAAI,OAAO,IAAI,MAAM,EAAE;AAC5E,YAAA,MAAM,CAAC,IAAI,CAAC,EAAE,CAAC;QACnB;IACJ;AACA,IAAA,OAAO,MAAM;AACjB;;"}
@@ -0,0 +1,9 @@
1
+ import { ChatAuthorKind } from '../Canvas/shapes/ChatBubble/ChatAuthorKind';
2
+ export interface ChatAuthor {
3
+ name: string;
4
+ initials?: string;
5
+ hasAvatar?: boolean;
6
+ kind: ChatAuthorKind;
7
+ avatarVersion?: number;
8
+ }
9
+ //# sourceMappingURL=ChatAuthor.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"ChatAuthor.d.ts","sourceRoot":"","sources":["../../../Chat/ChatAuthor.ts"],"names":[],"mappings":"AAGA,OAAO,EAAE,cAAc,EAAE,MAAM,4CAA4C,CAAC;AAQ5E,MAAM,WAAW,UAAU;IAGvB,IAAI,EAAE,MAAM,CAAC;IAGb,QAAQ,CAAC,EAAE,MAAM,CAAC;IAGlB,SAAS,CAAC,EAAE,OAAO,CAAC;IAGpB,IAAI,EAAE,cAAc,CAAC;IAGrB,aAAa,CAAC,EAAE,MAAM,CAAC;CAC1B"}
@@ -0,0 +1,2 @@
1
+ export {};
2
+ //# sourceMappingURL=ChatAuthor.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"ChatAuthor.js","sourceRoot":"","sources":["../../../Chat/ChatAuthor.ts"],"names":[],"mappings":""}
@@ -0,0 +1,38 @@
1
+ import React, { type ReactNode } from 'react';
2
+ import { type BuildAvatarUrlParams } from '../Canvas/shapes/ChatBubble/Avatar';
3
+ import { type ChatComposerLabels } from '../Canvas/shapes/ChatBubble/ChatComposer';
4
+ import type { ChatTypingAuthor } from '../Canvas/shapes/ChatBubble/ChatTypingAuthor';
5
+ import type { MentionCandidate } from '../Canvas/shapes/ChatBubble/Mentions';
6
+ import type { ChatAuthor } from './ChatAuthor';
7
+ import { type ChatIdentifier } from './ChatIdentifier';
8
+ import type { ChatMention } from './ChatMention';
9
+ import type { ChatMessage } from './ChatMessage';
10
+ import type { ChatMessageAction } from './ChatMessageAction';
11
+ import { type RelativeTimestampLabels } from './relativeTimestamp';
12
+ export interface ChatConversationLabels {
13
+ empty?: string;
14
+ typing?: string;
15
+ typingTwo?: string;
16
+ typingSeveral?: string;
17
+ quickReplyTo?: string;
18
+ timestamps?: RelativeTimestampLabels;
19
+ composer?: ChatComposerLabels;
20
+ }
21
+ export interface ChatConversationProps<TMessage extends ChatMessage = ChatMessage> {
22
+ messages: TMessage[];
23
+ onSendMessage: (body: string, mentions: ChatMention[]) => void;
24
+ authorOf?: (authorId: ChatIdentifier) => ChatAuthor;
25
+ renderAvatar?: (authorId: ChatIdentifier, author: ChatAuthor) => ReactNode;
26
+ renderAuthorName?: (authorId: ChatIdentifier, author: ChatAuthor) => ReactNode;
27
+ actions?: ChatMessageAction<TMessage>[];
28
+ mentionCandidates?: MentionCandidate[];
29
+ resolveMentionCandidates?: (query: string) => MentionCandidate[] | Promise<MentionCandidate[]>;
30
+ typingAuthors?: ChatTypingAuthor[];
31
+ quickReply?: boolean;
32
+ buildAvatarUrl?: (params: BuildAvatarUrlParams) => string;
33
+ autoFocus?: boolean;
34
+ labels?: ChatConversationLabels;
35
+ className?: string;
36
+ }
37
+ export declare const ChatConversation: <TMessage extends ChatMessage = ChatMessage>({ messages, onSendMessage, authorOf, renderAvatar, renderAuthorName, actions, mentionCandidates, resolveMentionCandidates, typingAuthors, quickReply, buildAvatarUrl, autoFocus, labels, className, }: ChatConversationProps<TMessage>) => React.JSX.Element;
38
+ //# sourceMappingURL=ChatConversation.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"ChatConversation.d.ts","sourceRoot":"","sources":["../../../Chat/ChatConversation.tsx"],"names":[],"mappings":"AAGA,OAAO,KAAK,EAAE,EAA8B,KAAK,SAAS,EAAE,MAAM,OAAO,CAAC;AAC1E,OAAO,EAAsB,KAAK,oBAAoB,EAAE,MAAM,oCAAoC,CAAC;AAEnG,OAAO,EAAyC,KAAK,kBAAkB,EAAE,MAAM,0CAA0C,CAAC;AAC1H,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,8CAA8C,CAAC;AACrF,OAAO,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EAAE,gBAAgB,EAAE,CAAC;IAQvC,wBAAwB,CAAC,EAAE,CAAC,KAAK,EAAE,MAAM,KAAK,gBAAgB,EAAE,GAAG,OAAO,CAAC,gBAAgB,EAAE,CAAC,CAAC;IAG/F,aAAa,CAAC,EAAE,gBAAgB,EAAE,CAAC;IAInC,UAAU,CAAC,EAAE,OAAO,CAAC;IAGrB,cAAc,CAAC,EAAE,CAAC,MAAM,EAAE,oBAAoB,KAAK,MAAM,CAAC;IAG1D,SAAS,CAAC,EAAE,OAAO,CAAC;IAGpB,MAAM,CAAC,EAAE,sBAAsB,CAAC;IAGhC,SAAS,CAAC,EAAE,MAAM,CAAC;CACtB;AA0DD,eAAO,MAAM,gBAAgB,GAAI,QAAQ,SAAS,WAAW,GAAG,WAAW,EAAE,uMAe1E,qBAAqB,CAAC,QAAQ,CAAC,sBA6GjC,CAAC"}
@@ -0,0 +1,73 @@
1
+ import { jsxs, jsx } from 'react/jsx-runtime';
2
+ import { useRef, useMemo, useEffect } from 'react';
3
+ import { PersonAvatarCircle } from '../Canvas/shapes/ChatBubble/Avatar/PersonAvatarCircle.js';
4
+ import { ChatAuthorKind } from '../Canvas/shapes/ChatBubble/ChatAuthorKind.js';
5
+ import { ChatComposer } from '../Canvas/shapes/ChatBubble/ChatComposer.js';
6
+ import { TypingIndicator } from '../Canvas/shapes/ChatBubble/TypingIndicator.js';
7
+ import { chatIdentifierString } from './ChatIdentifier.js';
8
+ import { ChatMessageBody } from './ChatMessageBody.js';
9
+ import { relativeTimestamp } from './relativeTimestamp.js';
10
+
11
+ /** The message's timestamp as a `Date` — data that traveled through JSON may carry it as a string. */
12
+ const timestampOf = (message) => message.timestamp instanceof Date ? message.timestamp : new Date(message.timestamp);
13
+ const sameMinute = (left, right) => left.getFullYear() === right.getFullYear() &&
14
+ left.getMonth() === right.getMonth() &&
15
+ left.getDate() === right.getDate() &&
16
+ left.getHours() === right.getHours() &&
17
+ left.getMinutes() === right.getMinutes();
18
+ const computeRenderInfo = (messages) => messages.map((message, index) => {
19
+ const previous = index > 0 ? messages[index - 1] : undefined;
20
+ const next = index < messages.length - 1 ? messages[index + 1] : undefined;
21
+ const showAuthor = !previous || chatIdentifierString(previous.authorId) !== chatIdentifierString(message.authorId);
22
+ const showTimestamp = !next ||
23
+ chatIdentifierString(next.authorId) !== chatIdentifierString(message.authorId) ||
24
+ !sameMinute(timestampOf(message), timestampOf(next));
25
+ return { showAuthor, showTimestamp };
26
+ });
27
+ /**
28
+ * Composes the "X is typing" line from whoever the conversation is waiting on.
29
+ * @param authors The authors currently typing or working.
30
+ * @param labels Label overrides, as passed to {@link ChatConversation}.
31
+ * @returns The label to show, empty when nobody is.
32
+ */
33
+ const typingLabel = (authors, labels) => {
34
+ if (authors.length === 0)
35
+ return '';
36
+ if (authors.length === 1)
37
+ return (labels?.typing ?? '{name} is typing').replace('{name}', authors[0].name);
38
+ if (authors.length === 2)
39
+ return (labels?.typingTwo ?? '{first} and {second} are typing').replace('{first}', authors[0].name).replace('{second}', authors[1].name);
40
+ return labels?.typingSeveral ?? 'Several people are typing';
41
+ };
42
+ /**
43
+ * One conversation — its messages and the composer to add to them. Host-agnostic by design: it
44
+ * renders whatever message array it is given (hand it a live query's data and it stays current),
45
+ * resolves authors through the host's {@link ChatConversationProps.authorOf | authorOf} and
46
+ * render callbacks, offers the host's own {@link ChatConversationProps.actions | actions} on
47
+ * each message, and reports sends back through
48
+ * {@link ChatConversationProps.onSendMessage | onSendMessage} without any opinion about the
49
+ * backend behind it. Mentions and the emoji picker come along through the composer.
50
+ */
51
+ const ChatConversation = ({ messages, onSendMessage, authorOf, renderAvatar, renderAuthorName, actions, mentionCandidates, resolveMentionCandidates, typingAuthors = [], quickReply = true, buildAvatarUrl, autoFocus = false, labels, className, }) => {
52
+ const composerRef = useRef(null);
53
+ const messagesEndRef = useRef(null);
54
+ const renderInfo = useMemo(() => computeRenderInfo(messages), [messages]);
55
+ useEffect(() => {
56
+ messagesEndRef.current?.scrollIntoView({ behavior: 'smooth', block: 'nearest' });
57
+ }, [messages, typingAuthors.length]);
58
+ const authorFor = (authorId) => authorOf?.(authorId) ?? { name: chatIdentifierString(authorId), kind: ChatAuthorKind.User };
59
+ const send = (text, mentioned) => onSendMessage(text, mentioned.map(candidate => ({ id: candidate.id, name: candidate.name, kind: candidate.kind })));
60
+ const quickReplyTo = (name) => composerRef.current?.prefill(`@${name} `);
61
+ return (jsxs("div", { className: `cratis-chat-conversation${className ? ` ${className}` : ''}`, children: [jsxs("div", { className: 'cratis-chat-conversation__messages', children: [messages.length === 0 && (jsx("p", { className: 'cratis-chat-conversation__empty', children: labels?.empty ?? 'No messages yet. Say hello!' })), messages.map((message, index) => {
62
+ const author = authorFor(message.authorId);
63
+ const { showAuthor, showTimestamp } = renderInfo[index];
64
+ const availableActions = (actions ?? []).filter(action => action.isAvailable?.(message) ?? true);
65
+ const showActionsRow = quickReply || availableActions.length > 0;
66
+ return (jsxs("div", { className: `cratis-chat-message${showAuthor ? '' : ' cratis-chat-message--continuation'}`, children: [showAuthor && (jsxs("div", { className: 'cratis-chat-message__author', children: [renderAvatar
67
+ ? renderAvatar(message.authorId, author)
68
+ : (jsx(PersonAvatarCircle, { userId: chatIdentifierString(message.authorId), name: author.name, hasAvatar: author.hasAvatar ?? false, size: 22, ownerType: author.kind === ChatAuthorKind.Agent ? 'Agents' : 'Users', version: author.avatarVersion, buildAvatarUrl: buildAvatarUrl })), jsx("span", { className: 'cratis-chat-message__author-name', children: renderAuthorName ? renderAuthorName(message.authorId, author) : author.name })] })), jsxs("div", { className: 'cratis-chat-message__content', children: [jsxs("div", { className: `cratis-chat-message__panel${showActionsRow ? ' cratis-chat-message__panel--with-actions' : ''}`, children: [jsx(ChatMessageBody, { body: message.body, mentions: message.mentions }), showActionsRow && (jsxs("div", { className: 'cratis-chat-message__actions', children: [quickReply && (jsx("button", { type: 'button', className: 'cratis-chat-message__action', title: (labels?.quickReplyTo ?? 'Reply to {name}').replace('{name}', author.name), "aria-label": (labels?.quickReplyTo ?? 'Reply to {name}').replace('{name}', author.name), onClick: () => quickReplyTo(author.name), children: jsx("i", { className: 'pi pi-reply', "aria-hidden": 'true' }) })), availableActions.map(action => (jsx("button", { type: 'button', className: 'cratis-chat-message__action', title: action.label, "aria-label": action.label, onClick: () => action.onInvoke(message), children: typeof action.icon === 'string' ? jsx("i", { className: action.icon, "aria-hidden": 'true' }) : action.icon }, action.id)))] }))] }), showTimestamp && (jsx("span", { className: 'cratis-chat-message__time', children: relativeTimestamp(timestampOf(message), new Date(), labels?.timestamps) }))] })] }, chatIdentifierString(message.id)));
69
+ }), jsx(TypingIndicator, { authors: typingAuthors, label: typingLabel(typingAuthors, labels), buildAvatarUrl: buildAvatarUrl }), jsx("div", { ref: messagesEndRef })] }), jsx(ChatComposer, { ref: composerRef, mentionCandidates: mentionCandidates, resolveMentionCandidates: resolveMentionCandidates, onSend: send, autoFocus: autoFocus, buildAvatarUrl: buildAvatarUrl, labels: labels?.composer })] }));
70
+ };
71
+
72
+ export { ChatConversation };
73
+ //# sourceMappingURL=ChatConversation.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"ChatConversation.js","sources":["../../../Chat/ChatConversation.tsx"],"sourcesContent":[null],"names":["_jsxs","_jsx"],"mappings":";;;;;;;;;;AA6HA;AACA,MAAM,WAAW,GAAG,CAAC,OAAoB,KACrC,OAAO,CAAC,SAAS,YAAY,IAAI,GAAG,OAAO,CAAC,SAAS,GAAG,IAAI,IAAI,CAAC,OAAO,CAAC,SAAS,CAAC;AAEvF,MAAM,UAAU,GAAG,CAAC,IAAU,EAAE,KAAW,KACvC,IAAI,CAAC,WAAW,EAAE,KAAK,KAAK,CAAC,WAAW,EAAE;AAC1C,IAAA,IAAI,CAAC,QAAQ,EAAE,KAAK,KAAK,CAAC,QAAQ,EAAE;AACpC,IAAA,IAAI,CAAC,OAAO,EAAE,KAAK,KAAK,CAAC,OAAO,EAAE;AAClC,IAAA,IAAI,CAAC,QAAQ,EAAE,KAAK,KAAK,CAAC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AG,EAAE,WAAW,EAChB,iBAAiB,EAAE,iBAAiB,EACpC,wBAAwB,EAAE,wBAAwB,EAClD,MAAM,EAAE,IAAI,EACZ,SAAS,EAAE,SAAS,EACpB,cAAc,EAAE,cAAc,EAC9B,MAAM,EAAE,MAAM,EAAE,QAAQ,EAAA,CAC1B,CAAA,EAAA,CACA;AAEd;;"}
@@ -0,0 +1,6 @@
1
+ export type ChatIdentifier = string | {
2
+ toString(): string;
3
+ };
4
+ export declare const chatIdentifierString: (identifier: ChatIdentifier) => string;
5
+ export declare const sameChatIdentifier: (left?: ChatIdentifier, right?: ChatIdentifier) => boolean;
6
+ //# sourceMappingURL=ChatIdentifier.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"ChatIdentifier.d.ts","sourceRoot":"","sources":["../../../Chat/ChatIdentifier.ts"],"names":[],"mappings":"AASA,MAAM,MAAM,cAAc,GAAG,MAAM,GAAG;IAAE,QAAQ,IAAI,MAAM,CAAA;CAAE,CAAC;AAO7D,eAAO,MAAM,oBAAoB,GAAI,YAAY,cAAc,KAAG,MAA4B,CAAC;AAS/F,eAAO,MAAM,kBAAkB,GAAI,OAAO,cAAc,EAAE,QAAQ,cAAc,KAAG,OACJ,CAAC"}
@@ -0,0 +1,19 @@
1
+ // Copyright (c) Cratis. All rights reserved.
2
+ // Licensed under the MIT license. See LICENSE file in the project root for full license information.
3
+ /**
4
+ * The canonical string form of an identifier, used for React keys and comparisons.
5
+ * @param identifier The identifier to render.
6
+ * @returns The identifier as a string.
7
+ */
8
+ const chatIdentifierString = (identifier) => String(identifier);
9
+ /**
10
+ * Whether two identifiers refer to the same thing, compared by their string form so a `Guid`
11
+ * and the string it prints as are the same identifier.
12
+ * @param left One identifier, possibly not set.
13
+ * @param right The other identifier, possibly not set.
14
+ * @returns True when both are set and equal.
15
+ */
16
+ const sameChatIdentifier = (left, right) => left !== undefined && right !== undefined && String(left) === String(right);
17
+
18
+ export { chatIdentifierString, sameChatIdentifier };
19
+ //# sourceMappingURL=ChatIdentifier.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"ChatIdentifier.js","sources":["../../../Chat/ChatIdentifier.ts"],"sourcesContent":[null],"names":[],"mappings":"AAAA;AACA;AAUA;;;;AAIG;AACI,MAAM,oBAAoB,GAAG,CAAC,UAA0B,KAAa,MAAM,CAAC,UAAU;AAE7F;;;;;;AAMG;AACI,MAAM,kBAAkB,GAAG,CAAC,IAAqB,EAAE,KAAsB,KAC5E,IAAI,KAAK,SAAS,IAAI,KAAK,KAAK,SAAS,IAAI,MAAM,CAAC,IAAI,CAAC,KAAK,MAAM,CAAC,KAAK;;"}
@@ -0,0 +1,8 @@
1
+ import { ChatAuthorKind } from '../Canvas/shapes/ChatBubble/ChatAuthorKind';
2
+ import type { ChatIdentifier } from './ChatIdentifier';
3
+ export interface ChatMention {
4
+ id: ChatIdentifier;
5
+ name: string;
6
+ kind: ChatAuthorKind;
7
+ }
8
+ //# sourceMappingURL=ChatMention.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"ChatMention.d.ts","sourceRoot":"","sources":["../../../Chat/ChatMention.ts"],"names":[],"mappings":"AAGA,OAAO,EAAE,cAAc,EAAE,MAAM,4CAA4C,CAAC;AAC5E,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,kBAAkB,CAAC;AAQvD,MAAM,WAAW,WAAW;IAGxB,EAAE,EAAE,cAAc,CAAC;IAGnB,IAAI,EAAE,MAAM,CAAC;IAGb,IAAI,EAAE,cAAc,CAAC;CACxB"}
@@ -0,0 +1,2 @@
1
+ export {};
2
+ //# sourceMappingURL=ChatMention.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"ChatMention.js","sourceRoot":"","sources":["../../../Chat/ChatMention.ts"],"names":[],"mappings":""}
@@ -0,0 +1,12 @@
1
+ import type { ChatIdentifier } from './ChatIdentifier';
2
+ import type { ChatMention } from './ChatMention';
3
+ export interface ChatMessage {
4
+ id: ChatIdentifier;
5
+ topicId: ChatIdentifier;
6
+ authorId: ChatIdentifier;
7
+ body: string;
8
+ timestamp: Date;
9
+ mentions?: ChatMention[];
10
+ metadata?: Record<string, unknown>;
11
+ }
12
+ //# sourceMappingURL=ChatMessage.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"ChatMessage.d.ts","sourceRoot":"","sources":["../../../Chat/ChatMessage.ts"],"names":[],"mappings":"AAGA,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,kBAAkB,CAAC;AACvD,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,eAAe,CAAC;AAYjD,MAAM,WAAW,WAAW;IAGxB,EAAE,EAAE,cAAc,CAAC;IAGnB,OAAO,EAAE,cAAc,CAAC;IAGxB,QAAQ,EAAE,cAAc,CAAC;IAGzB,IAAI,EAAE,MAAM,CAAC;IAGb,SAAS,EAAE,IAAI,CAAC;IAGhB,QAAQ,CAAC,EAAE,WAAW,EAAE,CAAC;IAGzB,QAAQ,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;CACtC"}
@@ -0,0 +1,2 @@
1
+ export {};
2
+ //# sourceMappingURL=ChatMessage.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"ChatMessage.js","sourceRoot":"","sources":["../../../Chat/ChatMessage.ts"],"names":[],"mappings":""}
@@ -0,0 +1,10 @@
1
+ import type { ReactNode } from 'react';
2
+ import type { ChatMessage } from './ChatMessage';
3
+ export interface ChatMessageAction<TMessage extends ChatMessage = ChatMessage> {
4
+ id: string;
5
+ label: string;
6
+ icon: string | ReactNode;
7
+ isAvailable?: (message: TMessage) => boolean;
8
+ onInvoke: (message: TMessage) => void;
9
+ }
10
+ //# sourceMappingURL=ChatMessageAction.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"ChatMessageAction.d.ts","sourceRoot":"","sources":["../../../Chat/ChatMessageAction.ts"],"names":[],"mappings":"AAGA,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,OAAO,CAAC;AACvC,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,eAAe,CAAC;AAQjD,MAAM,WAAW,iBAAiB,CAAC,QAAQ,SAAS,WAAW,GAAG,WAAW;IAGzE,EAAE,EAAE,MAAM,CAAC;IAGX,KAAK,EAAE,MAAM,CAAC;IAGd,IAAI,EAAE,MAAM,GAAG,SAAS,CAAC;IAOzB,WAAW,CAAC,EAAE,CAAC,OAAO,EAAE,QAAQ,KAAK,OAAO,CAAC;IAM7C,QAAQ,EAAE,CAAC,OAAO,EAAE,QAAQ,KAAK,IAAI,CAAC;CACzC"}
@@ -0,0 +1,2 @@
1
+ export {};
2
+ //# sourceMappingURL=ChatMessageAction.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"ChatMessageAction.js","sourceRoot":"","sources":["../../../Chat/ChatMessageAction.ts"],"names":[],"mappings":""}
@@ -0,0 +1,8 @@
1
+ import React from 'react';
2
+ import type { ChatMention } from './ChatMention';
3
+ export interface ChatMessageBodyProps {
4
+ body: string;
5
+ mentions?: ChatMention[];
6
+ }
7
+ export declare const ChatMessageBody: ({ body, mentions }: ChatMessageBodyProps) => React.JSX.Element;
8
+ //# sourceMappingURL=ChatMessageBody.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"ChatMessageBody.d.ts","sourceRoot":"","sources":["../../../Chat/ChatMessageBody.tsx"],"names":[],"mappings":"AAGA,OAAO,KAAK,MAAM,OAAO,CAAC;AAE1B,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,eAAe,CAAC;AAKjD,MAAM,WAAW,oBAAoB;IAGjC,IAAI,EAAE,MAAM,CAAC;IAGb,QAAQ,CAAC,EAAE,WAAW,EAAE,CAAC;CAC5B;AAQD,eAAO,MAAM,eAAe,GAAI,oBAAoB,oBAAoB,sBAgBvE,CAAC"}
@@ -0,0 +1,17 @@
1
+ import { jsx } from 'react/jsx-runtime';
2
+ import React from 'react';
3
+ import '../Canvas/shapes/ChatBubble/ChatAuthorKind.js';
4
+ import { mentionSegments } from '../Canvas/shapes/ChatBubble/Mentions/mentionSegments.js';
5
+
6
+ /**
7
+ * The text of one message. The body itself is plain text — including its `@Name` mentions — and
8
+ * this component is what makes the mentions *look* like mentions: each known one renders as its
9
+ * own element, marked with who it addresses, so a person and an agent mention can be styled
10
+ * apart and the host's own CSS can hang further behavior off them.
11
+ */
12
+ const ChatMessageBody = ({ body, mentions }) => (jsx("p", { className: 'cratis-chat-message__body', children: mentionSegments(body, mentions ?? []).map((segment, index) => segment.mention
13
+ ? (jsx("span", { className: 'cratis-chat-message__mention', "data-kind": segment.mention.kind, children: segment.text }, index))
14
+ : jsx(React.Fragment, { children: segment.text }, index)) }));
15
+
16
+ export { ChatMessageBody };
17
+ //# sourceMappingURL=ChatMessageBody.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"ChatMessageBody.js","sources":["../../../Chat/ChatMessageBody.tsx"],"sourcesContent":[null],"names":["_jsx"],"mappings":";;;;;AAmBA;;;;;AAKG;AACI,MAAM,eAAe,GAAG,CAAC,EAAE,IAAI,EAAE,QAAQ,EAAwB,MACpEA,GAAA,CAAA,GAAA,EAAA,EAAG,SAAS,EAAC,2BAA2B,EAAA,QAAA,EACnC,eAAe,CAAC,IAAI,EAAE,QAAQ,IAAI,EAAE,CAAC,CAAC,GAAG,CAAC,CAAC,OAAO,EAAE,KAAK,KACtD,OAAO,CAAC;AACJ,WACIA,GAAA,CAAA,MAAA,EAAA,EAEI,SAAS,EAAC,8BAA8B,eAC7B,OAAO,CAAC,OAAO,CAAC,IAAI,YAE9B,OAAO,CAAC,IAAI,EAAA,EAJR,KAAK,CAKP;AAEX,UAAEA,GAAA,CAAC,KAAK,CAAC,QAAQ,EAAA,EAAA,QAAA,EAAc,OAAO,CAAC,IAAI,IAApB,KAAK,CAAiC,CACpE,EAAA,CACD;;"}
@@ -0,0 +1,38 @@
1
+ import React from 'react';
2
+ import type { DrawerRootProps } from '@primereact/types/primitive/drawer';
3
+ import type { ChatConversationLabels, ChatConversationProps } from './ChatConversation';
4
+ import { type ChatIdentifier } from './ChatIdentifier';
5
+ import type { ChatMention } from './ChatMention';
6
+ import type { ChatMessage } from './ChatMessage';
7
+ import type { ChatTopic } from './ChatTopic';
8
+ import type { ChatTopicListLabels } from './ChatTopicList';
9
+ export interface ChatSidebarLabels {
10
+ topics?: string;
11
+ unnamedTopic?: string;
12
+ back?: string;
13
+ close?: string;
14
+ topicList?: ChatTopicListLabels;
15
+ conversation?: ChatConversationLabels;
16
+ }
17
+ export interface ChatSidebarProps<TMessage extends ChatMessage = ChatMessage, TTopic extends ChatTopic = ChatTopic> extends Omit<ChatConversationProps<TMessage>, 'messages' | 'onSendMessage' | 'labels' | 'className'> {
18
+ open: boolean;
19
+ onClose: () => void;
20
+ topics: TTopic[];
21
+ messages: TMessage[];
22
+ selectedTopicId?: ChatIdentifier | null;
23
+ onTopicSelected?: (topicId: ChatIdentifier | undefined, topic?: TTopic) => void;
24
+ onStartTopic?: () => ChatIdentifier | undefined | Promise<ChatIdentifier | undefined>;
25
+ onSendMessage: (topicId: ChatIdentifier, body: string, mentions: ChatMention[]) => void;
26
+ onRequestTopicName?: (topic: TTopic, firstMessageBody: string) => void;
27
+ isTopicUnnamed?: (topic: TTopic) => boolean;
28
+ position?: 'left' | 'right';
29
+ width?: string;
30
+ modal?: boolean;
31
+ labels?: ChatSidebarLabels;
32
+ className?: string;
33
+ pt?: DrawerRootProps['pt'];
34
+ ptOptions?: DrawerRootProps['ptOptions'];
35
+ unstyled?: boolean;
36
+ }
37
+ export declare const ChatSidebar: <TMessage extends ChatMessage = ChatMessage, TTopic extends ChatTopic = ChatTopic>({ open, onClose, topics, messages, selectedTopicId, onTopicSelected, onStartTopic, onSendMessage, onRequestTopicName, isTopicUnnamed, position, width, modal, labels, className, pt, ptOptions, unstyled, ...conversation }: ChatSidebarProps<TMessage, TTopic>) => React.JSX.Element;
38
+ //# sourceMappingURL=ChatSidebar.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"ChatSidebar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S,EAAE,KAAK,CAAC,EAAE,MAAM,KAAK,IAAI,CAAC;IAQhF,YAAY,CAAC,EAAE,MAAM,cAAc,GAAG,SAAS,GAAG,OAAO,CAAC,cAAc,GAAG,SAAS,CAAC,CAAC;IAStF,aAAa,EAAE,CAAC,OAAO,EAAE,cAAc,EAAE,IAAI,EAAE,MAAM,EAAE,QAAQ,EAAE,WAAW,EAAE,KAAK,IAAI,CAAC;IAUxF,kBAAkB,CAAC,EAAE,CAAC,KAAK,EAAE,MAAM,EAAE,gBAAgB,EAAE,MAAM,KAAK,IAAI,CAAC;IAOvE,cAAc,CAAC,EAAE,CAAC,KAAK,EAAE,MAAM,KAAK,OAAO,CAAC;IAG5C,QAAQ,CAAC,EAAE,MAAM,GAAG,OAAO,CAAC;IAG5B,KAAK,CAAC,EAAE,MAAM,CAAC;IAMf,KAAK,CAAC,EAAE,OAAO,CAAC;IAGhB,MAAM,CAAC,EAAE,iBAAiB,CAAC;IAG3B,SAAS,CAAC,EAAE,MAAM,CAAC;IAGnB,EAAE,CAAC,EAAE,eAAe,CAAC,IAAI,CAAC,CAAC;IAG3B,SAAS,CAAC,EAAE,eAAe,CAAC,WAAW,CAAC,CAAC;IAGzC,QAAQ,CAAC,EAAE,OAAO,CAAC;CACtB;AAWD,eAAO,MAAM,WAAW,GAAI,QAAQ,SAAS,WAAW,GAAG,WAAW,EAAE,MAAM,SAAS,SAAS,GAAG,SAAS,EAAE,6NAoB3G,gBAAgB,CAAC,QAAQ,EAAE,MAAM,CAAC,sBA+GpC,CAAC"}
@@ -0,0 +1,65 @@
1
+ import { jsx, jsxs } from 'react/jsx-runtime';
2
+ import { useState } from 'react';
3
+ import { Drawer } from 'primereact/drawer';
4
+ import { ChatConversation } from './ChatConversation.js';
5
+ import { sameChatIdentifier } from './ChatIdentifier.js';
6
+ import { ChatTopicList } from './ChatTopicList.js';
7
+ import { isTopicUnnamed } from './isTopicUnnamed.js';
8
+ import { shouldRequestTopicName } from './shouldRequestTopicName.js';
9
+
10
+ /**
11
+ * A topic-based chat in a sidebar next to the view, built on PrimeReact's Drawer. It opens on
12
+ * the topic list; picking a topic (or starting a new one) slides into that conversation, with a
13
+ * back affordance to the list. Everything about *data* is the host's: topics and messages come
14
+ * in as arrays (hand it live query data and it stays current), sends and new topics go out as
15
+ * callbacks, and when the first message lands in an unnamed topic the sidebar asks the host for
16
+ * a name through {@link ChatSidebarProps.onRequestTopicName | onRequestTopicName} — rendering a
17
+ * pending placeholder until the name arrives.
18
+ */
19
+ const ChatSidebar = ({ open, onClose, topics, messages, selectedTopicId, onTopicSelected, onStartTopic, onSendMessage, onRequestTopicName, isTopicUnnamed: isTopicUnnamed$1, position = 'right', width = '24rem', modal = false, labels, className, pt, ptOptions, unstyled, ...conversation }) => {
20
+ const [internalSelectedId, setInternalSelectedId] = useState(undefined);
21
+ const isControlled = selectedTopicId !== undefined;
22
+ const openTopicId = isControlled ? (selectedTopicId ?? undefined) : internalSelectedId;
23
+ const openTopic = openTopicId !== undefined ? topics.find(topic => sameChatIdentifier(topic.id, openTopicId)) : undefined;
24
+ const unnamed = isTopicUnnamed$1 ?? isTopicUnnamed;
25
+ const select = (topicId, topic) => {
26
+ if (!isControlled) {
27
+ setInternalSelectedId(topicId);
28
+ }
29
+ onTopicSelected?.(topicId, topic ?? (topicId !== undefined ? topics.find(candidate => sameChatIdentifier(candidate.id, topicId)) : undefined));
30
+ };
31
+ const startTopic = async () => {
32
+ const topicId = await onStartTopic?.();
33
+ if (topicId !== undefined) {
34
+ select(topicId);
35
+ }
36
+ };
37
+ const openMessages = openTopicId === undefined
38
+ ? []
39
+ : messages.filter(message => sameChatIdentifier(message.topicId, openTopicId));
40
+ const send = (body, mentions) => {
41
+ if (openTopicId === undefined)
42
+ return;
43
+ onSendMessage(openTopicId, body, mentions);
44
+ if (openTopic && shouldRequestTopicName(unnamed(openTopic), openMessages.length)) {
45
+ onRequestTopicName?.(openTopic, body);
46
+ }
47
+ };
48
+ const handleOpenChange = (event) => {
49
+ if (!event.value) {
50
+ onClose();
51
+ }
52
+ };
53
+ const title = openTopicId === undefined
54
+ ? (labels?.topics ?? 'Topics')
55
+ : openTopic && !unnamed(openTopic)
56
+ ? openTopic.name
57
+ : (labels?.unnamedTopic ?? 'New topic');
58
+ const titleIsPending = openTopicId !== undefined && (!openTopic || unnamed(openTopic));
59
+ return (jsx(Drawer.Root, { open: open, position: position, dismissable: modal, onOpenChange: handleOpenChange, pt: pt, ptOptions: ptOptions, unstyled: unstyled, children: jsxs(Drawer.Portal, { children: [modal && jsx(Drawer.Backdrop, {}), jsxs(Drawer.Popup, { className: `cratis-chat-sidebar${className ? ` ${className}` : ''}`, style: { width }, children: [jsxs(Drawer.Header, { className: 'cratis-chat-sidebar__header', children: [openTopicId !== undefined && (jsx("button", { type: 'button', className: 'cratis-chat-sidebar__back', title: labels?.back ?? 'Back to topics', "aria-label": labels?.back ?? 'Back to topics', onClick: () => select(undefined), children: jsx("i", { className: 'pi pi-arrow-left', "aria-hidden": 'true' }) })), jsx(Drawer.Title, { className: `cratis-chat-sidebar__title${titleIsPending ? ' cratis-chat-sidebar__title--pending' : ''}`, children: title }), jsx(Drawer.Close, { className: 'cratis-chat-sidebar__close', "aria-label": labels?.close ?? 'Close chat', children: jsx("i", { className: 'pi pi-times', "aria-hidden": 'true' }) })] }), jsx(Drawer.Content, { className: 'cratis-chat-sidebar__content', children: openTopicId === undefined
60
+ ? (jsx(ChatTopicList, { topics: topics, onOpen: topic => select(topic.id, topic), onStart: onStartTopic ? () => { void startTopic(); } : undefined, authorOf: conversation.authorOf, renderAvatar: conversation.renderAvatar, isTopicUnnamed: isTopicUnnamed$1, buildAvatarUrl: conversation.buildAvatarUrl, labels: { unnamedTopic: labels?.unnamedTopic, ...labels?.topicList } }))
61
+ : (jsx(ChatConversation, { ...conversation, messages: openMessages, onSendMessage: send, labels: labels?.conversation })) })] })] }) }));
62
+ };
63
+
64
+ export { ChatSidebar };
65
+ //# sourceMappingURL=ChatSidebar.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"ChatSidebar.js","sources":["../../../Chat/ChatSidebar.tsx"],"sourcesContent":[null],"names":["isTopicUnnamed","defaultIsTopicUnnamed","_jsx","PrimeDrawer","_jsxs"],"mappings":";;;;;;;;;AAgJA;;;;;;;;AAQG;AACI,MAAM,WAAW,GAAG,CAAmF,EAC1G,IAAI,EACJ,OAAO,EACP,MAAM,EACN,QAAQ,EACR,eAAe,EACf,eAAe,EACf,YAAY,EACZ,aAAa,EACb,kBAAkB,kBAClBA,gBAAc,EACd,QAAQ,GAAG,OAAO,EAClB,KAAK,GAAG,OAAO,EACf,KAAK,GAAG,KAAK,EACb,MAAM,EACN,SAAS,EACT,EAAE,EACF,SAAS,EACT,QAAQ,EACR,GAAG,YAAY,EACkB,KAAI;IACrC,MAAM,CAAC,kBAAkB,EAAE,qBAAqB,CAAC,GAAG,QAAQ,CAA6B,SAAS,CAAC;AACnG,IAAA,MAAM,YAAY,GAAG,eAAe,KAAK,SAAS;AAClD,IAAA,MAAM,WAAW,GAAG,YAAY,IAAI,eAAe,IAAI,SAAS,IAAI,kBAAkB;AACtF,IAAA,MAAM,SAAS,GAAG,WAAW,KAAK,SAAS,GAAG,MAAM,CAAC,IAAI,CAAC,KAAK,IAAI,kBAAkB,CAAC,KAAK,CAAC,EAAE,EAAE,WAAW,CAAC,CAAC,GAAG,SAAS;AACzH,IAAA,MAAM,OAAO,GAAGA,gBAAc,IAAIC,cAAqB;AAEvD,IAAA,MAAM,MAAM,GAAG,CAAC,OAAmC,EAAE,KAAc,KAAI;QACnE,IAAI,CAAC,YAAY,EAAE;YACf,qBAAqB,CAAC,OAAO,CAAC;QAClC;AACA,QAAA,eAAe,GAAG,OAAO,EAAE,KAAK,KAAK,OAAO,KAAK,SAAS,GAAG,MAAM,CAAC,IAAI,CAAC,SAAS,IAAI,kBAAkB,CAAC,SAAS,CAAC,EAAE,EAAE,OAAO,CAAC,CAAC,GAAG,SAAS,CAAC,CAAC;AAClJ,IAAA,CAA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,EAAA,EAAC,SAAS,EAAC,8BAA8B,EAAA,QAAA,EACxD,WAAW,KAAK;AACb,mCACID,GAAA,CAAC,aAAa,EAAA,EACV,MAAM,EAAE,MAAM,EACd,MAAM,EAAE,KAAK,IAAI,MAAM,CAAC,KAAK,CAAC,EAAE,EAAE,KAAK,CAAC,EACxC,OAAO,EAAE,YAAY,GAAG,MAAK,EAAG,KAAK,UAAU,EAAE,CAAC,CAAC,CAAC,GAAG,SAAS,EAChE,QAAQ,EAAE,YAAY,CAAC,QAAQ,EAC/B,YAAY,EAAE,YAAY,CAAC,YAAY,EACvC,cAAc,EAAEF,gBAAc,EAC9B,cAAc,EAAE,YAAY,CAAC,cAAc,EAC3C,MAAM,EAAE,EAAE,YAAY,EAAE,MAAM,EAAE,YAAY,EAAE,GAAG,MAAM,EAAE,SAAS,EAAE,GACtE;mCAGFE,GAAA,CAAC,gBAAgB,EAAA,EAAA,GACT,YAAY,EAChB,QAAQ,EAAE,YAAY,EACtB,aAAa,EAAE,IAAI,EACnB,MAAM,EAAE,MAAM,EAAE,YAAY,EAAA,CAC9B,CACL,EAAA,CACa,CAAA,EAAA,CACN,CAAA,EAAA,CACH,EAAA,CACN;AAE3B;;"}
@@ -0,0 +1,15 @@
1
+ import React from 'react';
2
+ import type { Constructor } from '@cratis/fundamentals';
3
+ import type { IObservableQueryFor } from '@cratis/arc/queries';
4
+ import { type ChatSidebarProps } from './ChatSidebar';
5
+ import type { ChatIdentifier } from './ChatIdentifier';
6
+ import type { ChatMessage } from './ChatMessage';
7
+ import type { ChatTopic } from './ChatTopic';
8
+ export interface ChatSidebarForObservableQueriesProps<TMessage extends ChatMessage, TTopic extends ChatTopic, TTopicsQuery extends IObservableQueryFor<TTopic[], TTopicsArguments>, TMessagesQuery extends IObservableQueryFor<TMessage[], TMessagesArguments>, TTopicsArguments extends object = object, TMessagesArguments extends object = object> extends Omit<ChatSidebarProps<TMessage, TTopic>, 'topics' | 'messages' | 'selectedTopicId'> {
9
+ topicsQuery: Constructor<TTopicsQuery>;
10
+ topicsArguments?: TTopicsArguments;
11
+ messagesQuery: Constructor<TMessagesQuery>;
12
+ messagesArguments: (topicId: ChatIdentifier | undefined) => TMessagesArguments | undefined;
13
+ }
14
+ export declare const ChatSidebarForObservableQueries: <TMessage extends ChatMessage, TTopic extends ChatTopic, TTopicsQuery extends IObservableQueryFor<TTopic[], TTopicsArguments>, TMessagesQuery extends IObservableQueryFor<TMessage[], TMessagesArguments>, TTopicsArguments extends object = object, TMessagesArguments extends object = object>({ topicsQuery, topicsArguments, messagesQuery, messagesArguments, onTopicSelected, ...sidebar }: ChatSidebarForObservableQueriesProps<TMessage, TTopic, TTopicsQuery, TMessagesQuery, TTopicsArguments, TMessagesArguments>) => React.JSX.Element;
15
+ //# sourceMappingURL=ChatSidebarForObservableQueries.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"ChatSidebarForObservableQueries.d.ts","sourceRoot":"","sources":["../../../Chat/ChatSidebarForObservableQueries.tsx"],"names":[],"mappings":"AAGA,OAAO,KAAmB,MAAM,OAAO,CAAC;AACxC,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,sBAAsB,CAAC;AACxD,OAAO,KAAK,EAAE,mBAAmB,EAAE,MAAM,qBAAqB,CAAC;AAE/D,OAAO,EAAe,KAAK,gBAAgB,EAAE,MAAM,eAAe,CAAC;AACnE,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,kBAAkB,CAAC;AACvD,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,eAAe,CAAC;AACjD,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,aAAa,CAAC;AAW7C,MAAM,WAAW,oCAAoC,CACjD,QAAQ,SAAS,WAAW,EAC5B,MAAM,SAAS,SAAS,EACxB,YAAY,SAAS,mBAAmB,CAAC,MAAM,EAAE,EAAE,gBAAgB,CAAC,EACpE,cAAc,SAAS,mBAAmB,CAAC,QAAQ,EAAE,EAAE,kBAAkB,CAAC,EAC1E,gBAAgB,SAAS,MAAM,GAAG,MAAM,EACxC,kBAAkB,SAAS,MAAM,GAAG,MAAM,CAC5C,SAAQ,IAAI,CAAC,gBAAgB,CAAC,QAAQ,EAAE,MAAM,CAAC,EAAE,QAAQ,GAAG,UAAU,GAAG,iBAAiB,CAAC;IAGzF,WAAW,EAAE,WAAW,CAAC,YAAY,CAAC,CAAC;IAGvC,eAAe,CAAC,EAAE,gBAAgB,CAAC;IAGnC,aAAa,EAAE,WAAW,CAAC,cAAc,CAAC,CAAC;IAQ3C,iBAAiB,EAAE,CAAC,OAAO,EAAE,cAAc,GAAG,SAAS,KAAK,kBAAkB,GAAG,SAAS,CAAC;CAC9F;AASD,eAAO,MAAM,+BAA+B,GACxC,QAAQ,SAAS,WAAW,EAC5B,MAAM,SAAS,SAAS,EACxB,YAAY,SAAS,mBAAmB,CAAC,MAAM,EAAE,EAAE,gBAAgB,CAAC,EACpE,cAAc,SAAS,mBAAmB,CAAC,QAAQ,EAAE,EAAE,kBAAkB,CAAC,EAC1E,gBAAgB,SAAS,MAAM,GAAG,MAAM,EACxC,kBAAkB,SAAS,MAAM,GAAG,MAAM,EAC5C,iGAOC,oCAAoC,CAAC,QAAQ,EAAE,MAAM,EAAE,YAAY,EAAE,cAAc,EAAE,gBAAgB,EAAE,kBAAkB,CAAC,sBA4B5H,CAAC"}
@@ -0,0 +1,27 @@
1
+ import { jsx } from 'react/jsx-runtime';
2
+ import { useState } from 'react';
3
+ import { useObservableQuery } from '@cratis/arc.react/queries';
4
+ import { ChatSidebar } from './ChatSidebar.js';
5
+
6
+ /**
7
+ * The {@link ChatSidebar} bound to real-time Cratis Arc observable queries — one for the topics,
8
+ * one for the open topic's messages — so both stay current as the read models change
9
+ * server-side. This is a thin, optional convenience on top of the pure {@link ChatSidebar}: every
10
+ * callback contract (sending, starting topics, naming, authors, actions, mentions) is exactly
11
+ * the same, and a host that prefers to own its subscriptions uses {@link ChatSidebar} directly.
12
+ */
13
+ const ChatSidebarForObservableQueries = ({ topicsQuery, topicsArguments, messagesQuery, messagesArguments, onTopicSelected, ...sidebar }) => {
14
+ const [selectedId, setSelectedId] = useState(undefined);
15
+ const [topicsResult] = useObservableQuery(topicsQuery, topicsArguments);
16
+ const messagesQueryArguments = messagesArguments(selectedId);
17
+ const [messagesResult] = useObservableQuery(messagesQuery, messagesQueryArguments, undefined, selectedId !== undefined && messagesQueryArguments !== undefined);
18
+ const topics = Array.isArray(topicsResult.data) ? topicsResult.data : [];
19
+ const messages = selectedId !== undefined && Array.isArray(messagesResult.data) ? messagesResult.data : [];
20
+ return (jsx(ChatSidebar, { ...sidebar, topics: topics, messages: messages, selectedTopicId: selectedId ?? null, onTopicSelected: (topicId, topic) => {
21
+ setSelectedId(topicId);
22
+ onTopicSelected?.(topicId, topic);
23
+ } }));
24
+ };
25
+
26
+ export { ChatSidebarForObservableQueries };
27
+ //# sourceMappingURL=ChatSidebarForObservableQueries.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"ChatSidebarForObservableQueries.js","sources":["../../../Chat/ChatSidebarForObservableQueries.tsx"],"sourcesContent":[null],"names":["_jsx"],"mappings":";;;;;AAgDA;;;;;;AAMG;MACU,+BAA+B,GAAG,CAO7C,EACE,WAAW,EACX,eAAe,EACf,aAAa,EACb,iBAAiB,EACjB,eAAe,EACf,GAAG,OAAO,EAC+G,KAAI;IAC7H,MAAM,CAAC,UAAU,EAAE,aAAa,CAAC,GAAG,QAAQ,CAA6B,SAAS,CAAC;IAEnF,MAAM,CAAC,YAAY,CAAC,GAAG,kBAAkB,CAA2C,WAAW,EAAE,eAAe,CAAC;AAEjH,IAAA,MAAM,sBAAsB,GAAG,iBAAiB,CAAC,UAAU,CAAC;IAC5D,MAAM,CAAC,cAAc,CAAC,GAAG,kBAAkB,CACvC,aAAa,EACb,sBAAsB,EACtB,SAAS,EACT,UAAU,KAAK,SAAS,IAAI,sBAAsB,KAAK,SAAS,CACnE;IAED,MAAM,MAAM,GAAG,KAAK,CAAC,OAAO,CAAC,YAAY,CAAC,IAAI,CAAC,GAAG,YAAY,CAAC,IAAI,GAAG,EAAE;IACxE,MAAM,QAAQ,GAAG,UAAU,KAAK,SAAS,IAAI,KAAK,CAAC,OAAO,CAAC,cAAc,CAAC,IAAI,CAAC,GAAG,cAAc,CAAC,IAAI,GAAG,EAAE;IAE1G,QACIA,GAAA,CAAC,WAAW,EAAA,EAAA,GACJ,OAAO,EACX,MAAM,EAAE,MAAM,EACd,QAAQ,EAAE,QAAQ,EAClB,eAAe,EAAE,UAAU,IAAI,IAAI,EACnC,eAAe,EAAE,CAAC,OAAO,EAAE,KAAK,KAAI;YAChC,aAAa,CAAC,OAAO,CAAC;AACtB,YAAA,eAAe,GAAG,OAAO,EAAE,KAAK,CAAC;QACrC,CAAC,EAAA,CACH;AAEV;;"}
@@ -0,0 +1,10 @@
1
+ import type { ChatIdentifier } from './ChatIdentifier';
2
+ export interface ChatTopic {
3
+ id: ChatIdentifier;
4
+ name?: string;
5
+ startedBy?: ChatIdentifier;
6
+ started?: Date;
7
+ lastActivity?: Date;
8
+ metadata?: Record<string, unknown>;
9
+ }
10
+ //# sourceMappingURL=ChatTopic.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"ChatTopic.d.ts","sourceRoot":"","sources":["../../../Chat/ChatTopic.ts"],"names":[],"mappings":"AAGA,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,kBAAkB,CAAC;AAQvD,MAAM,WAAW,SAAS;IAGtB,EAAE,EAAE,cAAc,CAAC;IAGnB,IAAI,CAAC,EAAE,MAAM,CAAC;IAGd,SAAS,CAAC,EAAE,cAAc,CAAC;IAG3B,OAAO,CAAC,EAAE,IAAI,CAAC;IAGf,YAAY,CAAC,EAAE,IAAI,CAAC;IAGpB,QAAQ,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;CACtC"}
@@ -0,0 +1,2 @@
1
+ export {};
2
+ //# sourceMappingURL=ChatTopic.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"ChatTopic.js","sourceRoot":"","sources":["../../../Chat/ChatTopic.ts"],"names":[],"mappings":""}
@@ -0,0 +1,26 @@
1
+ import React, { type ReactNode } from 'react';
2
+ import { type BuildAvatarUrlParams } from '../Canvas/shapes/ChatBubble/Avatar';
3
+ import type { ChatAuthor } from './ChatAuthor';
4
+ import { type ChatIdentifier } from './ChatIdentifier';
5
+ import type { ChatTopic } from './ChatTopic';
6
+ import { type RelativeTimestampLabels } from './relativeTimestamp';
7
+ export interface ChatTopicListLabels {
8
+ newTopic?: string;
9
+ unnamedTopic?: string;
10
+ startedBy?: string;
11
+ empty?: string;
12
+ timestamps?: RelativeTimestampLabels;
13
+ }
14
+ export interface ChatTopicListProps<TTopic extends ChatTopic = ChatTopic> {
15
+ topics: TTopic[];
16
+ onOpen: (topic: TTopic) => void;
17
+ onStart?: () => void;
18
+ authorOf?: (authorId: ChatIdentifier) => ChatAuthor;
19
+ renderAvatar?: (authorId: ChatIdentifier, author: ChatAuthor) => ReactNode;
20
+ isTopicUnnamed?: (topic: TTopic) => boolean;
21
+ buildAvatarUrl?: (params: BuildAvatarUrlParams) => string;
22
+ labels?: ChatTopicListLabels;
23
+ className?: string;
24
+ }
25
+ export declare const ChatTopicList: <TTopic extends ChatTopic = ChatTopic>({ topics, onOpen, onStart, authorOf, renderAvatar, isTopicUnnamed, buildAvatarUrl, labels, className, }: ChatTopicListProps<TTopic>) => React.JSX.Element;
26
+ //# sourceMappingURL=ChatTopicList.d.ts.map