@ankhorage/zora 1.4.9 → 1.4.11
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +12 -0
- package/README.md +103 -0
- package/dist/components/card/meta.d.ts +1 -1
- package/dist/foundation/meta.d.ts +4 -4
- package/dist/index.d.ts +2 -0
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +1 -0
- package/dist/index.js.map +1 -1
- package/dist/layout/auth-layout/meta.d.ts +1 -1
- package/dist/layout/page/meta.d.ts +1 -1
- package/dist/layout/page-section/meta.d.ts +1 -1
- package/dist/metadata/allowedChildren.d.ts +3 -3
- package/dist/metadata/allowedChildren.d.ts.map +1 -1
- package/dist/metadata/allowedChildren.js +1 -0
- package/dist/metadata/allowedChildren.js.map +1 -1
- package/dist/metadata/componentMeta.d.ts.map +1 -1
- package/dist/metadata/componentMeta.js +2 -0
- package/dist/metadata/componentMeta.js.map +1 -1
- package/dist/patterns/message-bubble/MessageBubble.d.ts +4 -0
- package/dist/patterns/message-bubble/MessageBubble.d.ts.map +1 -0
- package/dist/patterns/message-bubble/MessageBubble.js +126 -0
- package/dist/patterns/message-bubble/MessageBubble.js.map +1 -0
- package/dist/patterns/message-bubble/index.d.ts +3 -0
- package/dist/patterns/message-bubble/index.d.ts.map +1 -0
- package/dist/patterns/message-bubble/index.js +2 -0
- package/dist/patterns/message-bubble/index.js.map +1 -0
- package/dist/patterns/message-bubble/meta.d.ts +67 -0
- package/dist/patterns/message-bubble/meta.d.ts.map +1 -0
- package/dist/patterns/message-bubble/meta.js +66 -0
- package/dist/patterns/message-bubble/meta.js.map +1 -0
- package/dist/patterns/message-bubble/types.d.ts +40 -0
- package/dist/patterns/message-bubble/types.d.ts.map +1 -0
- package/dist/patterns/message-bubble/types.js +2 -0
- package/dist/patterns/message-bubble/types.js.map +1 -0
- package/dist/patterns/notice/meta.d.ts +1 -1
- package/dist/patterns/panel/meta.d.ts +1 -1
- package/dist/patterns/post-card/meta.d.ts +1 -1
- package/package.json +5 -5
- package/src/index.ts +8 -0
- package/src/metadata/allowedChildren.ts +1 -0
- package/src/metadata/componentMeta.test.ts +1 -0
- package/src/metadata/componentMeta.ts +2 -0
- package/src/patterns/message-bubble/MessageBubble.tsx +261 -0
- package/src/patterns/message-bubble/index.ts +8 -0
- package/src/patterns/message-bubble/meta.ts +68 -0
- package/src/patterns/message-bubble/types.ts +43 -0
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"MessageBubble.js","sourceRoot":"","sources":["../../../src/patterns/message-bubble/MessageBubble.tsx"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAE,MAAM,oBAAoB,CAAC;AAChD,OAAO,KAAK,MAAM,OAAO,CAAC;AAE1B,OAAO,EAAE,MAAM,EAAE,MAAM,yBAAyB,CAAC;AACjD,OAAO,EAAE,IAAI,EAAE,MAAM,uBAAuB,CAAC;AAC7C,OAAO,EAAE,GAAG,EAAE,MAAM,EAAE,KAAK,EAAE,MAAM,kBAAkB,CAAC;AACtD,OAAO,EAAE,YAAY,EAAE,MAAM,0BAA0B,CAAC;AACxD,OAAO,EAAE,kBAAkB,EAAE,MAAM,gCAAgC,CAAC;AAQpE,SAAS,iBAAiB,CAAC,EACzB,MAAM,EACN,UAAU,GAIX;IACC,IAAI,MAAM,EAAE,IAAI;QAAE,OAAO,MAAM,CAAC,IAAI,CAAC;IACrC,OAAO,OAAO,UAAU,KAAK,QAAQ,CAAC,CAAC,CAAC,UAAU,CAAC,CAAC,CAAC,SAAS,CAAC;AACjE,CAAC;AAED,SAAS,cAAc,CAAC,OAAgB;IACtC,OAAO,OAAO,CAAC,CAAC,CAAC,EAAE,EAAE,EAAE,GAAY,EAAE,EAAE,EAAE,GAAY,EAAE,CAAC,CAAC,CAAC,EAAE,EAAE,EAAE,GAAY,EAAE,EAAE,EAAE,GAAY,EAAE,CAAC;AACnG,CAAC;AAED,SAAS,kBAAkB,CAAC,MAA2B;IACrD,QA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O;gBACN,CAAC,SAAS,CAAC,CAAC,CAAC,CACX,CAAC,aAAa,CAAC,MAAM,CAAC,CAAC,YAAY,CAAC,CAAC,UAAU,CAAC,CAAC,UAAU,CAAC,CAAC,OAAO,CAAC,CAAC,OAAO,CAAC,EAAG,CAClF,CAAC,CAAC,CAAC,IAAI,CAAC,CACb;UAAA,EAAE,GAAG,CAAC,CACP,CAAC,CAAC,CAAC,IAAI,CACR;QAAA,CAAC,UAAU,IAAI,QAAQ,CAAC,CAAC,CAAC,CAAC,GAAG,CAAC,CAAC,QAAQ,CAAC,EAAE,GAAG,CAAC,CAAC,CAAC,CAAC,IAAI,CACtD;QAAA,CAAC,aAAa,CACd;QAAA,CAAC,UAAU,IAAI,OAAO,CAAC,CAAC,CAAC,CAAC,GAAG,CAAC,CAAC,OAAO,CAAC,EAAE,GAAG,CAAC,CAAC,CAAC,CAAC,IAAI,CACpD;QAAA,CAAC,CAAC,UAAU,IAAI,CAAC,QAAQ,IAAI,QAAQ,CAAC,CAAC,CAAC,CAAC,GAAG,CAAC,CAAC,QAAQ,CAAC,EAAE,GAAG,CAAC,CAAC,CAAC,CAAC,IAAI,CACtE;MAAA,EAAE,MAAM,CACR;MAAA,CAAC,MAAM,IAAI,IAAI,CAAC,CAAC,CAAC,CAChB,CAAC,GAAG,CAAC,SAAS,CAAC,CAAC,UAAU,CAAC,CAAC,CAAC,UAAU,CAAC,CAAC,CAAC,QAAQ,CAAC,CAAC,CAAC,QAAQ,CAAC,CAAC,CAAC,YAAY,CAAC,CAAC,CAAC,MAAM,CAAC,EAAE,GAAG,CAAC,CAC7F,CAAC,CAAC,CAAC,IAAI,CACV;IAAA,EAAE,KAAK,CAAC,CACT,CAAC;AACJ,CAAC;AAED,MAAM,CAAC,MAAM,aAAa,GAAG,kBAAkB,CAAC,kBAAkB,CAAC,CAAC","sourcesContent":["import { ButtonBase } from '@ankhorage/surface';\nimport React from 'react';\n\nimport { Avatar } from '../../components/avatar';\nimport { Text } from '../../components/text';\nimport { Box, Inline, Stack } from '../../foundation';\nimport { useZoraTheme } from '../../theme/useZoraTheme';\nimport { withZoraThemeScope } from '../../theme/withZoraThemeScope';\nimport type {\n MessageBubbleAvatar,\n MessageBubbleDirection,\n MessageBubbleProps,\n MessageBubbleStatus,\n} from './types';\n\nfunction resolveAvatarName({\n avatar,\n authorName,\n}: {\n avatar: MessageBubbleAvatar | undefined;\n authorName: React.ReactNode | undefined;\n}): string | undefined {\n if (avatar?.name) return avatar.name;\n return typeof authorName === 'string' ? authorName : undefined;\n}\n\nfunction resolvePadding(compact: boolean) {\n return compact ? { px: 'm' as const, py: 's' as const } : { px: 'm' as const, py: 'm' as const };\n}\n\nfunction resolveStatusLabel(status: MessageBubbleStatus): string {\n switch (status) {\n case 'sending':\n return 'Sending';\n case 'sent':\n return 'Sent';\n case 'delivered':\n return 'Delivered';\n case 'read':\n return 'Read';\n case 'failed':\n return 'Failed';\n default:\n return status;\n }\n}\n\nfunction isMessageBubbleStatus(\n status: MessageBubbleProps['status'],\n): status is MessageBubbleStatus {\n return (\n status === 'sending' ||\n status === 'sent' ||\n status === 'delivered' ||\n status === 'read' ||\n status === 'failed'\n );\n}\n\nfunction resolveStatus(status: MessageBubbleProps['status']) {\n if (status == null) return null;\n return isMessageBubbleStatus(status) ? resolveStatusLabel(status) : status;\n}\n\nfunction resolveBubbleStyles({\n direction,\n disabled,\n hovered,\n pressed,\n selected,\n theme,\n}: {\n direction: MessageBubbleDirection;\n disabled: boolean;\n hovered: boolean;\n pressed: boolean;\n selected: boolean;\n theme: ReturnType<typeof useZoraTheme>['theme'];\n}) {\n const borderColor = selected ? theme.semantics.border.focus : theme.semantics.border.default;\n\n if (direction === 'system') {\n return {\n bg: selected ? theme.semantics.neutral.surface : 'transparent',\n borderColor,\n borderWidth: selected ? 1 : 0,\n opacity: disabled ? 0.72 : 1,\n };\n }\n\n const interactiveBg = pressed\n ? theme.semantics.neutral.surfaceActive\n : hovered\n ? theme.semantics.neutral.surfaceHover\n : undefined;\n\n return {\n bg:\n interactiveBg ??\n (direction === 'outgoing' ? theme.semantics.neutral.surface : theme.semantics.surface.raised),\n borderColor,\n borderWidth: selected ? 1 : 0,\n opacity: disabled ? 0.72 : 1,\n };\n}\n\nfunction MessageAvatar({\n avatar,\n authorName,\n compact,\n}: {\n avatar: MessageBubbleAvatar;\n authorName: React.ReactNode | undefined;\n compact: boolean;\n}) {\n const avatarName = resolveAvatarName({ avatar, authorName });\n\n return (\n <Avatar\n initials={avatar.initials}\n label={avatar.label ?? avatarName}\n name={avatarName}\n shape={avatar.shape}\n size={avatar.size ?? (compact ? 'xs' : 's')}\n source={avatar.source}\n tone={avatar.tone}\n />\n );\n}\n\nfunction MessageBubbleInner({\n themeId: _themeId,\n mode: _mode,\n testID,\n direction = 'incoming',\n text,\n children,\n author,\n timestamp,\n meta,\n status,\n leading,\n trailing,\n footer,\n selected = false,\n disabled = false,\n compact = false,\n accessibilityLabel,\n onPress,\n}: MessageBubbleProps) {\n const { theme } = useZoraTheme();\n const padding = resolvePadding(compact);\n const isInteractive = Boolean(onPress);\n const isOutgoing = direction === 'outgoing';\n const isSystem = direction === 'system';\n const renderedStatus = resolveStatus(status);\n const authorName = author?.name;\n const authorAvatar = author?.avatar;\n const hasAuthorName = authorName != null && !isOutgoing && !isSystem;\n const hasAvatar = authorAvatar != null && !isOutgoing && !isSystem;\n const hasMetaRow = timestamp != null || meta != null || renderedStatus != null;\n\n const renderBubble = ({ pressed, hovered }: { pressed: boolean; hovered: boolean }) => {\n const styles = resolveBubbleStyles({ direction, disabled, hovered, pressed, selected, theme });\n\n return (\n <Box\n bg={styles.bg}\n borderColor={styles.borderColor}\n borderWidth={styles.borderWidth}\n px={padding.px}\n py={padding.py}\n radius={isSystem ? 'm' : 'l'}\n style={{ maxWidth: compact ? 420 : 560, opacity: styles.opacity }}\n >\n <Stack align={isSystem ? 'center' : 'flex-start'} gap={compact ? 'xxs' : 'xs'}>\n {hasAuthorName ? (\n <Text tone=\"muted\" variant=\"caption\" weight=\"semiBold\">\n {authorName}\n </Text>\n ) : null}\n {text != null ? (\n <Text align={isSystem ? 'center' : undefined} tone={disabled ? 'muted' : 'default'}>\n {text}\n </Text>\n ) : null}\n {children != null ? <Box width=\"100%\">{children}</Box> : null}\n {hasMetaRow ? (\n <Inline\n align=\"center\"\n gap=\"xs\"\n justify={isOutgoing ? 'flex-end' : isSystem ? 'center' : 'flex-start'}\n wrap=\"wrap\"\n >\n {timestamp != null ? (\n <Text tone=\"subtle\" variant=\"caption\">\n {timestamp}\n </Text>\n ) : null}\n {meta != null ? (\n <Text tone=\"subtle\" variant=\"caption\">\n {meta}\n </Text>\n ) : null}\n {renderedStatus != null ? (\n <Text tone={status === 'failed' ? 'danger' : 'subtle'} variant=\"caption\">\n {renderedStatus}\n </Text>\n ) : null}\n </Inline>\n ) : null}\n </Stack>\n </Box>\n );\n };\n\n const bubbleContent = isInteractive ? (\n <ButtonBase\n accessibilityLabel={accessibilityLabel}\n accessibilityRole=\"button\"\n accessibilityState={{ disabled, selected }}\n disabled={disabled}\n onPress={onPress}\n radius={isSystem ? 'm' : 'l'}\n testID={testID}\n >\n {(state) => renderBubble({ pressed: state.pressed, hovered: state.hovered })}\n </ButtonBase>\n ) : (\n <Box testID={testID}>{renderBubble({ pressed: false, hovered: false })}</Box>\n );\n\n return (\n <Stack gap=\"xs\" style={{ width: '100%' }}>\n <Inline\n align=\"flex-end\"\n gap=\"s\"\n justify={isSystem ? 'center' : isOutgoing ? 'flex-end' : 'flex-start'}\n wrap=\"nowrap\"\n >\n {!isOutgoing && !isSystem ? (\n <Box>\n {leading ??\n (hasAvatar ? (\n <MessageAvatar avatar={authorAvatar} authorName={authorName} compact={compact} />\n ) : null)}\n </Box>\n ) : null}\n {isOutgoing && trailing ? <Box>{trailing}</Box> : null}\n {bubbleContent}\n {isOutgoing && leading ? <Box>{leading}</Box> : null}\n {!isOutgoing && !isSystem && trailing ? <Box>{trailing}</Box> : null}\n </Inline>\n {footer != null ? (\n <Box alignSelf={isOutgoing ? 'flex-end' : isSystem ? 'center' : 'flex-start'}>{footer}</Box>\n ) : null}\n </Stack>\n );\n}\n\nexport const MessageBubble = withZoraThemeScope(MessageBubbleInner);\n"]}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/patterns/message-bubble/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,aAAa,EAAE,MAAM,iBAAiB,CAAC;AAChD,YAAY,EACV,mBAAmB,EACnB,mBAAmB,EACnB,sBAAsB,EACtB,kBAAkB,EAClB,mBAAmB,GACpB,MAAM,SAAS,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/patterns/message-bubble/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,aAAa,EAAE,MAAM,iBAAiB,CAAC","sourcesContent":["export { MessageBubble } from './MessageBubble';\nexport type {\n MessageBubbleAuthor,\n MessageBubbleAvatar,\n MessageBubbleDirection,\n MessageBubbleProps,\n MessageBubbleStatus,\n} from './types';\n"]}
|
|
@@ -0,0 +1,67 @@
|
|
|
1
|
+
export declare const messageBubbleMeta: {
|
|
2
|
+
readonly name: "MessageBubble";
|
|
3
|
+
readonly category: "pattern";
|
|
4
|
+
readonly description: "Chat/message bubble with direction, author, text, meta, and delivery status presentation.";
|
|
5
|
+
readonly directManifestNode: true;
|
|
6
|
+
readonly allowedChildren: readonly ["Box", "Stack", "Grid", "Container", "Divider", "Text", "Heading", "Button", "Input", "Textarea", "FormField", "Card", "Panel", "Notice", "EmptyState", "SectionHeader", "SettingsRow", "PostCard", "ChatListItem", "MessageBubble"];
|
|
7
|
+
readonly blueprint: {
|
|
8
|
+
readonly label: "Message bubble";
|
|
9
|
+
readonly icon: {
|
|
10
|
+
readonly name: "chatbubble-outline";
|
|
11
|
+
};
|
|
12
|
+
readonly defaultProps: {
|
|
13
|
+
readonly direction: "incoming";
|
|
14
|
+
readonly text: "Can you review the latest message pattern?";
|
|
15
|
+
readonly timestamp: "10:41";
|
|
16
|
+
};
|
|
17
|
+
};
|
|
18
|
+
readonly props: {
|
|
19
|
+
readonly direction: {
|
|
20
|
+
readonly type: "enum";
|
|
21
|
+
readonly category: "Content";
|
|
22
|
+
readonly label: "Direction";
|
|
23
|
+
readonly enum: readonly ["incoming", "outgoing", "system"];
|
|
24
|
+
readonly default: "incoming";
|
|
25
|
+
};
|
|
26
|
+
readonly text: {
|
|
27
|
+
readonly type: "string";
|
|
28
|
+
readonly category: "Content";
|
|
29
|
+
readonly label: "Text";
|
|
30
|
+
};
|
|
31
|
+
readonly timestamp: {
|
|
32
|
+
readonly type: "string";
|
|
33
|
+
readonly category: "Content";
|
|
34
|
+
readonly label: "Timestamp";
|
|
35
|
+
};
|
|
36
|
+
readonly meta: {
|
|
37
|
+
readonly type: "string";
|
|
38
|
+
readonly category: "Content";
|
|
39
|
+
readonly label: "Meta";
|
|
40
|
+
};
|
|
41
|
+
readonly status: {
|
|
42
|
+
readonly type: "enum";
|
|
43
|
+
readonly category: "Content";
|
|
44
|
+
readonly label: "Status";
|
|
45
|
+
readonly enum: readonly ["sending", "sent", "delivered", "read", "failed"];
|
|
46
|
+
};
|
|
47
|
+
readonly selected: {
|
|
48
|
+
readonly type: "boolean";
|
|
49
|
+
readonly category: "State";
|
|
50
|
+
readonly label: "Selected";
|
|
51
|
+
readonly default: false;
|
|
52
|
+
};
|
|
53
|
+
readonly disabled: {
|
|
54
|
+
readonly type: "boolean";
|
|
55
|
+
readonly category: "State";
|
|
56
|
+
readonly label: "Disabled";
|
|
57
|
+
readonly default: false;
|
|
58
|
+
};
|
|
59
|
+
readonly compact: {
|
|
60
|
+
readonly type: "boolean";
|
|
61
|
+
readonly category: "Layout";
|
|
62
|
+
readonly label: "Compact";
|
|
63
|
+
readonly default: false;
|
|
64
|
+
};
|
|
65
|
+
};
|
|
66
|
+
};
|
|
67
|
+
//# sourceMappingURL=meta.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"meta.d.ts","sourceRoot":"","sources":["../../../src/patterns/message-bubble/meta.ts"],"names":[],"mappings":"AAGA,eAAO,MAAM,iBAAiB;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;CAgEQ,CAAC"}
|
|
@@ -0,0 +1,66 @@
|
|
|
1
|
+
import { CONTAINER_ALLOWED_CHILDREN } from '../../metadata/allowedChildren';
|
|
2
|
+
export const messageBubbleMeta = {
|
|
3
|
+
name: 'MessageBubble',
|
|
4
|
+
category: 'pattern',
|
|
5
|
+
description: 'Chat/message bubble with direction, author, text, meta, and delivery status presentation.',
|
|
6
|
+
directManifestNode: true,
|
|
7
|
+
allowedChildren: [...CONTAINER_ALLOWED_CHILDREN],
|
|
8
|
+
blueprint: {
|
|
9
|
+
label: 'Message bubble',
|
|
10
|
+
icon: { name: 'chatbubble-outline' },
|
|
11
|
+
defaultProps: {
|
|
12
|
+
direction: 'incoming',
|
|
13
|
+
text: 'Can you review the latest message pattern?',
|
|
14
|
+
timestamp: '10:41',
|
|
15
|
+
},
|
|
16
|
+
},
|
|
17
|
+
props: {
|
|
18
|
+
direction: {
|
|
19
|
+
type: 'enum',
|
|
20
|
+
category: 'Content',
|
|
21
|
+
label: 'Direction',
|
|
22
|
+
enum: ['incoming', 'outgoing', 'system'],
|
|
23
|
+
default: 'incoming',
|
|
24
|
+
},
|
|
25
|
+
text: {
|
|
26
|
+
type: 'string',
|
|
27
|
+
category: 'Content',
|
|
28
|
+
label: 'Text',
|
|
29
|
+
},
|
|
30
|
+
timestamp: {
|
|
31
|
+
type: 'string',
|
|
32
|
+
category: 'Content',
|
|
33
|
+
label: 'Timestamp',
|
|
34
|
+
},
|
|
35
|
+
meta: {
|
|
36
|
+
type: 'string',
|
|
37
|
+
category: 'Content',
|
|
38
|
+
label: 'Meta',
|
|
39
|
+
},
|
|
40
|
+
status: {
|
|
41
|
+
type: 'enum',
|
|
42
|
+
category: 'Content',
|
|
43
|
+
label: 'Status',
|
|
44
|
+
enum: ['sending', 'sent', 'delivered', 'read', 'failed'],
|
|
45
|
+
},
|
|
46
|
+
selected: {
|
|
47
|
+
type: 'boolean',
|
|
48
|
+
category: 'State',
|
|
49
|
+
label: 'Selected',
|
|
50
|
+
default: false,
|
|
51
|
+
},
|
|
52
|
+
disabled: {
|
|
53
|
+
type: 'boolean',
|
|
54
|
+
category: 'State',
|
|
55
|
+
label: 'Disabled',
|
|
56
|
+
default: false,
|
|
57
|
+
},
|
|
58
|
+
compact: {
|
|
59
|
+
type: 'boolean',
|
|
60
|
+
category: 'Layout',
|
|
61
|
+
label: 'Compact',
|
|
62
|
+
default: false,
|
|
63
|
+
},
|
|
64
|
+
},
|
|
65
|
+
};
|
|
66
|
+
//# sourceMappingURL=meta.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"meta.js","sourceRoot":"","sources":["../../../src/patterns/message-bubble/meta.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,0BAA0B,EAAE,MAAM,gCAAgC,CAAC;AAE5E,MAAM,CAAC,MAAM,iBAAiB,GAAG;IAC/B,IAAI,EAAE,eAAe;IACrB,QAAQ,EAAE,SAAS;IACnB,WAAW,EACT,2FAA2F;IAC7F,kBAAkB,EAAE,IAAI;IACxB,eAAe,EAAE,CAAC,GAAG,0BAA0B,CAAC;IAChD,SAAS,EAAE;QACT,KAAK,EAAE,gBAAgB;QACvB,IAAI,EAAE,EAAE,IAAI,EAAE,oBAAoB,EAAE;QACpC,YAAY,EAAE;YACZ,SAAS,EAAE,UAAU;YACrB,IAAI,EAAE,4CAA4C;YAClD,SAAS,EAAE,OAAO;SACnB;KACF;IACD,KAAK,EAAE;QACL,SAAS,EAAE;YACT,IAAI,EAAE,MAAM;YACZ,QAAQ,EAAE,SAAS;YACnB,KAAK,EAAE,WAAW;YAClB,IAAI,EAAE,CAAC,UAAU,EAAE,UAAU,EAAE,QAAQ,CAAC;YACxC,OAAO,EAAE,UAAU;SACpB;QACD,IAAI,EAAE;YACJ,IAAI,EAAE,QAAQ;YACd,QAAQ,EAAE,SAAS;YACnB,KAAK,EAAE,MAAM;SACd;QACD,SAAS,EAAE;YACT,IAAI,EAAE,QAAQ;YACd,QAAQ,EAAE,SAAS;YACnB,KAAK,EAAE,WAAW;SACnB;QACD,IAAI,EAAE;YACJ,IAAI,EAAE,QAAQ;YACd,QAAQ,EAAE,SAAS;YACnB,KAAK,EAAE,MAAM;SACd;QACD,MAAM,EAAE;YACN,IAAI,EAAE,MAAM;YACZ,QAAQ,EAAE,SAAS;YACnB,KAAK,EAAE,QAAQ;YACf,IAAI,EAAE,CAAC,SAAS,EAAE,MAAM,EAAE,WAAW,EAAE,MAAM,EAAE,QAAQ,CAAC;SACzD;QACD,QAAQ,EAAE;YACR,IAAI,EAAE,SAAS;YACf,QAAQ,EAAE,OAAO;YACjB,KAAK,EAAE,UAAU;YACjB,OAAO,EAAE,KAAK;SACf;QACD,QAAQ,EAAE;YACR,IAAI,EAAE,SAAS;YACf,QAAQ,EAAE,OAAO;YACjB,KAAK,EAAE,UAAU;YACjB,OAAO,EAAE,KAAK;SACf;QACD,OAAO,EAAE;YACP,IAAI,EAAE,SAAS;YACf,QAAQ,EAAE,QAAQ;YAClB,KAAK,EAAE,SAAS;YAChB,OAAO,EAAE,KAAK;SACf;KACF;CACmC,CAAC","sourcesContent":["import type { ZoraComponentMeta } from '../../metadata';\nimport { CONTAINER_ALLOWED_CHILDREN } from '../../metadata/allowedChildren';\n\nexport const messageBubbleMeta = {\n name: 'MessageBubble',\n category: 'pattern',\n description:\n 'Chat/message bubble with direction, author, text, meta, and delivery status presentation.',\n directManifestNode: true,\n allowedChildren: [...CONTAINER_ALLOWED_CHILDREN],\n blueprint: {\n label: 'Message bubble',\n icon: { name: 'chatbubble-outline' },\n defaultProps: {\n direction: 'incoming',\n text: 'Can you review the latest message pattern?',\n timestamp: '10:41',\n },\n },\n props: {\n direction: {\n type: 'enum',\n category: 'Content',\n label: 'Direction',\n enum: ['incoming', 'outgoing', 'system'],\n default: 'incoming',\n },\n text: {\n type: 'string',\n category: 'Content',\n label: 'Text',\n },\n timestamp: {\n type: 'string',\n category: 'Content',\n label: 'Timestamp',\n },\n meta: {\n type: 'string',\n category: 'Content',\n label: 'Meta',\n },\n status: {\n type: 'enum',\n category: 'Content',\n label: 'Status',\n enum: ['sending', 'sent', 'delivered', 'read', 'failed'],\n },\n selected: {\n type: 'boolean',\n category: 'State',\n label: 'Selected',\n default: false,\n },\n disabled: {\n type: 'boolean',\n category: 'State',\n label: 'Disabled',\n default: false,\n },\n compact: {\n type: 'boolean',\n category: 'Layout',\n label: 'Compact',\n default: false,\n },\n },\n} as const satisfies ZoraComponentMeta;\n"]}
|
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
import type React from 'react';
|
|
2
|
+
import type { ImageSourcePropType } from 'react-native';
|
|
3
|
+
import type { AvatarShape, AvatarSize } from '../../components/avatar';
|
|
4
|
+
import type { ZoraTone } from '../../internal/recipes';
|
|
5
|
+
import type { ZoraBaseProps } from '../../theme/ZoraBaseProps';
|
|
6
|
+
export type MessageBubbleDirection = 'incoming' | 'outgoing' | 'system';
|
|
7
|
+
export type MessageBubbleStatus = 'sending' | 'sent' | 'delivered' | 'read' | 'failed';
|
|
8
|
+
type MessageBubbleStatusContent = MessageBubbleStatus | Exclude<React.ReactNode, string>;
|
|
9
|
+
export interface MessageBubbleAvatar {
|
|
10
|
+
source?: ImageSourcePropType;
|
|
11
|
+
name?: string;
|
|
12
|
+
initials?: string;
|
|
13
|
+
label?: string;
|
|
14
|
+
size?: AvatarSize;
|
|
15
|
+
shape?: AvatarShape;
|
|
16
|
+
tone?: ZoraTone;
|
|
17
|
+
}
|
|
18
|
+
export interface MessageBubbleAuthor {
|
|
19
|
+
name?: React.ReactNode;
|
|
20
|
+
avatar?: MessageBubbleAvatar;
|
|
21
|
+
}
|
|
22
|
+
export interface MessageBubbleProps extends ZoraBaseProps {
|
|
23
|
+
direction?: MessageBubbleDirection;
|
|
24
|
+
text?: React.ReactNode;
|
|
25
|
+
children?: React.ReactNode;
|
|
26
|
+
author?: MessageBubbleAuthor;
|
|
27
|
+
timestamp?: React.ReactNode;
|
|
28
|
+
meta?: React.ReactNode;
|
|
29
|
+
status?: MessageBubbleStatusContent;
|
|
30
|
+
leading?: React.ReactNode;
|
|
31
|
+
trailing?: React.ReactNode;
|
|
32
|
+
footer?: React.ReactNode;
|
|
33
|
+
selected?: boolean;
|
|
34
|
+
disabled?: boolean;
|
|
35
|
+
compact?: boolean;
|
|
36
|
+
accessibilityLabel?: string;
|
|
37
|
+
onPress?: () => void;
|
|
38
|
+
}
|
|
39
|
+
export {};
|
|
40
|
+
//# sourceMappingURL=types.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../../src/patterns/message-bubble/types.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,KAAK,MAAM,OAAO,CAAC;AAC/B,OAAO,KAAK,EAAE,mBAAmB,EAAE,MAAM,cAAc,CAAC;AAExD,OAAO,KAAK,EAAE,WAAW,EAAE,UAAU,EAAE,MAAM,yBAAyB,CAAC;AACvE,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,wBAAwB,CAAC;AACvD,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,2BAA2B,CAAC;AAE/D,MAAM,MAAM,sBAAsB,GAAG,UAAU,GAAG,UAAU,GAAG,QAAQ,CAAC;AACxE,MAAM,MAAM,mBAAmB,GAAG,SAAS,GAAG,MAAM,GAAG,WAAW,GAAG,MAAM,GAAG,QAAQ,CAAC;AACvF,KAAK,0BAA0B,GAAG,mBAAmB,GAAG,OAAO,CAAC,KAAK,CAAC,SAAS,EAAE,MAAM,CAAC,CAAC;AAEzF,MAAM,WAAW,mBAAmB;IAClC,MAAM,CAAC,EAAE,mBAAmB,CAAC;IAC7B,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,IAAI,CAAC,EAAE,UAAU,CAAC;IAClB,KAAK,CAAC,EAAE,WAAW,CAAC;IACpB,IAAI,CAAC,EAAE,QAAQ,CAAC;CACjB;AAED,MAAM,WAAW,mBAAmB;IAClC,IAAI,CAAC,EAAE,KAAK,CAAC,SAAS,CAAC;IACvB,MAAM,CAAC,EAAE,mBAAmB,CAAC;CAC9B;AAED,MAAM,WAAW,kBAAmB,SAAQ,aAAa;IACvD,SAAS,CAAC,EAAE,sBAAsB,CAAC;IACnC,IAAI,CAAC,EAAE,KAAK,CAAC,SAAS,CAAC;IACvB,QAAQ,CAAC,EAAE,KAAK,CAAC,SAAS,CAAC;IAC3B,MAAM,CAAC,EAAE,mBAAmB,CAAC;IAC7B,SAAS,CAAC,EAAE,KAAK,CAAC,SAAS,CAAC;IAC5B,IAAI,CAAC,EAAE,KAAK,CAAC,SAAS,CAAC;IACvB,MAAM,CAAC,EAAE,0BAA0B,CAAC;IACpC,OAAO,CAAC,EAAE,KAAK,CAAC,SAAS,CAAC;IAC1B,QAAQ,CAAC,EAAE,KAAK,CAAC,SAAS,CAAC;IAC3B,MAAM,CAAC,EAAE,KAAK,CAAC,SAAS,CAAC;IACzB,QAAQ,CAAC,EAAE,OAAO,CAAC;IACnB,QAAQ,CAAC,EAAE,OAAO,CAAC;IACnB,OAAO,CAAC,EAAE,OAAO,CAAC;IAClB,kBAAkB,CAAC,EAAE,MAAM,CAAC;IAC5B,OAAO,CAAC,EAAE,MAAM,IAAI,CAAC;CACtB"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"types.js","sourceRoot":"","sources":["../../../src/patterns/message-bubble/types.ts"],"names":[],"mappings":"","sourcesContent":["import type React from 'react';\nimport type { ImageSourcePropType } from 'react-native';\n\nimport type { AvatarShape, AvatarSize } from '../../components/avatar';\nimport type { ZoraTone } from '../../internal/recipes';\nimport type { ZoraBaseProps } from '../../theme/ZoraBaseProps';\n\nexport type MessageBubbleDirection = 'incoming' | 'outgoing' | 'system';\nexport type MessageBubbleStatus = 'sending' | 'sent' | 'delivered' | 'read' | 'failed';\ntype MessageBubbleStatusContent = MessageBubbleStatus | Exclude<React.ReactNode, string>;\n\nexport interface MessageBubbleAvatar {\n source?: ImageSourcePropType;\n name?: string;\n initials?: string;\n label?: string;\n size?: AvatarSize;\n shape?: AvatarShape;\n tone?: ZoraTone;\n}\n\nexport interface MessageBubbleAuthor {\n name?: React.ReactNode;\n avatar?: MessageBubbleAvatar;\n}\n\nexport interface MessageBubbleProps extends ZoraBaseProps {\n direction?: MessageBubbleDirection;\n text?: React.ReactNode;\n children?: React.ReactNode;\n author?: MessageBubbleAuthor;\n timestamp?: React.ReactNode;\n meta?: React.ReactNode;\n status?: MessageBubbleStatusContent;\n leading?: React.ReactNode;\n trailing?: React.ReactNode;\n footer?: React.ReactNode;\n selected?: boolean;\n disabled?: boolean;\n compact?: boolean;\n accessibilityLabel?: string;\n onPress?: () => void;\n}\n"]}
|
|
@@ -2,7 +2,7 @@ export declare const noticeMeta: {
|
|
|
2
2
|
readonly name: "Notice";
|
|
3
3
|
readonly category: "pattern";
|
|
4
4
|
readonly directManifestNode: true;
|
|
5
|
-
readonly allowedChildren: readonly ["Box", "Stack", "Grid", "Container", "Divider", "Text", "Heading", "Button", "Input", "Textarea", "FormField", "Card", "Panel", "Notice", "EmptyState", "SectionHeader", "SettingsRow", "PostCard", "ChatListItem"];
|
|
5
|
+
readonly allowedChildren: readonly ["Box", "Stack", "Grid", "Container", "Divider", "Text", "Heading", "Button", "Input", "Textarea", "FormField", "Card", "Panel", "Notice", "EmptyState", "SectionHeader", "SettingsRow", "PostCard", "ChatListItem", "MessageBubble"];
|
|
6
6
|
readonly blueprint: {
|
|
7
7
|
readonly label: "Notice";
|
|
8
8
|
readonly defaultProps: {
|
|
@@ -2,7 +2,7 @@ export declare const panelMeta: {
|
|
|
2
2
|
readonly name: "Panel";
|
|
3
3
|
readonly category: "pattern";
|
|
4
4
|
readonly directManifestNode: true;
|
|
5
|
-
readonly allowedChildren: readonly ["Box", "Stack", "Grid", "Container", "Divider", "Text", "Heading", "Button", "Input", "Textarea", "FormField", "Card", "Panel", "Notice", "EmptyState", "SectionHeader", "SettingsRow", "PostCard", "ChatListItem"];
|
|
5
|
+
readonly allowedChildren: readonly ["Box", "Stack", "Grid", "Container", "Divider", "Text", "Heading", "Button", "Input", "Textarea", "FormField", "Card", "Panel", "Notice", "EmptyState", "SectionHeader", "SettingsRow", "PostCard", "ChatListItem", "MessageBubble"];
|
|
6
6
|
readonly blueprint: {
|
|
7
7
|
readonly label: "Panel";
|
|
8
8
|
readonly defaultProps: {
|
|
@@ -3,7 +3,7 @@ export declare const postCardMeta: {
|
|
|
3
3
|
readonly category: "pattern";
|
|
4
4
|
readonly description: "Social/content post card with author identity, body, media, actions, and comment previews.";
|
|
5
5
|
readonly directManifestNode: true;
|
|
6
|
-
readonly allowedChildren: readonly ["Box", "Stack", "Grid", "Container", "Divider", "Text", "Heading", "Button", "Input", "Textarea", "FormField", "Card", "Panel", "Notice", "EmptyState", "SectionHeader", "SettingsRow", "PostCard", "ChatListItem"];
|
|
6
|
+
readonly allowedChildren: readonly ["Box", "Stack", "Grid", "Container", "Divider", "Text", "Heading", "Button", "Input", "Textarea", "FormField", "Card", "Panel", "Notice", "EmptyState", "SectionHeader", "SettingsRow", "PostCard", "ChatListItem", "MessageBubble"];
|
|
7
7
|
readonly blueprint: {
|
|
8
8
|
readonly label: "Post card";
|
|
9
9
|
readonly icon: {
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@ankhorage/zora",
|
|
3
3
|
"type": "module",
|
|
4
|
-
"version": "1.4.
|
|
4
|
+
"version": "1.4.11",
|
|
5
5
|
"description": "Opinionated React Native and React Native Web UI kit built on @ankhorage/surface.",
|
|
6
6
|
"homepage": "https://github.com/ankhorage/zora#readme",
|
|
7
7
|
"bugs": {
|
|
@@ -43,9 +43,9 @@
|
|
|
43
43
|
}
|
|
44
44
|
},
|
|
45
45
|
"dependencies": {
|
|
46
|
-
"@ankhorage/color-theory": "^0.0.
|
|
47
|
-
"@ankhorage/contracts": "^1.
|
|
48
|
-
"@ankhorage/surface": "^1.3.
|
|
46
|
+
"@ankhorage/color-theory": "^0.0.7",
|
|
47
|
+
"@ankhorage/contracts": "^1.3.1",
|
|
48
|
+
"@ankhorage/surface": "^1.3.1"
|
|
49
49
|
},
|
|
50
50
|
"files": [
|
|
51
51
|
"dist",
|
|
@@ -83,7 +83,7 @@
|
|
|
83
83
|
"version-packages": "changeset version"
|
|
84
84
|
},
|
|
85
85
|
"devDependencies": {
|
|
86
|
-
"@ankhorage/devtools": "^1.0.
|
|
86
|
+
"@ankhorage/devtools": "^1.0.6",
|
|
87
87
|
"@changesets/cli": "^2.31.0",
|
|
88
88
|
"@expo/vector-icons": "^15.1.1",
|
|
89
89
|
"@react-native-picker/picker": "^2.11.4",
|
package/src/index.ts
CHANGED
|
@@ -203,6 +203,14 @@ export type {
|
|
|
203
203
|
ListSectionProps,
|
|
204
204
|
} from './patterns/list';
|
|
205
205
|
export { List, ListRow, ListSection } from './patterns/list';
|
|
206
|
+
export type {
|
|
207
|
+
MessageBubbleAuthor,
|
|
208
|
+
MessageBubbleAvatar,
|
|
209
|
+
MessageBubbleDirection,
|
|
210
|
+
MessageBubbleProps,
|
|
211
|
+
MessageBubbleStatus,
|
|
212
|
+
} from './patterns/message-bubble';
|
|
213
|
+
export { MessageBubble } from './patterns/message-bubble';
|
|
206
214
|
export type { NoticeProps } from './patterns/notice';
|
|
207
215
|
export { Notice } from './patterns/notice';
|
|
208
216
|
export type { PanelProps } from './patterns/panel';
|
|
@@ -54,6 +54,7 @@ import { imagePreviewMeta } from '../patterns/image-preview/meta';
|
|
|
54
54
|
import { imageUploadFieldMeta } from '../patterns/image-upload-field/meta';
|
|
55
55
|
import { inspectorFieldMeta } from '../patterns/inspector-field/meta';
|
|
56
56
|
import { listMeta, listRowMeta, listSectionMeta } from '../patterns/list/meta';
|
|
57
|
+
import { messageBubbleMeta } from '../patterns/message-bubble/meta';
|
|
57
58
|
import { noticeMeta } from '../patterns/notice/meta';
|
|
58
59
|
import { panelMeta } from '../patterns/panel/meta';
|
|
59
60
|
import { postCardMeta } from '../patterns/post-card/meta';
|
|
@@ -133,6 +134,7 @@ export const ZORA_COMPONENT_META: ZoraComponentMetaRegistry = {
|
|
|
133
134
|
List: listMeta,
|
|
134
135
|
ListRow: listRowMeta,
|
|
135
136
|
ListSection: listSectionMeta,
|
|
137
|
+
MessageBubble: messageBubbleMeta,
|
|
136
138
|
Notice: noticeMeta,
|
|
137
139
|
Panel: panelMeta,
|
|
138
140
|
PostCard: postCardMeta,
|
|
@@ -0,0 +1,261 @@
|
|
|
1
|
+
import { ButtonBase } from '@ankhorage/surface';
|
|
2
|
+
import React from 'react';
|
|
3
|
+
|
|
4
|
+
import { Avatar } from '../../components/avatar';
|
|
5
|
+
import { Text } from '../../components/text';
|
|
6
|
+
import { Box, Inline, Stack } from '../../foundation';
|
|
7
|
+
import { useZoraTheme } from '../../theme/useZoraTheme';
|
|
8
|
+
import { withZoraThemeScope } from '../../theme/withZoraThemeScope';
|
|
9
|
+
import type {
|
|
10
|
+
MessageBubbleAvatar,
|
|
11
|
+
MessageBubbleDirection,
|
|
12
|
+
MessageBubbleProps,
|
|
13
|
+
MessageBubbleStatus,
|
|
14
|
+
} from './types';
|
|
15
|
+
|
|
16
|
+
function resolveAvatarName({
|
|
17
|
+
avatar,
|
|
18
|
+
authorName,
|
|
19
|
+
}: {
|
|
20
|
+
avatar: MessageBubbleAvatar | undefined;
|
|
21
|
+
authorName: React.ReactNode | undefined;
|
|
22
|
+
}): string | undefined {
|
|
23
|
+
if (avatar?.name) return avatar.name;
|
|
24
|
+
return typeof authorName === 'string' ? authorName : undefined;
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
function resolvePadding(compact: boolean) {
|
|
28
|
+
return compact ? { px: 'm' as const, py: 's' as const } : { px: 'm' as const, py: 'm' as const };
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
function resolveStatusLabel(status: MessageBubbleStatus): string {
|
|
32
|
+
switch (status) {
|
|
33
|
+
case 'sending':
|
|
34
|
+
return 'Sending';
|
|
35
|
+
case 'sent':
|
|
36
|
+
return 'Sent';
|
|
37
|
+
case 'delivered':
|
|
38
|
+
return 'Delivered';
|
|
39
|
+
case 'read':
|
|
40
|
+
return 'Read';
|
|
41
|
+
case 'failed':
|
|
42
|
+
return 'Failed';
|
|
43
|
+
default:
|
|
44
|
+
return status;
|
|
45
|
+
}
|
|
46
|
+
}
|
|
47
|
+
|
|
48
|
+
function isMessageBubbleStatus(
|
|
49
|
+
status: MessageBubbleProps['status'],
|
|
50
|
+
): status is MessageBubbleStatus {
|
|
51
|
+
return (
|
|
52
|
+
status === 'sending' ||
|
|
53
|
+
status === 'sent' ||
|
|
54
|
+
status === 'delivered' ||
|
|
55
|
+
status === 'read' ||
|
|
56
|
+
status === 'failed'
|
|
57
|
+
);
|
|
58
|
+
}
|
|
59
|
+
|
|
60
|
+
function resolveStatus(status: MessageBubbleProps['status']) {
|
|
61
|
+
if (status == null) return null;
|
|
62
|
+
return isMessageBubbleStatus(status) ? resolveStatusLabel(status) : status;
|
|
63
|
+
}
|
|
64
|
+
|
|
65
|
+
function resolveBubbleStyles({
|
|
66
|
+
direction,
|
|
67
|
+
disabled,
|
|
68
|
+
hovered,
|
|
69
|
+
pressed,
|
|
70
|
+
selected,
|
|
71
|
+
theme,
|
|
72
|
+
}: {
|
|
73
|
+
direction: MessageBubbleDirection;
|
|
74
|
+
disabled: boolean;
|
|
75
|
+
hovered: boolean;
|
|
76
|
+
pressed: boolean;
|
|
77
|
+
selected: boolean;
|
|
78
|
+
theme: ReturnType<typeof useZoraTheme>['theme'];
|
|
79
|
+
}) {
|
|
80
|
+
const borderColor = selected ? theme.semantics.border.focus : theme.semantics.border.default;
|
|
81
|
+
|
|
82
|
+
if (direction === 'system') {
|
|
83
|
+
return {
|
|
84
|
+
bg: selected ? theme.semantics.neutral.surface : 'transparent',
|
|
85
|
+
borderColor,
|
|
86
|
+
borderWidth: selected ? 1 : 0,
|
|
87
|
+
opacity: disabled ? 0.72 : 1,
|
|
88
|
+
};
|
|
89
|
+
}
|
|
90
|
+
|
|
91
|
+
const interactiveBg = pressed
|
|
92
|
+
? theme.semantics.neutral.surfaceActive
|
|
93
|
+
: hovered
|
|
94
|
+
? theme.semantics.neutral.surfaceHover
|
|
95
|
+
: undefined;
|
|
96
|
+
|
|
97
|
+
return {
|
|
98
|
+
bg:
|
|
99
|
+
interactiveBg ??
|
|
100
|
+
(direction === 'outgoing' ? theme.semantics.neutral.surface : theme.semantics.surface.raised),
|
|
101
|
+
borderColor,
|
|
102
|
+
borderWidth: selected ? 1 : 0,
|
|
103
|
+
opacity: disabled ? 0.72 : 1,
|
|
104
|
+
};
|
|
105
|
+
}
|
|
106
|
+
|
|
107
|
+
function MessageAvatar({
|
|
108
|
+
avatar,
|
|
109
|
+
authorName,
|
|
110
|
+
compact,
|
|
111
|
+
}: {
|
|
112
|
+
avatar: MessageBubbleAvatar;
|
|
113
|
+
authorName: React.ReactNode | undefined;
|
|
114
|
+
compact: boolean;
|
|
115
|
+
}) {
|
|
116
|
+
const avatarName = resolveAvatarName({ avatar, authorName });
|
|
117
|
+
|
|
118
|
+
return (
|
|
119
|
+
<Avatar
|
|
120
|
+
initials={avatar.initials}
|
|
121
|
+
label={avatar.label ?? avatarName}
|
|
122
|
+
name={avatarName}
|
|
123
|
+
shape={avatar.shape}
|
|
124
|
+
size={avatar.size ?? (compact ? 'xs' : 's')}
|
|
125
|
+
source={avatar.source}
|
|
126
|
+
tone={avatar.tone}
|
|
127
|
+
/>
|
|
128
|
+
);
|
|
129
|
+
}
|
|
130
|
+
|
|
131
|
+
function MessageBubbleInner({
|
|
132
|
+
themeId: _themeId,
|
|
133
|
+
mode: _mode,
|
|
134
|
+
testID,
|
|
135
|
+
direction = 'incoming',
|
|
136
|
+
text,
|
|
137
|
+
children,
|
|
138
|
+
author,
|
|
139
|
+
timestamp,
|
|
140
|
+
meta,
|
|
141
|
+
status,
|
|
142
|
+
leading,
|
|
143
|
+
trailing,
|
|
144
|
+
footer,
|
|
145
|
+
selected = false,
|
|
146
|
+
disabled = false,
|
|
147
|
+
compact = false,
|
|
148
|
+
accessibilityLabel,
|
|
149
|
+
onPress,
|
|
150
|
+
}: MessageBubbleProps) {
|
|
151
|
+
const { theme } = useZoraTheme();
|
|
152
|
+
const padding = resolvePadding(compact);
|
|
153
|
+
const isInteractive = Boolean(onPress);
|
|
154
|
+
const isOutgoing = direction === 'outgoing';
|
|
155
|
+
const isSystem = direction === 'system';
|
|
156
|
+
const renderedStatus = resolveStatus(status);
|
|
157
|
+
const authorName = author?.name;
|
|
158
|
+
const authorAvatar = author?.avatar;
|
|
159
|
+
const hasAuthorName = authorName != null && !isOutgoing && !isSystem;
|
|
160
|
+
const hasAvatar = authorAvatar != null && !isOutgoing && !isSystem;
|
|
161
|
+
const hasMetaRow = timestamp != null || meta != null || renderedStatus != null;
|
|
162
|
+
|
|
163
|
+
const renderBubble = ({ pressed, hovered }: { pressed: boolean; hovered: boolean }) => {
|
|
164
|
+
const styles = resolveBubbleStyles({ direction, disabled, hovered, pressed, selected, theme });
|
|
165
|
+
|
|
166
|
+
return (
|
|
167
|
+
<Box
|
|
168
|
+
bg={styles.bg}
|
|
169
|
+
borderColor={styles.borderColor}
|
|
170
|
+
borderWidth={styles.borderWidth}
|
|
171
|
+
px={padding.px}
|
|
172
|
+
py={padding.py}
|
|
173
|
+
radius={isSystem ? 'm' : 'l'}
|
|
174
|
+
style={{ maxWidth: compact ? 420 : 560, opacity: styles.opacity }}
|
|
175
|
+
>
|
|
176
|
+
<Stack align={isSystem ? 'center' : 'flex-start'} gap={compact ? 'xxs' : 'xs'}>
|
|
177
|
+
{hasAuthorName ? (
|
|
178
|
+
<Text tone="muted" variant="caption" weight="semiBold">
|
|
179
|
+
{authorName}
|
|
180
|
+
</Text>
|
|
181
|
+
) : null}
|
|
182
|
+
{text != null ? (
|
|
183
|
+
<Text align={isSystem ? 'center' : undefined} tone={disabled ? 'muted' : 'default'}>
|
|
184
|
+
{text}
|
|
185
|
+
</Text>
|
|
186
|
+
) : null}
|
|
187
|
+
{children != null ? <Box width="100%">{children}</Box> : null}
|
|
188
|
+
{hasMetaRow ? (
|
|
189
|
+
<Inline
|
|
190
|
+
align="center"
|
|
191
|
+
gap="xs"
|
|
192
|
+
justify={isOutgoing ? 'flex-end' : isSystem ? 'center' : 'flex-start'}
|
|
193
|
+
wrap="wrap"
|
|
194
|
+
>
|
|
195
|
+
{timestamp != null ? (
|
|
196
|
+
<Text tone="subtle" variant="caption">
|
|
197
|
+
{timestamp}
|
|
198
|
+
</Text>
|
|
199
|
+
) : null}
|
|
200
|
+
{meta != null ? (
|
|
201
|
+
<Text tone="subtle" variant="caption">
|
|
202
|
+
{meta}
|
|
203
|
+
</Text>
|
|
204
|
+
) : null}
|
|
205
|
+
{renderedStatus != null ? (
|
|
206
|
+
<Text tone={status === 'failed' ? 'danger' : 'subtle'} variant="caption">
|
|
207
|
+
{renderedStatus}
|
|
208
|
+
</Text>
|
|
209
|
+
) : null}
|
|
210
|
+
</Inline>
|
|
211
|
+
) : null}
|
|
212
|
+
</Stack>
|
|
213
|
+
</Box>
|
|
214
|
+
);
|
|
215
|
+
};
|
|
216
|
+
|
|
217
|
+
const bubbleContent = isInteractive ? (
|
|
218
|
+
<ButtonBase
|
|
219
|
+
accessibilityLabel={accessibilityLabel}
|
|
220
|
+
accessibilityRole="button"
|
|
221
|
+
accessibilityState={{ disabled, selected }}
|
|
222
|
+
disabled={disabled}
|
|
223
|
+
onPress={onPress}
|
|
224
|
+
radius={isSystem ? 'm' : 'l'}
|
|
225
|
+
testID={testID}
|
|
226
|
+
>
|
|
227
|
+
{(state) => renderBubble({ pressed: state.pressed, hovered: state.hovered })}
|
|
228
|
+
</ButtonBase>
|
|
229
|
+
) : (
|
|
230
|
+
<Box testID={testID}>{renderBubble({ pressed: false, hovered: false })}</Box>
|
|
231
|
+
);
|
|
232
|
+
|
|
233
|
+
return (
|
|
234
|
+
<Stack gap="xs" style={{ width: '100%' }}>
|
|
235
|
+
<Inline
|
|
236
|
+
align="flex-end"
|
|
237
|
+
gap="s"
|
|
238
|
+
justify={isSystem ? 'center' : isOutgoing ? 'flex-end' : 'flex-start'}
|
|
239
|
+
wrap="nowrap"
|
|
240
|
+
>
|
|
241
|
+
{!isOutgoing && !isSystem ? (
|
|
242
|
+
<Box>
|
|
243
|
+
{leading ??
|
|
244
|
+
(hasAvatar ? (
|
|
245
|
+
<MessageAvatar avatar={authorAvatar} authorName={authorName} compact={compact} />
|
|
246
|
+
) : null)}
|
|
247
|
+
</Box>
|
|
248
|
+
) : null}
|
|
249
|
+
{isOutgoing && trailing ? <Box>{trailing}</Box> : null}
|
|
250
|
+
{bubbleContent}
|
|
251
|
+
{isOutgoing && leading ? <Box>{leading}</Box> : null}
|
|
252
|
+
{!isOutgoing && !isSystem && trailing ? <Box>{trailing}</Box> : null}
|
|
253
|
+
</Inline>
|
|
254
|
+
{footer != null ? (
|
|
255
|
+
<Box alignSelf={isOutgoing ? 'flex-end' : isSystem ? 'center' : 'flex-start'}>{footer}</Box>
|
|
256
|
+
) : null}
|
|
257
|
+
</Stack>
|
|
258
|
+
);
|
|
259
|
+
}
|
|
260
|
+
|
|
261
|
+
export const MessageBubble = withZoraThemeScope(MessageBubbleInner);
|