@flamingo-stack/openframe-frontend-core 0.0.617 → 0.0.618
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/dist/{chunk-CGCV4QT2.js → chunk-2DTZXXY3.js} +5 -5
- package/dist/{chunk-BJDQZH62.cjs → chunk-3FTNQDLP.cjs} +5 -5
- package/dist/{chunk-BJDQZH62.cjs.map → chunk-3FTNQDLP.cjs.map} +1 -1
- package/dist/{chunk-VJJ7LGOI.js → chunk-5P74E24M.js} +5 -5
- package/dist/{chunk-BLUL2TE3.js → chunk-6XJS3WU7.js} +2 -2
- package/dist/{chunk-QPAPUIF3.cjs → chunk-7ZEQMFP3.cjs} +30 -30
- package/dist/{chunk-QPAPUIF3.cjs.map → chunk-7ZEQMFP3.cjs.map} +1 -1
- package/dist/{chunk-UVK7AQAG.js → chunk-ANMD7SM4.js} +3 -3
- package/dist/{chunk-332JHI2D.cjs → chunk-BGDYSUA2.cjs} +11 -11
- package/dist/{chunk-332JHI2D.cjs.map → chunk-BGDYSUA2.cjs.map} +1 -1
- package/dist/{chunk-USP3UWID.cjs → chunk-BXNSKTEG.cjs} +57 -57
- package/dist/{chunk-USP3UWID.cjs.map → chunk-BXNSKTEG.cjs.map} +1 -1
- package/dist/{chunk-67XFJ442.cjs → chunk-CM6DNLK7.cjs} +521 -449
- package/dist/chunk-CM6DNLK7.cjs.map +1 -0
- package/dist/{chunk-7YHUP5BR.js → chunk-CWMKY2UJ.js} +3 -3
- package/dist/{chunk-UQEOAPAI.cjs → chunk-E2EGTHYA.cjs} +28 -12
- package/dist/chunk-E2EGTHYA.cjs.map +1 -0
- package/dist/{chunk-JZELYIFZ.cjs → chunk-E7VXPU3R.cjs} +33 -33
- package/dist/{chunk-JZELYIFZ.cjs.map → chunk-E7VXPU3R.cjs.map} +1 -1
- package/dist/{chunk-ULM5FCFN.cjs → chunk-EJGZIYC7.cjs} +6 -6
- package/dist/{chunk-ULM5FCFN.cjs.map → chunk-EJGZIYC7.cjs.map} +1 -1
- package/dist/{chunk-LFLJ3IHE.cjs → chunk-EXEXX34Q.cjs} +28 -28
- package/dist/{chunk-LFLJ3IHE.cjs.map → chunk-EXEXX34Q.cjs.map} +1 -1
- package/dist/{chunk-FP5WYJ3S.js → chunk-FCN2HN6Q.js} +2 -2
- package/dist/{chunk-2OJVGAGX.cjs → chunk-G7NEMLNW.cjs} +10 -10
- package/dist/{chunk-2OJVGAGX.cjs.map → chunk-G7NEMLNW.cjs.map} +1 -1
- package/dist/{chunk-GH4F4ODL.js → chunk-GD7CV2JI.js} +6 -6
- package/dist/{chunk-WFM5OAM6.js → chunk-GFWKEWEH.js} +4 -4
- package/dist/{chunk-RU3IKVY2.js → chunk-GXUGYZ6H.js} +27 -11
- package/dist/chunk-GXUGYZ6H.js.map +1 -0
- package/dist/{chunk-ZQOK4TCN.cjs → chunk-IDMEC4ZK.cjs} +22 -22
- package/dist/{chunk-ZQOK4TCN.cjs.map → chunk-IDMEC4ZK.cjs.map} +1 -1
- package/dist/{chunk-UVXMIZYK.js → chunk-IPHA3AQ6.js} +7 -7
- package/dist/{chunk-45OAW4M2.js → chunk-J25M43YI.js} +6 -6
- package/dist/{chunk-V23BJC2Q.cjs → chunk-K26VN65M.cjs} +15 -15
- package/dist/{chunk-V23BJC2Q.cjs.map → chunk-K26VN65M.cjs.map} +1 -1
- package/dist/{chunk-7FFKXXWY.cjs → chunk-MOC7JLEP.cjs} +80 -80
- package/dist/{chunk-7FFKXXWY.cjs.map → chunk-MOC7JLEP.cjs.map} +1 -1
- package/dist/{chunk-ZJYZOOTU.js → chunk-NUU5ZEEG.js} +4 -4
- package/dist/{chunk-VNNIRX23.cjs → chunk-PIJK3FV6.cjs} +3 -3
- package/dist/{chunk-VNNIRX23.cjs.map → chunk-PIJK3FV6.cjs.map} +1 -1
- package/dist/{chunk-HR6CHKD6.cjs → chunk-RDEFB354.cjs} +6 -6
- package/dist/{chunk-HR6CHKD6.cjs.map → chunk-RDEFB354.cjs.map} +1 -1
- package/dist/{chunk-7GLJC4EO.cjs → chunk-ROQTWRV7.cjs} +145 -145
- package/dist/{chunk-7GLJC4EO.cjs.map → chunk-ROQTWRV7.cjs.map} +1 -1
- package/dist/{chunk-6RMFEGJ4.js → chunk-RROIA6WY.js} +2 -2
- package/dist/{chunk-FMNS5NN2.cjs → chunk-U6B3MM4U.cjs} +20 -20
- package/dist/{chunk-FMNS5NN2.cjs.map → chunk-U6B3MM4U.cjs.map} +1 -1
- package/dist/{chunk-TRY3CUWJ.cjs → chunk-UKFBPJBK.cjs} +29 -29
- package/dist/{chunk-TRY3CUWJ.cjs.map → chunk-UKFBPJBK.cjs.map} +1 -1
- package/dist/{chunk-5KKLN7Q2.js → chunk-UUXLDIK3.js} +3 -3
- package/dist/{chunk-HGPGF6SF.js → chunk-VRN5YYD3.js} +3 -3
- package/dist/{chunk-CXEGV3ZS.js → chunk-WVRXDGGP.js} +3 -3
- package/dist/{chunk-RZURBPBS.js → chunk-XUNFDRMP.js} +3 -3
- package/dist/{chunk-VHS3OYE4.js → chunk-YCZBCEQO.js} +2531 -2459
- package/dist/chunk-YCZBCEQO.js.map +1 -0
- package/dist/components/case-studies/index.cjs +10 -10
- package/dist/components/case-studies/index.js +4 -4
- package/dist/components/chat/index.cjs +3 -3
- package/dist/components/chat/index.js +2 -2
- package/dist/components/contact/index.cjs +5 -5
- package/dist/components/contact/index.js +4 -4
- package/dist/components/docs/index.cjs +8 -8
- package/dist/components/docs/index.js +7 -7
- package/dist/components/embeds/index.cjs +5 -5
- package/dist/components/embeds/index.js +4 -4
- package/dist/components/faq/index.cjs +5 -5
- package/dist/components/faq/index.js +4 -4
- package/dist/components/features/index.cjs +4 -4
- package/dist/components/features/index.js +3 -3
- package/dist/components/help-center-pages/index.cjs +24 -24
- package/dist/components/help-center-pages/index.js +15 -15
- package/dist/components/index.cjs +57 -53
- package/dist/components/index.cjs.map +1 -1
- package/dist/components/index.js +19 -15
- package/dist/components/index.js.map +1 -1
- package/dist/components/meeting-scheduler/index.cjs +34 -34
- package/dist/components/meeting-scheduler/index.cjs.map +1 -1
- package/dist/components/meeting-scheduler/index.js +5 -5
- package/dist/components/meeting-scheduler/index.js.map +1 -1
- package/dist/components/navigation/index.cjs +7 -7
- package/dist/components/navigation/index.js +6 -6
- package/dist/components/onboarding-guides/index.cjs +7 -7
- package/dist/components/onboarding-guides/index.js +6 -6
- package/dist/components/related-content/index.cjs +3 -3
- package/dist/components/related-content/index.js +2 -2
- package/dist/components/tickets/index.cjs +8 -8
- package/dist/components/tickets/index.js +7 -7
- package/dist/components/ui/avatar-stack.d.ts +16 -3
- package/dist/components/ui/avatar-stack.d.ts.map +1 -1
- package/dist/components/ui/index.cjs +8 -4
- package/dist/components/ui/index.cjs.map +1 -1
- package/dist/components/ui/index.d.ts +1 -0
- package/dist/components/ui/index.d.ts.map +1 -1
- package/dist/components/ui/index.js +7 -3
- package/dist/components/ui/people-cell.d.ts +46 -0
- package/dist/components/ui/people-cell.d.ts.map +1 -0
- package/dist/index.cjs +14 -8
- package/dist/index.cjs.map +1 -1
- package/dist/index.js +13 -7
- package/dist/index.js.map +1 -1
- package/dist/utils/format.d.ts +8 -0
- package/dist/utils/format.d.ts.map +1 -1
- package/dist/utils/index.cjs +5 -0
- package/dist/utils/index.cjs.map +1 -1
- package/dist/utils/index.d.ts +1 -1
- package/dist/utils/index.d.ts.map +1 -1
- package/dist/utils/index.js +5 -1
- package/dist/utils/index.js.map +1 -1
- package/package.json +1 -1
- package/src/components/meeting-scheduler/context-panel.tsx +1 -1
- package/src/components/meeting-scheduler/directory.tsx +1 -1
- package/src/components/ui/__tests__/people-cell.test.tsx +97 -0
- package/src/components/ui/avatar-stack.tsx +40 -13
- package/src/components/ui/index.ts +1 -0
- package/src/components/ui/people-cell.tsx +133 -0
- package/src/components/ui/table/__tests__/header-hint.test.tsx +2 -2
- package/src/utils/format.ts +13 -0
- package/src/utils/index.ts +1 -0
- package/dist/chunk-67XFJ442.cjs.map +0 -1
- package/dist/chunk-RU3IKVY2.js.map +0 -1
- package/dist/chunk-UQEOAPAI.cjs.map +0 -1
- package/dist/chunk-VHS3OYE4.js.map +0 -1
- /package/dist/{chunk-CGCV4QT2.js.map → chunk-2DTZXXY3.js.map} +0 -0
- /package/dist/{chunk-VJJ7LGOI.js.map → chunk-5P74E24M.js.map} +0 -0
- /package/dist/{chunk-BLUL2TE3.js.map → chunk-6XJS3WU7.js.map} +0 -0
- /package/dist/{chunk-UVK7AQAG.js.map → chunk-ANMD7SM4.js.map} +0 -0
- /package/dist/{chunk-7YHUP5BR.js.map → chunk-CWMKY2UJ.js.map} +0 -0
- /package/dist/{chunk-FP5WYJ3S.js.map → chunk-FCN2HN6Q.js.map} +0 -0
- /package/dist/{chunk-GH4F4ODL.js.map → chunk-GD7CV2JI.js.map} +0 -0
- /package/dist/{chunk-WFM5OAM6.js.map → chunk-GFWKEWEH.js.map} +0 -0
- /package/dist/{chunk-UVXMIZYK.js.map → chunk-IPHA3AQ6.js.map} +0 -0
- /package/dist/{chunk-45OAW4M2.js.map → chunk-J25M43YI.js.map} +0 -0
- /package/dist/{chunk-ZJYZOOTU.js.map → chunk-NUU5ZEEG.js.map} +0 -0
- /package/dist/{chunk-6RMFEGJ4.js.map → chunk-RROIA6WY.js.map} +0 -0
- /package/dist/{chunk-5KKLN7Q2.js.map → chunk-UUXLDIK3.js.map} +0 -0
- /package/dist/{chunk-HGPGF6SF.js.map → chunk-VRN5YYD3.js.map} +0 -0
- /package/dist/{chunk-CXEGV3ZS.js.map → chunk-WVRXDGGP.js.map} +0 -0
- /package/dist/{chunk-RZURBPBS.js.map → chunk-XUNFDRMP.js.map} +0 -0
package/package.json
CHANGED
|
@@ -222,7 +222,7 @@ export function SchedulerContextPanel({
|
|
|
222
222
|
)}
|
|
223
223
|
{hosts.length > 3 && (
|
|
224
224
|
<div className="flex flex-col gap-[var(--spacing-system-xs)]">
|
|
225
|
-
<AvatarStack people={hosts} max={4} size="lg" />
|
|
225
|
+
<AvatarStack people={hosts} max={4} size="lg" label="Hosts" />
|
|
226
226
|
<p className="text-ods-text-secondary text-h6">{hosts.length} hosts on this calendar</p>
|
|
227
227
|
</div>
|
|
228
228
|
)}
|
|
@@ -114,7 +114,7 @@ function DirectoryRow({
|
|
|
114
114
|
{/* Hosts stay visible on mobile too — the facepile is the row's "who
|
|
115
115
|
you're booking with" signal; only the chip and next-available meta
|
|
116
116
|
collapse on narrow widths. */}
|
|
117
|
-
<AvatarStack people={link.hosts} max={3} size="md" className="flex shrink-0" />
|
|
117
|
+
<AvatarStack people={link.hosts} max={3} size="md" label="Hosts" className="flex shrink-0" />
|
|
118
118
|
|
|
119
119
|
<div className="hidden w-44 shrink-0 flex-col items-end justify-center md:flex">
|
|
120
120
|
<p className="text-ods-text-secondary text-h6">Next available</p>
|
|
@@ -0,0 +1,97 @@
|
|
|
1
|
+
import { render, screen } from '@testing-library/react';
|
|
2
|
+
import { describe, expect, it } from 'vitest';
|
|
3
|
+
|
|
4
|
+
import { personFirstName } from '../../../utils/format';
|
|
5
|
+
import { AvatarStack } from '../avatar-stack';
|
|
6
|
+
import { PeopleCell, PersonCell } from '../people-cell';
|
|
7
|
+
|
|
8
|
+
/**
|
|
9
|
+
* The people-column contract, pinned at the primitive:
|
|
10
|
+
*
|
|
11
|
+
* · one person reads as ONE layout wherever it appears (name + second line),
|
|
12
|
+
* so a single implementation owner and a DRI look identical;
|
|
13
|
+
* · several people become first names beside a FIXED-width stack, so every
|
|
14
|
+
* multi-person row's names start at the same x;
|
|
15
|
+
* · the "+N" count, and the group's accessible name, say what they mean.
|
|
16
|
+
*/
|
|
17
|
+
|
|
18
|
+
const person = (name: string, key: string | number = name) => ({
|
|
19
|
+
key,
|
|
20
|
+
name,
|
|
21
|
+
avatarUrl: null,
|
|
22
|
+
secondary: `${name} title`,
|
|
23
|
+
});
|
|
24
|
+
|
|
25
|
+
describe('personFirstName', () => {
|
|
26
|
+
it('takes the first word, ignoring surrounding whitespace', () => {
|
|
27
|
+
expect(personFirstName(' Ada Lovelace ')).toBe('Ada');
|
|
28
|
+
});
|
|
29
|
+
it('falls back on an empty or missing name', () => {
|
|
30
|
+
expect(personFirstName(' ')).toBeNull();
|
|
31
|
+
expect(personFirstName(null, 'friend')).toBe('friend');
|
|
32
|
+
});
|
|
33
|
+
});
|
|
34
|
+
|
|
35
|
+
describe('PersonCell', () => {
|
|
36
|
+
it('renders the name and the second line', () => {
|
|
37
|
+
render(<PersonCell name="Ada Lovelace" secondary="Engineer" />);
|
|
38
|
+
expect(screen.getByText('Ada Lovelace')).toBeTruthy();
|
|
39
|
+
expect(screen.getByText('Engineer')).toBeTruthy();
|
|
40
|
+
});
|
|
41
|
+
it('marks an expected-but-missing second line, and names the empty state', () => {
|
|
42
|
+
render(<PersonCell secondary={null} />);
|
|
43
|
+
expect(screen.getByText('Unassigned')).toBeTruthy();
|
|
44
|
+
expect(screen.getByText('·')).toBeTruthy();
|
|
45
|
+
});
|
|
46
|
+
it('becomes a button when clickable', () => {
|
|
47
|
+
render(<PersonCell name="Ada" onClick={() => {}} actionTitle="Filter by Ada" />);
|
|
48
|
+
expect(screen.getByRole('button', { name: /Ada/ }).getAttribute('title')).toBe('Filter by Ada');
|
|
49
|
+
});
|
|
50
|
+
});
|
|
51
|
+
|
|
52
|
+
describe('PeopleCell', () => {
|
|
53
|
+
it('renders one person exactly as PersonCell does', () => {
|
|
54
|
+
const { container: single } = render(<PeopleCell people={[person('Ada Lovelace')]} />);
|
|
55
|
+
const { container: direct } = render(<PersonCell name="Ada Lovelace" secondary="Ada Lovelace title" />);
|
|
56
|
+
expect(single.innerHTML).toBe(direct.innerHTML);
|
|
57
|
+
});
|
|
58
|
+
|
|
59
|
+
it('joins first names with & and keeps the full names for assistive tech', () => {
|
|
60
|
+
render(<PeopleCell people={[person('Dmytro K'), person('Michael A'), person('Ilona K')]} />);
|
|
61
|
+
expect(screen.getByText('Dmytro & Michael & Ilona')).toBeTruthy();
|
|
62
|
+
expect(screen.getByText('Dmytro K, Michael A, Ilona K')).toBeTruthy();
|
|
63
|
+
expect(screen.queryByText('Dmytro K title')).toBeNull();
|
|
64
|
+
});
|
|
65
|
+
|
|
66
|
+
it('reserves the same stack width for two people and for five', () => {
|
|
67
|
+
const width = (count: number) => {
|
|
68
|
+
const { unmount } = render(<PeopleCell people={Array.from({ length: count }, (_, i) => person(`P${i} X`, i))} />);
|
|
69
|
+
// `hidden`: the stack is decorative (aria-hidden) beside the names.
|
|
70
|
+
const value = screen.getByRole('group', { hidden: true }).style.width;
|
|
71
|
+
unmount();
|
|
72
|
+
return value;
|
|
73
|
+
};
|
|
74
|
+
expect(width(2)).toBe('52px');
|
|
75
|
+
expect(width(5)).toBe('52px');
|
|
76
|
+
});
|
|
77
|
+
});
|
|
78
|
+
|
|
79
|
+
describe('AvatarStack', () => {
|
|
80
|
+
it('in slots mode shows slots-1 faces and a count for the rest', () => {
|
|
81
|
+
render(<AvatarStack size="sm" slots={2} people={[person('A'), person('B'), person('C')]} />);
|
|
82
|
+
expect(screen.getByText('+2')).toBeTruthy();
|
|
83
|
+
expect(screen.getAllByTitle(/^[ABC]$/)).toHaveLength(1);
|
|
84
|
+
});
|
|
85
|
+
it('fills every slot with a face when the people fit', () => {
|
|
86
|
+
render(<AvatarStack size="sm" slots={2} people={[person('A'), person('B')]} />);
|
|
87
|
+
expect(screen.queryByText(/^\+/)).toBeNull();
|
|
88
|
+
});
|
|
89
|
+
it('names the group after what the people are', () => {
|
|
90
|
+
render(<AvatarStack label="Hosts" people={[person('Ada'), person('Lin')]} />);
|
|
91
|
+
expect(screen.getByRole('group', { name: 'Hosts: Ada, Lin' })).toBeTruthy();
|
|
92
|
+
});
|
|
93
|
+
it('defaults the group name to Assignees', () => {
|
|
94
|
+
render(<AvatarStack people={[person('Ada')]} />);
|
|
95
|
+
expect(screen.getByRole('group', { name: 'Assignees: Ada' })).toBeTruthy();
|
|
96
|
+
});
|
|
97
|
+
});
|
|
@@ -19,43 +19,66 @@ export interface AvatarStackPerson {
|
|
|
19
19
|
key?: string | number;
|
|
20
20
|
}
|
|
21
21
|
|
|
22
|
+
type AvatarStackSize = 'xs' | 'sm' | 'md' | 'lg';
|
|
23
|
+
|
|
22
24
|
export interface AvatarStackProps {
|
|
23
25
|
people: AvatarStackPerson[];
|
|
24
|
-
/** Avatars shown before collapsing into the "+N" circle. */
|
|
26
|
+
/** Avatars shown before collapsing into the "+N" circle. Ignored when `slots` is set. */
|
|
25
27
|
max?: number;
|
|
28
|
+
/**
|
|
29
|
+
* FIXED-WIDTH mode: the stack always occupies exactly `slots` positions, the
|
|
30
|
+
* "+N" circle counting as one. Up to `slots` people show as faces; more show
|
|
31
|
+
* `slots - 1` faces and the circle. Use it wherever rows must line up (a
|
|
32
|
+
* table column): the width no longer depends on how many people a row holds,
|
|
33
|
+
* so the text beside every stack starts at the same x.
|
|
34
|
+
*/
|
|
35
|
+
slots?: number;
|
|
26
36
|
/** Size bucket (also sizes the "+N" circle). `xs` (24px) is for
|
|
27
37
|
* dense card meta rows (chat compact cards, delivery rows). */
|
|
28
|
-
size?:
|
|
38
|
+
size?: AvatarStackSize;
|
|
29
39
|
/** Ring color class separating overlapped avatars from each other —
|
|
30
40
|
* MUST match the surface the stack sits on (default: card surface).
|
|
31
41
|
* Without the surface-colored ring, overlapping photos read as one
|
|
32
42
|
* smeared blob — the ring is what makes a stack look deliberate. */
|
|
33
43
|
ringClassName?: string;
|
|
44
|
+
/** What these people ARE, for the group's accessible name ("Hosts: Ada, Lin").
|
|
45
|
+
* Default "Assignees". */
|
|
46
|
+
label?: string;
|
|
34
47
|
className?: string;
|
|
35
48
|
}
|
|
36
49
|
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
50
|
+
/** Face diameter and how far each later face tucks under the previous one — the
|
|
51
|
+
* `SquareAvatar` buckets and the `-ml-*` classes below, in px, for `slots`. */
|
|
52
|
+
const SIZE_PX: Record<AvatarStackSize, number> = { xs: 24, sm: 32, md: 40, lg: 48 };
|
|
53
|
+
const OVERLAP_PX: Record<AvatarStackSize, number> = { xs: 8, sm: 12, md: 12, lg: 12 };
|
|
54
|
+
|
|
55
|
+
const OVERFLOW_CIRCLE_SIZE: Record<AvatarStackSize, string> = {
|
|
56
|
+
xs: 'h-6 min-w-6',
|
|
57
|
+
sm: 'h-8 min-w-8',
|
|
58
|
+
md: 'h-10 min-w-10',
|
|
59
|
+
lg: 'h-12 min-w-12',
|
|
42
60
|
};
|
|
43
61
|
|
|
44
62
|
export function AvatarStack({
|
|
45
63
|
people,
|
|
46
64
|
max = 3,
|
|
65
|
+
slots,
|
|
47
66
|
size = 'md',
|
|
48
67
|
ringClassName = 'ring-ods-card',
|
|
68
|
+
label = 'Assignees',
|
|
49
69
|
className,
|
|
50
70
|
}: AvatarStackProps) {
|
|
51
71
|
if (people.length === 0) return null;
|
|
52
|
-
const
|
|
53
|
-
const
|
|
72
|
+
const faces = slots ? (people.length > slots ? slots - 1 : slots) : max;
|
|
73
|
+
const visible = people.slice(0, faces);
|
|
74
|
+
const overflow = people.slice(faces);
|
|
75
|
+
const compact = size === 'xs';
|
|
54
76
|
return (
|
|
55
77
|
<div
|
|
56
|
-
className={cn('flex items-center', className)}
|
|
78
|
+
className={cn('flex items-center', slots && 'shrink-0', className)}
|
|
79
|
+
style={slots ? { width: SIZE_PX[size] + (slots - 1) * (SIZE_PX[size] - OVERLAP_PX[size]) } : undefined}
|
|
57
80
|
role="group"
|
|
58
|
-
aria-label={
|
|
81
|
+
aria-label={`${label}: ${people.map(p => p.name).join(', ')}`}
|
|
59
82
|
>
|
|
60
83
|
{visible.map((person, i) => (
|
|
61
84
|
<SquareAvatar
|
|
@@ -66,7 +89,7 @@ export function AvatarStack({
|
|
|
66
89
|
alt={person.name}
|
|
67
90
|
fallback={person.name}
|
|
68
91
|
title={person.name}
|
|
69
|
-
className={cn('relative ring-2', ringClassName, i > 0 && (
|
|
92
|
+
className={cn('relative ring-2', ringClassName, i > 0 && (compact ? '-ml-2' : '-ml-3'))}
|
|
70
93
|
// Leftmost (primary assignee) on TOP — later avatars tuck
|
|
71
94
|
// BEHIND, so the first face is always fully visible.
|
|
72
95
|
style={{ zIndex: visible.length - i }}
|
|
@@ -78,7 +101,11 @@ export function AvatarStack({
|
|
|
78
101
|
className={cn(
|
|
79
102
|
'relative z-0 flex shrink-0 items-center justify-center rounded-full bg-ods-bg text-ods-text-secondary ring-2',
|
|
80
103
|
ringClassName,
|
|
81
|
-
|
|
104
|
+
// The circle tucks under the last face like every other avatar, so
|
|
105
|
+
// its left edge is covered: the left padding equals that overlap,
|
|
106
|
+
// centering "+N" in the part that shows. `min-w` (not a fixed
|
|
107
|
+
// width) lets a two-digit count widen the circle instead of clipping.
|
|
108
|
+
compact ? '-ml-2 pl-2 pr-1 text-badge' : '-ml-3 pl-3 pr-1.5 text-h6',
|
|
82
109
|
OVERFLOW_CIRCLE_SIZE[size],
|
|
83
110
|
)}
|
|
84
111
|
>
|
|
@@ -115,6 +115,7 @@ export * from './page-actions';
|
|
|
115
115
|
export * from './service-card';
|
|
116
116
|
export * from './slider';
|
|
117
117
|
export * from './avatar-stack';
|
|
118
|
+
export * from './people-cell';
|
|
118
119
|
export * from './deleted-user-avatar';
|
|
119
120
|
export * from './square-avatar';
|
|
120
121
|
export * from './tab-selector';
|
|
@@ -0,0 +1,133 @@
|
|
|
1
|
+
'use client';
|
|
2
|
+
|
|
3
|
+
import { personFirstName } from '../../utils/format';
|
|
4
|
+
import { AvatarStack } from './avatar-stack';
|
|
5
|
+
import { Button } from './button';
|
|
6
|
+
import { FloatingTooltip } from './floating-tooltip';
|
|
7
|
+
import { SquareAvatar } from './square-avatar';
|
|
8
|
+
import { TruncateText } from './truncate-text';
|
|
9
|
+
|
|
10
|
+
/**
|
|
11
|
+
* THE person cells for tables and dense lists — one for a single person, one
|
|
12
|
+
* for a column that may hold several — so every column of people in every app
|
|
13
|
+
* reads the same way.
|
|
14
|
+
*
|
|
15
|
+
* - `PersonCell` → avatar, name, then a second line (a title, an email)
|
|
16
|
+
* - `PeopleCell` → zero or one person IS `PersonCell`; several become an
|
|
17
|
+
* `AvatarStack` in a FIXED two-position slot beside their
|
|
18
|
+
* first names ("Dmytro & Michael & Ilona") across both
|
|
19
|
+
* lines. A title per person does not fit, and the names are
|
|
20
|
+
* what the column is read for; the tooltip carries the full
|
|
21
|
+
* names. The fixed slot keeps every multi-person row's names
|
|
22
|
+
* on the same x, whether it holds two people or twelve.
|
|
23
|
+
*/
|
|
24
|
+
|
|
25
|
+
export interface PersonCellProps {
|
|
26
|
+
name?: string | null;
|
|
27
|
+
avatarUrl?: string | null;
|
|
28
|
+
/**
|
|
29
|
+
* The second line: a job title, an email, a department. Omitted keeps the
|
|
30
|
+
* two-line height with an empty line; `null` or `''` (a value that is
|
|
31
|
+
* expected but missing) renders a `·` placeholder.
|
|
32
|
+
*/
|
|
33
|
+
secondary?: string | null;
|
|
34
|
+
/** Shown when there is no name — "Unassigned", "Unknown", … */
|
|
35
|
+
fallbackName?: string;
|
|
36
|
+
/** Makes the whole cell a button and the name an accent link (e.g. filter by this person). */
|
|
37
|
+
onClick?: () => void;
|
|
38
|
+
/** Tooltip for the clickable cell ("Filter by ada@example.com"). */
|
|
39
|
+
actionTitle?: string;
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
export function PersonCell({
|
|
43
|
+
name,
|
|
44
|
+
avatarUrl,
|
|
45
|
+
secondary,
|
|
46
|
+
fallbackName = 'Unassigned',
|
|
47
|
+
onClick,
|
|
48
|
+
actionTitle,
|
|
49
|
+
}: PersonCellProps) {
|
|
50
|
+
const displayName = name || fallbackName;
|
|
51
|
+
const row = (
|
|
52
|
+
<div className="group/person-cell flex min-w-0 items-center gap-3">
|
|
53
|
+
<SquareAvatar size="sm" src={avatarUrl ?? undefined} alt={displayName} fallback={displayName} />
|
|
54
|
+
<div className="min-w-0 flex-1">
|
|
55
|
+
<TruncateText
|
|
56
|
+
variant="h6"
|
|
57
|
+
className={onClick ? 'text-ods-accent group-hover/person-cell:underline' : undefined}
|
|
58
|
+
>
|
|
59
|
+
{displayName}
|
|
60
|
+
</TruncateText>
|
|
61
|
+
<TruncateText variant="h6" tone="secondary">
|
|
62
|
+
{secondary === undefined ? ' ' : secondary || '·'}
|
|
63
|
+
</TruncateText>
|
|
64
|
+
</div>
|
|
65
|
+
</div>
|
|
66
|
+
);
|
|
67
|
+
if (!onClick) return row;
|
|
68
|
+
return (
|
|
69
|
+
<Button
|
|
70
|
+
variant="transparent"
|
|
71
|
+
onClick={onClick}
|
|
72
|
+
title={actionTitle}
|
|
73
|
+
// No hover background — only the name underlines. `text-left`: a button
|
|
74
|
+
// centers its text by default, which would center the second line.
|
|
75
|
+
className="h-auto w-full min-w-0 cursor-pointer justify-start bg-transparent p-0 text-left hover:bg-transparent focus:bg-transparent"
|
|
76
|
+
>
|
|
77
|
+
{row}
|
|
78
|
+
</Button>
|
|
79
|
+
);
|
|
80
|
+
}
|
|
81
|
+
|
|
82
|
+
export interface PeopleCellPerson {
|
|
83
|
+
/** Stable render key (a profile id) — names can collide or be blank. */
|
|
84
|
+
key?: string | number;
|
|
85
|
+
name?: string | null;
|
|
86
|
+
avatarUrl?: string | null;
|
|
87
|
+
/** The single-person second line — see `PersonCellProps.secondary`. */
|
|
88
|
+
secondary?: string | null;
|
|
89
|
+
}
|
|
90
|
+
|
|
91
|
+
export interface PeopleCellProps {
|
|
92
|
+
people: PeopleCellPerson[];
|
|
93
|
+
/** Shown when the list is empty — the same slot `PersonCell` fills. */
|
|
94
|
+
fallbackName?: string;
|
|
95
|
+
}
|
|
96
|
+
|
|
97
|
+
/** Positions the multi-person stack reserves: two faces, or one face and "+N". */
|
|
98
|
+
const PEOPLE_CELL_STACK_SLOTS = 2;
|
|
99
|
+
|
|
100
|
+
export function PeopleCell({ people, fallbackName = 'Unassigned' }: PeopleCellProps) {
|
|
101
|
+
if (people.length <= 1) {
|
|
102
|
+
const [person] = people;
|
|
103
|
+
return (
|
|
104
|
+
<PersonCell
|
|
105
|
+
name={person?.name}
|
|
106
|
+
avatarUrl={person?.avatarUrl}
|
|
107
|
+
secondary={person ? person.secondary : undefined}
|
|
108
|
+
fallbackName={fallbackName}
|
|
109
|
+
/>
|
|
110
|
+
);
|
|
111
|
+
}
|
|
112
|
+
const fullNames = people.map(p => p.name || 'Unknown').join(', ');
|
|
113
|
+
return (
|
|
114
|
+
<FloatingTooltip content={fullNames} triggerClassName="min-w-0 max-w-full">
|
|
115
|
+
{/* Same gap and two-line height as `PersonCell`, so the two sit on one rhythm. */}
|
|
116
|
+
<div className="flex min-w-0 items-center gap-3">
|
|
117
|
+
{/* Decorative here: the names are the text right beside it, so the
|
|
118
|
+
stack's own accessible name would read every name twice. */}
|
|
119
|
+
<div aria-hidden className="shrink-0">
|
|
120
|
+
<AvatarStack
|
|
121
|
+
size="sm"
|
|
122
|
+
slots={PEOPLE_CELL_STACK_SLOTS}
|
|
123
|
+
people={people.map(p => ({ key: p.key, name: p.name || 'Unknown', avatarUrl: p.avatarUrl }))}
|
|
124
|
+
/>
|
|
125
|
+
</div>
|
|
126
|
+
<p className="line-clamp-2 min-w-0 flex-1 break-words text-ods-text-primary text-h6">
|
|
127
|
+
<span aria-hidden>{people.map(p => personFirstName(p.name, 'Unknown')).join(' & ')}</span>
|
|
128
|
+
<span className="sr-only">{fullNames}</span>
|
|
129
|
+
</p>
|
|
130
|
+
</div>
|
|
131
|
+
</FloatingTooltip>
|
|
132
|
+
);
|
|
133
|
+
}
|
|
@@ -25,7 +25,7 @@ const data: Row[] = [{ id: '1', name: 'Alpha' }];
|
|
|
25
25
|
// narrow branch, so this file opts into the wide one for its own cases.
|
|
26
26
|
const realMatchMedia = window.matchMedia;
|
|
27
27
|
beforeEach(() => {
|
|
28
|
-
window.matchMedia = (
|
|
28
|
+
window.matchMedia = (query: string) => ({
|
|
29
29
|
matches: true,
|
|
30
30
|
media: query,
|
|
31
31
|
onchange: null,
|
|
@@ -34,7 +34,7 @@ beforeEach(() => {
|
|
|
34
34
|
addListener: () => {},
|
|
35
35
|
removeListener: () => {},
|
|
36
36
|
dispatchEvent: () => false,
|
|
37
|
-
})
|
|
37
|
+
});
|
|
38
38
|
});
|
|
39
39
|
afterEach(() => {
|
|
40
40
|
window.matchMedia = realMatchMedia;
|
package/src/utils/format.ts
CHANGED
|
@@ -207,6 +207,19 @@ export function personInitials(name?: string | null): string {
|
|
|
207
207
|
return nameInitials(name, '', { pick: 'first-last' });
|
|
208
208
|
}
|
|
209
209
|
|
|
210
|
+
/**
|
|
211
|
+
* A PERSON's first name: the first whitespace-delimited word, or `fallback`
|
|
212
|
+
* (default `null`) when there is nothing usable. THE named first-name policy,
|
|
213
|
+
* beside `personInitials`, so a greeting, a byline and a people cell agree on
|
|
214
|
+
* leading whitespace and on an empty name.
|
|
215
|
+
*/
|
|
216
|
+
export function personFirstName(name: string | null | undefined): string | null;
|
|
217
|
+
export function personFirstName(name: string | null | undefined, fallback: string): string;
|
|
218
|
+
export function personFirstName(name: string | null | undefined, fallback: string | null = null): string | null {
|
|
219
|
+
const first = (typeof name === 'string' ? name.trim() : '').split(/\s+/)[0];
|
|
220
|
+
return first || fallback;
|
|
221
|
+
}
|
|
222
|
+
|
|
210
223
|
/** A single leading letter, `?` when there is no name. THE named one-letter policy. */
|
|
211
224
|
export function singleInitial(name?: string | null): string {
|
|
212
225
|
return nameInitials(name, '?', { maxLetters: 1 });
|