@astryxdesign/lab 0.7.2-canary.f16dc9f → 0.7.2-canary.f2b60a0

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 (156) hide show
  1. package/blocks/CommentComposerShowcase.doc.mjs +15 -0
  2. package/blocks/CommentComposerShowcase.tsx +45 -0
  3. package/blocks/CommentPinInMargin.doc.mjs +14 -0
  4. package/blocks/CommentPinInMargin.tsx +77 -0
  5. package/blocks/CommentPinShowcase.doc.mjs +15 -0
  6. package/blocks/CommentPinShowcase.tsx +188 -0
  7. package/blocks/CommentThreadInPopover.doc.mjs +21 -0
  8. package/blocks/CommentThreadInPopover.tsx +89 -0
  9. package/blocks/CommentThreadShowcase.doc.mjs +15 -0
  10. package/blocks/CommentThreadShowcase.tsx +67 -0
  11. package/blocks/CommentsInCard.doc.mjs +14 -0
  12. package/blocks/CommentsInCard.tsx +78 -0
  13. package/blocks/CommentsInline.doc.mjs +14 -0
  14. package/blocks/CommentsInline.tsx +297 -0
  15. package/blocks/CommentsShowcase.doc.mjs +15 -0
  16. package/blocks/CommentsShowcase.tsx +341 -0
  17. package/blocks/EmojiPickerInPopover.doc.mjs +14 -0
  18. package/blocks/EmojiPickerInPopover.tsx +48 -0
  19. package/blocks/EmojiPickerShowcase.doc.mjs +15 -0
  20. package/blocks/EmojiPickerShowcase.tsx +33 -0
  21. package/dist/Chat/ChatTypingIndicator.d.ts.map +1 -1
  22. package/dist/Chat/ChatTypingIndicator.js +1 -1
  23. package/dist/CommentPin/CommentPin.d.ts +86 -0
  24. package/dist/CommentPin/CommentPin.d.ts.map +1 -0
  25. package/dist/CommentPin/CommentPin.js +260 -0
  26. package/dist/CommentPin/index.d.ts +9 -0
  27. package/dist/CommentPin/index.d.ts.map +1 -0
  28. package/dist/CommentPin/index.js +11 -0
  29. package/dist/Comments/CommentActions.d.ts +55 -0
  30. package/dist/Comments/CommentActions.d.ts.map +1 -0
  31. package/dist/Comments/CommentActions.js +472 -0
  32. package/dist/Comments/CommentComposer.d.ts +108 -0
  33. package/dist/Comments/CommentComposer.d.ts.map +1 -0
  34. package/dist/Comments/CommentComposer.js +507 -0
  35. package/dist/Comments/CommentMarkdown.d.ts +15 -0
  36. package/dist/Comments/CommentMarkdown.d.ts.map +1 -0
  37. package/dist/Comments/CommentMarkdown.js +136 -0
  38. package/dist/Comments/CommentParts.d.ts +238 -0
  39. package/dist/Comments/CommentParts.d.ts.map +1 -0
  40. package/dist/Comments/CommentParts.js +823 -0
  41. package/dist/Comments/CommentRow.d.ts +20 -0
  42. package/dist/Comments/CommentRow.d.ts.map +1 -0
  43. package/dist/Comments/CommentRow.js +693 -0
  44. package/dist/Comments/CommentThread.d.ts +66 -0
  45. package/dist/Comments/CommentThread.d.ts.map +1 -0
  46. package/dist/Comments/CommentThread.js +169 -0
  47. package/dist/Comments/Comments.d.ts +105 -0
  48. package/dist/Comments/Comments.d.ts.map +1 -0
  49. package/dist/Comments/Comments.js +426 -0
  50. package/dist/Comments/CommentsContext.d.ts +117 -0
  51. package/dist/Comments/CommentsContext.d.ts.map +1 -0
  52. package/dist/Comments/CommentsContext.js +515 -0
  53. package/dist/Comments/i18n.d.ts +18 -0
  54. package/dist/Comments/i18n.d.ts.map +1 -0
  55. package/dist/Comments/i18n.js +34 -0
  56. package/dist/Comments/icons.d.ts +24 -0
  57. package/dist/Comments/icons.d.ts.map +1 -0
  58. package/dist/Comments/icons.js +93 -0
  59. package/dist/Comments/index.d.ts +16 -0
  60. package/dist/Comments/index.d.ts.map +1 -0
  61. package/dist/Comments/index.js +15 -0
  62. package/dist/Comments/types.d.ts +341 -0
  63. package/dist/Comments/types.d.ts.map +1 -0
  64. package/dist/Comments/types.js +100 -0
  65. package/dist/Comments/useCommentThreadDismissal.d.ts +88 -0
  66. package/dist/Comments/useCommentThreadDismissal.d.ts.map +1 -0
  67. package/dist/Comments/useCommentThreadDismissal.js +344 -0
  68. package/dist/Comments/utils.d.ts +44 -0
  69. package/dist/Comments/utils.d.ts.map +1 -0
  70. package/dist/Comments/utils.js +84 -0
  71. package/dist/EmojiPicker/EmojiPicker.d.ts +96 -0
  72. package/dist/EmojiPicker/EmojiPicker.d.ts.map +1 -0
  73. package/dist/EmojiPicker/EmojiPicker.js +451 -0
  74. package/dist/EmojiPicker/emojiData.d.ts +13 -0
  75. package/dist/EmojiPicker/emojiData.d.ts.map +1 -0
  76. package/dist/EmojiPicker/emojiData.js +36 -0
  77. package/dist/EmojiPicker/index.d.ts +9 -0
  78. package/dist/EmojiPicker/index.d.ts.map +1 -0
  79. package/dist/EmojiPicker/index.js +11 -0
  80. package/dist/index.d.ts +3 -1
  81. package/dist/index.d.ts.map +1 -1
  82. package/dist/index.js +9 -3
  83. package/dist/lab.css +105 -46
  84. package/package.json +8 -6
  85. package/src/Chat/ChatTypingIndicator.tsx +3 -0
  86. package/src/CommentPin/CommentPin.doc.mjs +328 -0
  87. package/src/CommentPin/CommentPin.spec.md +307 -0
  88. package/src/CommentPin/CommentPin.test.tsx +350 -0
  89. package/src/CommentPin/CommentPin.tsx +484 -0
  90. package/src/CommentPin/index.ts +13 -0
  91. package/src/Comments/CommentActions.tsx +542 -0
  92. package/src/Comments/CommentComposer.doc.mjs +177 -0
  93. package/src/Comments/CommentComposer.test.tsx +255 -0
  94. package/src/Comments/CommentComposer.tsx +680 -0
  95. package/src/Comments/CommentMarkdown.tsx +184 -0
  96. package/src/Comments/CommentParts.tsx +937 -0
  97. package/src/Comments/CommentRow.tsx +918 -0
  98. package/src/Comments/CommentThread.doc.mjs +580 -0
  99. package/src/Comments/CommentThread.test.tsx +634 -0
  100. package/src/Comments/CommentThread.tsx +226 -0
  101. package/src/Comments/Comments.doc.mjs +648 -0
  102. package/src/Comments/Comments.test.tsx +1335 -0
  103. package/src/Comments/Comments.tsx +643 -0
  104. package/src/Comments/CommentsContext.tsx +755 -0
  105. package/src/Comments/i18n.ts +40 -0
  106. package/src/Comments/icons.tsx +129 -0
  107. package/src/Comments/index.ts +39 -0
  108. package/src/Comments/types.ts +392 -0
  109. package/src/Comments/useCommentThreadDismissal.ts +426 -0
  110. package/src/Comments/utils.ts +114 -0
  111. package/src/EmojiPicker/EmojiPicker.doc.mjs +186 -0
  112. package/src/EmojiPicker/EmojiPicker.test.tsx +276 -0
  113. package/src/EmojiPicker/EmojiPicker.tsx +574 -0
  114. package/src/EmojiPicker/emojiData.test.ts +32 -0
  115. package/src/EmojiPicker/emojiData.ts +3138 -0
  116. package/src/EmojiPicker/index.ts +13 -0
  117. package/src/index.ts +46 -8
  118. package/blocks/DrawerFullWidthMobile.doc.mjs +0 -21
  119. package/blocks/DrawerFullWidthMobile.tsx +0 -42
  120. package/blocks/DrawerHeaderShowcase.doc.mjs +0 -15
  121. package/blocks/DrawerHeaderShowcase.tsx +0 -73
  122. package/blocks/DrawerHeaderSubtitleEndContent.doc.mjs +0 -22
  123. package/blocks/DrawerHeaderSubtitleEndContent.tsx +0 -49
  124. package/blocks/DrawerHeaderWithCloseButton.doc.mjs +0 -21
  125. package/blocks/DrawerHeaderWithCloseButton.tsx +0 -42
  126. package/blocks/DrawerMobileReveal.doc.mjs +0 -21
  127. package/blocks/DrawerMobileReveal.tsx +0 -43
  128. package/blocks/DrawerScrim.doc.mjs +0 -22
  129. package/blocks/DrawerScrim.tsx +0 -68
  130. package/blocks/DrawerShowcase.doc.mjs +0 -22
  131. package/blocks/DrawerShowcase.tsx +0 -41
  132. package/blocks/DrawerStart.doc.mjs +0 -21
  133. package/blocks/DrawerStart.tsx +0 -41
  134. package/blocks/DrawerWidths.doc.mjs +0 -22
  135. package/blocks/DrawerWidths.tsx +0 -54
  136. package/dist/Drawer/Drawer.d.ts +0 -181
  137. package/dist/Drawer/Drawer.d.ts.map +0 -1
  138. package/dist/Drawer/Drawer.js +0 -388
  139. package/dist/Drawer/DrawerHeader.d.ts +0 -82
  140. package/dist/Drawer/DrawerHeader.d.ts.map +0 -1
  141. package/dist/Drawer/DrawerHeader.js +0 -131
  142. package/dist/Drawer/index.d.ts +0 -11
  143. package/dist/Drawer/index.d.ts.map +0 -1
  144. package/dist/Drawer/index.js +0 -11
  145. package/dist/Drawer/useDrawerDialogPresence.d.ts +0 -42
  146. package/dist/Drawer/useDrawerDialogPresence.d.ts.map +0 -1
  147. package/dist/Drawer/useDrawerDialogPresence.js +0 -235
  148. package/src/Drawer/Drawer.doc.mjs +0 -470
  149. package/src/Drawer/Drawer.spec.md +0 -343
  150. package/src/Drawer/Drawer.test.tsx +0 -1039
  151. package/src/Drawer/Drawer.tsx +0 -618
  152. package/src/Drawer/DrawerHeader.doc.mjs +0 -291
  153. package/src/Drawer/DrawerHeader.test.tsx +0 -89
  154. package/src/Drawer/DrawerHeader.tsx +0 -237
  155. package/src/Drawer/index.ts +0 -13
  156. package/src/Drawer/useDrawerDialogPresence.ts +0 -283
@@ -0,0 +1,48 @@
1
+ // Copyright (c) Meta Platforms, Inc. and affiliates.
2
+
3
+ 'use client';
4
+
5
+ /**
6
+ * @input Controlled popover state and the text the picks build
7
+ * @output An emoji button opening the picker in a Popover; the Popover's own
8
+ * autofocus lands in the picker's search field
9
+ * @position Copyable Lab EmojiPicker example
10
+ */
11
+
12
+ import {useState} from 'react';
13
+ import {HStack} from '@astryxdesign/core/Layout';
14
+ import {IconButton} from '@astryxdesign/core/IconButton';
15
+ import {Popover} from '@astryxdesign/core/Popover';
16
+ import {Text} from '@astryxdesign/core/Text';
17
+ import {EmojiPicker} from '@astryxdesign/lab';
18
+
19
+ export default function EmojiPickerInPopover() {
20
+ const [isOpen, setIsOpen] = useState(false);
21
+ const [text, setText] = useState('');
22
+
23
+ return (
24
+ <HStack gap={2} align="center">
25
+ <Popover
26
+ isOpen={isOpen}
27
+ onOpenChange={setIsOpen}
28
+ label="Add emoji"
29
+ padding={0}
30
+ width={352}
31
+ content={
32
+ <EmojiPicker
33
+ onSelect={emoji => {
34
+ setText(current => current + emoji);
35
+ setIsOpen(false);
36
+ }}
37
+ />
38
+ }>
39
+ <IconButton
40
+ label="Add emoji"
41
+ variant="secondary"
42
+ icon={<span aria-hidden="true">🙂</span>}
43
+ />
44
+ </Popover>
45
+ <Text type="large">{text === '' ? 'Pick some emoji' : text}</Text>
46
+ </HStack>
47
+ );
48
+ }
@@ -0,0 +1,15 @@
1
+ // Copyright (c) Meta Platforms, Inc. and affiliates.
2
+
3
+ /** @type {import('@astryxdesign/cli/authoring').TemplateDoc} */
4
+ export default {
5
+ type: 'block',
6
+ name: 'Inline picker',
7
+ displayName: 'Inline picker',
8
+ description:
9
+ 'An emoji picker inline in a Card: search by name or keyword, move with the arrow keys, and pick; the last pick shows above it.',
10
+ exampleFor: 'EmojiPicker',
11
+ isReady: true,
12
+ isShowcase: true,
13
+ aspectRatio: 1,
14
+ componentsUsed: ['EmojiPicker', 'Card', 'HStack', 'VStack', 'Text'],
15
+ };
@@ -0,0 +1,33 @@
1
+ // Copyright (c) Meta Platforms, Inc. and affiliates.
2
+
3
+ 'use client';
4
+
5
+ /**
6
+ * @input The picked emoji, kept in local state
7
+ * @output An inline emoji picker in a Card, naming the last pick
8
+ * @position Lab EmojiPicker's docsite showcase and copyable CLI block
9
+ */
10
+
11
+ import {useState} from 'react';
12
+ import {Card} from '@astryxdesign/core/Card';
13
+ import {HStack, VStack} from '@astryxdesign/core/Layout';
14
+ import {Text} from '@astryxdesign/core/Text';
15
+ import {EmojiPicker, type EmojiOption} from '@astryxdesign/lab';
16
+
17
+ export default function EmojiPickerShowcase() {
18
+ const [picked, setPicked] = useState<EmojiOption | null>(null);
19
+
20
+ return (
21
+ <VStack gap={3} width={352}>
22
+ <HStack gap={2} align="center">
23
+ <Text type="label">Picked:</Text>
24
+ <Text type="body" color="secondary">
25
+ {picked == null ? 'Nothing yet' : `${picked.emoji} ${picked.name}`}
26
+ </Text>
27
+ </HStack>
28
+ <Card padding={0} width="100%">
29
+ <EmojiPicker onSelect={(_, option) => setPicked(option)} />
30
+ </Card>
31
+ </VStack>
32
+ );
33
+ }
@@ -1 +1 @@
1
- {"version":3,"file":"ChatTypingIndicator.d.ts","sourceRoot":"","sources":["../../src/Chat/ChatTypingIndicator.tsx"],"names":[],"mappings":"AA+BA,OAAO,KAAK,EAAC,SAAS,EAAC,MAAM,oBAAoB,CAAC;AAMlD,MAAM,WAAW,wBAAyB,SAAQ,SAAS,CAAC,cAAc,CAAC;IACzE,wCAAwC;IACxC,GAAG,CAAC,EAAE,KAAK,CAAC,GAAG,CAAC,cAAc,CAAC,CAAC;IAEhC;;;;;OAKG;IACH,KAAK,CAAC,EAAE,MAAM,EAAE,CAAC;CAClB;AAuFD;;;;;;;;;;;;GAYG;AACH,wBAAgB,mBAAmB,CAAC,EAClC,KAAK,EACL,MAAM,EACN,SAAS,EACT,KAAK,EAAE,SAAS,EAChB,aAAa,EAAE,MAAM,EACrB,GAAG,GACJ,EAAE,wBAAwB,+BA4B1B;yBAnCe,mBAAmB"}
1
+ {"version":3,"file":"ChatTypingIndicator.d.ts","sourceRoot":"","sources":["../../src/Chat/ChatTypingIndicator.tsx"],"names":[],"mappings":"AA+BA,OAAO,KAAK,EAAC,SAAS,EAAC,MAAM,oBAAoB,CAAC;AAMlD,MAAM,WAAW,wBAAyB,SAAQ,SAAS,CAAC,cAAc,CAAC;IACzE,wCAAwC;IACxC,GAAG,CAAC,EAAE,KAAK,CAAC,GAAG,CAAC,cAAc,CAAC,CAAC;IAEhC;;;;;OAKG;IACH,KAAK,CAAC,EAAE,MAAM,EAAE,CAAC;CAClB;AA0FD;;;;;;;;;;;;GAYG;AACH,wBAAgB,mBAAmB,CAAC,EAClC,KAAK,EACL,MAAM,EACN,SAAS,EACT,KAAK,EAAE,SAAS,EAChB,aAAa,EAAE,MAAM,EACrB,GAAG,GACJ,EAAE,wBAAwB,+BA4B1B;yBAnCe,mBAAmB"}
@@ -108,7 +108,7 @@ export function ChatTypingIndicator({
108
108
  children: [/*#__PURE__*/_jsxs("span", {
109
109
  "aria-hidden": "true",
110
110
  ...{
111
- className: "x3nfvp2 x6s0dn4 x1lsbc85"
111
+ className: "x3nfvp2 x6s0dn4 xl56j7k x2lah0s x1lout4y x1lsbc85"
112
112
  },
113
113
  children: [/*#__PURE__*/_jsx("span", {
114
114
  ...{
@@ -0,0 +1,86 @@
1
+ import type { BaseProps } from '@astryxdesign/core';
2
+ /** Identity data for one representative shown inside a CommentPin. */
3
+ export interface CommentPinParticipant {
4
+ /** Stable identity used to remove duplicate representatives. */
5
+ id: string;
6
+ /** Display name used by Avatar for image fallback initials. */
7
+ name: string;
8
+ /** Optional image source passed to Avatar. */
9
+ avatarSrc?: string;
10
+ }
11
+ export interface CommentPinProps extends Omit<BaseProps<HTMLButtonElement>, 'children'> {
12
+ /** Ref forwarded to the marker button. */
13
+ ref?: React.Ref<HTMLButtonElement>;
14
+ /**
15
+ * Accessible action name and visual hover/focus tooltip.
16
+ * Include grouped, unread, or resolved context when it changes the action's
17
+ * meaning.
18
+ */
19
+ label: string;
20
+ /**
21
+ * Ordered participants, lead first. A single marker shows the first. A
22
+ * grouped marker shows distinct IDs as an AvatarGroup of at most three
23
+ * circles: every participant when three or fewer are distinct, otherwise the
24
+ * first two plus a `+N` overflow circle. Pass every distinct participant so
25
+ * the overflow count is accurate.
26
+ */
27
+ participants: readonly [CommentPinParticipant, ...CommentPinParticipant[]];
28
+ /**
29
+ * Total number of threads represented by this marker. Values above one use
30
+ * the grouped presentation and show the exact total.
31
+ * @default 1
32
+ */
33
+ threadCount?: number;
34
+ /**
35
+ * Number of represented threads with unread activity. When above zero, an
36
+ * accent badge shows this number in place of the thread total, on single
37
+ * and grouped pins alike. Values above `threadCount` are capped.
38
+ * @default 0
39
+ */
40
+ unreadCount?: number;
41
+ /** Whether this pin is the currently selected annotation target. */
42
+ isSelected?: boolean;
43
+ /**
44
+ * Whether another pin is selected in the host. Dims this pin without
45
+ * disabling it, so it remains available to switch selection.
46
+ */
47
+ isDimmed?: boolean;
48
+ /** Whether every thread represented by this pin is resolved. */
49
+ isResolved?: boolean;
50
+ /** Whether activation is unavailable. */
51
+ isDisabled?: boolean;
52
+ }
53
+ /**
54
+ * Avatar-first annotation anchor for one thread or a caller-defined group.
55
+ *
56
+ * The caller owns grouping, representative selection, coordinates, collision
57
+ * handling, and the content opened by activation. Absolute placement maps the
58
+ * host anchor to the pin's logical bottom-start corner. The pin only owns its
59
+ * compact button surface and controlled visual states.
60
+ *
61
+ * @example
62
+ * ```
63
+ * <CommentPin
64
+ * label="Open annotation from Ada"
65
+ * participants={[{id: 'ada', name: 'Ada Lovelace'}]}
66
+ * onClick={() => openThread('thread-1')}
67
+ * />
68
+ * ```
69
+ *
70
+ * @example
71
+ * ```
72
+ * <CommentPin
73
+ * label="Open 6 grouped annotations from Ada, Lin, and 3 others, 2 unread"
74
+ * participants={[ada, lin, mira, noah, sam]}
75
+ * threadCount={6}
76
+ * unreadCount={2}
77
+ * isSelected
78
+ * onClick={() => openCluster('cluster-1')}
79
+ * />
80
+ * ```
81
+ */
82
+ export declare function CommentPin({ label, participants, threadCount, unreadCount, isSelected, isDimmed, isResolved, isDisabled, ref, xstyle, className, style, ...rest }: CommentPinProps): React.ReactNode;
83
+ export declare namespace CommentPin {
84
+ var displayName: string;
85
+ }
86
+ //# sourceMappingURL=CommentPin.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"CommentPin.d.ts","sourceRoot":"","sources":["../../src/CommentPin/CommentPin.tsx"],"names":[],"mappings":"AAuBA,OAAO,KAAK,EAAC,SAAS,EAAC,MAAM,oBAAoB,CAAC;AA2BlD,sEAAsE;AACtE,MAAM,WAAW,qBAAqB;IACpC,gEAAgE;IAChE,EAAE,EAAE,MAAM,CAAC;IACX,+DAA+D;IAC/D,IAAI,EAAE,MAAM,CAAC;IACb,8CAA8C;IAC9C,SAAS,CAAC,EAAE,MAAM,CAAC;CACpB;AAED,MAAM,WAAW,eAAgB,SAAQ,IAAI,CAC3C,SAAS,CAAC,iBAAiB,CAAC,EAC5B,UAAU,CACX;IACC,0CAA0C;IAC1C,GAAG,CAAC,EAAE,KAAK,CAAC,GAAG,CAAC,iBAAiB,CAAC,CAAC;IACnC;;;;OAIG;IACH,KAAK,EAAE,MAAM,CAAC;IACd;;;;;;OAMG;IACH,YAAY,EAAE,SAAS,CAAC,qBAAqB,EAAE,GAAG,qBAAqB,EAAE,CAAC,CAAC;IAC3E;;;;OAIG;IACH,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB;;;;;OAKG;IACH,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB,oEAAoE;IACpE,UAAU,CAAC,EAAE,OAAO,CAAC;IACrB;;;OAGG;IACH,QAAQ,CAAC,EAAE,OAAO,CAAC;IACnB,gEAAgE;IAChE,UAAU,CAAC,EAAE,OAAO,CAAC;IACrB,yCAAyC;IACzC,UAAU,CAAC,EAAE,OAAO,CAAC;CACtB;AAqMD;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA4BG;AACH,wBAAgB,UAAU,CAAC,EACzB,KAAK,EACL,YAAY,EACZ,WAAe,EACf,WAAe,EACf,UAAkB,EAClB,QAAgB,EAChB,UAAkB,EAClB,UAAkB,EAClB,GAAG,EACH,MAAM,EACN,SAAS,EACT,KAAK,EACL,GAAG,IAAI,EACR,EAAE,eAAe,GAAG,KAAK,CAAC,SAAS,CAyInC;yBAvJe,UAAU"}
@@ -0,0 +1,260 @@
1
+ // Copyright (c) Meta Platforms, Inc. and affiliates.
2
+
3
+ 'use client';
4
+
5
+ /**
6
+ * @file CommentPin.tsx
7
+ * @input Ordered participants (grouped pins show at most three circles),
8
+ * total and unread represented thread counts, controlled
9
+ * selected/dimmed/resolved/disabled state, and button DOM props
10
+ * @output Exports the avatar-first CommentPin button and its public types
11
+ * @position Lab collaboration primitive for annotation anchors over content or
12
+ * in content margins; callers own grouping, coordinates, and opened content
13
+ *
14
+ * SYNC: When modified, update these files to stay in sync:
15
+ * - /packages/lab/src/CommentPin/CommentPin.doc.mjs
16
+ * - /packages/lab/src/CommentPin/CommentPin.spec.md
17
+ * - /packages/lab/src/CommentPin/CommentPin.test.tsx
18
+ * - /packages/lab/src/CommentPin/index.ts
19
+ * - /apps/storybook/stories/CommentPin.stories.tsx
20
+ * - /packages/lab/blocks/CommentPinShowcase.tsx
21
+ */
22
+ import * as stylex from '@stylexjs/stylex';
23
+ import { Avatar } from '@astryxdesign/core/Avatar';
24
+ import { AvatarGroup, AvatarGroupOverflow } from '@astryxdesign/core/AvatarGroup';
25
+ import { useDevWarning, useMergedRefs, usePressFeedback } from '@astryxdesign/core/hooks';
26
+ import '@astryxdesign/core/theme/tokens.stylex';
27
+ import { borderVars, colorVars, fontWeightVars, radiusVars, shadowVars, sizeVars, spacingVars, typeScaleVars, typographyVars } from '@astryxdesign/core/theme/tokens.stylex';
28
+ import { useTooltip } from '@astryxdesign/core/Tooltip';
29
+ import { focusOutlineProps, interactionOverlayStyles, mergeProps, themeProps } from '@astryxdesign/core/utils';
30
+
31
+ /** Identity data for one representative shown inside a CommentPin. */
32
+ import { jsx as _jsx, jsxs as _jsxs, Fragment as _Fragment } from "react/jsx-runtime";
33
+ const styles = {
34
+ root: {
35
+ kysU6D: "xjyslct",
36
+ kB7OPa: "x9f619",
37
+ kVAEAm: "x1n2onr6",
38
+ k1xSpc: "x3nfvp2",
39
+ kGNEyG: "x6s0dn4",
40
+ kjj79g: "xl56j7k",
41
+ kmuXW: "x2lah0s",
42
+ kXLuUW: "xxymvpz",
43
+ k3nNDw: "x1bd091l x173emx3",
44
+ k7Eaqz: "x1nkkqge",
45
+ kZKoxP: "x6k0iem",
46
+ kogj98: "x1ghz6dp",
47
+ kmVPX3: "x12nba7r",
48
+ kMzoRj: "x1litavf",
49
+ ksu8eU: "x1y0btm7",
50
+ kVAM5u: "x9r1u3d",
51
+ krdFHd: "x19415el",
52
+ kfmiAY: "x8agd5o",
53
+ kT0f0o: "x1dgc8on",
54
+ kVL7Gh: "x1pczhz8",
55
+ kWkggS: "x1prclbq",
56
+ kKwaWg: "x18o3ruo",
57
+ kGVxlE: "x14hfi27",
58
+ kMwMTN: "xv1l7n4",
59
+ kkrTdU: "x1ypdohk x16khyan",
60
+ kMv6JI: "x9ynric",
61
+ kGuDYH: "x141an7d",
62
+ k63SB2: "x2mo6ok",
63
+ kLWn49: "x1ltkj2j",
64
+ khDVqt: "xuxw1ft",
65
+ kfSwDN: "x87ps6o",
66
+ $$css: true
67
+ },
68
+ withCount: {
69
+ kjj79g: "x1nhvcw1",
70
+ kOIVth: "xzye2dw",
71
+ kZCmMZ: "x138rykx",
72
+ kwRFfy: "x1djylfy",
73
+ $$css: true
74
+ },
75
+ selected: {
76
+ kAXs8y: "x1kzknox",
77
+ kSiTet: "x1hc1fzr",
78
+ kVAM5u: "x9r1u3d x1n2ykn",
79
+ kWkggS: "x1prclbq x1jzqe4",
80
+ kGVxlE: "xcydmya xwaqzdf",
81
+ kMwMTN: "xv1l7n4 x1k5gbb1",
82
+ $$css: true
83
+ },
84
+ resolved: {
85
+ kAXs8y: "x1kzknox",
86
+ kVAM5u: "x9r1u3d x1w1tqly",
87
+ kWkggS: "xwmxj5m x9yvj25",
88
+ kGVxlE: "x1gnnqk1",
89
+ kMwMTN: "xv1l7n4 xs5hli",
90
+ kSiTet: "xf9vgkq x1tbh5bv",
91
+ $$css: true
92
+ },
93
+ dimmed: {
94
+ kSiTet: "xti2d7y x1tbh5bv",
95
+ $$css: true
96
+ },
97
+ disabled: {
98
+ kkrTdU: "xt0e3qv",
99
+ kSiTet: "xyd83as x1tbh5bv",
100
+ $$css: true
101
+ },
102
+ overflowCircle: {
103
+ kg3NbH: "xnjsko4",
104
+ $$css: true
105
+ }
106
+ };
107
+ function takeDistinctParticipants(participants, limit) {
108
+ const result = [];
109
+ const seen = new Set();
110
+ for (const participant of participants) {
111
+ if (seen.has(participant.id)) {
112
+ continue;
113
+ }
114
+ seen.add(participant.id);
115
+ result.push(participant);
116
+ if (result.length === limit) {
117
+ break;
118
+ }
119
+ }
120
+ return result;
121
+ }
122
+ function isValidThreadCount(threadCount) {
123
+ return Number.isFinite(threadCount) && Number.isInteger(threadCount) && threadCount >= 1;
124
+ }
125
+ function isValidUnreadCount(unreadCount) {
126
+ return Number.isFinite(unreadCount) && Number.isInteger(unreadCount) && unreadCount >= 0;
127
+ }
128
+
129
+ /** Grouped pins never show more than this many circles, overflow included. */
130
+ const MAX_GROUP_CIRCLES = 3;
131
+
132
+ /**
133
+ * Avatar-first annotation anchor for one thread or a caller-defined group.
134
+ *
135
+ * The caller owns grouping, representative selection, coordinates, collision
136
+ * handling, and the content opened by activation. Absolute placement maps the
137
+ * host anchor to the pin's logical bottom-start corner. The pin only owns its
138
+ * compact button surface and controlled visual states.
139
+ *
140
+ * @example
141
+ * ```
142
+ * <CommentPin
143
+ * label="Open annotation from Ada"
144
+ * participants={[{id: 'ada', name: 'Ada Lovelace'}]}
145
+ * onClick={() => openThread('thread-1')}
146
+ * />
147
+ * ```
148
+ *
149
+ * @example
150
+ * ```
151
+ * <CommentPin
152
+ * label="Open 6 grouped annotations from Ada, Lin, and 3 others, 2 unread"
153
+ * participants={[ada, lin, mira, noah, sam]}
154
+ * threadCount={6}
155
+ * unreadCount={2}
156
+ * isSelected
157
+ * onClick={() => openCluster('cluster-1')}
158
+ * />
159
+ * ```
160
+ */
161
+ export function CommentPin({
162
+ label,
163
+ participants,
164
+ threadCount = 1,
165
+ unreadCount = 0,
166
+ isSelected = false,
167
+ isDimmed = false,
168
+ isResolved = false,
169
+ isDisabled = false,
170
+ ref,
171
+ xstyle,
172
+ className,
173
+ style,
174
+ ...rest
175
+ }) {
176
+ const validThreadCount = isValidThreadCount(threadCount);
177
+ const resolvedThreadCount = validThreadCount ? threadCount : 1;
178
+ const isGrouped = resolvedThreadCount > 1;
179
+ const validUnreadCount = isValidUnreadCount(unreadCount);
180
+ const resolvedUnreadCount = validUnreadCount ? Math.min(unreadCount, resolvedThreadCount) : 0;
181
+ const hasUnread = resolvedUnreadCount > 0;
182
+
183
+ // Grouped pins cap at MAX_GROUP_CIRCLES circles: every distinct participant
184
+ // when they fit, otherwise one fewer Avatar plus a `+N` overflow circle.
185
+ const distinctParticipants = takeDistinctParticipants(participants, isGrouped ? Number.POSITIVE_INFINITY : 1);
186
+ const hasOverflow = isGrouped && distinctParticipants.length > MAX_GROUP_CIRCLES;
187
+ const visibleParticipants = hasOverflow ? distinctParticipants.slice(0, MAX_GROUP_CIRCLES - 1) : distinctParticipants;
188
+ const overflowCount = distinctParticipants.length - visibleParticipants.length;
189
+ useDevWarning('CommentPin', '`participants` should contain at least one participant. Pass the lead participant for a single thread or every distinct participant for a group.', participants.length === 0);
190
+ useDevWarning('CommentPin', '`threadCount` must be a finite positive integer. Invalid values fall back to 1.', !validThreadCount);
191
+ useDevWarning('CommentPin', '`unreadCount` must be a finite non-negative integer no greater than `threadCount`. Invalid values are ignored and larger values are capped.', !validUnreadCount || unreadCount > resolvedThreadCount);
192
+ useDevWarning('CommentPin', '`label` must be a non-empty accessible action name.', label.trim() === '');
193
+ const pressFeedback = usePressFeedback();
194
+ const hasTooltip = !isDisabled && label.trim() !== '';
195
+ const tooltip = useTooltip({
196
+ placement: 'above',
197
+ isEnabled: hasTooltip
198
+ });
199
+ const mergedRef = useMergedRefs(ref, hasTooltip ? tooltip.ref : undefined);
200
+ const avatarParticipants = visibleParticipants.length > 0 ? visibleParticipants : [{
201
+ id: '__anonymous__',
202
+ name: '',
203
+ avatarSrc: undefined
204
+ }];
205
+ const marker = /*#__PURE__*/_jsxs("button", {
206
+ ...rest,
207
+ ...pressFeedback,
208
+ ref: mergedRef,
209
+ type: "button",
210
+ "aria-label": label,
211
+ "aria-pressed": isSelected,
212
+ disabled: isDisabled,
213
+ ...mergeProps(themeProps('comment-pin', {
214
+ grouped: isGrouped ? 'grouped' : null,
215
+ unread: hasUnread ? 'unread' : null,
216
+ selected: isSelected ? 'selected' : null,
217
+ dimmed: isDimmed ? 'dimmed' : null,
218
+ resolved: isResolved ? 'resolved' : null,
219
+ disabled: isDisabled ? 'disabled' : null
220
+ }), focusOutlineProps.focusVisible(styles.root, interactionOverlayStyles.backgroundImage, (isGrouped || hasUnread) && styles.withCount, isResolved && !isSelected && styles.resolved, isDimmed && !isSelected && styles.dimmed, isSelected && styles.selected, isDisabled && styles.disabled, xstyle), className, style),
221
+ children: [/*#__PURE__*/_jsx("span", {
222
+ "aria-hidden": "true",
223
+ ...{
224
+ className: "x3nfvp2 x6s0dn4 x2lah0s"
225
+ },
226
+ children: isGrouped ? /*#__PURE__*/_jsxs(AvatarGroup, {
227
+ size: "xsm",
228
+ children: [avatarParticipants.map(participant => /*#__PURE__*/_jsx(Avatar, {
229
+ name: participant.name,
230
+ src: participant.avatarSrc,
231
+ tooltip: false
232
+ }, participant.id)), overflowCount > 0 ? /*#__PURE__*/_jsx(AvatarGroupOverflow, {
233
+ count: overflowCount,
234
+ xstyle: styles.overflowCircle
235
+ }) : null]
236
+ }) : avatarParticipants.map(participant => /*#__PURE__*/_jsx(Avatar, {
237
+ name: participant.name,
238
+ src: participant.avatarSrc,
239
+ size: "xsm",
240
+ tooltip: false
241
+ }, participant.id))
242
+ }), hasUnread ? /*#__PURE__*/_jsx("span", {
243
+ "aria-hidden": "true",
244
+ ...{
245
+ className: "x1kzknox x3nfvp2 x6s0dn4 xl56j7k x9f619 x16asifk x1grt7ep x7a5moj xjspbzw x1ewilqj x1jzqe4 x17wrial x1k5gbb1 xss6m8b xo5v014"
246
+ },
247
+ children: resolvedUnreadCount
248
+ }) : isGrouped ? /*#__PURE__*/_jsx("span", {
249
+ "aria-hidden": "true",
250
+ ...{
251
+ className: "x1rg5ohu x163how x1heor9g xss6m8b x2b8uid"
252
+ },
253
+ children: resolvedThreadCount
254
+ }) : null]
255
+ });
256
+ return /*#__PURE__*/_jsxs(_Fragment, {
257
+ children: [marker, hasTooltip ? tooltip.renderTooltip(label) : null]
258
+ });
259
+ }
260
+ CommentPin.displayName = 'CommentPin';
@@ -0,0 +1,9 @@
1
+ /**
2
+ * @file index.ts
3
+ * @input CommentPin implementation and public types
4
+ * @output CommentPin module exports
5
+ * @position Public Lab subpath; re-exported by packages/lab/src/index.ts
6
+ */
7
+ export { CommentPin } from './CommentPin';
8
+ export type { CommentPinParticipant, CommentPinProps } from './CommentPin';
9
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/CommentPin/index.ts"],"names":[],"mappings":"AAIA;;;;;GAKG;AAEH,OAAO,EAAC,UAAU,EAAC,MAAM,cAAc,CAAC;AACxC,YAAY,EAAC,qBAAqB,EAAE,eAAe,EAAC,MAAM,cAAc,CAAC"}
@@ -0,0 +1,11 @@
1
+ // Copyright (c) Meta Platforms, Inc. and affiliates.
2
+
3
+ 'use client';
4
+
5
+ /**
6
+ * @file index.ts
7
+ * @input CommentPin implementation and public types
8
+ * @output CommentPin module exports
9
+ * @position Public Lab subpath; re-exported by packages/lab/src/index.ts
10
+ */
11
+ export { CommentPin } from "./CommentPin.js";
@@ -0,0 +1,55 @@
1
+ /**
2
+ * @file CommentActions.tsx
3
+ * @input Uses React, React DOM flushSync, StyleX, IconButton, Button, Tooltip,
4
+ * ToggleButton, OverflowList, DropdownMenu, Popover, Text
5
+ * @output Exports CommentActions (a comment's header actions), ReactionSummary
6
+ * (its reaction toggles), and the action-lookup helpers rows use for focus
7
+ * hand-offs
8
+ * @position Internal parts of a comment row in the Comments family
9
+ */
10
+ import { type ReactNode } from 'react';
11
+ import { type DropdownMenuOption } from '@astryxdesign/core/DropdownMenu';
12
+ import { type AnyComment } from './utils';
13
+ import type { CommentReactionOption } from './types';
14
+ export type CommentActionId = 'resolve' | 'reopen' | 'react' | 'reply' | 'link';
15
+ /** Mark as resolved on an open thread, Reopen on a resolved one. */
16
+ export type ResolveAction = {
17
+ kind: 'resolve' | 'reopen';
18
+ onClick: () => void;
19
+ };
20
+ /** One of a comment's action buttons, as it shows. OverflowList renders a
21
+ * hidden copy of every item to measure it; only the copy in the visible list
22
+ * can take focus. */
23
+ export declare function visibleCommentAction(root: HTMLElement | null, action: CommentActionId): HTMLElement | null;
24
+ export declare function commentMoreMenuTrigger(root: HTMLElement | null): HTMLElement | null;
25
+ /** A comment's reactions: a toggle for each, pressed where the viewer reacted. */
26
+ export declare function ReactionSummary({ canReact, comment, isBusy, onReact, }: {
27
+ canReact: boolean;
28
+ comment: AnyComment;
29
+ isBusy: boolean;
30
+ onReact: (comment: AnyComment, key: string) => void;
31
+ }): import("react").JSX.Element | null;
32
+ /**
33
+ * A comment's actions, in its header's top-end corner: Mark as resolved or
34
+ * Reopen, Add reaction, Reply, and Copy link as icon buttons, then the more
35
+ * menu. When the header runs out of room the buttons collapse into the more
36
+ * menu, Copy link first, beside Edit and Delete where the viewer may use them.
37
+ */
38
+ export declare function CommentActions({ additionalActions, canCopyLink, canReact, canReply, comment, isBusy, menuItems, menuLabel, onOpenChange, onReact, onReply, options, resolveAction, }: {
39
+ additionalActions?: ReactNode;
40
+ canCopyLink: boolean;
41
+ canReact: boolean;
42
+ canReply: boolean;
43
+ comment: AnyComment;
44
+ isBusy: boolean;
45
+ /** Edit and Delete, where the viewer may use them. */
46
+ menuItems: readonly DropdownMenuOption[];
47
+ menuLabel: string;
48
+ /** Pins the revealed actions while the picker or the menu is open. */
49
+ onOpenChange: (isOpen: boolean) => void;
50
+ onReact: (comment: AnyComment, key: string, option?: CommentReactionOption) => void;
51
+ onReply: () => void;
52
+ options: readonly CommentReactionOption[];
53
+ resolveAction?: ResolveAction;
54
+ }): import("react").JSX.Element;
55
+ //# sourceMappingURL=CommentActions.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"CommentActions.d.ts","sourceRoot":"","sources":["../../src/Comments/CommentActions.tsx"],"names":[],"mappings":"AAIA;;;;;;;;GAQG;AAEH,OAAO,EAA2C,KAAK,SAAS,EAAC,MAAM,OAAO,CAAC;AAI/E,OAAO,EAEL,KAAK,kBAAkB,EACxB,MAAM,iCAAiC,CAAC;AAazC,OAAO,EAAkB,KAAK,UAAU,EAAC,MAAM,SAAS,CAAC;AACzD,OAAO,KAAK,EAAkB,qBAAqB,EAAC,MAAM,SAAS,CAAC;AAoBpE,MAAM,MAAM,eAAe,GAAG,SAAS,GAAG,QAAQ,GAAG,OAAO,GAAG,OAAO,GAAG,MAAM,CAAC;AAEhF,oEAAoE;AACpE,MAAM,MAAM,aAAa,GAAG;IAAC,IAAI,EAAE,SAAS,GAAG,QAAQ,CAAC;IAAC,OAAO,EAAE,MAAM,IAAI,CAAA;CAAC,CAAC;AAE9E;;sBAEsB;AACtB,wBAAgB,oBAAoB,CAClC,IAAI,EAAE,WAAW,GAAG,IAAI,EACxB,MAAM,EAAE,eAAe,GACtB,WAAW,GAAG,IAAI,CAMpB;AAED,wBAAgB,sBAAsB,CACpC,IAAI,EAAE,WAAW,GAAG,IAAI,GACvB,WAAW,GAAG,IAAI,CAIpB;AAiCD,kFAAkF;AAClF,wBAAgB,eAAe,CAAC,EAC9B,QAAQ,EACR,OAAO,EACP,MAAM,EACN,OAAO,GACR,EAAE;IACD,QAAQ,EAAE,OAAO,CAAC;IAClB,OAAO,EAAE,UAAU,CAAC;IACpB,MAAM,EAAE,OAAO,CAAC;IAChB,OAAO,EAAE,CAAC,OAAO,EAAE,UAAU,EAAE,GAAG,EAAE,MAAM,KAAK,IAAI,CAAC;CACrD,sCA0CA;AAkDD;;;;;GAKG;AACH,wBAAgB,cAAc,CAAC,EAC7B,iBAAiB,EACjB,WAAW,EACX,QAAQ,EACR,QAAQ,EACR,OAAO,EACP,MAAM,EACN,SAAS,EACT,SAAS,EACT,YAAY,EACZ,OAAO,EACP,OAAO,EACP,OAAO,EACP,aAAa,GACd,EAAE;IACD,iBAAiB,CAAC,EAAE,SAAS,CAAC;IAC9B,WAAW,EAAE,OAAO,CAAC;IACrB,QAAQ,EAAE,OAAO,CAAC;IAClB,QAAQ,EAAE,OAAO,CAAC;IAClB,OAAO,EAAE,UAAU,CAAC;IACpB,MAAM,EAAE,OAAO,CAAC;IAChB,sDAAsD;IACtD,SAAS,EAAE,SAAS,kBAAkB,EAAE,CAAC;IACzC,SAAS,EAAE,MAAM,CAAC;IAClB,sEAAsE;IACtE,YAAY,EAAE,CAAC,MAAM,EAAE,OAAO,KAAK,IAAI,CAAC;IACxC,OAAO,EAAE,CACP,OAAO,EAAE,UAAU,EACnB,GAAG,EAAE,MAAM,EACX,MAAM,CAAC,EAAE,qBAAqB,KAC3B,IAAI,CAAC;IACV,OAAO,EAAE,MAAM,IAAI,CAAC;IACpB,OAAO,EAAE,SAAS,qBAAqB,EAAE,CAAC;IAC1C,aAAa,CAAC,EAAE,aAAa,CAAC;CAC/B,+BA6RA"}