@cratis/components 4.54.0 → 4.55.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.
Files changed (110) hide show
  1. package/compat-manifest.json +13 -13
  2. package/dist/esm/Chat/ChatConversation.d.ts.map +1 -1
  3. package/dist/esm/Chat/ChatConversation.js +38 -10
  4. package/dist/esm/Chat/ChatConversation.js.map +1 -1
  5. package/dist/esm/Chat/ChatMessageBody.js +1 -1
  6. package/dist/esm/Chat/ChatMessageBody.js.map +1 -1
  7. package/dist/esm/Chat/ChatTopicList.js +1 -1
  8. package/dist/esm/Chat/ChatTopicList.js.map +1 -1
  9. package/dist/esm/Chat/Kit/Avatar/PersonAvatarCircle.d.ts.map +1 -1
  10. package/dist/esm/Chat/Kit/Avatar/PersonAvatarCircle.js +1 -1
  11. package/dist/esm/Chat/Kit/Avatar/PersonAvatarCircle.js.map +1 -1
  12. package/dist/esm/Chat/Kit/ChatComposer.js +1 -1
  13. package/dist/esm/Chat/Kit/ChatComposer.js.map +1 -1
  14. package/dist/esm/Chat/Kit/ChatMessageBubble.d.ts.map +1 -1
  15. package/dist/esm/Chat/Kit/ChatMessageBubble.js +18 -11
  16. package/dist/esm/Chat/Kit/ChatMessageBubble.js.map +1 -1
  17. package/dist/esm/Chat/Kit/Emoji/EmojiPicker.js +1 -1
  18. package/dist/esm/Chat/Kit/Emoji/EmojiPicker.js.map +1 -1
  19. package/dist/esm/Chat/Kit/FailedReply.js +1 -1
  20. package/dist/esm/Chat/Kit/FailedReply.js.map +1 -1
  21. package/dist/esm/Chat/Kit/Mentions/MentionSuggestions.js +1 -1
  22. package/dist/esm/Chat/Kit/Mentions/MentionSuggestions.js.map +1 -1
  23. package/dist/esm/Chat/Kit/MessageReactions.js +1 -1
  24. package/dist/esm/Chat/Kit/MessageReactions.js.map +1 -1
  25. package/dist/esm/Chat/Kit/ReactionPicker.js +1 -1
  26. package/dist/esm/Chat/Kit/ReactionPicker.js.map +1 -1
  27. package/dist/esm/Chat/Kit/TypingIndicator.js +1 -1
  28. package/dist/esm/Chat/Kit/TypingIndicator.js.map +1 -1
  29. package/dist/esm/Common/CratisComponentsProvider.d.ts +4 -0
  30. package/dist/esm/Common/CratisComponentsProvider.d.ts.map +1 -1
  31. package/dist/esm/Common/CratisComponentsProvider.js.map +1 -1
  32. package/dist/esm/DataTables/DataTableCard.d.ts +4 -0
  33. package/dist/esm/DataTables/DataTableCard.d.ts.map +1 -0
  34. package/dist/esm/DataTables/DataTableCard.js +43 -0
  35. package/dist/esm/DataTables/DataTableCard.js.map +1 -0
  36. package/dist/esm/DataTables/DataTableCardControls.d.ts +6 -0
  37. package/dist/esm/DataTables/DataTableCardControls.d.ts.map +1 -0
  38. package/dist/esm/DataTables/DataTableCardControls.js +27 -0
  39. package/dist/esm/DataTables/DataTableCardControls.js.map +1 -0
  40. package/dist/esm/DataTables/DataTableCards.d.ts +16 -0
  41. package/dist/esm/DataTables/DataTableCards.d.ts.map +1 -0
  42. package/dist/esm/DataTables/DataTableCards.js +40 -0
  43. package/dist/esm/DataTables/DataTableCards.js.map +1 -0
  44. package/dist/esm/DataTables/DataTableCore.d.ts +3 -1
  45. package/dist/esm/DataTables/DataTableCore.d.ts.map +1 -1
  46. package/dist/esm/DataTables/DataTableCore.js +8 -2
  47. package/dist/esm/DataTables/DataTableCore.js.map +1 -1
  48. package/dist/esm/DataTables/DataTableForObservableQuery.d.ts +2 -1
  49. package/dist/esm/DataTables/DataTableForObservableQuery.d.ts.map +1 -1
  50. package/dist/esm/DataTables/DataTableForObservableQuery.js +1 -1
  51. package/dist/esm/DataTables/DataTableForObservableQuery.js.map +1 -1
  52. package/dist/esm/DataTables/DataTableForQuery.d.ts +2 -1
  53. package/dist/esm/DataTables/DataTableForQuery.d.ts.map +1 -1
  54. package/dist/esm/DataTables/DataTableForQuery.js +1 -1
  55. package/dist/esm/DataTables/DataTableForQuery.js.map +1 -1
  56. package/dist/esm/DataTables/DataTableHeaderCell.d.ts +2 -2
  57. package/dist/esm/DataTables/DataTableHeaderCell.d.ts.map +1 -1
  58. package/dist/esm/DataTables/DataTableHeaderCell.js +5 -19
  59. package/dist/esm/DataTables/DataTableHeaderCell.js.map +1 -1
  60. package/dist/esm/DataTables/DataTableHeaderContent.d.ts +11 -0
  61. package/dist/esm/DataTables/DataTableHeaderContent.d.ts.map +1 -0
  62. package/dist/esm/DataTables/DataTableHeaderContent.js +37 -0
  63. package/dist/esm/DataTables/DataTableHeaderContent.js.map +1 -0
  64. package/dist/esm/DataTables/DataTableMessages.d.ts +2 -0
  65. package/dist/esm/DataTables/DataTableMessages.d.ts.map +1 -1
  66. package/dist/esm/DataTables/DataTableMessages.js.map +1 -1
  67. package/dist/esm/DataTables/DataTableMobileLayoutProps.d.ts +8 -0
  68. package/dist/esm/DataTables/DataTableMobileLayoutProps.d.ts.map +1 -0
  69. package/dist/esm/DataTables/DataTableMobileLayoutProps.js +4 -0
  70. package/dist/esm/DataTables/DataTableMobileLayoutProps.js.map +1 -0
  71. package/dist/esm/DataTables/DataTableParts.d.ts +12 -0
  72. package/dist/esm/DataTables/DataTableParts.d.ts.map +1 -1
  73. package/dist/esm/DataTables/DataTableParts.js.map +1 -1
  74. package/dist/esm/DataTables/DataTableRow.d.ts +3 -1
  75. package/dist/esm/DataTables/DataTableRow.d.ts.map +1 -1
  76. package/dist/esm/DataTables/DataTableRow.js +23 -18
  77. package/dist/esm/DataTables/DataTableRow.js.map +1 -1
  78. package/dist/esm/DataTables/DataTableRows.d.ts.map +1 -1
  79. package/dist/esm/DataTables/DataTableRows.js +1 -1
  80. package/dist/esm/DataTables/DataTableRows.js.map +1 -1
  81. package/dist/esm/DataTables/dataTableCellContent.d.ts +5 -0
  82. package/dist/esm/DataTables/dataTableCellContent.d.ts.map +1 -0
  83. package/dist/esm/DataTables/dataTableCellContent.js +11 -0
  84. package/dist/esm/DataTables/dataTableCellContent.js.map +1 -0
  85. package/dist/esm/DataTables/useDataTableMessages.d.ts.map +1 -1
  86. package/dist/esm/DataTables/useDataTableMessages.js +2 -0
  87. package/dist/esm/DataTables/useDataTableMessages.js.map +1 -1
  88. package/dist/esm/DataTables/useDataTablePresentationFocus.d.ts +3 -0
  89. package/dist/esm/DataTables/useDataTablePresentationFocus.d.ts.map +1 -0
  90. package/dist/esm/DataTables/useDataTablePresentationFocus.js +45 -0
  91. package/dist/esm/DataTables/useDataTablePresentationFocus.js.map +1 -0
  92. package/dist/esm/DataTables/useMobileLayout.d.ts +4 -0
  93. package/dist/esm/DataTables/useMobileLayout.d.ts.map +1 -0
  94. package/dist/esm/DataTables/useMobileLayout.js +20 -0
  95. package/dist/esm/DataTables/useMobileLayout.js.map +1 -0
  96. package/dist/esm/DataTables/useRowSelection.d.ts.map +1 -1
  97. package/dist/esm/DataTables/useRowSelection.js +1 -1
  98. package/dist/esm/DataTables/useRowSelection.js.map +1 -1
  99. package/dist/esm/SchemaEditor/Tree/PropertyTypeGlyph.js +1 -1
  100. package/dist/esm/SchemaEditor/Tree/PropertyTypeGlyph.js.map +1 -1
  101. package/dist/esm/styles.DataPage.css +66 -0
  102. package/dist/esm/styles.DataTables.css +66 -0
  103. package/dist/esm/styles.SchemaEditor.css +66 -0
  104. package/dist/esm/styles.css +66 -0
  105. package/dist/esm/styles.renderer.builtin.css +66 -0
  106. package/dist/esm/types/parts.d.ts +21 -3
  107. package/dist/esm/types/parts.d.ts.map +1 -1
  108. package/dist/esm/types/parts.js +21 -3
  109. package/dist/esm/types/parts.js.map +1 -1
  110. package/package.json +1 -1
@@ -1 +1 @@
1
- {"version":3,"file":"ChatComposer.js","sources":["../../../../Chat/Kit/ChatComposer.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 React from 'react';\nimport { forwardRef, useEffect, useId, useImperativeHandle, useRef, useState } from 'react';\nimport { AnchoredOverlay } from './AnchoredOverlay';\nimport type { BuildAvatarUrlParams } from './Avatar';\nimport { activeMentionQuery } from './Mentions/activeMentionQuery';\nimport { applyMention } from './Mentions/applyMention';\nimport { mentionOptionId } from './Mentions/mentionOptionId';\nimport { extractMentions } from './Mentions/extractMentions';\nimport { matchCandidates } from './Mentions/matchCandidates';\nimport { MentionSuggestions, type MentionCandidate } from './Mentions';\nimport { ReactionPicker, type ReactionPickerLabels } from './ReactionPicker';\n\n/** Overrides for the composer's own labels. Any field left unset falls back to a literal English\n * default. */\nexport interface ChatComposerLabels {\n /** Placeholder text for the draft input. Defaults to `'Write a message… (Enter to send)'`. */\n placeholder?: string;\n /** Tooltip/accessible label for the emoji-insert toggle. Defaults to `'Insert emoji'`. */\n insertEmoji?: string;\n /** Tooltip for the send button. Defaults to `'Send'`. */\n send?: string;\n /** Accessible label for the send button. Defaults to `'Send message'`. */\n sendMessage?: string;\n /** Labels forwarded to the emoji-insert {@link ReactionPicker}. */\n reactionPicker?: ReactionPickerLabels;\n}\n\n/**\n * Props for the compose row of a conversation — the text area, the `@` mention list it opens, and\n * the send button. It owns the draft so the surrounding panel stays a renderer of messages.\n */\nexport interface ChatComposerProps {\n /** Everyone who can be mentioned from this conversation. Omit to turn mentions off. */\n mentionCandidates?: MentionCandidate[];\n\n /**\n * Resolves who can be mentioned as the person types, invoked with what has been typed after\n * the `@` — for hosts whose candidates come from a lookup rather than a list they already\n * hold. May answer synchronously or with a promise; a stale answer (one that arrives after\n * the query has moved on) is dropped. Combines with {@link mentionCandidates} when both are\n * given.\n * @param query What has been typed after the `@`.\n * @returns The candidates matching the query.\n */\n resolveMentionCandidates?: (\n query: string,\n ) => MentionCandidate[] | Promise<MentionCandidate[]>;\n\n /**\n * Invoked with the trimmed message text when the user sends, together with who that text\n * actually mentions — reduced from every candidate the draft saw, so a mention that was\n * picked but edited away again does not count.\n */\n onSend: (text: string, mentions: MentionCandidate[]) => void;\n\n /** Whether to take focus when mounted. */\n autoFocus?: boolean;\n\n /** Disables drafting, emoji insertion, and sending. Defaults to false. */\n disabled?: boolean;\n\n /** Builds the avatar image URL for mention candidates. Omit to always show initials. */\n buildAvatarUrl?: (params: BuildAvatarUrlParams) => string;\n\n /** Overrides for the composer's labels. Unset fields fall back to literal English defaults. */\n labels?: ChatComposerLabels;\n}\n\n/**\n * Imperative actions a caller can drive on the composer without owning its draft state — used by a\n * quick reply, which sets the starting text for whatever the person types next rather than sending\n * anything itself.\n */\nexport interface ChatComposerHandle {\n /** Replaces the current draft and takes focus, caret placed at the end. */\n prefill: (text: string) => void;\n}\n\n/**\n * The compose row of a conversation — the text area, the `@` mention list it opens, and the send\n * button. It owns the draft so the surrounding panel stays a renderer of messages.\n */\nexport const ChatComposer = forwardRef<ChatComposerHandle, ChatComposerProps>(\n (\n {\n mentionCandidates,\n resolveMentionCandidates,\n onSend,\n autoFocus = false,\n disabled = false,\n buildAvatarUrl,\n labels,\n },\n handleRef,\n ) => {\n const [draft, setDraft] = useState({ text: '', caret: 0 });\n const [highlightedIndex, setHighlightedIndex] = useState(0);\n // The query the user dismissed with Escape; it stays closed until the query itself changes.\n const [dismissed, setDismissed] = useState<{ start: number; text: string } | null>(null);\n const listId = useId();\n const [showEmojiPicker, setShowEmojiPicker] = useState(false);\n const [resolvedCandidates, setResolvedCandidates] = useState<MentionCandidate[]>(\n [],\n );\n const inputRef = useRef<HTMLTextAreaElement>(null);\n const didAutoFocus = useRef(false);\n const emojiButtonRef = useRef<HTMLButtonElement>(null);\n // Every candidate this draft has seen — resolved or picked — so the mentions reported on\n // send can be found again even when the resolver's latest answer no longer includes them.\n const seenCandidatesRef = useRef(new Map<string, MentionCandidate>());\n\n const mentionsEnabled = !!mentionCandidates || !!resolveMentionCandidates;\n const query = mentionsEnabled\n ? activeMentionQuery(draft.text, draft.caret)\n : null;\n const queryText = query?.text;\n const isDismissed =\n dismissed !== null && query?.start === dismissed.start && query.text === dismissed.text;\n\n useEffect(() => {\n if (dismissed !== null && !isDismissed) {\n setDismissed(null);\n }\n }, [dismissed, isDismissed]);\n\n useEffect(() => {\n if (!resolveMentionCandidates || queryText === undefined) {\n setResolvedCandidates((previous) =>\n previous.length === 0 ? previous : [],\n );\n return;\n }\n let cancelled = false;\n Promise.resolve(resolveMentionCandidates(queryText))\n .then((candidates) => {\n if (cancelled) return;\n setResolvedCandidates(candidates);\n candidates.forEach((candidate) =>\n seenCandidatesRef.current.set(candidate.id, candidate),\n );\n })\n .catch(() => {\n if (!cancelled) {\n setResolvedCandidates([]);\n }\n });\n return () => {\n cancelled = true;\n };\n }, [resolveMentionCandidates, queryText]);\n\n const uniqueById = (candidates: MentionCandidate[]): MentionCandidate[] => {\n const byId = new Map<string, MentionCandidate>();\n candidates.forEach((candidate) => {\n if (!byId.has(candidate.id)) {\n byId.set(candidate.id, candidate);\n }\n });\n return [...byId.values()];\n };\n\n const candidatePool = uniqueById([\n ...(mentionCandidates ?? []),\n ...resolvedCandidates,\n ]);\n // A query that ends in whitespace and spells a candidate's full name is a mention already\n // made — the trailing space applyMention writes is its closing. Without this, Enter right\n // after picking would re-pick the same name instead of sending the message.\n const queryIsCompleteMention =\n query !== null &&\n /\\s$/.test(query.text) &&\n candidatePool.some(\n (candidate) =>\n candidate.name.toLowerCase() === query.text.trim().toLowerCase(),\n );\n const suggestions =\n query && !queryIsCompleteMention && !isDismissed\n ? matchCandidates(candidatePool, query.text)\n : [];\n const isSuggesting = !disabled && suggestions.length > 0;\n const highlighted = Math.min(highlightedIndex, suggestions.length - 1);\n\n useEffect(() => {\n if (autoFocus && !disabled && !didAutoFocus.current && inputRef.current) {\n inputRef.current.focus();\n didAutoFocus.current = true;\n }\n }, [autoFocus, disabled]);\n\n useEffect(() => {\n if (disabled) {\n setShowEmojiPicker(false);\n }\n }, [disabled]);\n\n useImperativeHandle(\n handleRef,\n () => ({\n prefill: (text: string) => {\n setDraft({ text, caret: text.length });\n requestAnimationFrame(() => {\n inputRef.current?.focus();\n inputRef.current?.setSelectionRange(text.length, text.length);\n });\n },\n }),\n [],\n );\n\n const readDraft = (element: HTMLTextAreaElement) => {\n const text = element.value;\n // Only editing the text restarts the selection. Resetting on every key event would undo the\n // arrow-key navigation on the very next keyup.\n if (text !== draft.text) {\n setHighlightedIndex(0);\n }\n setDraft({ text, caret: element.selectionStart ?? text.length });\n };\n\n const send = () => {\n const trimmed = draft.text.trim();\n if (!trimmed || disabled) return;\n const known = uniqueById([\n ...(mentionCandidates ?? []),\n ...seenCandidatesRef.current.values(),\n ]);\n onSend(trimmed, extractMentions(trimmed, known));\n seenCandidatesRef.current.clear();\n setDraft({ text: '', caret: 0 });\n };\n\n const choose = (candidate: MentionCandidate) => {\n if (!query) return;\n seenCandidatesRef.current.set(candidate.id, candidate);\n const applied = applyMention(draft.text, draft.caret, query, candidate.name);\n setDraft(applied);\n setHighlightedIndex(0);\n // The caret has to be restored after React has written the new value back into the element.\n requestAnimationFrame(() =>\n inputRef.current?.setSelectionRange(applied.caret, applied.caret),\n );\n inputRef.current?.focus();\n };\n\n const insertEmoji = (emoji: string) => {\n const text = `${draft.text.slice(0, draft.caret)}${emoji}${draft.text.slice(draft.caret)}`;\n const caret = draft.caret + emoji.length;\n setDraft({ text, caret });\n setShowEmojiPicker(false);\n // Same restore-after-write pattern as choose() above — React has to write the new value in\n // before the caret can be placed past the emoji it inserted.\n requestAnimationFrame(() => {\n inputRef.current?.focus();\n inputRef.current?.setSelectionRange(caret, caret);\n });\n };\n\n const handleKeyDown = (event: React.KeyboardEvent<HTMLTextAreaElement>) => {\n if (isSuggesting) {\n if (event.key === 'ArrowDown' || event.key === 'ArrowUp') {\n event.preventDefault();\n const step = event.key === 'ArrowDown' ? 1 : suggestions.length - 1;\n setHighlightedIndex((highlighted + step) % suggestions.length);\n return;\n }\n\n if (event.key === 'Enter' || event.key === 'Tab') {\n event.preventDefault();\n choose(suggestions[highlighted]);\n return;\n }\n\n if (event.key === 'Escape') {\n event.preventDefault();\n // The Escape belongs to the list while it is open, not to a dialog around the composer.\n event.stopPropagation();\n // Closing the list leaves the draft and caret alone.\n setDismissed(query);\n return;\n }\n }\n\n if (event.key === 'Enter' && !event.shiftKey) {\n event.preventDefault();\n send();\n }\n };\n\n return (\n <div className='chat-composer'>\n {isSuggesting && (\n <MentionSuggestions\n candidates={suggestions}\n highlightedIndex={highlighted}\n id={listId}\n onSelect={choose}\n onHighlight={setHighlightedIndex}\n buildAvatarUrl={buildAvatarUrl}\n />\n )}\n <textarea\n ref={inputRef}\n className='chat-composer__input'\n value={draft.text}\n onChange={(event) => readDraft(event.target)}\n onKeyUp={(event) => readDraft(event.currentTarget)}\n onClick={(event) => readDraft(event.currentTarget)}\n onKeyDown={handleKeyDown}\n placeholder={\n labels?.placeholder ?? 'Write a message… (Enter to send)'\n }\n rows={2}\n aria-autocomplete={isSuggesting ? 'list' : undefined}\n aria-controls={isSuggesting ? listId : undefined}\n aria-activedescendant={isSuggesting ? mentionOptionId(listId, highlighted) : undefined}\n disabled={disabled}\n />\n <button\n ref={emojiButtonRef}\n type='button'\n className='chat-composer__emoji-toggle'\n disabled={disabled}\n onMouseDown={(event) => event.preventDefault()}\n onClick={() => setShowEmojiPicker((previous) => !previous)}\n title={labels?.insertEmoji ?? 'Insert emoji'}\n aria-label={labels?.insertEmoji ?? 'Insert emoji'}\n aria-expanded={showEmojiPicker}\n >\n ☺\n </button>\n <button\n type='button'\n className='chat-composer__send'\n onClick={send}\n disabled={disabled || !draft.text.trim()}\n title={labels?.send ?? 'Send'}\n aria-label={labels?.sendMessage ?? 'Send message'}\n >\n <svg\n width='16'\n height='16'\n viewBox='0 0 24 24'\n fill='none'\n stroke='currentColor'\n strokeWidth='2.5'\n aria-hidden='true'\n >\n <line x1='22' y1='2' x2='11' y2='13' />\n <polygon points='22 2 15 22 11 13 2 9 22 2' />\n </svg>\n </button>\n {/* Portaled to <body>, same reason as the reaction picker on a message bubble: the chat\n panel scrolls/clips, so a picker positioned inside it would be cut off at the edge. */}\n <AnchoredOverlay\n anchorRef={emojiButtonRef}\n open={showEmojiPicker && !disabled}\n side='above'\n align='right'\n gap={6}\n >\n <ReactionPicker\n anchorRef={emojiButtonRef}\n onPick={insertEmoji}\n onDismiss={() => setShowEmojiPicker(false)}\n labels={labels?.reactionPicker}\n />\n </AnchoredOverlay>\n </div>\n );\n },\n);\nChatComposer.displayName = 'ChatComposer';\n"],"names":["_jsxs","_jsx"],"mappings":";;;;;;;;;;;AAqFO,MAAM,YAAY,GAAG,UAAU,CAClC,CACI,EACI,iBAAiB,EACjB,wBAAwB,EACxB,MAAM,EACN,SAAS,GAAG,KAAK,EACjB,QAAQ,GAAG,KAAK,EAChB,cAAc,EACd,MAAM,GACT,EACD,SAAS,KACT;AACA,IAAA,MAAM,CAAC,KAAK,EAAE,QAAQ,CAAC,GAAG,QAAQ,CAAC,EAAE,IAAI,EAAE,EAAE,EAAE,KAAK,EAAE,CAAC,EAAE,CAAC;IAC1D,MAAM,CAAC,gBAAgB,EAAE,mBAAmB,CAAC,GAAG,QAAQ,CAAC,CAAC,CAAC;IAE3D,MAAM,CAAC,SAAS,EAAE,YAAY,CAAC,GAAG,QAAQ,CAAyC,IAAI,CAAC;AACxF,IAAA,MAAM,MAAM,GAAG,KAAK,EAAE;IACtB,MAAM,CAAC,eAAe,EAAE,kBAAkB,CAAC,GAAG,QAAQ,CAAC,KAAK,CAAC;IAC7D,MAAM,CAAC,kBAAkB,EAAE,qBAAqB,CAAC,GAAG,QAAQ,CACxD,EAAE,CACL;AACD,IAAA,MAAM,QAAQ,GAAG,MAAM,CAAsB,IAAI,CAAC;AAClD,IAAA,MAAM,YAAY,GAAG,MAAM,CAAC,KAAK,CAAC;AAClC,IAAA,MAAM,cAAc,GAAG,MAAM,CAAoB,IAAI,CAAC;IAGtD,MAAM,iBAAiB,GAAG,MAAM,CAAC,IAAI,GAAG,EAA4B,CAAC;IAErE,MAAM,eAAe,GAAG,CAAC,CAAC,iBAAiB,IAAI,CAAC,CAAC,wBAAwB;IACzE,MAAM,KAAK,GAAG;UACR,kBAAkB,CAAC,KAAK,CAAC,IAAI,EAAE,KAAK,CAAC,KAAK;UAC1C,IAAI;AACV,IA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AAE,QAAQ,IAAI,CAAC,KAAK,CAAC,IAAI,CAAC,IAAI,EAAE,EACxC,KAAK,EAAE,MAAM,EAAE,IAAI,IAAI,MAAM,gBACjB,MAAM,EAAE,WAAW,IAAI,cAAc,EAAA,QAAA,EAEjDD,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,iBACL,MAAM,EAAA,QAAA,EAAA,CAElBC,cAAM,EAAE,EAAC,IAAI,EAAC,EAAE,EAAC,GAAG,EAAC,EAAE,EAAC,IAAI,EAAC,EAAE,EAAC,IAAI,EAAA,CAAG,EACvCA,GAAA,CAAA,SAAA,EAAA,EAAS,MAAM,EAAC,2BAA2B,EAAA,CAAG,IAC5C,EAAA,CACD,EAGTA,IAAC,eAAe,EAAA,EACZ,SAAS,EAAE,cAAc,EACzB,IAAI,EAAE,eAAe,IAAI,CAAC,QAAQ,EAClC,IAAI,EAAC,OAAO,EACZ,KAAK,EAAC,OAAO,EACb,GAAG,EAAE,CAAC,EAAA,QAAA,EAENA,IAAC,cAAc,EAAA,EACX,SAAS,EAAE,cAAc,EACzB,MAAM,EAAE,WAAW,EACnB,SAAS,EAAE,MAAM,kBAAkB,CAAC,KAAK,CAAC,EAC1C,MAAM,EAAE,MAAM,EAAE,cAAc,GAChC,EAAA,CACY,CAAA,EAAA,CAChB;AAEd,CAAC;AAEL,YAAY,CAAC,WAAW,GAAG,cAAc;;"}
1
+ {"version":3,"file":"ChatComposer.js","sources":["../../../../Chat/Kit/ChatComposer.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 React from 'react';\nimport { forwardRef, useEffect, useId, useImperativeHandle, useRef, useState } from 'react';\nimport { AnchoredOverlay } from './AnchoredOverlay';\nimport type { BuildAvatarUrlParams } from './Avatar';\nimport { activeMentionQuery } from './Mentions/activeMentionQuery';\nimport { applyMention } from './Mentions/applyMention';\nimport { mentionOptionId } from './Mentions/mentionOptionId';\nimport { extractMentions } from './Mentions/extractMentions';\nimport { matchCandidates } from './Mentions/matchCandidates';\nimport { MentionSuggestions, type MentionCandidate } from './Mentions';\nimport { ReactionPicker, type ReactionPickerLabels } from './ReactionPicker';\n\n/** Overrides for the composer's own labels. Any field left unset falls back to a literal English\n * default. */\nexport interface ChatComposerLabels {\n /** Placeholder text for the draft input. Defaults to `'Write a message… (Enter to send)'`. */\n placeholder?: string;\n /** Tooltip/accessible label for the emoji-insert toggle. Defaults to `'Insert emoji'`. */\n insertEmoji?: string;\n /** Tooltip for the send button. Defaults to `'Send'`. */\n send?: string;\n /** Accessible label for the send button. Defaults to `'Send message'`. */\n sendMessage?: string;\n /** Labels forwarded to the emoji-insert {@link ReactionPicker}. */\n reactionPicker?: ReactionPickerLabels;\n}\n\n/**\n * Props for the compose row of a conversation — the text area, the `@` mention list it opens, and\n * the send button. It owns the draft so the surrounding panel stays a renderer of messages.\n */\nexport interface ChatComposerProps {\n /** Everyone who can be mentioned from this conversation. Omit to turn mentions off. */\n mentionCandidates?: MentionCandidate[];\n\n /**\n * Resolves who can be mentioned as the person types, invoked with what has been typed after\n * the `@` — for hosts whose candidates come from a lookup rather than a list they already\n * hold. May answer synchronously or with a promise; a stale answer (one that arrives after\n * the query has moved on) is dropped. Combines with {@link mentionCandidates} when both are\n * given.\n * @param query What has been typed after the `@`.\n * @returns The candidates matching the query.\n */\n resolveMentionCandidates?: (\n query: string,\n ) => MentionCandidate[] | Promise<MentionCandidate[]>;\n\n /**\n * Invoked with the trimmed message text when the user sends, together with who that text\n * actually mentions — reduced from every candidate the draft saw, so a mention that was\n * picked but edited away again does not count.\n */\n onSend: (text: string, mentions: MentionCandidate[]) => void;\n\n /** Whether to take focus when mounted. */\n autoFocus?: boolean;\n\n /** Disables drafting, emoji insertion, and sending. Defaults to false. */\n disabled?: boolean;\n\n /** Builds the avatar image URL for mention candidates. Omit to always show initials. */\n buildAvatarUrl?: (params: BuildAvatarUrlParams) => string;\n\n /** Overrides for the composer's labels. Unset fields fall back to literal English defaults. */\n labels?: ChatComposerLabels;\n}\n\n/**\n * Imperative actions a caller can drive on the composer without owning its draft state — used by a\n * quick reply, which sets the starting text for whatever the person types next rather than sending\n * anything itself.\n */\nexport interface ChatComposerHandle {\n /** Replaces the current draft and takes focus, caret placed at the end. */\n prefill: (text: string) => void;\n}\n\n/**\n * The compose row of a conversation — the text area, the `@` mention list it opens, and the send\n * button. It owns the draft so the surrounding panel stays a renderer of messages.\n */\nexport const ChatComposer = forwardRef<ChatComposerHandle, ChatComposerProps>(\n (\n {\n mentionCandidates,\n resolveMentionCandidates,\n onSend,\n autoFocus = false,\n disabled = false,\n buildAvatarUrl,\n labels,\n },\n handleRef,\n ) => {\n const [draft, setDraft] = useState({ text: '', caret: 0 });\n const [highlightedIndex, setHighlightedIndex] = useState(0);\n // The query the user dismissed with Escape; it stays closed until the query itself changes.\n const [dismissed, setDismissed] = useState<{ start: number; text: string } | null>(null);\n const listId = useId();\n const [showEmojiPicker, setShowEmojiPicker] = useState(false);\n const [resolvedCandidates, setResolvedCandidates] = useState<MentionCandidate[]>(\n [],\n );\n const inputRef = useRef<HTMLTextAreaElement>(null);\n const didAutoFocus = useRef(false);\n const emojiButtonRef = useRef<HTMLButtonElement>(null);\n // Every candidate this draft has seen — resolved or picked — so the mentions reported on\n // send can be found again even when the resolver's latest answer no longer includes them.\n const seenCandidatesRef = useRef(new Map<string, MentionCandidate>());\n\n const mentionsEnabled = !!mentionCandidates || !!resolveMentionCandidates;\n const query = mentionsEnabled\n ? activeMentionQuery(draft.text, draft.caret)\n : null;\n const queryText = query?.text;\n const isDismissed =\n dismissed !== null && query?.start === dismissed.start && query.text === dismissed.text;\n\n useEffect(() => {\n if (dismissed !== null && !isDismissed) {\n setDismissed(null);\n }\n }, [dismissed, isDismissed]);\n\n useEffect(() => {\n if (!resolveMentionCandidates || queryText === undefined) {\n setResolvedCandidates((previous) =>\n previous.length === 0 ? previous : [],\n );\n return;\n }\n let cancelled = false;\n Promise.resolve(resolveMentionCandidates(queryText))\n .then((candidates) => {\n if (cancelled) return;\n setResolvedCandidates(candidates);\n candidates.forEach((candidate) =>\n seenCandidatesRef.current.set(candidate.id, candidate),\n );\n })\n .catch(() => {\n if (!cancelled) {\n setResolvedCandidates([]);\n }\n });\n return () => {\n cancelled = true;\n };\n }, [resolveMentionCandidates, queryText]);\n\n const uniqueById = (candidates: MentionCandidate[]): MentionCandidate[] => {\n const byId = new Map<string, MentionCandidate>();\n candidates.forEach((candidate) => {\n if (!byId.has(candidate.id)) {\n byId.set(candidate.id, candidate);\n }\n });\n return [...byId.values()];\n };\n\n const candidatePool = uniqueById([\n ...(mentionCandidates ?? []),\n ...resolvedCandidates,\n ]);\n // A query that ends in whitespace and spells a candidate's full name is a mention already\n // made — the trailing space applyMention writes is its closing. Without this, Enter right\n // after picking would re-pick the same name instead of sending the message.\n const queryIsCompleteMention =\n query !== null &&\n /\\s$/.test(query.text) &&\n candidatePool.some(\n (candidate) =>\n candidate.name.toLowerCase() === query.text.trim().toLowerCase(),\n );\n const suggestions =\n query && !queryIsCompleteMention && !isDismissed\n ? matchCandidates(candidatePool, query.text)\n : [];\n const isSuggesting = !disabled && suggestions.length > 0;\n const highlighted = Math.min(highlightedIndex, suggestions.length - 1);\n\n useEffect(() => {\n if (autoFocus && !disabled && !didAutoFocus.current && inputRef.current) {\n inputRef.current.focus();\n didAutoFocus.current = true;\n }\n }, [autoFocus, disabled]);\n\n useEffect(() => {\n if (disabled) {\n setShowEmojiPicker(false);\n }\n }, [disabled]);\n\n useImperativeHandle(\n handleRef,\n () => ({\n prefill: (text: string) => {\n setDraft({ text, caret: text.length });\n requestAnimationFrame(() => {\n inputRef.current?.focus();\n inputRef.current?.setSelectionRange(text.length, text.length);\n });\n },\n }),\n [],\n );\n\n const readDraft = (element: HTMLTextAreaElement) => {\n const text = element.value;\n // Only editing the text restarts the selection. Resetting on every key event would undo the\n // arrow-key navigation on the very next keyup.\n if (text !== draft.text) {\n setHighlightedIndex(0);\n }\n setDraft({ text, caret: element.selectionStart ?? text.length });\n };\n\n const send = () => {\n const trimmed = draft.text.trim();\n if (!trimmed || disabled) return;\n const known = uniqueById([\n ...(mentionCandidates ?? []),\n ...seenCandidatesRef.current.values(),\n ]);\n onSend(trimmed, extractMentions(trimmed, known));\n seenCandidatesRef.current.clear();\n setDraft({ text: '', caret: 0 });\n };\n\n const choose = (candidate: MentionCandidate) => {\n if (!query) return;\n seenCandidatesRef.current.set(candidate.id, candidate);\n const applied = applyMention(draft.text, draft.caret, query, candidate.name);\n setDraft(applied);\n setHighlightedIndex(0);\n // The caret has to be restored after React has written the new value back into the element.\n requestAnimationFrame(() =>\n inputRef.current?.setSelectionRange(applied.caret, applied.caret),\n );\n inputRef.current?.focus();\n };\n\n const insertEmoji = (emoji: string) => {\n const text = `${draft.text.slice(0, draft.caret)}${emoji}${draft.text.slice(draft.caret)}`;\n const caret = draft.caret + emoji.length;\n setDraft({ text, caret });\n setShowEmojiPicker(false);\n // Same restore-after-write pattern as choose() above — React has to write the new value in\n // before the caret can be placed past the emoji it inserted.\n requestAnimationFrame(() => {\n inputRef.current?.focus();\n inputRef.current?.setSelectionRange(caret, caret);\n });\n };\n\n const handleKeyDown = (event: React.KeyboardEvent<HTMLTextAreaElement>) => {\n if (isSuggesting) {\n if (event.key === 'ArrowDown' || event.key === 'ArrowUp') {\n event.preventDefault();\n const step = event.key === 'ArrowDown' ? 1 : suggestions.length - 1;\n setHighlightedIndex((highlighted + step) % suggestions.length);\n return;\n }\n\n if (event.key === 'Enter' || event.key === 'Tab') {\n event.preventDefault();\n choose(suggestions[highlighted]);\n return;\n }\n\n if (event.key === 'Escape') {\n event.preventDefault();\n // The Escape belongs to the list while it is open, not to a dialog around the composer.\n event.stopPropagation();\n // Closing the list leaves the draft and caret alone.\n setDismissed(query);\n return;\n }\n }\n\n if (event.key === 'Enter' && !event.shiftKey) {\n event.preventDefault();\n send();\n }\n };\n\n return (\n <div className='chat-composer' data-cratis-component='ChatComposer'>\n {isSuggesting && (\n <MentionSuggestions\n candidates={suggestions}\n highlightedIndex={highlighted}\n id={listId}\n onSelect={choose}\n onHighlight={setHighlightedIndex}\n buildAvatarUrl={buildAvatarUrl}\n />\n )}\n <textarea\n ref={inputRef}\n className='chat-composer__input'\n value={draft.text}\n onChange={(event) => readDraft(event.target)}\n onKeyUp={(event) => readDraft(event.currentTarget)}\n onClick={(event) => readDraft(event.currentTarget)}\n onKeyDown={handleKeyDown}\n placeholder={\n labels?.placeholder ?? 'Write a message… (Enter to send)'\n }\n rows={2}\n aria-autocomplete={isSuggesting ? 'list' : undefined}\n aria-controls={isSuggesting ? listId : undefined}\n aria-activedescendant={isSuggesting ? mentionOptionId(listId, highlighted) : undefined}\n disabled={disabled}\n />\n <button\n ref={emojiButtonRef}\n type='button'\n className='chat-composer__emoji-toggle'\n disabled={disabled}\n onMouseDown={(event) => event.preventDefault()}\n onClick={() => setShowEmojiPicker((previous) => !previous)}\n title={labels?.insertEmoji ?? 'Insert emoji'}\n aria-label={labels?.insertEmoji ?? 'Insert emoji'}\n aria-expanded={showEmojiPicker}\n >\n ☺\n </button>\n <button\n type='button'\n className='chat-composer__send'\n onClick={send}\n disabled={disabled || !draft.text.trim()}\n title={labels?.send ?? 'Send'}\n aria-label={labels?.sendMessage ?? 'Send message'}\n >\n <svg\n width='16'\n height='16'\n viewBox='0 0 24 24'\n fill='none'\n stroke='currentColor'\n strokeWidth='2.5'\n aria-hidden='true'\n >\n <line x1='22' y1='2' x2='11' y2='13' />\n <polygon points='22 2 15 22 11 13 2 9 22 2' />\n </svg>\n </button>\n {/* Portaled to <body>, same reason as the reaction picker on a message bubble: the chat\n panel scrolls/clips, so a picker positioned inside it would be cut off at the edge. */}\n <AnchoredOverlay\n anchorRef={emojiButtonRef}\n open={showEmojiPicker && !disabled}\n side='above'\n align='right'\n gap={6}\n >\n <ReactionPicker\n anchorRef={emojiButtonRef}\n onPick={insertEmoji}\n onDismiss={() => setShowEmojiPicker(false)}\n labels={labels?.reactionPicker}\n />\n </AnchoredOverlay>\n </div>\n );\n },\n);\nChatComposer.displayName = 'ChatComposer';\n"],"names":["_jsxs","_jsx"],"mappings":";;;;;;;;;;;AAqFO,MAAM,YAAY,GAAG,UAAU,CAClC,CACI,EACI,iBAAiB,EACjB,wBAAwB,EACxB,MAAM,EACN,SAAS,GAAG,KAAK,EACjB,QAAQ,GAAG,KAAK,EAChB,cAAc,EACd,MAAM,GACT,EACD,SAAS,KACT;AACA,IAAA,MAAM,CAAC,KAAK,EAAE,QAAQ,CAAC,GAAG,QAAQ,CAAC,EAAE,IAAI,EAAE,EAAE,EAAE,KAAK,EAAE,CAAC,EAAE,CAAC;IAC1D,MAAM,CAAC,gBAAgB,EAAE,mBAAmB,CAAC,GAAG,QAAQ,CAAC,CAAC,CAAC;IAE3D,MAAM,CAAC,SAAS,EAAE,YAAY,CAAC,GAAG,QAAQ,CAAyC,IAAI,CAAC;AACxF,IAAA,MAAM,MAAM,GAAG,KAAK,EAAE;IACtB,MAAM,CAAC,eAAe,EAAE,kBAAkB,CAAC,GAAG,QAAQ,CAAC,KAAK,CAAC;IAC7D,MAAM,CAAC,kBAAkB,EAAE,qBAAqB,CAAC,GAAG,QAAQ,CACxD,EAAE,CACL;AACD,IAAA,MAAM,QAAQ,GAAG,MAAM,CAAsB,IAAI,CAAC;AAClD,IAAA,MAAM,YAAY,GAAG,MAAM,CAAC,KAAK,CAAC;AAClC,IAAA,MAAM,cAAc,GAAG,MAAM,CAAoB,IAAI,CAAC;IAGtD,MAAM,iBAAiB,GAAG,MAAM,CAAC,IAAI,GAAG,EAA4B,CAAC;IAErE,MAAM,eAAe,GAAG,CAAC,CAAC,iBAAiB,IAAI,CAAC,CAAC,wBAAwB;IACzE,MAAM,KAAK,GAAG;UACR,kBAAkB,CAAC,KAAK,CAAC,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B,KAAK,MAAM,CAAC;IAE1D,6FAA6F;IAC7F,MAAM,CAAC,EAAE,uBAAuB,CAAC;CACpC;AAwFD;;;;GAIG;AACH,eAAO,MAAM,iBAAiB,qIAW3B,sBAAsB,gCA8DxB,CAAC"}
@@ -9,6 +9,13 @@ import { ReactionPicker } from './ReactionPicker.js';
9
9
  import { reactionsExcludingUser } from './reactionsExcludingUser.js';
10
10
  import { FaReply, FaBolt } from 'react-icons/fa6';
11
11
 
12
+ const renderBubbleAuthor = (message, buildAvatarUrl) => (jsxs("div", { className: 'chat-bubble-author', children: [jsx(PersonAvatarCircle, { userId: message.authorId, name: message.authorName, hasAvatar: message.hasAvatar, size: 22, ownerType: message.authorKind === ChatAuthorKind.Agent ? 'Agents' : 'Users', buildAvatarUrl: buildAvatarUrl }), jsx("span", { className: 'chat-bubble-name', children: message.authorName })] }));
13
+ const reactionButtonLabel = (ownReaction, labels) => ownReaction
14
+ ? (labels?.yourReaction ?? 'You reacted with {emoji}').replace('{emoji}', ownReaction.emoji)
15
+ : (labels?.addReaction ?? 'Add a quick reaction');
16
+ const renderQuickReplyAction = (message, onQuickReply, labels) => (jsx("button", { type: 'button', className: 'chat-bubble-action', title: (labels?.quickReplyTo ?? 'Reply to {name}').replace('{name}', message.authorName), "aria-label": (labels?.quickReplyTo ?? 'Reply to {name}').replace('{name}', message.authorName), onClick: () => onQuickReply(message.authorName), children: jsx(FaReply, { "aria-hidden": 'true' }) }));
17
+ const renderActAction = (message, onAct, labels) => (jsx("button", { type: 'button', className: 'chat-bubble-action', title: labels?.convertToAction ?? 'Turn into an action', "aria-label": labels?.convertToAction ?? 'Turn into an action', onClick: () => onAct(message.id), children: jsx(FaBolt, { "aria-hidden": 'true' }) }));
18
+ const renderBubbleActions = ({ message, onQuickReply, onAct, labels, supportsReactions, ownReaction, reactionButtonRef, pickerOpen, onTogglePicker, }) => (jsxs("div", { className: 'chat-bubble-actions', children: [supportsReactions && (jsx("button", { ref: reactionButtonRef, type: 'button', className: `chat-bubble-action${ownReaction ? ' chat-bubble-action--own-reaction' : ''}`, title: reactionButtonLabel(ownReaction, labels), "aria-label": reactionButtonLabel(ownReaction, labels), "aria-expanded": pickerOpen, onClick: onTogglePicker, children: ownReaction ? ownReaction.emoji : '☺' })), onQuickReply && renderQuickReplyAction(message, onQuickReply, labels), onAct && renderActAction(message, onAct, labels)] }));
12
19
  const ChatMessageBubble = ({ message, showAuthor, showTimestamp, formattedTimestamp, currentUserId, onReact, onQuickReply, onAct, buildAvatarUrl, labels, }) => {
13
20
  const [pickerOpen, setPickerOpen] = useState(false);
14
21
  const reactionButtonRef = useRef(null);
@@ -24,17 +31,17 @@ const ChatMessageBubble = ({ message, showAuthor, showTimestamp, formattedTimest
24
31
  setPickerOpen(false);
25
32
  onReact?.(message.id, emoji);
26
33
  };
27
- return (jsxs("div", { className: `chat-bubble${showAuthor ? '' : ' chat-bubble--continuation'}`, children: [showAuthor && (jsxs("div", { className: 'chat-bubble-author', children: [jsx(PersonAvatarCircle, { userId: message.authorId, name: message.authorName, hasAvatar: message.hasAvatar, size: 22, ownerType: message.authorKind === ChatAuthorKind.Agent
28
- ? 'Agents'
29
- : 'Users', buildAvatarUrl: buildAvatarUrl }), jsx("span", { className: 'chat-bubble-name', children: message.authorName })] })), jsxs("div", { className: 'chat-bubble-body', children: [jsxs("div", { className: `chat-bubble-panel${showActionsRow ? ' chat-bubble-panel--with-actions' : ''}`, children: [jsx("p", { className: 'chat-bubble-text', children: message.text }), showActionsRow && (jsxs("div", { className: 'chat-bubble-actions', children: [supportsReactions && (jsx("button", { ref: reactionButtonRef, type: 'button', className: `chat-bubble-action${ownReaction ? ' chat-bubble-action--own-reaction' : ''}`, title: ownReaction
30
- ? (labels?.yourReaction ??
31
- 'You reacted with {emoji}').replace('{emoji}', ownReaction.emoji)
32
- : (labels?.addReaction ??
33
- 'Add a quick reaction'), "aria-label": ownReaction
34
- ? (labels?.yourReaction ??
35
- 'You reacted with {emoji}').replace('{emoji}', ownReaction.emoji)
36
- : (labels?.addReaction ??
37
- 'Add a quick reaction'), "aria-expanded": pickerOpen, onClick: () => setPickerOpen((previous) => !previous), children: ownReaction ? ownReaction.emoji : '☺' })), onQuickReply && (jsx("button", { type: 'button', className: 'chat-bubble-action', title: (labels?.quickReplyTo ?? 'Reply to {name}').replace('{name}', message.authorName), "aria-label": (labels?.quickReplyTo ?? 'Reply to {name}').replace('{name}', message.authorName), onClick: () => onQuickReply(message.authorName), children: jsx(FaReply, { "aria-hidden": 'true' }) })), onAct && (jsx("button", { type: 'button', className: 'chat-bubble-action', title: labels?.convertToAction ?? 'Turn into an action', "aria-label": labels?.convertToAction ?? 'Turn into an action', onClick: () => onAct(message.id), children: jsx(FaBolt, { "aria-hidden": 'true' }) }))] }))] }), showTimestamp && (jsx("span", { className: 'chat-bubble-time', children: formattedTimestamp })), supportsReactions && jsx(MessageReactions, { reactions: otherReactions }), jsx(AnchoredOverlay, { anchorRef: reactionButtonRef, open: pickerOpen, side: 'above', align: 'right', gap: 6, children: jsx(ReactionPicker, { ownEmoji: ownReaction?.emoji, reactions: message.reactions, anchorRef: reactionButtonRef, onPick: pick, onDismiss: () => setPickerOpen(false), labels: labels?.reactionPicker }) })] })] }));
34
+ return (jsxs("div", { className: `chat-bubble${showAuthor ? '' : ' chat-bubble--continuation'}`, "data-cratis-component": 'ChatMessageBubble', children: [showAuthor && renderBubbleAuthor(message, buildAvatarUrl), jsxs("div", { className: 'chat-bubble-body', children: [jsxs("div", { className: `chat-bubble-panel${showActionsRow ? ' chat-bubble-panel--with-actions' : ''}`, children: [jsx("p", { className: 'chat-bubble-text', children: message.text }), showActionsRow && renderBubbleActions({
35
+ message,
36
+ onQuickReply,
37
+ onAct,
38
+ labels,
39
+ supportsReactions,
40
+ ownReaction,
41
+ reactionButtonRef,
42
+ pickerOpen,
43
+ onTogglePicker: () => setPickerOpen((previous) => !previous),
44
+ })] }), showTimestamp && (jsx("span", { className: 'chat-bubble-time', children: formattedTimestamp })), supportsReactions && jsx(MessageReactions, { reactions: otherReactions }), jsx(AnchoredOverlay, { anchorRef: reactionButtonRef, open: pickerOpen, side: 'above', align: 'right', gap: 6, children: jsx(ReactionPicker, { ownEmoji: ownReaction?.emoji, reactions: message.reactions, anchorRef: reactionButtonRef, onPick: pick, onDismiss: () => setPickerOpen(false), labels: labels?.reactionPicker }) })] })] }));
38
45
  };
39
46
 
40
47
  export { ChatMessageBubble };
@@ -1 +1 @@
1
- {"version":3,"file":"ChatMessageBubble.js","sources":["../../../../Chat/Kit/ChatMessageBubble.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 { useRef, useState } from 'react';\nimport type { Guid } from '@cratis/fundamentals';\nimport { AnchoredOverlay } from './AnchoredOverlay';\nimport { PersonAvatarCircle, type BuildAvatarUrlParams } from './Avatar';\nimport { ChatAuthorKind } from './ChatAuthorKind';\nimport type { ChatMessage } from './ChatMessage';\nimport { findOwnReaction } from './findOwnReaction';\nimport { MessageReactions } from './MessageReactions';\nimport { ReactionPicker, type ReactionPickerLabels } from './ReactionPicker';\nimport { reactionsExcludingUser } from './reactionsExcludingUser';\nimport { FaBolt, FaReply } from 'react-icons/fa6';\n\n/** Overrides for the bubble's own labels. Any field left unset falls back to a literal English\n * default. `{emoji}`/`{name}` placeholders are substituted by the component. */\nexport interface ChatMessageBubbleLabels {\n /** Tooltip/accessible label when the viewer has already reacted. Defaults to\n * `'You reacted with {emoji}'`. */\n yourReaction?: string;\n /** Tooltip/accessible label for the reaction button before reacting. Defaults to\n * `'Add a quick reaction'`. */\n addReaction?: string;\n /** Tooltip/accessible label for the quick-reply button. Defaults to `'Reply to {name}'`. */\n quickReplyTo?: string;\n /** Tooltip/accessible label for the \"turn into an action\" button. Defaults to\n * `'Turn into an action'`. */\n convertToAction?: string;\n /** Labels forwarded to the reaction {@link ReactionPicker}. */\n reactionPicker?: ReactionPickerLabels;\n}\n\n/**\n * Props for one message bubble in a conversation, with optional quick-reaction and quick-reply\n * affordances. The affordances are opt-in via {@link currentUserId} — a conversation that does not\n * pass it renders exactly as it did before reactions existed.\n */\nexport interface ChatMessageBubbleProps {\n /** The message to render. */\n message: ChatMessage;\n\n /** Whether to show the author row above the message — false for a continuation bubble. */\n showAuthor: boolean;\n\n /** Whether to show the timestamp below the message. */\n showTimestamp: boolean;\n\n /** The formatted relative timestamp to render when {@link showTimestamp} is true. */\n formattedTimestamp: string;\n\n /**\n * The identifier of whoever is looking at the conversation. Reactions and quick reply are only\n * offered when this is given — a conversation whose backend cannot yet record a reaction simply\n * does not render the affordance.\n */\n currentUserId?: Guid;\n\n /** Invoked with the emoji picked for this message, whether given, changed, or taken back. */\n onReact?: (messageId: Guid, emoji: string) => void;\n\n /** Invoked to prefill the composer with a reply addressed to this message's author. */\n onQuickReply?: (authorName: string) => void;\n\n /**\n * Invoked to ask for what this message asks for to be carried out. Omit to leave the affordance off.\n */\n onAct?: (messageId: Guid) => void;\n\n /** Builds the avatar image URL. Omit to always show initials. */\n buildAvatarUrl?: (params: BuildAvatarUrlParams) => string;\n\n /** Overrides for the bubble's labels. Unset fields fall back to literal English defaults. */\n labels?: ChatMessageBubbleLabels;\n}\n\n/**\n * One message in a conversation, with the optional quick-reaction and quick-reply affordances a\n * conversation may offer. The affordances are opt-in via {@link ChatMessageBubbleProps.currentUserId} —\n * a conversation that does not pass it renders exactly as it did before reactions existed.\n */\nexport const ChatMessageBubble = ({\n message,\n showAuthor,\n showTimestamp,\n formattedTimestamp,\n currentUserId,\n onReact,\n onQuickReply,\n onAct,\n buildAvatarUrl,\n labels,\n}: ChatMessageBubbleProps) => {\n const [pickerOpen, setPickerOpen] = useState(false);\n const reactionButtonRef = useRef<HTMLButtonElement>(null);\n const supportsReactions = !!currentUserId && !!onReact;\n const showActionsRow = supportsReactions || !!onQuickReply || !!onAct;\n const ownReaction = supportsReactions\n ? findOwnReaction(message.reactions, currentUserId)\n : undefined;\n const otherReactions = supportsReactions\n ? reactionsExcludingUser(message.reactions, currentUserId)\n : [];\n\n const pick = (emoji: string) => {\n setPickerOpen(false);\n onReact?.(message.id, emoji);\n };\n\n return (\n <div className={`chat-bubble${showAuthor ? '' : ' chat-bubble--continuation'}`}>\n {showAuthor && (\n <div className='chat-bubble-author'>\n <PersonAvatarCircle\n userId={message.authorId}\n name={message.authorName}\n hasAvatar={message.hasAvatar}\n size={22}\n ownerType={\n message.authorKind === ChatAuthorKind.Agent\n ? 'Agents'\n : 'Users'\n }\n buildAvatarUrl={buildAvatarUrl}\n />\n <span className='chat-bubble-name'>{message.authorName}</span>\n </div>\n )}\n <div className='chat-bubble-body'>\n <div\n className={`chat-bubble-panel${showActionsRow ? ' chat-bubble-panel--with-actions' : ''}`}\n >\n <p className='chat-bubble-text'>{message.text}</p>\n {showActionsRow && (\n <div className='chat-bubble-actions'>\n {supportsReactions && (\n <button\n ref={reactionButtonRef}\n type='button'\n className={`chat-bubble-action${ownReaction ? ' chat-bubble-action--own-reaction' : ''}`}\n title={\n ownReaction\n ? (\n labels?.yourReaction ??\n 'You reacted with {emoji}'\n ).replace('{emoji}', ownReaction.emoji)\n : (labels?.addReaction ??\n 'Add a quick reaction')\n }\n aria-label={\n ownReaction\n ? (\n labels?.yourReaction ??\n 'You reacted with {emoji}'\n ).replace('{emoji}', ownReaction.emoji)\n : (labels?.addReaction ??\n 'Add a quick reaction')\n }\n aria-expanded={pickerOpen}\n onClick={() => setPickerOpen((previous) => !previous)}\n >\n {ownReaction ? ownReaction.emoji : '☺'}\n </button>\n )}\n {onQuickReply && (\n <button\n type='button'\n className='chat-bubble-action'\n title={(\n labels?.quickReplyTo ?? 'Reply to {name}'\n ).replace('{name}', message.authorName)}\n aria-label={(\n labels?.quickReplyTo ?? 'Reply to {name}'\n ).replace('{name}', message.authorName)}\n onClick={() => onQuickReply(message.authorName)}\n >\n <FaReply aria-hidden='true' />\n </button>\n )}\n {onAct && (\n <button\n type='button'\n className='chat-bubble-action'\n title={\n labels?.convertToAction ?? 'Turn into an action'\n }\n aria-label={\n labels?.convertToAction ?? 'Turn into an action'\n }\n onClick={() => onAct(message.id)}\n >\n <FaBolt aria-hidden='true' />\n </button>\n )}\n </div>\n )}\n </div>\n {showTimestamp && (\n <span className='chat-bubble-time'>{formattedTimestamp}</span>\n )}\n {supportsReactions && <MessageReactions reactions={otherReactions} />}\n {/* Portaled to <body> rather than positioned inside the bubble: the chat panel scrolls,\n so a picker positioned within it is clipped the moment it reaches the panel's edge. */}\n <AnchoredOverlay\n anchorRef={reactionButtonRef}\n open={pickerOpen}\n side='above'\n align='right'\n gap={6}\n >\n <ReactionPicker\n ownEmoji={ownReaction?.emoji}\n reactions={message.reactions}\n anchorRef={reactionButtonRef}\n onPick={pick}\n onDismiss={() => setPickerOpen(false)}\n labels={labels?.reactionPicker}\n />\n </AnchoredOverlay>\n </div>\n </div>\n );\n};\n"],"names":["_jsxs","_jsx"],"mappings":";;;;;;;;;;;AAiFO,MAAM,iBAAiB,GAAG,CAAC,EAC9B,OAAO,EACP,UAAU,EACV,aAAa,EACb,kBAAkB,EAClB,aAAa,EACb,OAAO,EACP,YAAY,EACZ,KAAK,EACL,cAAc,EACd,MAAM,GACe,KAAI;IACzB,MAAM,CAAC,UAAU,EAAE,aAAa,CAAC,GAAG,QAAQ,CAAC,KAAK,CAAC;AACnD,IAAA,MAAM,iBAAiB,GAAG,MAAM,CAAoB,IAAI,CAAC;IACzD,MAAM,iBAAiB,GAAG,CAAC,CAAC,aAAa,IAAI,CAAC,CAAC,OAAO;IACtD,MAAM,cAAc,GAAG,iBAAiB,IAAI,CAAC,CAAC,YAAY,IAAI,CAAC,CAAC,KAAK;IACrE,MAAM,WAAW,GAAG;UACd,eAAe,CAAC,OAAO,CAAC,SAAS,EAAE,aAAa;UAChD,SAAS;IACf,MAAM,cAAc,GAAG;UACjB,sBAAsB,CAAC,OAAO,CAAC,SAAS,EAAE,aAAa;UACvD,EAAE;AAER,IAAA,MAAM,IAAI,GAAG,CAAC,KAAa,KAAI;QAC3B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AAA,QAAA,EAEhCA,GAAA,CAAC,MAAM,EAAA,EAAA,aAAA,EAAa,MAAM,EAAA,CAAG,EAAA,CACxB,CACZ,CAAA,EAAA,CACC,CACT,IACC,EACL,aAAa,KACVA,GAAA,CAAA,MAAA,EAAA,EAAM,SAAS,EAAC,kBAAkB,EAAA,QAAA,EAAE,kBAAkB,EAAA,CAAQ,CACjE,EACA,iBAAiB,IAAIA,GAAA,CAAC,gBAAgB,EAAA,EAAC,SAAS,EAAE,cAAc,EAAA,CAAI,EAGrEA,GAAA,CAAC,eAAe,EAAA,EACZ,SAAS,EAAE,iBAAiB,EAC5B,IAAI,EAAE,UAAU,EAChB,IAAI,EAAC,OAAO,EACZ,KAAK,EAAC,OAAO,EACb,GAAG,EAAE,CAAC,YAENA,GAAA,CAAC,cAAc,EAAA,EACX,QAAQ,EAAE,WAAW,EAAE,KAAK,EAC5B,SAAS,EAAE,OAAO,CAAC,SAAS,EAC5B,SAAS,EAAE,iBAAiB,EAC5B,MAAM,EAAE,IAAI,EACZ,SAAS,EAAE,MAAM,aAAa,CAAC,KAAK,CAAC,EACrC,MAAM,EAAE,MAAM,EAAE,cAAc,EAAA,CAChC,EAAA,CACY,CAAA,EAAA,CAChB,CAAA,EAAA,CACJ;AAEd;;"}
1
+ {"version":3,"file":"ChatMessageBubble.js","sources":["../../../../Chat/Kit/ChatMessageBubble.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 { useRef, useState, type RefObject } from 'react';\nimport type { Guid } from '@cratis/fundamentals';\nimport { AnchoredOverlay } from './AnchoredOverlay';\nimport { PersonAvatarCircle, type BuildAvatarUrlParams } from './Avatar';\nimport { ChatAuthorKind } from './ChatAuthorKind';\nimport type { ChatMessage } from './ChatMessage';\nimport { findOwnReaction } from './findOwnReaction';\nimport { MessageReactions } from './MessageReactions';\nimport { ReactionPicker, type ReactionPickerLabels } from './ReactionPicker';\nimport { reactionsExcludingUser } from './reactionsExcludingUser';\nimport { FaBolt, FaReply } from 'react-icons/fa6';\n\n/** Overrides for the bubble's own labels. Any field left unset falls back to a literal English\n * default. `{emoji}`/`{name}` placeholders are substituted by the component. */\nexport interface ChatMessageBubbleLabels {\n /** Tooltip/accessible label when the viewer has already reacted. Defaults to\n * `'You reacted with {emoji}'`. */\n yourReaction?: string;\n /** Tooltip/accessible label for the reaction button before reacting. Defaults to\n * `'Add a quick reaction'`. */\n addReaction?: string;\n /** Tooltip/accessible label for the quick-reply button. Defaults to `'Reply to {name}'`. */\n quickReplyTo?: string;\n /** Tooltip/accessible label for the \"turn into an action\" button. Defaults to\n * `'Turn into an action'`. */\n convertToAction?: string;\n /** Labels forwarded to the reaction {@link ReactionPicker}. */\n reactionPicker?: ReactionPickerLabels;\n}\n\n/**\n * Props for one message bubble in a conversation, with optional quick-reaction and quick-reply\n * affordances. The affordances are opt-in via {@link currentUserId} — a conversation that does not\n * pass it renders exactly as it did before reactions existed.\n */\nexport interface ChatMessageBubbleProps {\n /** The message to render. */\n message: ChatMessage;\n\n /** Whether to show the author row above the message — false for a continuation bubble. */\n showAuthor: boolean;\n\n /** Whether to show the timestamp below the message. */\n showTimestamp: boolean;\n\n /** The formatted relative timestamp to render when {@link showTimestamp} is true. */\n formattedTimestamp: string;\n\n /**\n * The identifier of whoever is looking at the conversation. Reactions and quick reply are only\n * offered when this is given — a conversation whose backend cannot yet record a reaction simply\n * does not render the affordance.\n */\n currentUserId?: Guid;\n\n /** Invoked with the emoji picked for this message, whether given, changed, or taken back. */\n onReact?: (messageId: Guid, emoji: string) => void;\n\n /** Invoked to prefill the composer with a reply addressed to this message's author. */\n onQuickReply?: (authorName: string) => void;\n\n /**\n * Invoked to ask for what this message asks for to be carried out. Omit to leave the affordance off.\n */\n onAct?: (messageId: Guid) => void;\n\n /** Builds the avatar image URL. Omit to always show initials. */\n buildAvatarUrl?: (params: BuildAvatarUrlParams) => string;\n\n /** Overrides for the bubble's labels. Unset fields fall back to literal English defaults. */\n labels?: ChatMessageBubbleLabels;\n}\n\nconst renderBubbleAuthor = (\n message: ChatMessage,\n buildAvatarUrl: ChatMessageBubbleProps['buildAvatarUrl'],\n) => (\n <div className='chat-bubble-author'>\n <PersonAvatarCircle\n userId={message.authorId}\n name={message.authorName}\n hasAvatar={message.hasAvatar}\n size={22}\n ownerType={message.authorKind === ChatAuthorKind.Agent ? 'Agents' : 'Users'}\n buildAvatarUrl={buildAvatarUrl}\n />\n <span className='chat-bubble-name'>{message.authorName}</span>\n </div>\n);\n\nconst reactionButtonLabel = (\n ownReaction: ReturnType<typeof findOwnReaction>,\n labels: ChatMessageBubbleLabels | undefined,\n) => ownReaction\n ? (labels?.yourReaction ?? 'You reacted with {emoji}').replace('{emoji}', ownReaction.emoji)\n : (labels?.addReaction ?? 'Add a quick reaction');\n\nconst renderQuickReplyAction = (\n message: ChatMessage,\n onQuickReply: NonNullable<ChatMessageBubbleProps['onQuickReply']>,\n labels: ChatMessageBubbleLabels | undefined,\n) => (\n <button\n type='button'\n className='chat-bubble-action'\n title={(labels?.quickReplyTo ?? 'Reply to {name}').replace('{name}', message.authorName)}\n aria-label={(labels?.quickReplyTo ?? 'Reply to {name}').replace('{name}', message.authorName)}\n onClick={() => onQuickReply(message.authorName)}\n >\n <FaReply aria-hidden='true' />\n </button>\n);\n\nconst renderActAction = (\n message: ChatMessage,\n onAct: NonNullable<ChatMessageBubbleProps['onAct']>,\n labels: ChatMessageBubbleLabels | undefined,\n) => (\n <button\n type='button'\n className='chat-bubble-action'\n title={labels?.convertToAction ?? 'Turn into an action'}\n aria-label={labels?.convertToAction ?? 'Turn into an action'}\n onClick={() => onAct(message.id)}\n >\n <FaBolt aria-hidden='true' />\n </button>\n);\n\ninterface BubbleActionsProps extends Pick<ChatMessageBubbleProps, 'message' | 'onQuickReply' | 'onAct' | 'labels'> {\n supportsReactions: boolean;\n ownReaction: ReturnType<typeof findOwnReaction>;\n reactionButtonRef: RefObject<HTMLButtonElement | null>;\n pickerOpen: boolean;\n onTogglePicker: () => void;\n}\n\nconst renderBubbleActions = ({\n message, onQuickReply, onAct, labels, supportsReactions, ownReaction, reactionButtonRef, pickerOpen, onTogglePicker,\n}: BubbleActionsProps) => (\n <div className='chat-bubble-actions'>\n {supportsReactions && (\n <button\n ref={reactionButtonRef}\n type='button'\n className={`chat-bubble-action${ownReaction ? ' chat-bubble-action--own-reaction' : ''}`}\n title={reactionButtonLabel(ownReaction, labels)}\n aria-label={reactionButtonLabel(ownReaction, labels)}\n aria-expanded={pickerOpen}\n onClick={onTogglePicker}\n >\n {ownReaction ? ownReaction.emoji : '☺'}\n </button>\n )}\n {onQuickReply && renderQuickReplyAction(message, onQuickReply, labels)}\n {onAct && renderActAction(message, onAct, labels)}\n </div>\n);\n\n/**\n * One message in a conversation, with the optional quick-reaction and quick-reply affordances a\n * conversation may offer. The affordances are opt-in via {@link ChatMessageBubbleProps.currentUserId} —\n * a conversation that does not pass it renders exactly as it did before reactions existed.\n */\nexport const ChatMessageBubble = ({\n message,\n showAuthor,\n showTimestamp,\n formattedTimestamp,\n currentUserId,\n onReact,\n onQuickReply,\n onAct,\n buildAvatarUrl,\n labels,\n}: ChatMessageBubbleProps) => {\n const [pickerOpen, setPickerOpen] = useState(false);\n const reactionButtonRef = useRef<HTMLButtonElement>(null);\n const supportsReactions = !!currentUserId && !!onReact;\n const showActionsRow = supportsReactions || !!onQuickReply || !!onAct;\n const ownReaction = supportsReactions\n ? findOwnReaction(message.reactions, currentUserId)\n : undefined;\n const otherReactions = supportsReactions\n ? reactionsExcludingUser(message.reactions, currentUserId)\n : [];\n\n const pick = (emoji: string) => {\n setPickerOpen(false);\n onReact?.(message.id, emoji);\n };\n\n return (\n <div className={`chat-bubble${showAuthor ? '' : ' chat-bubble--continuation'}`} data-cratis-component='ChatMessageBubble'>\n {showAuthor && renderBubbleAuthor(message, buildAvatarUrl)}\n <div className='chat-bubble-body'>\n <div\n className={`chat-bubble-panel${showActionsRow ? ' chat-bubble-panel--with-actions' : ''}`}\n >\n <p className='chat-bubble-text'>{message.text}</p>\n {showActionsRow && renderBubbleActions({\n message,\n onQuickReply,\n onAct,\n labels,\n supportsReactions,\n ownReaction,\n reactionButtonRef,\n pickerOpen,\n onTogglePicker: () => setPickerOpen((previous) => !previous),\n })}\n </div>\n {showTimestamp && (\n <span className='chat-bubble-time'>{formattedTimestamp}</span>\n )}\n {supportsReactions && <MessageReactions reactions={otherReactions} />}\n {/* Portaled to <body> rather than positioned inside the bubble: the chat panel scrolls,\n so a picker positioned within it is clipped the moment it reaches the panel's edge. */}\n <AnchoredOverlay\n anchorRef={reactionButtonRef}\n open={pickerOpen}\n side='above'\n align='right'\n gap={6}\n >\n <ReactionPicker\n ownEmoji={ownReaction?.emoji}\n reactions={message.reactions}\n anchorRef={reactionButtonRef}\n onPick={pick}\n onDismiss={() => setPickerOpen(false)}\n labels={labels?.reactionPicker}\n />\n </AnchoredOverlay>\n </div>\n </div>\n );\n};\n"],"names":["_jsxs","_jsx"],"mappings":";;;;;;;;;;;AA4EA,MAAM,kBAAkB,GAAG,CACvB,OAAoB,EACpB,cAAwD,MAExDA,IAAA,CAAA,KAAA,EAAA,EAAK,SAAS,EAAC,oBAAoB,aAC/BC,GAAA,CAAC,kBAAkB,EAAA,EACf,MAAM,EAAE,OAAO,CAAC,QAAQ,EACxB,IAAI,EAAE,OAAO,CAAC,UAAU,EACxB,SAAS,EAAE,OAAO,CAAC,SAAS,EAC5B,IAAI,EAAE,EAAE,EACR,SAAS,EAAE,OAAO,CAAC,UAAU,KAAK,cAAc,CAAC,KAAK,GAAG,QAAQ,GAAG,OAAO,EAC3E,cAAc,EAAE,cAAc,EAAA,CAChC,EACFA,cAAM,SAAS,EAAC,kBAAkB,EAAA,QAAA,EAAE,OAAO,CAAC,UAAU,EAAA,CAAQ,CAAA,EAAA,CAC5D,CACT;AAED,MAAM,mBAAmB,GAAG,CACxB,WAA+C,EAC/C,MAA2C,KAC1C;AACD,MAAE,CAAC,MAAM,EAAE,YAA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,CAAC,EAAA,QAAA,EAENA,IAAC,cAAc,EAAA,EACX,QAAQ,EAAE,WAAW,EAAE,KAAK,EAC5B,SAAS,EAAE,OAAO,CAAC,SAAS,EAC5B,SAAS,EAAE,iBAAiB,EAC5B,MAAM,EAAE,IAAI,EACZ,SAAS,EAAE,MAAM,aAAa,CAAC,KAAK,CAAC,EACrC,MAAM,EAAE,MAAM,EAAE,cAAc,EAAA,CAChC,GACY,CAAA,EAAA,CAChB,CAAA,EAAA,CACJ;AAEd;;"}
@@ -32,7 +32,7 @@ const EmojiPicker = ({ ownEmoji, onPick, labels }) => {
32
32
  const [category, setCategory] = useState(EmojiCategoryKey.Smileys);
33
33
  const rootRef = useEmojiPickerFocus();
34
34
  const categoryLabel = (key) => labels?.categories?.[key] ?? DEFAULT_CATEGORY_LABELS[key];
35
- return (jsx("div", { ref: rootRef, className: 'emoji-picker', role: 'group', "aria-label": labels?.allEmojis ?? 'All emojis', children: jsxs(Tabs, { selectedKey: category, onSelectionChange: (key) => setCategory(key), className: 'emoji-picker__categories', children: [jsx(TabList, { className: 'emoji-picker__tabs', "aria-label": labels?.emojiCategories ?? 'Emoji categories', children: EMOJI_CATALOG.map((section) => (jsx(Tab, { id: section.key, "aria-label": categoryLabel(section.key), className: ({ isSelected }) => `emoji-picker__tab${isSelected ? ' emoji-picker__tab--current' : ''}`, children: jsx("span", { title: categoryLabel(section.key), children: CATEGORY_GLYPHS[section.key] }) }, section.key))) }), EMOJI_CATALOG.map((section) => (jsx(TabPanel, { id: section.key, children: jsx(EmojiOptions, { emojis: section.emojis, ownEmoji: ownEmoji, columns: 8, label: labels?.pickEmoji ?? 'Pick an emoji', className: 'emoji-picker__grid', optionClassName: 'emoji-picker__emoji', onPick: onPick }) }, section.key)))] }) }));
35
+ return (jsx("div", { ref: rootRef, className: 'emoji-picker', "data-cratis-component": 'EmojiPicker', role: 'group', "aria-label": labels?.allEmojis ?? 'All emojis', children: jsxs(Tabs, { selectedKey: category, onSelectionChange: (key) => setCategory(key), className: 'emoji-picker__categories', children: [jsx(TabList, { className: 'emoji-picker__tabs', "aria-label": labels?.emojiCategories ?? 'Emoji categories', children: EMOJI_CATALOG.map((section) => (jsx(Tab, { id: section.key, "aria-label": categoryLabel(section.key), className: ({ isSelected }) => `emoji-picker__tab${isSelected ? ' emoji-picker__tab--current' : ''}`, children: jsx("span", { title: categoryLabel(section.key), children: CATEGORY_GLYPHS[section.key] }) }, section.key))) }), EMOJI_CATALOG.map((section) => (jsx(TabPanel, { id: section.key, children: jsx(EmojiOptions, { emojis: section.emojis, ownEmoji: ownEmoji, columns: 8, label: labels?.pickEmoji ?? 'Pick an emoji', className: 'emoji-picker__grid', optionClassName: 'emoji-picker__emoji', onPick: onPick }) }, section.key)))] }) }));
36
36
  };
37
37
 
38
38
  export { EmojiPicker };
@@ -1 +1 @@
1
- {"version":3,"file":"EmojiPicker.js","sources":["../../../../../Chat/Kit/Emoji/EmojiPicker.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 { useState } from 'react';\nimport { Tab, TabList, TabPanel, Tabs } from 'react-aria-components/Tabs';\nimport { EmojiOptions } from './EmojiOptions';\nimport { useEmojiPickerFocus } from './useEmojiPickerFocus';\nimport { EMOJI_CATALOG } from './emojiCatalog';\nimport { EmojiCategoryKey } from './EmojiCategoryKey';\n\n/** The tab glyph for each section — the picker's own labels are its icons, as pickers of this kind are. */\nconst CATEGORY_GLYPHS: Record<EmojiCategoryKey, string> = {\n [EmojiCategoryKey.Smileys]: '😀',\n [EmojiCategoryKey.People]: '👋',\n [EmojiCategoryKey.Nature]: '🐻',\n [EmojiCategoryKey.Food]: '🍔',\n [EmojiCategoryKey.Activity]: '⚽',\n [EmojiCategoryKey.Travel]: '🚗',\n [EmojiCategoryKey.Objects]: '💡',\n [EmojiCategoryKey.Symbols]: '❤️',\n [EmojiCategoryKey.Flags]: '🏳️',\n};\n\n/** The literal English defaults for each category's accessible name/title, used when\n * {@link EmojiPickerLabels.categories} does not override a given key. */\nconst DEFAULT_CATEGORY_LABELS: Record<EmojiCategoryKey, string> = {\n [EmojiCategoryKey.Smileys]: 'Smileys',\n [EmojiCategoryKey.People]: 'People',\n [EmojiCategoryKey.Nature]: 'Animals & nature',\n [EmojiCategoryKey.Food]: 'Food & drink',\n [EmojiCategoryKey.Activity]: 'Activity',\n [EmojiCategoryKey.Travel]: 'Travel & places',\n [EmojiCategoryKey.Objects]: 'Objects',\n [EmojiCategoryKey.Symbols]: 'Symbols',\n [EmojiCategoryKey.Flags]: 'Flags',\n};\n\n/** Overrides for the picker's labels. Any field left unset falls back to a literal English default. */\nexport interface EmojiPickerLabels {\n /** Accessible label for the picker group. Defaults to `'All emojis'`. */\n allEmojis?: string;\n /** Accessible label for the emoji button group. Defaults to `'Pick an emoji'`. */\n pickEmoji?: string;\n /** Accessible label for the category tab list. Defaults to `'Emoji categories'`. */\n emojiCategories?: string;\n /** Per-category accessible names/titles. Unset categories fall back to their English name. */\n categories?: Partial<Record<EmojiCategoryKey, string>>;\n}\n\n/**\n * Props for the full emoji picker the quick row's last button opens — every emoji offered, in the\n * sections a picker is expected to have. Only the selected section is mounted.\n */\nexport interface EmojiPickerProps {\n /** The emoji the viewer already gave, marked so picking it again reads as taking it back. */\n ownEmoji?: string;\n\n /** Invoked with the emoji that was picked. */\n onPick: (emoji: string) => void;\n\n /** Overrides for the picker's labels. Unset fields fall back to literal English defaults. */\n labels?: EmojiPickerLabels;\n}\n\n/**\n * The full emoji picker the quick row's last button opens — every emoji offered, in the sections a\n * picker is expected to have.\n *\n * Only the selected section is mounted. A thousand buttons at once is what makes a picker of this kind\n * feel slow to open, and there is never more than one section on screen to look at anyway.\n */\nexport const EmojiPicker = ({ ownEmoji, onPick, labels }: EmojiPickerProps) => {\n const [category, setCategory] = useState(EmojiCategoryKey.Smileys);\n const rootRef = useEmojiPickerFocus();\n const categoryLabel = (key: EmojiCategoryKey) =>\n labels?.categories?.[key] ?? DEFAULT_CATEGORY_LABELS[key];\n\n return (\n <div ref={rootRef} className='emoji-picker' role='group' aria-label={labels?.allEmojis ?? 'All emojis'}>\n <Tabs selectedKey={category} onSelectionChange={(key) => setCategory(key as EmojiCategoryKey)} className='emoji-picker__categories'>\n <TabList className='emoji-picker__tabs' aria-label={labels?.emojiCategories ?? 'Emoji categories'}>\n {EMOJI_CATALOG.map((section) => (\n <Tab\n key={section.key}\n id={section.key}\n aria-label={categoryLabel(section.key)}\n className={({ isSelected }) => `emoji-picker__tab${isSelected ? ' emoji-picker__tab--current' : ''}`}\n >\n <span title={categoryLabel(section.key)}>{CATEGORY_GLYPHS[section.key]}</span>\n </Tab>\n ))}\n </TabList>\n {EMOJI_CATALOG.map((section) => (\n <TabPanel key={section.key} id={section.key}>\n <EmojiOptions\n emojis={section.emojis}\n ownEmoji={ownEmoji}\n columns={8}\n label={labels?.pickEmoji ?? 'Pick an emoji'}\n className='emoji-picker__grid'\n optionClassName='emoji-picker__emoji'\n onPick={onPick}\n />\n </TabPanel>\n ))}\n </Tabs>\n </div>\n );\n};\n"],"names":["_jsx","_jsxs"],"mappings":";;;;;;;;AAWA,MAAM,eAAe,GAAqC;AACtD,IAAA,CAAC,gBAAgB,CAAC,OAAO,GAAG,IAAI;AAChC,IAAA,CAAC,gBAAgB,CAAC,MAAM,GAAG,IAAI;AAC/B,IAAA,CAAC,gBAAgB,CAAC,MAAM,GAAG,IAAI;AAC/B,IAAA,CAAC,gBAAgB,CAAC,IAAI,GAAG,IAAI;AAC7B,IAAA,CAAC,gBAAgB,CAAC,QAAQ,GAAG,GAAG;AAChC,IAAA,CAAC,gBAAgB,CAAC,MAAM,GAAG,IAAI;AAC/B,IAAA,CAAC,gBAAgB,CAAC,OAAO,GAAG,IAAI;AAChC,IAAA,CAAC,gBAAgB,CAAC,OAAO,GAAG,IAAI;AAChC,IAAA,CAAC,gBAAgB,CAAC,KAAK,GAAG,KAAK;CAClC;AAID,MAAM,uBAAuB,GAAqC;AAC9D,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,CAAC,CAAC,OAAO,MACvBA,GAAA,CAAC,GAAG,EAAA,EAEA,EAAE,EAAE,OAAO,CAAC,GAAG,EAAA,YAAA,EACH,aAAa,CAAC,OAAO,CAAC,GAAG,CAAC,EACtC,SAAS,EAAE,CAAC,EAAE,UAAU,EAAE,KAAK,CAAA,iBAAA,EAAoB,UAAU,GAAG,6BAA6B,GAAG,EAAE,CAAA,CAAE,EAAA,QAAA,EAEpGA,cAAM,KAAK,EAAE,aAAa,CAAC,OAAO,CAAC,GAAG,CAAC,YAAG,eAAe,CAAC,OAAO,CAAC,GAAG,CAAC,EAAA,CAAQ,EAAA,EALzE,OAAO,CAAC,GAAG,CAMd,CACT,CAAC,EAAA,CACI,EACT,aAAa,CAAC,GAAG,CAAC,CAAC,OAAO,MACvBA,GAAA,CAAC,QAAQ,EAAA,EAAmB,EAAE,EAAE,OAAO,CAAC,GAAG,YACvCA,GAAA,CAAC,YAAY,IACT,MAAM,EAAE,OAAO,CAAC,MAAM,EACtB,QAAQ,EAAE,QAAQ,EAClB,OAAO,EAAE,CAAC,EACV,KAAK,EAAE,MAAM,EAAE,SAAS,IAAI,eAAe,EAC3C,SAAS,EAAC,oBAAoB,EAC9B,eAAe,EAAC,qBAAqB,EACrC,MAAM,EAAE,MAAM,GAChB,EAAA,EATS,OAAO,CAAC,GAAG,CAUf,CACd,CAAC,CAAA,EAAA,CACC,EAAA,CACL;AAEd;;"}
1
+ {"version":3,"file":"EmojiPicker.js","sources":["../../../../../Chat/Kit/Emoji/EmojiPicker.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 { useState } from 'react';\nimport { Tab, TabList, TabPanel, Tabs } from 'react-aria-components/Tabs';\nimport { EmojiOptions } from './EmojiOptions';\nimport { useEmojiPickerFocus } from './useEmojiPickerFocus';\nimport { EMOJI_CATALOG } from './emojiCatalog';\nimport { EmojiCategoryKey } from './EmojiCategoryKey';\n\n/** The tab glyph for each section — the picker's own labels are its icons, as pickers of this kind are. */\nconst CATEGORY_GLYPHS: Record<EmojiCategoryKey, string> = {\n [EmojiCategoryKey.Smileys]: '😀',\n [EmojiCategoryKey.People]: '👋',\n [EmojiCategoryKey.Nature]: '🐻',\n [EmojiCategoryKey.Food]: '🍔',\n [EmojiCategoryKey.Activity]: '⚽',\n [EmojiCategoryKey.Travel]: '🚗',\n [EmojiCategoryKey.Objects]: '💡',\n [EmojiCategoryKey.Symbols]: '❤️',\n [EmojiCategoryKey.Flags]: '🏳️',\n};\n\n/** The literal English defaults for each category's accessible name/title, used when\n * {@link EmojiPickerLabels.categories} does not override a given key. */\nconst DEFAULT_CATEGORY_LABELS: Record<EmojiCategoryKey, string> = {\n [EmojiCategoryKey.Smileys]: 'Smileys',\n [EmojiCategoryKey.People]: 'People',\n [EmojiCategoryKey.Nature]: 'Animals & nature',\n [EmojiCategoryKey.Food]: 'Food & drink',\n [EmojiCategoryKey.Activity]: 'Activity',\n [EmojiCategoryKey.Travel]: 'Travel & places',\n [EmojiCategoryKey.Objects]: 'Objects',\n [EmojiCategoryKey.Symbols]: 'Symbols',\n [EmojiCategoryKey.Flags]: 'Flags',\n};\n\n/** Overrides for the picker's labels. Any field left unset falls back to a literal English default. */\nexport interface EmojiPickerLabels {\n /** Accessible label for the picker group. Defaults to `'All emojis'`. */\n allEmojis?: string;\n /** Accessible label for the emoji button group. Defaults to `'Pick an emoji'`. */\n pickEmoji?: string;\n /** Accessible label for the category tab list. Defaults to `'Emoji categories'`. */\n emojiCategories?: string;\n /** Per-category accessible names/titles. Unset categories fall back to their English name. */\n categories?: Partial<Record<EmojiCategoryKey, string>>;\n}\n\n/**\n * Props for the full emoji picker the quick row's last button opens — every emoji offered, in the\n * sections a picker is expected to have. Only the selected section is mounted.\n */\nexport interface EmojiPickerProps {\n /** The emoji the viewer already gave, marked so picking it again reads as taking it back. */\n ownEmoji?: string;\n\n /** Invoked with the emoji that was picked. */\n onPick: (emoji: string) => void;\n\n /** Overrides for the picker's labels. Unset fields fall back to literal English defaults. */\n labels?: EmojiPickerLabels;\n}\n\n/**\n * The full emoji picker the quick row's last button opens — every emoji offered, in the sections a\n * picker is expected to have.\n *\n * Only the selected section is mounted. A thousand buttons at once is what makes a picker of this kind\n * feel slow to open, and there is never more than one section on screen to look at anyway.\n */\nexport const EmojiPicker = ({ ownEmoji, onPick, labels }: EmojiPickerProps) => {\n const [category, setCategory] = useState(EmojiCategoryKey.Smileys);\n const rootRef = useEmojiPickerFocus();\n const categoryLabel = (key: EmojiCategoryKey) =>\n labels?.categories?.[key] ?? DEFAULT_CATEGORY_LABELS[key];\n\n return (\n <div ref={rootRef} className='emoji-picker' data-cratis-component='EmojiPicker' role='group' aria-label={labels?.allEmojis ?? 'All emojis'}>\n <Tabs selectedKey={category} onSelectionChange={(key) => setCategory(key as EmojiCategoryKey)} className='emoji-picker__categories'>\n <TabList className='emoji-picker__tabs' aria-label={labels?.emojiCategories ?? 'Emoji categories'}>\n {EMOJI_CATALOG.map((section) => (\n <Tab\n key={section.key}\n id={section.key}\n aria-label={categoryLabel(section.key)}\n className={({ isSelected }) => `emoji-picker__tab${isSelected ? ' emoji-picker__tab--current' : ''}`}\n >\n <span title={categoryLabel(section.key)}>{CATEGORY_GLYPHS[section.key]}</span>\n </Tab>\n ))}\n </TabList>\n {EMOJI_CATALOG.map((section) => (\n <TabPanel key={section.key} id={section.key}>\n <EmojiOptions\n emojis={section.emojis}\n ownEmoji={ownEmoji}\n columns={8}\n label={labels?.pickEmoji ?? 'Pick an emoji'}\n className='emoji-picker__grid'\n optionClassName='emoji-picker__emoji'\n onPick={onPick}\n />\n </TabPanel>\n ))}\n </Tabs>\n </div>\n );\n};\n"],"names":["_jsx","_jsxs"],"mappings":";;;;;;;;AAWA,MAAM,eAAe,GAAqC;AACtD,IAAA,CAAC,gBAAgB,CAAC,OAAO,GAAG,IAAI;AAChC,IAAA,CAAC,gBAAgB,CAAC,MAAM,GAAG,IAAI;AAC/B,IAAA,CAA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A,EATS,OAAO,CAAC,GAAG,CAUf,CACd,CAAC,CAAA,EAAA,CACC,EAAA,CACL;AAEd;;"}
@@ -15,7 +15,7 @@ const FailedReply = ({ message, buildReportUrl, labels }) => {
15
15
  detail,
16
16
  commentId: message.id.toString(),
17
17
  });
18
- return (jsxs("div", { className: 'chat-failed-reply', "aria-live": 'polite', children: [jsxs("div", { className: 'chat-failed-reply__line', children: [jsx(FaTriangleExclamation, { className: 'chat-failed-reply__icon', "aria-hidden": 'true' }), jsx("span", { className: 'chat-failed-reply__text', children: withName(labels?.replyFailed ?? '{name} could not answer') })] }), jsxs("div", { className: 'chat-failed-reply__actions', children: [jsx("button", { type: 'button', className: 'chat-failed-reply__action', onClick: () => setDetailShown(true), children: labels?.seeError ?? 'See error' }), reportUrl && (jsx("a", { className: 'chat-failed-reply__action', href: reportUrl, target: '_blank', rel: 'noreferrer', children: labels?.report ?? 'Report a bug' }))] }), detailShown && (jsx(Dialog, { title: withName(labels?.errorTitle ?? 'Why {name} could not answer'), width: '40rem', buttons: DialogButtons.Ok, okLabel: labels?.close ?? 'Close', onConfirm: () => setDetailShown(false), onCancel: () => setDetailShown(false), children: jsx("pre", { className: 'chat-failed-reply__detail', children: detail }) }))] }));
18
+ return (jsxs("div", { className: 'chat-failed-reply', "data-cratis-component": 'FailedReply', "aria-live": 'polite', children: [jsxs("div", { className: 'chat-failed-reply__line', children: [jsx(FaTriangleExclamation, { className: 'chat-failed-reply__icon', "aria-hidden": 'true' }), jsx("span", { className: 'chat-failed-reply__text', children: withName(labels?.replyFailed ?? '{name} could not answer') })] }), jsxs("div", { className: 'chat-failed-reply__actions', children: [jsx("button", { type: 'button', className: 'chat-failed-reply__action', onClick: () => setDetailShown(true), children: labels?.seeError ?? 'See error' }), reportUrl && (jsx("a", { className: 'chat-failed-reply__action', href: reportUrl, target: '_blank', rel: 'noreferrer', children: labels?.report ?? 'Report a bug' }))] }), detailShown && (jsx(Dialog, { title: withName(labels?.errorTitle ?? 'Why {name} could not answer'), width: '40rem', buttons: DialogButtons.Ok, okLabel: labels?.close ?? 'Close', onConfirm: () => setDetailShown(false), onCancel: () => setDetailShown(false), children: jsx("pre", { className: 'chat-failed-reply__detail', children: detail }) }))] }));
19
19
  };
20
20
 
21
21
  export { FailedReply };
@@ -1 +1 @@
1
- {"version":3,"file":"FailedReply.js","sources":["../../../../Chat/Kit/FailedReply.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 { useState } from 'react';\nimport { DialogButtons } from '@cratis/arc.react/dialogs';\nimport { Dialog } from '../../Dialogs/Dialog';\nimport type { ChatMessage } from './ChatMessage';\nimport { FaTriangleExclamation } from 'react-icons/fa6';\n\n/** The pieces of a would-be issue report, handed to {@link FailedReplyProps.buildReportUrl}. */\nexport interface FailedReplyReportDetails {\n /** A one-line title for the report. */\n title: string;\n\n /** A short summary of what went wrong. */\n summary: string;\n\n /** The raw failure detail from the message. */\n detail: string;\n\n /** The identifier of the message whose turn failed, so the turn can be traced by it. */\n commentId: string;\n}\n\n/** Overrides for the failure line's own labels. Any field left unset falls back to a literal English\n * default. A `{name}` placeholder is substituted with the message's author name. */\nexport interface FailedReplyLabels {\n /** Defaults to `'{name} could not answer'`. */\n replyFailed?: string;\n /** Defaults to `'See error'`. */\n seeError?: string;\n /** Defaults to `'Report a bug'`. Only rendered when {@link FailedReplyProps.buildReportUrl} is given. */\n report?: string;\n /** Title of the \"see error\" dialog. Defaults to `'Why {name} could not answer'`. */\n errorTitle?: string;\n /** The report's own title, passed to {@link FailedReplyProps.buildReportUrl}. Defaults to\n * `'\"{name}\" could not answer a comment'`. */\n reportTitle?: string;\n /** The report's own summary, passed to {@link FailedReplyProps.buildReportUrl}. Defaults to\n * `'{name} failed while answering a comment. The error it reported follows.'`. */\n reportSummary?: string;\n /** Close button label on the \"see error\" dialog. Defaults to `'Close'`. */\n close?: string;\n}\n\n/**\n * Props for the line a failed turn leaves behind, standing where the answer would have been. It says\n * plainly that the answer never came, and offers the two things somebody staring at it actually wants:\n * the error itself, and — when {@link buildReportUrl} is wired up — a way to report it without\n * transcribing anything by hand.\n */\nexport interface FailedReplyProps {\n /** The message whose turn ended in failure; its `failureDetail` carries the reason. */\n message: ChatMessage;\n\n /**\n * Builds the href for a \"report this\" link from the failure's details. Omit to hide the report\n * action entirely — this library has no issue tracker of its own to link, so a host opts in by\n * passing its own report URL builder.\n */\n buildReportUrl?: (details: FailedReplyReportDetails) => string;\n\n /** Overrides for the failure line's labels. Unset fields fall back to literal English defaults. */\n labels?: FailedReplyLabels;\n}\n\n/**\n * The line a failed turn leaves behind, standing where the answer would have been. It says plainly\n * that the answer never came, and offers the two things somebody staring at it actually wants: the\n * error itself, and — when the host wires up {@link FailedReplyProps.buildReportUrl} — a way to report\n * it without transcribing anything by hand.\n */\nexport const FailedReply = ({ message, buildReportUrl, labels }: FailedReplyProps) => {\n const [detailShown, setDetailShown] = useState(false);\n const detail = message.failureDetail ?? '';\n const withName = (text: string) => text.replace('{name}', message.authorName);\n\n const reportUrl = buildReportUrl?.({\n title: withName(labels?.reportTitle ?? '\"{name}\" could not answer a comment'),\n summary: withName(\n labels?.reportSummary ??\n '{name} failed while answering a comment. The error it reported follows.',\n ),\n detail,\n // The comment the failed turn was written as is the only identifier the reply carries, and it\n // is what the turn can be traced by on the server.\n commentId: message.id.toString(),\n });\n\n return (\n <div className='chat-failed-reply' aria-live='polite'>\n <div className='chat-failed-reply__line'>\n <FaTriangleExclamation\n className='chat-failed-reply__icon'\n aria-hidden='true'\n />\n <span className='chat-failed-reply__text'>\n {withName(labels?.replyFailed ?? '{name} could not answer')}\n </span>\n </div>\n <div className='chat-failed-reply__actions'>\n <button\n type='button'\n className='chat-failed-reply__action'\n onClick={() => setDetailShown(true)}\n >\n {labels?.seeError ?? 'See error'}\n </button>\n {reportUrl && (\n <a\n className='chat-failed-reply__action'\n href={reportUrl}\n target='_blank'\n rel='noreferrer'\n >\n {labels?.report ?? 'Report a bug'}\n </a>\n )}\n </div>\n {detailShown && (\n <Dialog\n title={withName(labels?.errorTitle ?? 'Why {name} could not answer')}\n width='40rem'\n buttons={DialogButtons.Ok}\n okLabel={labels?.close ?? 'Close'}\n onConfirm={() => setDetailShown(false)}\n onCancel={() => setDetailShown(false)}\n >\n <pre className='chat-failed-reply__detail'>{detail}</pre>\n </Dialog>\n )}\n </div>\n );\n};\n"],"names":["_jsxs","_jsx"],"mappings":";;;;;;AAwEO,MAAM,WAAW,GAAG,CAAC,EAAE,OAAO,EAAE,cAAc,EAAE,MAAM,EAAoB,KAAI;IACjF,MAAM,CAAC,WAAW,EAAE,cAAc,CAAC,GAAG,QAAQ,CAAC,KAAK,CAAC;AACrD,IAAA,MAAM,MAAM,GAAG,OAAO,CAAC,aAAa,IAAI,EAAE;AAC1C,IAAA,MAAM,QAAQ,GAAG,CAAC,IAAY,KAAK,IAAI,CAAC,OAAO,CAAC,QAAQ,EAAE,OAAO,CAAC,UAAU,CAAC;AAE7E,IAAA,MAAM,SAAS,GAAG,cAAc,GAAG;QAC/B,KAAK,EAAE,QAAQ,CAAC,MAAM,EAAE,WAAW,IAAI,qCAAqC,CAAC;AAC7E,QAAA,OAAO,EAAE,QAAQ,CACb,MAAM,EAAE,aAAa;AACjB,YAAA,yEAAyE,CAChF;QACD,MAAM;AAGN,QAAA,SAAS,EAAE,OAAO,CAAC,EAAE,CAAC,QAAQ,EAAE;AACnC,KAAA,CAAC;AAEF,IAAA,QACIA,IAAA,CAAA,KAAA,EAAA,EAAK,SAAS,EAAC,mBAAmB,eAAW,QAAQ,EAAA,QAAA,EAAA,CACjDA,IAAA,CAAA,KAAA,EAAA,EAAK,SAAS,EAAC,yBAAyB,EAAA,QAAA,EAAA,CACpCC,IAAC,qBAAqB,EAAA,EAClB,SAAS,EAAC,yBAAyB,EAAA,aAAA,EACvB,MAAM,GACpB,EACFA,GAAA,CAAA,MAAA,EAAA,EAAM,SAAS,EAAC,yBAAyB,EAAA,QAAA,EACpC,QAAQ,CAAC,MAAM,EAAE,WAAW,IAAI,yBAAyB,CAAC,EAAA,CACxD,IACL,EACND,IAAA,CAAA,KAAA,EAAA,EAAK,SAAS,EAAC,4BAA4B,EAAA,QAAA,EAAA,CACvCC,GAAA,CAAA,QAAA,EAAA,EACI,IAAI,EAAC,QAAQ,EACb,SAAS,EAAC,2BAA2B,EACrC,OAAO,EAAE,MAAM,cAAc,CAAC,IAAI,CAAC,EAAA,QAAA,EAElC,MAAM,EAAE,QAAQ,IAAI,WAAW,GAC3B,EACR,SAAS,KACNA,WACI,SAAS,EAAC,2BAA2B,EACrC,IAAI,EAAE,SAAS,EACf,MAAM,EAAC,QAAQ,EACf,GAAG,EAAC,YAAY,YAEf,MAAM,EAAE,MAAM,IAAI,cAAc,EAAA,CACjC,CACP,IACC,EACL,WAAW,KACRA,GAAA,CAAC,MAAM,EAAA,EACH,KAAK,EAAE,QAAQ,CAAC,MAAM,EAAE,UAAU,IAAI,6BAA6B,CAAC,EACpE,KAAK,EAAC,OAAO,EACb,OAAO,EAAE,aAAa,CAAC,EAAE,EACzB,OAAO,EAAE,MAAM,EAAE,KAAK,IAAI,OAAO,EACjC,SAAS,EAAE,MAAM,cAAc,CAAC,KAAK,CAAC,EACtC,QAAQ,EAAE,MAAM,cAAc,CAAC,KAAK,CAAC,YAErCA,GAAA,CAAA,KAAA,EAAA,EAAK,SAAS,EAAC,2BAA2B,YAAE,MAAM,EAAA,CAAO,GACpD,CACZ,CAAA,EAAA,CACC;AAEd;;"}
1
+ {"version":3,"file":"FailedReply.js","sources":["../../../../Chat/Kit/FailedReply.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 { useState } from 'react';\nimport { DialogButtons } from '@cratis/arc.react/dialogs';\nimport { Dialog } from '../../Dialogs/Dialog';\nimport type { ChatMessage } from './ChatMessage';\nimport { FaTriangleExclamation } from 'react-icons/fa6';\n\n/** The pieces of a would-be issue report, handed to {@link FailedReplyProps.buildReportUrl}. */\nexport interface FailedReplyReportDetails {\n /** A one-line title for the report. */\n title: string;\n\n /** A short summary of what went wrong. */\n summary: string;\n\n /** The raw failure detail from the message. */\n detail: string;\n\n /** The identifier of the message whose turn failed, so the turn can be traced by it. */\n commentId: string;\n}\n\n/** Overrides for the failure line's own labels. Any field left unset falls back to a literal English\n * default. A `{name}` placeholder is substituted with the message's author name. */\nexport interface FailedReplyLabels {\n /** Defaults to `'{name} could not answer'`. */\n replyFailed?: string;\n /** Defaults to `'See error'`. */\n seeError?: string;\n /** Defaults to `'Report a bug'`. Only rendered when {@link FailedReplyProps.buildReportUrl} is given. */\n report?: string;\n /** Title of the \"see error\" dialog. Defaults to `'Why {name} could not answer'`. */\n errorTitle?: string;\n /** The report's own title, passed to {@link FailedReplyProps.buildReportUrl}. Defaults to\n * `'\"{name}\" could not answer a comment'`. */\n reportTitle?: string;\n /** The report's own summary, passed to {@link FailedReplyProps.buildReportUrl}. Defaults to\n * `'{name} failed while answering a comment. The error it reported follows.'`. */\n reportSummary?: string;\n /** Close button label on the \"see error\" dialog. Defaults to `'Close'`. */\n close?: string;\n}\n\n/**\n * Props for the line a failed turn leaves behind, standing where the answer would have been. It says\n * plainly that the answer never came, and offers the two things somebody staring at it actually wants:\n * the error itself, and — when {@link buildReportUrl} is wired up — a way to report it without\n * transcribing anything by hand.\n */\nexport interface FailedReplyProps {\n /** The message whose turn ended in failure; its `failureDetail` carries the reason. */\n message: ChatMessage;\n\n /**\n * Builds the href for a \"report this\" link from the failure's details. Omit to hide the report\n * action entirely — this library has no issue tracker of its own to link, so a host opts in by\n * passing its own report URL builder.\n */\n buildReportUrl?: (details: FailedReplyReportDetails) => string;\n\n /** Overrides for the failure line's labels. Unset fields fall back to literal English defaults. */\n labels?: FailedReplyLabels;\n}\n\n/**\n * The line a failed turn leaves behind, standing where the answer would have been. It says plainly\n * that the answer never came, and offers the two things somebody staring at it actually wants: the\n * error itself, and — when the host wires up {@link FailedReplyProps.buildReportUrl} — a way to report\n * it without transcribing anything by hand.\n */\nexport const FailedReply = ({ message, buildReportUrl, labels }: FailedReplyProps) => {\n const [detailShown, setDetailShown] = useState(false);\n const detail = message.failureDetail ?? '';\n const withName = (text: string) => text.replace('{name}', message.authorName);\n\n const reportUrl = buildReportUrl?.({\n title: withName(labels?.reportTitle ?? '\"{name}\" could not answer a comment'),\n summary: withName(\n labels?.reportSummary ??\n '{name} failed while answering a comment. The error it reported follows.',\n ),\n detail,\n // The comment the failed turn was written as is the only identifier the reply carries, and it\n // is what the turn can be traced by on the server.\n commentId: message.id.toString(),\n });\n\n return (\n <div className='chat-failed-reply' data-cratis-component='FailedReply' aria-live='polite'>\n <div className='chat-failed-reply__line'>\n <FaTriangleExclamation\n className='chat-failed-reply__icon'\n aria-hidden='true'\n />\n <span className='chat-failed-reply__text'>\n {withName(labels?.replyFailed ?? '{name} could not answer')}\n </span>\n </div>\n <div className='chat-failed-reply__actions'>\n <button\n type='button'\n className='chat-failed-reply__action'\n onClick={() => setDetailShown(true)}\n >\n {labels?.seeError ?? 'See error'}\n </button>\n {reportUrl && (\n <a\n className='chat-failed-reply__action'\n href={reportUrl}\n target='_blank'\n rel='noreferrer'\n >\n {labels?.report ?? 'Report a bug'}\n </a>\n )}\n </div>\n {detailShown && (\n <Dialog\n title={withName(labels?.errorTitle ?? 'Why {name} could not answer')}\n width='40rem'\n buttons={DialogButtons.Ok}\n okLabel={labels?.close ?? 'Close'}\n onConfirm={() => setDetailShown(false)}\n onCancel={() => setDetailShown(false)}\n >\n <pre className='chat-failed-reply__detail'>{detail}</pre>\n </Dialog>\n )}\n </div>\n );\n};\n"],"names":["_jsxs","_jsx"],"mappings":";;;;;;AAwEO,MAAM,WAAW,GAAG,CAAC,EAAE,OAAO,EAAE,cAAc,EAAE,MAAM,EAAoB,KAAI;IACjF,MAAM,CAAC,WAAW,EAAE,cAAc,CAAC,GAAG,QAAQ,CAAC,KAAK,CAAC;AACrD,IAAA,MAAM,MAAM,G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ACf,GAAG,EAAC,YAAY,EAAA,QAAA,EAEf,MAAM,EAAE,MAAM,IAAI,cAAc,EAAA,CACjC,CACP,CAAA,EAAA,CACC,EACL,WAAW,KACRA,GAAA,CAAC,MAAM,IACH,KAAK,EAAE,QAAQ,CAAC,MAAM,EAAE,UAAU,IAAI,6BAA6B,CAAC,EACpE,KAAK,EAAC,OAAO,EACb,OAAO,EAAE,aAAa,CAAC,EAAE,EACzB,OAAO,EAAE,MAAM,EAAE,KAAK,IAAI,OAAO,EACjC,SAAS,EAAE,MAAM,cAAc,CAAC,KAAK,CAAC,EACtC,QAAQ,EAAE,MAAM,cAAc,CAAC,KAAK,CAAC,YAErCA,GAAA,CAAA,KAAA,EAAA,EAAK,SAAS,EAAC,2BAA2B,YAAE,MAAM,EAAA,CAAO,GACpD,CACZ,CAAA,EAAA,CACC;AAEd;;"}
@@ -3,7 +3,7 @@ import { PersonAvatarCircle } from '../Avatar/PersonAvatarCircle.js';
3
3
  import { ChatAuthorKind } from '../ChatAuthorKind.js';
4
4
  import { mentionOptionId } from './mentionOptionId.js';
5
5
 
6
- const MentionSuggestions = ({ candidates, highlightedIndex, onSelect, onHighlight, buildAvatarUrl, id, 'aria-label': ariaLabel = 'Mention suggestions', }) => (jsx("div", { id: id, className: 'mention-suggestions', role: 'listbox', "aria-label": ariaLabel, children: candidates.map((candidate, index) => (jsxs("button", { id: id === undefined ? undefined : mentionOptionId(id, index), type: 'button', tabIndex: -1, role: 'option', "aria-selected": index === highlightedIndex, className: `mention-suggestions__item${index === highlightedIndex ? ' mention-suggestions__item--highlighted' : ''}`, onMouseDown: (event) => event.preventDefault(), onMouseEnter: () => onHighlight(index), onClick: () => onSelect(candidate), children: [jsx(PersonAvatarCircle, { userId: candidate.id, name: candidate.name, hasAvatar: candidate.hasAvatar, size: 20, ownerType: candidate.kind === ChatAuthorKind.Agent ? 'Agents' : 'Users', version: candidate.avatarVersion, buildAvatarUrl: buildAvatarUrl }), jsx("span", { className: 'mention-suggestions__name', children: candidate.name })] }, candidate.id))) }));
6
+ const MentionSuggestions = ({ candidates, highlightedIndex, onSelect, onHighlight, buildAvatarUrl, id, 'aria-label': ariaLabel = 'Mention suggestions', }) => (jsx("div", { id: id, className: 'mention-suggestions', "data-cratis-component": 'MentionSuggestions', role: 'listbox', "aria-label": ariaLabel, children: candidates.map((candidate, index) => (jsxs("button", { id: id === undefined ? undefined : mentionOptionId(id, index), type: 'button', tabIndex: -1, role: 'option', "aria-selected": index === highlightedIndex, className: `mention-suggestions__item${index === highlightedIndex ? ' mention-suggestions__item--highlighted' : ''}`, onMouseDown: (event) => event.preventDefault(), onMouseEnter: () => onHighlight(index), onClick: () => onSelect(candidate), children: [jsx(PersonAvatarCircle, { userId: candidate.id, name: candidate.name, hasAvatar: candidate.hasAvatar, size: 20, ownerType: candidate.kind === ChatAuthorKind.Agent ? 'Agents' : 'Users', version: candidate.avatarVersion, buildAvatarUrl: buildAvatarUrl }), jsx("span", { className: 'mention-suggestions__name', children: candidate.name })] }, candidate.id))) }));
7
7
 
8
8
  export { MentionSuggestions };
9
9
  //# sourceMappingURL=MentionSuggestions.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"MentionSuggestions.js","sources":["../../../../../Chat/Kit/Mentions/MentionSuggestions.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 { PersonAvatarCircle, type BuildAvatarUrlParams } from '../Avatar';\nimport { ChatAuthorKind } from '../ChatAuthorKind';\nimport type { MentionCandidate } from './MentionCandidate';\nimport { mentionOptionId } from './mentionOptionId';\n\n/**\n * Props for the list that opens while an `@` mention is being typed, showing people and agents\n * together with their avatars.\n */\nexport interface MentionSuggestionsProps {\n /** The candidates to offer, already filtered by what has been typed. */\n candidates: MentionCandidate[];\n\n /** The index of the highlighted candidate, which Enter picks. */\n highlightedIndex: number;\n\n /** Invoked with the candidate the user picked. */\n onSelect: (candidate: MentionCandidate) => void;\n\n /** Invoked when the pointer moves onto a candidate, so hover and keyboard stay in step. */\n onHighlight: (index: number) => void;\n\n /** Id of the list element. When given, each option gets a position-based id the input can reference with `aria-activedescendant`. */\n id?: string;\n\n /** Accessible name for the suggestion list. Defaults to `'Mention suggestions'`. */\n 'aria-label'?: string;\n\n /** Builds the avatar image URL. Omit to always show initials — see {@link PersonAvatarCircleProps}. */\n buildAvatarUrl?: (params: BuildAvatarUrlParams) => string;\n}\n\n/**\n * The list that opens while an `@` mention is being typed, showing people and agents together with\n * their avatars.\n */\nexport const MentionSuggestions = ({\n candidates,\n highlightedIndex,\n onSelect,\n onHighlight,\n buildAvatarUrl,\n id,\n 'aria-label': ariaLabel = 'Mention suggestions',\n}: MentionSuggestionsProps) => (\n <div id={id} className='mention-suggestions' role='listbox' aria-label={ariaLabel}>\n {candidates.map((candidate, index) => (\n <button\n key={candidate.id}\n id={id === undefined ? undefined : mentionOptionId(id, index)}\n type='button'\n tabIndex={-1}\n role='option'\n aria-selected={index === highlightedIndex}\n className={`mention-suggestions__item${index === highlightedIndex ? ' mention-suggestions__item--highlighted' : ''}`}\n // The input must keep focus, so the pointer press never reaches it as a blur.\n onMouseDown={(event) => event.preventDefault()}\n onMouseEnter={() => onHighlight(index)}\n onClick={() => onSelect(candidate)}\n >\n <PersonAvatarCircle\n userId={candidate.id}\n name={candidate.name}\n hasAvatar={candidate.hasAvatar}\n size={20}\n ownerType={\n candidate.kind === ChatAuthorKind.Agent ? 'Agents' : 'Users'\n }\n version={candidate.avatarVersion}\n buildAvatarUrl={buildAvatarUrl}\n />\n <span className='mention-suggestions__name'>{candidate.name}</span>\n </button>\n ))}\n </div>\n);\n"],"names":["_jsx","_jsxs"],"mappings":";;;;;MAuCa,kBAAkB,GAAG,CAAC,EAC/B,UAAU,EACV,gBAAgB,EAChB,QAAQ,EACR,WAAW,EACX,cAAc,EACd,EAAE,EACF,YAAY,EAAE,SAAS,GAAG,qBAAqB,GACzB,MACtBA,aAAK,EAAE,EAAE,EAAE,EAAE,SAAS,EAAC,qBAAqB,EAAC,IAAI,EAAC,SAAS,EAAA,YAAA,EAAa,SAAS,EAAA,QAAA,EAC5E,UAAU,CAAC,GAAG,CAAC,CAAC,SAAS,EAAE,KAAK,MAC7BC,iBAEI,EAAE,EAAE,EAAE,KAAK,SAAS,GAAG,SAAS,GAAG,eAAe,CAAC,EAAE,EAAE,KAAK,CAAC,EAC7D,IAAI,EAAC,QAAQ,EACb,QAAQ,EAAE,EAAE,EACZ,IAAI,EAAC,QAAQ,EAAA,eAAA,EACE,KAAK,KAAK,gBAAgB,EACzC,SAAS,EAAE,CAAA,yBAAA,EAA4B,KAAK,KAAK,gBAAgB,GAAG,yCAAyC,GAAG,EAAE,EAAE,EAEpH,WAAW,EAAE,CAAC,KAAK,KAAK,KAAK,CAAC,cAAc,EAAE,EAC9C,YAAY,EAAE,MAAM,WAAW,CAAC,KAAK,CAAC,EACtC,OAAO,EAAE,MAAM,QAAQ,CAAC,SAAS,CAAC,aAElCD,GAAA,CAAC,kBAAkB,EAAA,EACf,MAAM,EAAE,SAAS,CAAC,EAAE,EACpB,IAAI,EAAE,SAAS,CAAC,IAAI,EACpB,SAAS,EAAE,SAAS,CAAC,SAAS,EAC9B,IAAI,EAAE,EAAE,EACR,SAAS,EACL,SAAS,CAAC,IAAI,KAAK,cAAc,CAAC,KAAK,GAAG,QAAQ,GAAG,OAAO,EAEhE,OAAO,EAAE,SAAS,CAAC,aAAa,EAChC,cAAc,EAAE,cAAc,EAAA,CAChC,EACFA,GAAA,CAAA,MAAA,EAAA,EAAM,SAAS,EAAC,2BAA2B,EAAA,QAAA,EAAE,SAAS,CAAC,IAAI,EAAA,CAAQ,CAAA,EAAA,EAvB9D,SAAS,CAAC,EAAE,CAwBZ,CACZ,CAAC,EAAA,CACA;;"}
1
+ {"version":3,"file":"MentionSuggestions.js","sources":["../../../../../Chat/Kit/Mentions/MentionSuggestions.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 { PersonAvatarCircle, type BuildAvatarUrlParams } from '../Avatar';\nimport { ChatAuthorKind } from '../ChatAuthorKind';\nimport type { MentionCandidate } from './MentionCandidate';\nimport { mentionOptionId } from './mentionOptionId';\n\n/**\n * Props for the list that opens while an `@` mention is being typed, showing people and agents\n * together with their avatars.\n */\nexport interface MentionSuggestionsProps {\n /** The candidates to offer, already filtered by what has been typed. */\n candidates: MentionCandidate[];\n\n /** The index of the highlighted candidate, which Enter picks. */\n highlightedIndex: number;\n\n /** Invoked with the candidate the user picked. */\n onSelect: (candidate: MentionCandidate) => void;\n\n /** Invoked when the pointer moves onto a candidate, so hover and keyboard stay in step. */\n onHighlight: (index: number) => void;\n\n /** Id of the list element. When given, each option gets a position-based id the input can reference with `aria-activedescendant`. */\n id?: string;\n\n /** Accessible name for the suggestion list. Defaults to `'Mention suggestions'`. */\n 'aria-label'?: string;\n\n /** Builds the avatar image URL. Omit to always show initials — see {@link PersonAvatarCircleProps}. */\n buildAvatarUrl?: (params: BuildAvatarUrlParams) => string;\n}\n\n/**\n * The list that opens while an `@` mention is being typed, showing people and agents together with\n * their avatars.\n */\nexport const MentionSuggestions = ({\n candidates,\n highlightedIndex,\n onSelect,\n onHighlight,\n buildAvatarUrl,\n id,\n 'aria-label': ariaLabel = 'Mention suggestions',\n}: MentionSuggestionsProps) => (\n <div id={id} className='mention-suggestions' data-cratis-component='MentionSuggestions' role='listbox' aria-label={ariaLabel}>\n {candidates.map((candidate, index) => (\n <button\n key={candidate.id}\n id={id === undefined ? undefined : mentionOptionId(id, index)}\n type='button'\n tabIndex={-1}\n role='option'\n aria-selected={index === highlightedIndex}\n className={`mention-suggestions__item${index === highlightedIndex ? ' mention-suggestions__item--highlighted' : ''}`}\n // The input must keep focus, so the pointer press never reaches it as a blur.\n onMouseDown={(event) => event.preventDefault()}\n onMouseEnter={() => onHighlight(index)}\n onClick={() => onSelect(candidate)}\n >\n <PersonAvatarCircle\n userId={candidate.id}\n name={candidate.name}\n hasAvatar={candidate.hasAvatar}\n size={20}\n ownerType={\n candidate.kind === ChatAuthorKind.Agent ? 'Agents' : 'Users'\n }\n version={candidate.avatarVersion}\n buildAvatarUrl={buildAvatarUrl}\n />\n <span className='mention-suggestions__name'>{candidate.name}</span>\n </button>\n ))}\n </div>\n);\n"],"names":["_jsx","_jsxs"],"mappings":";;;;;MAuCa,kBAAkB,GAAG,CAAC,EAC/B,UAAU,EACV,gBAAgB,EAChB,QAAQ,EACR,WAAW,EACX,cAAc,EACd,EAAE,EACF,YAAY,EAAE,SAAS,GAAG,qBAAqB,GACzB,MACtBA,aAAK,EAAE,EAAE,EAAE,EAAE,SAAS,EAAC,qBAAqB,EAAA,uBAAA,EAAuB,oBAAoB,EAAC,IAAI,EAAC,SAAS,EAAA,YAAA,EAAa,SAAS,EAAA,QAAA,EACvH,UAAU,CAAC,GAAG,CAAC,CAAC,SAAS,EAAE,KAAK,MAC7BC,IAAA,CAAA,QAAA,EAAA,EAEI,EAAE,EAAE,EAAE,KAAK,SAAS,GAAG,SAAS,GAAG,eAAe,CAAC,EAAE,EAAE,KAAK,CAAC,EAC7D,IAAI,EAAC,QAAQ,EACb,QAAQ,EAAE,EAAE,EACZ,IAAI,EAAC,QAAQ,EAAA,eAAA,EACE,KAAK,KAAK,gBAAgB,EACzC,SAAS,EAAE,CAAA,yBAAA,EAA4B,KAAK,KAAK,gBAAgB,GAAG,yCAAyC,GAAG,EAAE,CAAA,CAAE,EAEpH,WAAW,EAAE,CAAC,KAAK,KAAK,KAAK,CAAC,cAAc,EAAE,EAC9C,YAAY,EAAE,MAAM,WAAW,CAAC,KAAK,CAAC,EACtC,OAAO,EAAE,MAAM,QAAQ,CAAC,SAAS,CAAC,EAAA,QAAA,EAAA,CAElCD,GAAA,CAAC,kBAAkB,EAAA,EACf,MAAM,EAAE,SAAS,CAAC,EAAE,EACpB,IAAI,EAAE,SAAS,CAAC,IAAI,EACpB,SAAS,EAAE,SAAS,CAAC,SAAS,EAC9B,IAAI,EAAE,EAAE,EACR,SAAS,EACL,SAAS,CAAC,IAAI,KAAK,cAAc,CAAC,KAAK,GAAG,QAAQ,GAAG,OAAO,EAEhE,OAAO,EAAE,SAAS,CAAC,aAAa,EAChC,cAAc,EAAE,cAAc,EAAA,CAChC,EACFA,GAAA,CAAA,MAAA,EAAA,EAAM,SAAS,EAAC,2BAA2B,EAAA,QAAA,EAAE,SAAS,CAAC,IAAI,EAAA,CAAQ,CAAA,EAAA,EAvB9D,SAAS,CAAC,EAAE,CAwBZ,CACZ,CAAC,EAAA,CACA;;"}
@@ -12,7 +12,7 @@ const ReactionBadge = ({ reaction }) => {
12
12
  const MessageReactions = ({ reactions }) => {
13
13
  if (reactions.length === 0)
14
14
  return null;
15
- return (jsx("div", { className: 'message-reactions', children: reactions.map((reaction) => (jsx(ReactionBadge, { reaction: reaction }, reaction.emoji))) }));
15
+ return (jsx("div", { className: 'message-reactions', "data-cratis-component": 'MessageReactions', children: reactions.map((reaction) => (jsx(ReactionBadge, { reaction: reaction }, reaction.emoji))) }));
16
16
  };
17
17
 
18
18
  export { MessageReactions };
@@ -1 +1 @@
1
- {"version":3,"file":"MessageReactions.js","sources":["../../../../Chat/Kit/MessageReactions.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 { useRef, useState } from 'react';\nimport { AnchoredOverlay } from './AnchoredOverlay';\nimport type { ChatMessageReaction } from './ChatMessageReaction';\n\nconst MAX_STACKED_GLYPHS = 3;\n\n/**\n * Props for the row of emoji badges a message's reactions render as, sitting below the message text.\n * Each badge says who is behind it on hover, emoji on the left and name on the right, one line per person.\n */\nexport interface MessageReactionsProps {\n /**\n * The reactions to render, one badge per distinct emoji. Several people behind the same emoji\n * render as a stack rather than repeating the glyph; a different emoji gets its own badge on the\n * line.\n */\n reactions: ChatMessageReaction[];\n}\n\ninterface ReactionBadgeProps {\n /** The reaction this badge stands for. */\n reaction: ChatMessageReaction;\n}\n\n/**\n * One emoji's badge. Who gave it is shown on hover — that is the whole mechanism, so there is nothing\n * to discover and nothing extra to click. Clicking pins the same list open, which is what makes it\n * reachable on a touch screen, where there is no hover to rely on.\n */\nconst ReactionBadge = ({ reaction }: ReactionBadgeProps) => {\n const anchorRef = useRef<HTMLDivElement>(null);\n const [isHovered, setIsHovered] = useState(false);\n const [isPinned, setIsPinned] = useState(false);\n\n return (\n <div\n ref={anchorRef}\n className='message-reactions__badge-wrapper'\n onMouseEnter={() => setIsHovered(true)}\n onMouseLeave={() => setIsHovered(false)}\n >\n <button\n type='button'\n className='message-reactions__badge'\n onFocus={() => setIsHovered(true)}\n onBlur={() => setIsHovered(false)}\n onClick={() => setIsPinned((pinned) => !pinned)}\n >\n <span className='message-reactions__stack'>\n {reaction.users.slice(0, MAX_STACKED_GLYPHS).map((user, index) => (\n <span\n key={user.id.toString()}\n className='message-reactions__glyph'\n style={{ zIndex: MAX_STACKED_GLYPHS - index }}\n >\n {reaction.emoji}\n </span>\n ))}\n </span>\n {reaction.users.length > 1 && (\n <span className='message-reactions__count'>\n {reaction.users.length}\n </span>\n )}\n </button>\n {/* Portaled rather than positioned inside the bubble: the chat panel scrolls, and anything\n positioned within it is clipped the moment it reaches the panel's edge. */}\n <AnchoredOverlay\n anchorRef={anchorRef}\n open={isHovered || isPinned}\n side='above'\n align='left'\n gap={6}\n >\n <div className='message-reactions__tooltip' role='tooltip'>\n {reaction.users.map((user) => (\n <div\n key={user.id.toString()}\n className='message-reactions__tooltip-row'\n >\n <span className='message-reactions__tooltip-emoji'>\n {reaction.emoji}\n </span>\n <span className='message-reactions__tooltip-name'>\n {user.name}\n </span>\n </div>\n ))}\n </div>\n </AnchoredOverlay>\n </div>\n );\n};\n\n/**\n * The row of emoji badges a message's reactions render as, sitting below the message text. Each badge\n * says who is behind it on hover, emoji on the left and name on the right, one line per person.\n */\nexport const MessageReactions = ({ reactions }: MessageReactionsProps) => {\n if (reactions.length === 0) return null;\n\n return (\n <div className='message-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A,EAAsB,QAAQ,EAAE,QAAQ,EAAA,EAAlC,QAAQ,CAAC,KAAK,CAAwB,CAC7D,CAAC,EAAA,CACA;AAEd;;"}
1
+ {"version":3,"file":"MessageReactions.js","sources":["../../../../Chat/Kit/MessageReactions.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 { useRef, useState } from 'react';\nimport { AnchoredOverlay } from './AnchoredOverlay';\nimport type { ChatMessageReaction } from './ChatMessageReaction';\n\nconst MAX_STACKED_GLYPHS = 3;\n\n/**\n * Props for the row of emoji badges a message's reactions render as, sitting below the message text.\n * Each badge says who is behind it on hover, emoji on the left and name on the right, one line per person.\n */\nexport interface MessageReactionsProps {\n /**\n * The reactions to render, one badge per distinct emoji. Several people behind the same emoji\n * render as a stack rather than repeating the glyph; a different emoji gets its own badge on the\n * line.\n */\n reactions: ChatMessageReaction[];\n}\n\ninterface ReactionBadgeProps {\n /** The reaction this badge stands for. */\n reaction: ChatMessageReaction;\n}\n\n/**\n * One emoji's badge. Who gave it is shown on hover — that is the whole mechanism, so there is nothing\n * to discover and nothing extra to click. Clicking pins the same list open, which is what makes it\n * reachable on a touch screen, where there is no hover to rely on.\n */\nconst ReactionBadge = ({ reaction }: ReactionBadgeProps) => {\n const anchorRef = useRef<HTMLDivElement>(null);\n const [isHovered, setIsHovered] = useState(false);\n const [isPinned, setIsPinned] = useState(false);\n\n return (\n <div\n ref={anchorRef}\n className='message-reactions__badge-wrapper'\n onMouseEnter={() => setIsHovered(true)}\n onMouseLeave={() => setIsHovered(false)}\n >\n <button\n type='button'\n className='message-reactions__badge'\n onFocus={() => setIsHovered(true)}\n onBlur={() => setIsHovered(false)}\n onClick={() => setIsPinned((pinned) => !pinned)}\n >\n <span className='message-reactions__stack'>\n {reaction.users.slice(0, MAX_STACKED_GLYPHS).map((user, index) => (\n <span\n key={user.id.toString()}\n className='message-reactions__glyph'\n style={{ zIndex: MAX_STACKED_GLYPHS - index }}\n >\n {reaction.emoji}\n </span>\n ))}\n </span>\n {reaction.users.length > 1 && (\n <span className='message-reactions__count'>\n {reaction.users.length}\n </span>\n )}\n </button>\n {/* Portaled rather than positioned inside the bubble: the chat panel scrolls, and anything\n positioned within it is clipped the moment it reaches the panel's edge. */}\n <AnchoredOverlay\n anchorRef={anchorRef}\n open={isHovered || isPinned}\n side='above'\n align='left'\n gap={6}\n >\n <div className='message-reactions__tooltip' role='tooltip'>\n {reaction.users.map((user) => (\n <div\n key={user.id.toString()}\n className='message-reactions__tooltip-row'\n >\n <span className='message-reactions__tooltip-emoji'>\n {reaction.emoji}\n </span>\n <span className='message-reactions__tooltip-name'>\n {user.name}\n </span>\n </div>\n ))}\n </div>\n </AnchoredOverlay>\n </div>\n );\n};\n\n/**\n * The row of emoji badges a message's reactions render as, sitting below the message text. Each badge\n * says who is behind it on hover, emoji on the left and name on the right, one line per person.\n */\nexport const MessageReactions = ({ reactions }: MessageReactionsProps) => {\n if (reactions.length === 0) return null;\n\n return (\n <div className='message-reactions' data-cratis-component='MessageReactions'>\n {reactions.map((reaction) => (\n <ReactionBadge key={reaction.emoji} reaction={reaction} />\n ))}\n </div>\n );\n};\n"],"names":["_jsxs","_jsx"],"mappings":";;;;AAOA,MAAM,kBAAkB,GAAG,CAAC;AAyB5B,MAAM,aAAa,GAAG,CAAC,EAAE,QAAQ,EAAsB,KAAI;AACvD,IAAA,MAAM,SAAS,GAAG,MAAM,CAAiB,IAAI,CAAC;IAC9C,MAAM,CAAC,SAAS,EAAE,YAAY,CAAC,GAAG,QAAQ,CAAC,KAAK,CAAC;IACjD,MAAM,CAAC,QAAQ,EAAE,WAAW,CAAC,GAAG,QAAQ,CAAC,KAAK,CAAC;IAE/C,QACIA,IAAA,CAAA,KAAA,EAAA,EACI,GAAG,EAAE,SAAS,EACd,SAAS,EAAC,kCAAkC,EAC5C,YAAY,EAAE,MAAM,YAAY,CAAC,IAAI,CAAC,EACtC,YAAY,EAAE,MAAM,YAAY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AA,EAAA,EAEI,SAAS,EAAC,gCAAgC,EAAA,QAAA,EAAA,CAE1CC,GAAA,CAAA,MAAA,EAAA,EAAM,SAAS,EAAC,kCAAkC,YAC7C,QAAQ,CAAC,KAAK,EAAA,CACZ,EACPA,GAAA,CAAA,MAAA,EAAA,EAAM,SAAS,EAAC,iCAAiC,EAAA,QAAA,EAC5C,IAAI,CAAC,IAAI,EAAA,CACP,CAAA,EAAA,EARF,IAAI,CAAC,EAAE,CAAC,QAAQ,EAAE,CASrB,CACT,CAAC,EAAA,CACA,EAAA,CACQ,CAAA,EAAA,CAChB;AAEd,CAAC;MAMY,gBAAgB,GAAG,CAAC,EAAE,SAAS,EAAyB,KAAI;AACrE,IAAA,IAAI,SAAS,CAAC,MAAM,KAAK,CAAC;AAAE,QAAA,OAAO,IAAI;AAEvC,IAAA,QACIA,GAAA,CAAA,KAAA,EAAA,EAAK,SAAS,EAAC,mBAAmB,EAAA,uBAAA,EAAuB,kBAAkB,EAAA,QAAA,EACtE,SAAS,CAAC,GAAG,CAAC,CAAC,QAAQ,MACpBA,GAAA,CAAC,aAAa,EAAA,EAAsB,QAAQ,EAAE,QAAQ,EAAA,EAAlC,QAAQ,CAAC,KAAK,CAAwB,CAC7D,CAAC,EAAA,CACA;AAEd;;"}
@@ -17,7 +17,7 @@ const ReactionPicker = ({ ownEmoji, reactions = [], memory, anchorRef, onPick, o
17
17
  setQuickEmojis(rememberEmoji(store, emoji));
18
18
  onPick(emoji);
19
19
  };
20
- return (jsx(FocusScope, { restoreFocus: true, autoFocus: true, children: jsxs("div", { ref: rootRef, className: 'reaction-picker', onKeyDown: onKeyDown, children: [jsxs("div", { className: 'reaction-picker__quick', children: [jsx(EmojiOptions, { emojis: quickEmojis, ownEmoji: ownEmoji, label: labels?.pickEmoji ?? 'Pick an emoji', className: 'reaction-picker__options', optionClassName: 'reaction-picker__item', onPick: pick }), jsx("button", { type: 'button', className: `reaction-picker__more${showingAll ? ' reaction-picker__more--open' : ''}`, title: labels?.allEmojis ?? 'All emojis', "aria-label": labels?.allEmojis ?? 'All emojis', "aria-expanded": showingAll, "aria-controls": showingAll ? fullPickerId : undefined, onClick: () => setShowingAll((open) => !open), children: "\u263A" })] }), showingAll && (jsx("div", { id: fullPickerId, children: jsx(EmojiPicker, { ownEmoji: ownEmoji, onPick: pick, labels: labels?.emojiPicker }) })), !showingAll && reactions.length > 0 && (jsx("div", { className: 'reaction-picker__given', children: reactions.flatMap((reaction) => reaction.users.map((user) => (jsxs("div", { className: 'reaction-picker__given-row', children: [jsx("span", { className: 'reaction-picker__given-emoji', children: reaction.emoji }), jsx("span", { className: 'reaction-picker__given-name', children: user.name })] }, `${reaction.emoji}-${user.id.toString()}`)))) }))] }) }));
20
+ return (jsx(FocusScope, { restoreFocus: true, autoFocus: true, children: jsxs("div", { ref: rootRef, className: 'reaction-picker', "data-cratis-component": 'ReactionPicker', onKeyDown: onKeyDown, children: [jsxs("div", { className: 'reaction-picker__quick', children: [jsx(EmojiOptions, { emojis: quickEmojis, ownEmoji: ownEmoji, label: labels?.pickEmoji ?? 'Pick an emoji', className: 'reaction-picker__options', optionClassName: 'reaction-picker__item', onPick: pick }), jsx("button", { type: 'button', className: `reaction-picker__more${showingAll ? ' reaction-picker__more--open' : ''}`, title: labels?.allEmojis ?? 'All emojis', "aria-label": labels?.allEmojis ?? 'All emojis', "aria-expanded": showingAll, "aria-controls": showingAll ? fullPickerId : undefined, onClick: () => setShowingAll((open) => !open), children: "\u263A" })] }), showingAll && (jsx("div", { id: fullPickerId, children: jsx(EmojiPicker, { ownEmoji: ownEmoji, onPick: pick, labels: labels?.emojiPicker }) })), !showingAll && reactions.length > 0 && (jsx("div", { className: 'reaction-picker__given', children: reactions.flatMap((reaction) => reaction.users.map((user) => (jsxs("div", { className: 'reaction-picker__given-row', children: [jsx("span", { className: 'reaction-picker__given-emoji', children: reaction.emoji }), jsx("span", { className: 'reaction-picker__given-name', children: user.name })] }, `${reaction.emoji}-${user.id.toString()}`)))) }))] }) }));
21
21
  };
22
22
 
23
23
  export { ReactionPicker };
@@ -1 +1 @@
1
- {"version":3,"file":"ReactionPicker.js","sources":["../../../../Chat/Kit/ReactionPicker.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 { RefObject, useId, useState } from 'react';\nimport { FocusScope } from 'react-aria';\nimport { EmojiOptions } from './Emoji/EmojiOptions';\nimport { EmojiPicker, type EmojiPickerLabels } from './Emoji/EmojiPicker';\nimport { recentEmojis, rememberEmoji } from './Emoji/recentEmojis';\nimport type { EmojiMemory } from './Emoji/EmojiMemory';\nimport type { ChatMessageReaction } from './ChatMessageReaction';\nimport { useReactionPickerFocus } from './useReactionPickerFocus';\n\n/** Overrides for the picker's own labels. Any field left unset falls back to a literal English\n * default. */\nexport interface ReactionPickerLabels {\n /** Accessible label for the quick row. Defaults to `'Pick an emoji'`. */\n pickEmoji?: string;\n /** Tooltip/accessible label for the \"more\" button that opens the full picker. Defaults to\n * `'All emojis'`. */\n allEmojis?: string;\n /** Labels forwarded to the full {@link EmojiPicker} when it is opened. */\n emojiPicker?: EmojiPickerLabels;\n}\n\n/**\n * Props for the popover a reaction button opens: the emojis this person reached for most recently,\n * and a muted button at the end that opens the full picker — the shape Apple's tapback bar established,\n * where the quick row answers almost every reaction and the rest is one click further away.\n */\nexport interface ReactionPickerProps {\n /** The emoji the viewer already gave, highlighted so picking it again reads as \"remove\". */\n ownEmoji?: string;\n\n /**\n * The reactions already on the message. Shown as a list of who gave what underneath the quick row,\n * so somebody opening the picker can see where the message stands without a second gesture.\n */\n reactions?: readonly ChatMessageReaction[];\n\n /**\n * Where the recently used emojis are remembered. Defaults to the browser's local storage; a spec\n * (or a host without storage) can pass its own.\n */\n memory?: EmojiMemory;\n\n /**\n * The button that opened the picker. A click on it is that button's business — without this the\n * picker would dismiss on the way down and the button would reopen it on the way up, leaving a\n * toggle that never closes.\n */\n anchorRef?: RefObject<HTMLElement | null>;\n\n /** Invoked with the emoji that was picked. */\n onPick: (emoji: string) => void;\n\n /** Invoked when the picker should close without a pick (an outside click, or Escape). */\n onDismiss: () => void;\n\n /** Overrides for the picker's labels. Unset fields fall back to literal English defaults. */\n labels?: ReactionPickerLabels;\n}\n\n/**\n * The popover a reaction button opens: the emojis this person reached for most recently, and a muted\n * button at the end that opens the full picker — the shape Apple's tapback bar established, where the\n * quick row answers almost every reaction and the rest is one click further away.\n *\n * Picking the emoji already given is how a reaction is taken back; the caller decides\n * give/change/revoke from what was clicked.\n */\nexport const ReactionPicker = ({\n ownEmoji,\n reactions = [],\n memory,\n anchorRef,\n onPick,\n onDismiss,\n labels,\n}: ReactionPickerProps) => {\n const { rootRef, onKeyDown } = useReactionPickerFocus(anchorRef, onDismiss);\n const fullPickerId = useId();\n const store =\n memory ?? (typeof window === 'undefined' ? undefined : window.localStorage);\n const [quickEmojis, setQuickEmojis] = useState(() =>\n store ? recentEmojis(store) : [],\n );\n const [showingAll, setShowingAll] = useState(false);\n\n const pick = (emoji: string) => {\n // Remembered before it is handed on: the caller closes the picker, and the row has to already\n // be in its new order the next time it opens.\n if (store) setQuickEmojis(rememberEmoji(store, emoji));\n onPick(emoji);\n };\n\n return (\n <FocusScope restoreFocus autoFocus>\n <div ref={rootRef} className='reaction-picker' onKeyDown={onKeyDown}>\n <div className='reaction-picker__quick'>\n <EmojiOptions\n emojis={quickEmojis}\n ownEmoji={ownEmoji}\n label={labels?.pickEmoji ?? 'Pick an emoji'}\n className='reaction-picker__options'\n optionClassName='reaction-picker__item'\n onPick={pick}\n />\n <button\n type='button'\n className={`reaction-picker__more${showingAll ? ' reaction-picker__more--open' : ''}`}\n title={labels?.allEmojis ?? 'All emojis'}\n aria-label={labels?.allEmojis ?? 'All emojis'}\n aria-expanded={showingAll}\n aria-controls={showingAll ? fullPickerId : undefined}\n onClick={() => setShowingAll((open) => !open)}\n >\n ☺\n </button>\n </div>\n {showingAll && (\n <div id={fullPickerId}>\n <EmojiPicker\n ownEmoji={ownEmoji}\n onPick={pick}\n labels={labels?.emojiPicker}\n />\n </div>\n )}\n {!showingAll && reactions.length > 0 && (\n <div className='reaction-picker__given'>\n {reactions.flatMap((reaction) =>\n reaction.users.map((user) => (\n <div\n key={`${reaction.emoji}-${user.id.toString()}`}\n className='reaction-picker__given-row'\n >\n <span className='reaction-picker__given-emoji'>\n {reaction.emoji}\n </span>\n <span className='reaction-picker__given-name'>\n {user.name}\n </span>\n </div>\n )),\n )}\n </div>\n )}\n </div>\n </FocusScope>\n );\n};\n"],"names":["_jsx","_jsxs"],"mappings":";;;;;;;;MAsEa,cAAc,GAAG,CAAC,EAC3B,QAAQ,EACR,SAAS,GAAG,EAAE,EACd,MAAM,EACN,SAAS,EACT,MAAM,EACN,SAAS,EACT,MAAM,GACY,KAAI;AACtB,IAAA,MAAM,EAAE,OAAO,EAAE,SAAS,EAAE,GAAG,sBAAsB,CAAC,SAAS,EAAE,SAAS,CAAC;AAC3E,IAAA,MAAM,YAAY,GAAG,KAAK,EAAE;IAC5B,MAAM,KAAK,GACP,MAAM,KAAK,OAAO,MAAM,KAAK,WAAW,GAAG,SAAS,GAAG,MAAM,CAAC,YAAY,CAAC;IAC/E,MAAM,CAAC,WAAW,EAAE,cAAc,CAAC,GAAG,QAAQ,CAAC,MAC3C,KAAK,GAAG,YAAY,CAAC,KAAK,CAAC,GAAG,EAAE,CACnC;IACD,MAAM,CAAC,UAAU,EAAE,aAAa,CAAC,GAAG,QAAQ,CAAC,KAAK,CAAC;AAEnD,IAAA,MAAM,IAAI,GAAG,CAAC,KAAa,KAAI;AAG3B,QAAA,IAAI,KAAK;YAAE,cAAc,CAAC,aAAa,CAAC,KAAK,EAAE,KAAK,CAAC,CAAC;QACtD,MAAM,CAAC,KAAK,CAAC;AACjB,IAAA,CAAC;IAED,QACIA,GAAA,CAAC,UAAU,EAAA,EAAC,YAAY,QAAC,SAAS,EAAA,IAAA,EAAA,QAAA,EAC9BC,IAAA,CAAA,KAAA,EAAA,EAAK,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A,CAAA,KAAA,EAAA,EAEI,SAAS,EAAC,4BAA4B,EAAA,QAAA,EAAA,CAEtCD,GAAA,CAAA,MAAA,EAAA,EAAM,SAAS,EAAC,8BAA8B,EAAA,QAAA,EACzC,QAAQ,CAAC,KAAK,EAAA,CACZ,EACPA,GAAA,CAAA,MAAA,EAAA,EAAM,SAAS,EAAC,6BAA6B,EAAA,QAAA,EACxC,IAAI,CAAC,IAAI,EAAA,CACP,CAAA,EAAA,EARF,CAAA,EAAG,QAAQ,CAAC,KAAK,CAAA,CAAA,EAAI,IAAI,CAAC,EAAE,CAAC,QAAQ,EAAE,CAAA,CAAE,CAS5C,CACT,CAAC,CACL,EAAA,CACC,CACT,CAAA,EAAA,CACC,EAAA,CACG;AAErB;;"}
1
+ {"version":3,"file":"ReactionPicker.js","sources":["../../../../Chat/Kit/ReactionPicker.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 { RefObject, useId, useState } from 'react';\nimport { FocusScope } from 'react-aria';\nimport { EmojiOptions } from './Emoji/EmojiOptions';\nimport { EmojiPicker, type EmojiPickerLabels } from './Emoji/EmojiPicker';\nimport { recentEmojis, rememberEmoji } from './Emoji/recentEmojis';\nimport type { EmojiMemory } from './Emoji/EmojiMemory';\nimport type { ChatMessageReaction } from './ChatMessageReaction';\nimport { useReactionPickerFocus } from './useReactionPickerFocus';\n\n/** Overrides for the picker's own labels. Any field left unset falls back to a literal English\n * default. */\nexport interface ReactionPickerLabels {\n /** Accessible label for the quick row. Defaults to `'Pick an emoji'`. */\n pickEmoji?: string;\n /** Tooltip/accessible label for the \"more\" button that opens the full picker. Defaults to\n * `'All emojis'`. */\n allEmojis?: string;\n /** Labels forwarded to the full {@link EmojiPicker} when it is opened. */\n emojiPicker?: EmojiPickerLabels;\n}\n\n/**\n * Props for the popover a reaction button opens: the emojis this person reached for most recently,\n * and a muted button at the end that opens the full picker — the shape Apple's tapback bar established,\n * where the quick row answers almost every reaction and the rest is one click further away.\n */\nexport interface ReactionPickerProps {\n /** The emoji the viewer already gave, highlighted so picking it again reads as \"remove\". */\n ownEmoji?: string;\n\n /**\n * The reactions already on the message. Shown as a list of who gave what underneath the quick row,\n * so somebody opening the picker can see where the message stands without a second gesture.\n */\n reactions?: readonly ChatMessageReaction[];\n\n /**\n * Where the recently used emojis are remembered. Defaults to the browser's local storage; a spec\n * (or a host without storage) can pass its own.\n */\n memory?: EmojiMemory;\n\n /**\n * The button that opened the picker. A click on it is that button's business — without this the\n * picker would dismiss on the way down and the button would reopen it on the way up, leaving a\n * toggle that never closes.\n */\n anchorRef?: RefObject<HTMLElement | null>;\n\n /** Invoked with the emoji that was picked. */\n onPick: (emoji: string) => void;\n\n /** Invoked when the picker should close without a pick (an outside click, or Escape). */\n onDismiss: () => void;\n\n /** Overrides for the picker's labels. Unset fields fall back to literal English defaults. */\n labels?: ReactionPickerLabels;\n}\n\n/**\n * The popover a reaction button opens: the emojis this person reached for most recently, and a muted\n * button at the end that opens the full picker — the shape Apple's tapback bar established, where the\n * quick row answers almost every reaction and the rest is one click further away.\n *\n * Picking the emoji already given is how a reaction is taken back; the caller decides\n * give/change/revoke from what was clicked.\n */\nexport const ReactionPicker = ({\n ownEmoji,\n reactions = [],\n memory,\n anchorRef,\n onPick,\n onDismiss,\n labels,\n}: ReactionPickerProps) => {\n const { rootRef, onKeyDown } = useReactionPickerFocus(anchorRef, onDismiss);\n const fullPickerId = useId();\n const store =\n memory ?? (typeof window === 'undefined' ? undefined : window.localStorage);\n const [quickEmojis, setQuickEmojis] = useState(() =>\n store ? recentEmojis(store) : [],\n );\n const [showingAll, setShowingAll] = useState(false);\n\n const pick = (emoji: string) => {\n // Remembered before it is handed on: the caller closes the picker, and the row has to already\n // be in its new order the next time it opens.\n if (store) setQuickEmojis(rememberEmoji(store, emoji));\n onPick(emoji);\n };\n\n return (\n <FocusScope restoreFocus autoFocus>\n <div ref={rootRef} className='reaction-picker' data-cratis-component='ReactionPicker' onKeyDown={onKeyDown}>\n <div className='reaction-picker__quick'>\n <EmojiOptions\n emojis={quickEmojis}\n ownEmoji={ownEmoji}\n label={labels?.pickEmoji ?? 'Pick an emoji'}\n className='reaction-picker__options'\n optionClassName='reaction-picker__item'\n onPick={pick}\n />\n <button\n type='button'\n className={`reaction-picker__more${showingAll ? ' reaction-picker__more--open' : ''}`}\n title={labels?.allEmojis ?? 'All emojis'}\n aria-label={labels?.allEmojis ?? 'All emojis'}\n aria-expanded={showingAll}\n aria-controls={showingAll ? fullPickerId : undefined}\n onClick={() => setShowingAll((open) => !open)}\n >\n ☺\n </button>\n </div>\n {showingAll && (\n <div id={fullPickerId}>\n <EmojiPicker\n ownEmoji={ownEmoji}\n onPick={pick}\n labels={labels?.emojiPicker}\n />\n </div>\n )}\n {!showingAll && reactions.length > 0 && (\n <div className='reaction-picker__given'>\n {reactions.flatMap((reaction) =>\n reaction.users.map((user) => (\n <div\n key={`${reaction.emoji}-${user.id.toString()}`}\n className='reaction-picker__given-row'\n >\n <span className='reaction-picker__given-emoji'>\n {reaction.emoji}\n </span>\n <span className='reaction-picker__given-name'>\n {user.name}\n </span>\n </div>\n )),\n )}\n </div>\n )}\n </div>\n </FocusScope>\n );\n};\n"],"names":["_jsx","_jsxs"],"mappings":";;;;;;;;MAsEa,cAAc,GAAG,CAAC,EAC3B,QAAQ,EACR,SAAS,GAAG,EAAE,EACd,MAAM,EACN,SAAS,EACT,MAAM,EACN,SAAS,EACT,MAAM,GACY,KAAI;AACtB,IAAA,MAAM,EAAE,OAAO,EAAE,SAAS,EAAE,GAAG,sBAAsB,CAAC,SAAS,EAAE,SAAS,CAAC;AAC3E,IAAA,MAAM,YAAY,GAAG,KAAK,EAAE;IAC5B,MAAM,KAAK,GACP,MAAM,KAAK,OAAO,MAAM,KAAK,WAAW,GAAG,SAAS,GAAG,MAAM,CAAC,YAAY,CAAC;IAC/E,MAAM,CAAC,WAAW,EAAE,cAAc,CAAC,GAAG,QAAQ,CAAC,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,CAAA,EAAA,CACP,EACL,UAAU,KACPA,GAAA,CAAA,KAAA,EAAA,EAAK,EAAE,EAAE,YAAY,YACjBA,GAAA,CAAC,WAAW,EAAA,EACR,QAAQ,EAAE,QAAQ,EAClB,MAAM,EAAE,IAAI,EACZ,MAAM,EAAE,MAAM,EAAE,WAAW,EAAA,CAC7B,EAAA,CACA,CACT,EACA,CAAC,UAAU,IAAI,SAAS,CAAC,MAAM,GAAG,CAAC,KAChCA,GAAA,CAAA,KAAA,EAAA,EAAK,SAAS,EAAC,wBAAwB,EAAA,QAAA,EAClC,SAAS,CAAC,OAAO,CAAC,CAAC,QAAQ,KACxB,QAAQ,CAAC,KAAK,CAAC,GAAG,CAAC,CAAC,IAAI,MACpBC,IAAA,CAAA,KAAA,EAAA,EAEI,SAAS,EAAC,4BAA4B,EAAA,QAAA,EAAA,CAEtCD,GAAA,CAAA,MAAA,EAAA,EAAM,SAAS,EAAC,8BAA8B,EAAA,QAAA,EACzC,QAAQ,CAAC,KAAK,EAAA,CACZ,EACPA,GAAA,CAAA,MAAA,EAAA,EAAM,SAAS,EAAC,6BAA6B,EAAA,QAAA,EACxC,IAAI,CAAC,IAAI,EAAA,CACP,CAAA,EAAA,EARF,CAAA,EAAG,QAAQ,CAAC,KAAK,CAAA,CAAA,EAAI,IAAI,CAAC,EAAE,CAAC,QAAQ,EAAE,CAAA,CAAE,CAS5C,CACT,CAAC,CACL,EAAA,CACC,CACT,CAAA,EAAA,CACC,EAAA,CACG;AAErB;;"}
@@ -6,7 +6,7 @@ const TypingIndicator = ({ authors, label, buildAvatarUrl, }) => {
6
6
  if (authors.length === 0) {
7
7
  return null;
8
8
  }
9
- return (jsxs("div", { className: 'chat-typing', "aria-live": 'polite', children: [jsx("div", { className: 'chat-typing__authors', children: authors.map((author) => (jsx(PersonAvatarCircle, { userId: author.id, name: author.name, hasAvatar: author.hasAvatar, size: 18, ownerType: author.kind === ChatAuthorKind.Agent ? 'Agents' : 'Users', buildAvatarUrl: buildAvatarUrl }, author.id))) }), jsx("span", { className: 'chat-typing__label', children: label }), jsxs("span", { className: 'chat-typing__dots', "aria-hidden": 'true', children: [jsx("span", { className: 'chat-typing__dot' }), jsx("span", { className: 'chat-typing__dot' }), jsx("span", { className: 'chat-typing__dot' })] })] }));
9
+ return (jsxs("div", { className: 'chat-typing', "data-cratis-component": 'TypingIndicator', "aria-live": 'polite', children: [jsx("div", { className: 'chat-typing__authors', children: authors.map((author) => (jsx(PersonAvatarCircle, { userId: author.id, name: author.name, hasAvatar: author.hasAvatar, size: 18, ownerType: author.kind === ChatAuthorKind.Agent ? 'Agents' : 'Users', buildAvatarUrl: buildAvatarUrl }, author.id))) }), jsx("span", { className: 'chat-typing__label', children: label }), jsxs("span", { className: 'chat-typing__dots', "aria-hidden": 'true', children: [jsx("span", { className: 'chat-typing__dot' }), jsx("span", { className: 'chat-typing__dot' }), jsx("span", { className: 'chat-typing__dot' })] })] }));
10
10
  };
11
11
 
12
12
  export { TypingIndicator };
@@ -1 +1 @@
1
- {"version":3,"file":"TypingIndicator.js","sources":["../../../../Chat/Kit/TypingIndicator.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 { PersonAvatarCircle, type BuildAvatarUrlParams } from './Avatar';\nimport { ChatAuthorKind } from './ChatAuthorKind';\nimport type { ChatTypingAuthor } from './ChatTypingAuthor';\n\n/**\n * Props for the classic jumping dots, shown while somebody is composing a message — a person typing\n * or an agent working on its answer. Both read the same way on purpose: an agent at work is a teammate\n * mid-sentence, not a spinner.\n */\nexport interface TypingIndicatorProps {\n /** Who is currently typing or working. Rendering is skipped when nobody is. */\n authors: ChatTypingAuthor[];\n\n /** The label shown next to the dots, already composed from the authors' names. */\n label: string;\n\n /** Builds the avatar image URL. Omit to always show initials — see {@link PersonAvatarCircleProps}. */\n buildAvatarUrl?: (params: BuildAvatarUrlParams) => string;\n}\n\n/**\n * The classic jumping dots, shown while somebody is composing a message — a person typing or an\n * agent working on its answer. Both read the same way on purpose: an agent at work is a teammate\n * mid-sentence, not a spinner.\n */\nexport const TypingIndicator = ({\n authors,\n label,\n buildAvatarUrl,\n}: TypingIndicatorProps) => {\n if (authors.length === 0) {\n return null;\n }\n\n return (\n <div className='chat-typing' aria-live='polite'>\n <div className='chat-typing__authors'>\n {authors.map((author) => (\n <PersonAvatarCircle\n key={author.id}\n userId={author.id}\n name={author.name}\n hasAvatar={author.hasAvatar}\n size={18}\n ownerType={\n author.kind === ChatAuthorKind.Agent ? 'Agents' : 'Users'\n }\n buildAvatarUrl={buildAvatarUrl}\n />\n ))}\n </div>\n <span className='chat-typing__label'>{label}</span>\n <span className='chat-typing__dots' aria-hidden='true'>\n <span className='chat-typing__dot' />\n <span className='chat-typing__dot' />\n <span className='chat-typing__dot' />\n </span>\n </div>\n );\n};\n"],"names":["_jsxs","_jsx"],"mappings":";;;;AA4BO,MAAM,eAAe,GAAG,CAAC,EAC5B,OAAO,EACP,KAAK,EACL,cAAc,GACK,KAAI;AACvB,IAAA,IAAI,OAAO,CAAC,MAAM,KAAK,CAAC,EAAE;AACtB,QAAA,OAAO,IAAI;IACf;IAEA,QACIA,IAAA,CAAA,KAAA,EAAA,EAAK,SAAS,EAAC,aAAa,eAAW,QAAQ,EAAA,QAAA,EAAA,CAC3CC,GAAA,CAAA,KAAA,EAAA,EAAK,SAAS,EAAC,sBAAsB,YAChC,OAAO,CAAC,GAAG,CAAC,CAAC,MAAM,MAChBA,GAAA,CAAC,kBAAkB,EAAA,EAEf,MAAM,EAAE,MAAM,CAAC,EAAE,EACjB,IAAI,EAAE,MAAM,CAAC,IAAI,EACjB,SAAS,EAAE,MAAM,CAAC,SAAS,EAC3B,IAAI,EAAE,EAAE,EACR,SAAS,EACL,MAAM,CAAC,IAAI,KAAK,cAAc,CAAC,KAAK,GAAG,QAAQ,GAAG,OAAO,EAE7D,cAAc,EAAE,cAAc,EAAA,EARzB,MAAM,CAAC,EAAE,CAShB,CACL,CAAC,EAAA,CACA,EACNA,GAAA,CAAA,MAAA,EAAA,EAAM,SAAS,EAAC,oBAAoB,EAAA,QAAA,EAAE,KAAK,EAAA,CAAQ,EACnDD,IAAA,CAAA,MAAA,EAAA,EAAM,SAAS,EAAC,mBAAmB,EAAA,aAAA,EAAa,MAAM,EAAA,QAAA,EAAA,CAClDC,GAAA,CAAA,MAAA,EAAA,EAAM,SAAS,EAAC,kBAAkB,EAAA,CAAG,EACrCA,GAAA,CAAA,MAAA,EAAA,EAAM,SAAS,EAAC,kBAAkB,EAAA,CAAG,EACrCA,GAAA,CAAA,MAAA,EAAA,EAAM,SAAS,EAAC,kBAAkB,EAAA,CAAG,CAAA,EAAA,CAClC,CAAA,EAAA,CACL;AAEd;;"}
1
+ {"version":3,"file":"TypingIndicator.js","sources":["../../../../Chat/Kit/TypingIndicator.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 { PersonAvatarCircle, type BuildAvatarUrlParams } from './Avatar';\nimport { ChatAuthorKind } from './ChatAuthorKind';\nimport type { ChatTypingAuthor } from './ChatTypingAuthor';\n\n/**\n * Props for the classic jumping dots, shown while somebody is composing a message — a person typing\n * or an agent working on its answer. Both read the same way on purpose: an agent at work is a teammate\n * mid-sentence, not a spinner.\n */\nexport interface TypingIndicatorProps {\n /** Who is currently typing or working. Rendering is skipped when nobody is. */\n authors: ChatTypingAuthor[];\n\n /** The label shown next to the dots, already composed from the authors' names. */\n label: string;\n\n /** Builds the avatar image URL. Omit to always show initials — see {@link PersonAvatarCircleProps}. */\n buildAvatarUrl?: (params: BuildAvatarUrlParams) => string;\n}\n\n/**\n * The classic jumping dots, shown while somebody is composing a message — a person typing or an\n * agent working on its answer. Both read the same way on purpose: an agent at work is a teammate\n * mid-sentence, not a spinner.\n */\nexport const TypingIndicator = ({\n authors,\n label,\n buildAvatarUrl,\n}: TypingIndicatorProps) => {\n if (authors.length === 0) {\n return null;\n }\n\n return (\n <div className='chat-typing' data-cratis-component='TypingIndicator' aria-live='polite'>\n <div className='chat-typing__authors'>\n {authors.map((author) => (\n <PersonAvatarCircle\n key={author.id}\n userId={author.id}\n name={author.name}\n hasAvatar={author.hasAvatar}\n size={18}\n ownerType={\n author.kind === ChatAuthorKind.Agent ? 'Agents' : 'Users'\n }\n buildAvatarUrl={buildAvatarUrl}\n />\n ))}\n </div>\n <span className='chat-typing__label'>{label}</span>\n <span className='chat-typing__dots' aria-hidden='true'>\n <span className='chat-typing__dot' />\n <span className='chat-typing__dot' />\n <span className='chat-typing__dot' />\n </span>\n </div>\n );\n};\n"],"names":["_jsxs","_jsx"],"mappings":";;;;AA4BO,MAAM,eAAe,GAAG,CAAC,EAC5B,OAAO,EACP,KAAK,EACL,cAAc,GACK,KAAI;AACvB,IAAA,IAAI,OAAO,CAAC,MAAM,KAAK,CAAC,EAAE;AACtB,QAAA,OAAO,IAAI;IACf;IAEA,QACIA,IAAA,CAAA,KAAA,EAAA,EAAK,SAAS,EAAC,aAAa,2BAAuB,iBAAiB,EAAA,WAAA,EAAW,QAAQ,EAAA,QAAA,EAAA,CACnFC,GAAA,CAAA,KAAA,EAAA,EAAK,SAAS,EAAC,sBAAsB,EAAA,QAAA,EAChC,OAAO,CAAC,GAAG,CAAC,CAAC,MAAM,MAChBA,GAAA,CAAC,kBAAkB,IAEf,MAAM,EAAE,MAAM,CAAC,EAAE,EACjB,IAAI,EAAE,MAAM,CAAC,IAAI,EACjB,SAAS,EAAE,MAAM,CAAC,SAAS,EAC3B,IAAI,EAAE,EAAE,EACR,SAAS,EACL,MAAM,CAAC,IAAI,KAAK,cAAc,CAAC,KAAK,GAAG,QAAQ,GAAG,OAAO,EAE7D,cAAc,EAAE,cAAc,EAAA,EARzB,MAAM,CAAC,EAAE,CAShB,CACL,CAAC,EAAA,CACA,EACNA,GAAA,CAAA,MAAA,EAAA,EAAM,SAAS,EAAC,oBAAoB,EAAA,QAAA,EAAE,KAAK,EAAA,CAAQ,EACnDD,IAAA,CAAA,MAAA,EAAA,EAAM,SAAS,EAAC,mBAAmB,EAAA,aAAA,EAAa,MAAM,EAAA,QAAA,EAAA,CAClDC,GAAA,CAAA,MAAA,EAAA,EAAM,SAAS,EAAC,kBAAkB,EAAA,CAAG,EACrCA,GAAA,CAAA,MAAA,EAAA,EAAM,SAAS,EAAC,kBAAkB,EAAA,CAAG,EACrCA,GAAA,CAAA,MAAA,EAAA,EAAM,SAAS,EAAC,kBAAkB,EAAA,CAAG,CAAA,EAAA,CAClC,CAAA,EAAA,CACL;AAEd;;"}
@@ -94,6 +94,10 @@ export interface CratisDataTableMessages {
94
94
  selectRow?: string;
95
95
  /** Accessible name for the select-all control in a multiple-selection header. */
96
96
  selectAllRows?: string;
97
+ /** Audible ascending sort direction in card controls. Defaults to 'Ascending'. */
98
+ sortAscending?: string;
99
+ /** Audible descending sort direction in card controls. Defaults to 'Descending'. */
100
+ sortDescending?: string;
97
101
  /** Placeholder for the loaded-page search input. */
98
102
  search?: string;
99
103
  /** Accessible name for the loaded-page search input. */