@estiva-app/ui 0.107.0 → 0.108.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/FollowSwitch.d.ts +42 -0
- package/dist/FollowSwitch.d.ts.map +1 -0
- package/dist/MembersDialog.d.ts +25 -0
- package/dist/MembersDialog.d.ts.map +1 -1
- package/dist/MembersPill.d.ts +3 -1
- package/dist/MembersPill.d.ts.map +1 -1
- package/dist/WhoFollowsDialog.d.ts +27 -0
- package/dist/WhoFollowsDialog.d.ts.map +1 -0
- package/dist/editor.js +1 -1
- package/dist/editor.js.map +2 -2
- package/dist/eslint/index.js +1 -1
- package/dist/eslint/index.js.map +2 -2
- package/dist/eslint/no-native-title.d.ts +1 -1
- package/dist/eslint/no-native-title.d.ts.map +1 -1
- package/dist/index.d.ts +2 -0
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +1089 -952
- package/dist/index.js.map +4 -4
- package/package.json +2 -2
- package/registry.json +231 -3
- package/src/FollowSwitch.mdx +64 -0
- package/src/FollowSwitch.stories.tsx +54 -0
- package/src/FollowSwitch.test.tsx +139 -0
- package/src/FollowSwitch.tsx +127 -0
- package/src/MembersDialog.tsx +115 -62
- package/src/MembersPill.tsx +4 -2
- package/src/WhoFollowsDialog.mdx +65 -0
- package/src/WhoFollowsDialog.stories.tsx +40 -0
- package/src/WhoFollowsDialog.tsx +74 -0
- package/src/eslint/no-native-title.ts +1 -1
- package/src/index.ts +2 -0
- package/src/registry/registry.test.ts +6 -6
- package/stories/Choosing.mdx +2 -0
package/src/MembersDialog.tsx
CHANGED
|
@@ -67,6 +67,102 @@ export interface MembersDialogProps {
|
|
|
67
67
|
// The icon in the accent as text: Ship's button blue read at 2.7:1 on its grey square (Katerina, 8 October).
|
|
68
68
|
const LEADING_CLASSES = 'size-8 rounded-md bg-accent-muted flex items-center justify-center shrink-0 text-accent-text'
|
|
69
69
|
|
|
70
|
+
/** One person in a roster: a face, a name, a second line, and an optional control at the end. Shared with `WhoFollowsDialog`. */
|
|
71
|
+
export function RosterRow({ member, trailing }: { member: MembersDialogMember; trailing?: ReactNode }) {
|
|
72
|
+
return (
|
|
73
|
+
<div className="flex h-12 items-center gap-3 px-5">
|
|
74
|
+
<Avatar size={32} name={member.name} src={member.picture} bot={member.bot} />
|
|
75
|
+
<div className="flex min-w-0 flex-1 flex-col justify-center gap-[2px]">
|
|
76
|
+
<div className="truncate text-body-2 text-text-primary">{member.name}</div>
|
|
77
|
+
{member.caption && <div className="truncate text-caption text-text-secondary">{member.caption}</div>}
|
|
78
|
+
</div>
|
|
79
|
+
{trailing}
|
|
80
|
+
</div>
|
|
81
|
+
)
|
|
82
|
+
}
|
|
83
|
+
|
|
84
|
+
/** The row on top that opens the add layer. Shared with `WhoFollowsDialog`. */
|
|
85
|
+
export function AddRow({ label, onClick }: { label: string; onClick: () => void }) {
|
|
86
|
+
return (
|
|
87
|
+
<MenuItem
|
|
88
|
+
size="tall"
|
|
89
|
+
className="py-2"
|
|
90
|
+
onClick={onClick}
|
|
91
|
+
leading={<span className={LEADING_CLASSES}><IconUserPlus size={16} stroke={1.5} /></span>}
|
|
92
|
+
label={label}
|
|
93
|
+
/>
|
|
94
|
+
)
|
|
95
|
+
}
|
|
96
|
+
|
|
97
|
+
/**
|
|
98
|
+
* The add layer: an "Invite people" picker over `candidates`, with a back
|
|
99
|
+
* arrow. Shared with `WhoFollowsDialog`, so adding somebody looks and works
|
|
100
|
+
* the same wherever it opens (Miky, 6 November: "We have standard that it
|
|
101
|
+
* opens modal and there is add").
|
|
102
|
+
*/
|
|
103
|
+
export function AddPeopleLayer({
|
|
104
|
+
title,
|
|
105
|
+
backLabel,
|
|
106
|
+
candidates,
|
|
107
|
+
excludeIds,
|
|
108
|
+
onAdd,
|
|
109
|
+
onBack,
|
|
110
|
+
onClose,
|
|
111
|
+
}: {
|
|
112
|
+
title: string
|
|
113
|
+
backLabel: string
|
|
114
|
+
candidates: MembersDialogCandidate[]
|
|
115
|
+
excludeIds: string[]
|
|
116
|
+
onAdd: (chosen: MembersDialogCandidate[]) => void | boolean | Promise<void | boolean>
|
|
117
|
+
onBack: () => void
|
|
118
|
+
onClose: () => void
|
|
119
|
+
}) {
|
|
120
|
+
const [chosen, setChosen] = useState<MembersDialogCandidate[]>([])
|
|
121
|
+
const formId = useId()
|
|
122
|
+
const add = async () => {
|
|
123
|
+
if (chosen.length === 0) return
|
|
124
|
+
if ((await onAdd(chosen)) === false) return
|
|
125
|
+
setChosen([])
|
|
126
|
+
onBack()
|
|
127
|
+
}
|
|
128
|
+
return (
|
|
129
|
+
<DialogShell
|
|
130
|
+
title={title}
|
|
131
|
+
onClose={onClose}
|
|
132
|
+
headerContent={
|
|
133
|
+
<div className="flex min-w-0 items-center gap-2">
|
|
134
|
+
<IconButton tooltip={backLabel} aria-label={backLabel} className="-ml-2" onClick={onBack}>
|
|
135
|
+
<IconArrowLeft size={16} stroke={1.5} />
|
|
136
|
+
</IconButton>
|
|
137
|
+
<span className="truncate text-h4 text-text-primary">{title}</span>
|
|
138
|
+
</div>
|
|
139
|
+
}
|
|
140
|
+
bodyClassName="flex flex-col gap-6"
|
|
141
|
+
footer={
|
|
142
|
+
<>
|
|
143
|
+
<Button variant="muted" onClick={onClose}>Cancel</Button>
|
|
144
|
+
<Button variant="primary" type="submit" form={formId} disabled={chosen.length === 0}>Invite</Button>
|
|
145
|
+
</>
|
|
146
|
+
}
|
|
147
|
+
>
|
|
148
|
+
<Form id={formId} onSubmit={add}>
|
|
149
|
+
<Field label="Invite people" required>
|
|
150
|
+
<ChipInput
|
|
151
|
+
value={chosen}
|
|
152
|
+
onChange={setChosen}
|
|
153
|
+
options={candidates}
|
|
154
|
+
placeholder="Search people..."
|
|
155
|
+
excludeIds={excludeIds}
|
|
156
|
+
chipLeading={(o) => <Avatar name={o.label} src={o.picture} bot={o.bot} size={16} />}
|
|
157
|
+
rowLeading={(o) => <Avatar name={o.label} src={o.picture} bot={o.bot} size={32} />}
|
|
158
|
+
autoFocus
|
|
159
|
+
/>
|
|
160
|
+
</Field>
|
|
161
|
+
</Form>
|
|
162
|
+
</DialogShell>
|
|
163
|
+
)
|
|
164
|
+
}
|
|
165
|
+
|
|
70
166
|
/**
|
|
71
167
|
* Who is in this, with joining, leaving and adding people — the list a
|
|
72
168
|
* `MembersPill` opens.
|
|
@@ -81,9 +177,7 @@ const LEADING_CLASSES = 'size-8 rounded-md bg-accent-muted flex items-center jus
|
|
|
81
177
|
*/
|
|
82
178
|
export function MembersDialog({ members, count, self, candidates = [], onAdd, note, initialView = 'list', onClose }: MembersDialogProps) {
|
|
83
179
|
const [view, setView] = useState<'list' | 'add'>(onAdd ? initialView : 'list')
|
|
84
|
-
const [chosen, setChosen] = useState<MembersDialogCandidate[]>([])
|
|
85
180
|
const [toggling, setToggling] = useState(false)
|
|
86
|
-
const formId = useId()
|
|
87
181
|
|
|
88
182
|
const toggle = async () => {
|
|
89
183
|
if (!self || toggling) return
|
|
@@ -95,13 +189,6 @@ export function MembersDialog({ members, count, self, candidates = [], onAdd, no
|
|
|
95
189
|
}
|
|
96
190
|
}
|
|
97
191
|
|
|
98
|
-
const add = async () => {
|
|
99
|
-
if (!onAdd || chosen.length === 0) return
|
|
100
|
-
if ((await onAdd(chosen)) === false) return
|
|
101
|
-
setChosen([])
|
|
102
|
-
setView('list')
|
|
103
|
-
}
|
|
104
|
-
|
|
105
192
|
// Leave sits on the viewer's own row, drawn first. A viewer with no row of their own gets Leave on top, as Join is.
|
|
106
193
|
const ownRow = self?.action === 'leave' ? members.find((m) => m.id === self.id) : undefined
|
|
107
194
|
const roster = ownRow ? [ownRow, ...members.filter((m) => m !== ownRow)] : members
|
|
@@ -109,40 +196,15 @@ export function MembersDialog({ members, count, self, candidates = [], onAdd, no
|
|
|
109
196
|
|
|
110
197
|
if (view === 'add' && onAdd) {
|
|
111
198
|
return (
|
|
112
|
-
<
|
|
199
|
+
<AddPeopleLayer
|
|
113
200
|
title="Add members"
|
|
201
|
+
backLabel="Back to members"
|
|
202
|
+
candidates={candidates}
|
|
203
|
+
excludeIds={members.map((m) => m.id)}
|
|
204
|
+
onAdd={onAdd}
|
|
205
|
+
onBack={() => setView('list')}
|
|
114
206
|
onClose={onClose}
|
|
115
|
-
|
|
116
|
-
<div className="flex min-w-0 items-center gap-2">
|
|
117
|
-
<IconButton tooltip="Back to members" aria-label="Back to members" className="-ml-2" onClick={() => setView('list')}>
|
|
118
|
-
<IconArrowLeft size={16} stroke={1.5} />
|
|
119
|
-
</IconButton>
|
|
120
|
-
<span className="truncate text-h4 text-text-primary">Add members</span>
|
|
121
|
-
</div>
|
|
122
|
-
}
|
|
123
|
-
bodyClassName="flex flex-col gap-6"
|
|
124
|
-
footer={
|
|
125
|
-
<>
|
|
126
|
-
<Button variant="muted" onClick={onClose}>Cancel</Button>
|
|
127
|
-
<Button variant="primary" type="submit" form={formId} disabled={chosen.length === 0}>Invite</Button>
|
|
128
|
-
</>
|
|
129
|
-
}
|
|
130
|
-
>
|
|
131
|
-
<Form id={formId} onSubmit={add}>
|
|
132
|
-
<Field label="Invite people" required>
|
|
133
|
-
<ChipInput
|
|
134
|
-
value={chosen}
|
|
135
|
-
onChange={setChosen}
|
|
136
|
-
options={candidates}
|
|
137
|
-
placeholder="Search people..."
|
|
138
|
-
excludeIds={members.map((m) => m.id)}
|
|
139
|
-
chipLeading={(o) => <Avatar name={o.label} src={o.picture} bot={o.bot} size={16} />}
|
|
140
|
-
rowLeading={(o) => <Avatar name={o.label} src={o.picture} bot={o.bot} size={32} />}
|
|
141
|
-
autoFocus
|
|
142
|
-
/>
|
|
143
|
-
</Field>
|
|
144
|
-
</Form>
|
|
145
|
-
</DialogShell>
|
|
207
|
+
/>
|
|
146
208
|
)
|
|
147
209
|
}
|
|
148
210
|
|
|
@@ -173,30 +235,21 @@ export function MembersDialog({ members, count, self, candidates = [], onAdd, no
|
|
|
173
235
|
label={self.action === 'join' ? 'Join' : 'Leave'}
|
|
174
236
|
/>
|
|
175
237
|
)}
|
|
176
|
-
{onAdd && (
|
|
177
|
-
<MenuItem
|
|
178
|
-
size="tall"
|
|
179
|
-
className="py-2"
|
|
180
|
-
onClick={() => setView('add')}
|
|
181
|
-
leading={<span className={LEADING_CLASSES}><IconUserPlus size={16} stroke={1.5} /></span>}
|
|
182
|
-
label="Add members"
|
|
183
|
-
/>
|
|
184
|
-
)}
|
|
238
|
+
{onAdd && <AddRow label="Add members" onClick={() => setView('add')} />}
|
|
185
239
|
</div>
|
|
186
240
|
)}
|
|
187
241
|
{roster.map((member) => (
|
|
188
|
-
<
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
</div>
|
|
242
|
+
<RosterRow
|
|
243
|
+
key={member.id}
|
|
244
|
+
member={member}
|
|
245
|
+
trailing={
|
|
246
|
+
member === ownRow && (
|
|
247
|
+
<Button variant="destructive" size="small" disabled={toggling} onClick={() => void toggle()}>
|
|
248
|
+
Leave
|
|
249
|
+
</Button>
|
|
250
|
+
)
|
|
251
|
+
}
|
|
252
|
+
/>
|
|
200
253
|
))}
|
|
201
254
|
{note && <div className="px-5 pb-2 pt-3 text-caption text-text-secondary">{note}</div>}
|
|
202
255
|
</DialogShell>
|
package/src/MembersPill.tsx
CHANGED
|
@@ -10,6 +10,8 @@ export interface MembersPillProps {
|
|
|
10
10
|
count?: number
|
|
11
11
|
/** Opens the list — usually a `MembersDialog`. Without it the pill is disabled. */
|
|
12
12
|
onClick?: () => void
|
|
13
|
+
/** The button's accessible name, when the list it opens is not "members" — "Who follows <name>: 4". Defaults to "4 members". */
|
|
14
|
+
label?: string
|
|
13
15
|
className?: string
|
|
14
16
|
}
|
|
15
17
|
|
|
@@ -23,11 +25,11 @@ export interface MembersPillProps {
|
|
|
23
25
|
* pick of 15 September). `disabled` rather than another element when there is
|
|
24
26
|
* nothing to press, so one element keeps one set of pixels.
|
|
25
27
|
*/
|
|
26
|
-
export function MembersPill({ members, count, onClick, className }: MembersPillProps) {
|
|
28
|
+
export function MembersPill({ members, count, onClick, label, className }: MembersPillProps) {
|
|
27
29
|
const total = count ?? members.length
|
|
28
30
|
if (total === 0) return null
|
|
29
31
|
return (
|
|
30
|
-
<Button variant="outlined" aria-label={`${total} ${total === 1 ? 'member' : 'members'}`} disabled={!onClick} onClick={onClick} className={cn('gap-2 pl-[3px] pr-2', className)}>
|
|
32
|
+
<Button variant="outlined" aria-label={label ?? `${total} ${total === 1 ? 'member' : 'members'}`} disabled={!onClick} onClick={onClick} className={cn('gap-2 pl-[3px] pr-2', className)}>
|
|
31
33
|
<AvatarGroup members={members} />
|
|
32
34
|
<span className={cn(MONO_CAPTION_CLASSES, 'signal:tabular-nums')}>{total}</span>
|
|
33
35
|
</Button>
|
|
@@ -0,0 +1,65 @@
|
|
|
1
|
+
import { Meta, Canvas, Controls } from '@storybook/addon-docs/blocks'
|
|
2
|
+
import * as WhoFollowsDialogStories from './WhoFollowsDialog.stories'
|
|
3
|
+
|
|
4
|
+
<Meta of={WhoFollowsDialogStories} />
|
|
5
|
+
|
|
6
|
+
# WhoFollowsDialog
|
|
7
|
+
|
|
8
|
+
Who follows a place, at All and at Important, with "Add someone" — the list a
|
|
9
|
+
**MembersPill** opens beside a **FollowSwitch**.
|
|
10
|
+
|
|
11
|
+
<Canvas of={WhoFollowsDialogStories.Default} />
|
|
12
|
+
|
|
13
|
+
## When
|
|
14
|
+
|
|
15
|
+
- Behind the faces beside a place's title: everyone it lists, by level, and
|
|
16
|
+
adding someone.
|
|
17
|
+
- Straight on the add layer (`initialView="add"`), from a menu's "Add someone…".
|
|
18
|
+
|
|
19
|
+
## When not
|
|
20
|
+
|
|
21
|
+
- Being in a thing or not, with no levels → **MembersDialog**.
|
|
22
|
+
- Changing your own level → **FollowSwitch**; nobody's level changes here.
|
|
23
|
+
|
|
24
|
+
## How
|
|
25
|
+
|
|
26
|
+
```tsx
|
|
27
|
+
import { WhoFollowsDialog } from '@estiva-app/ui'
|
|
28
|
+
|
|
29
|
+
const atAll: { id: string; name: string; picture?: string; caption?: string }[] = []
|
|
30
|
+
const atImportant: { id: string; name: string; picture?: string; caption?: string }[] = []
|
|
31
|
+
const directory: { id: string; label: string; picture?: string }[] = []
|
|
32
|
+
const [open, setOpen] = useState(false)
|
|
33
|
+
|
|
34
|
+
{open && (
|
|
35
|
+
<WhoFollowsDialog
|
|
36
|
+
title="Item one"
|
|
37
|
+
all={atAll}
|
|
38
|
+
important={atImportant}
|
|
39
|
+
candidates={directory}
|
|
40
|
+
onAdd={(chosen) => {}}
|
|
41
|
+
onClose={() => setOpen(false)}
|
|
42
|
+
/>
|
|
43
|
+
)}
|
|
44
|
+
```
|
|
45
|
+
|
|
46
|
+
- A row is **MembersDialog**'s: `{ id, name, picture?, bot?, caption? }`. The
|
|
47
|
+
caption says how they are in it ("Chose it", "Added by …").
|
|
48
|
+
- Each group is drawn with its count, and "Nobody" when it is empty.
|
|
49
|
+
- `onAdd` shows **Add someone**, which opens the same add layer as
|
|
50
|
+
**MembersDialog**'s, leaving out everyone listed by id. Return `false` to
|
|
51
|
+
stay on it; otherwise it returns to the list.
|
|
52
|
+
|
|
53
|
+
## What it owns
|
|
54
|
+
|
|
55
|
+
It does these by itself, on top of what **DialogShell** and **ChipInput** own.
|
|
56
|
+
What an add does is yours.
|
|
57
|
+
|
|
58
|
+
| It does | So you never write | Refused when written by hand |
|
|
59
|
+
|---|---|---|
|
|
60
|
+
| Goes between the list and the add layer, and back after an add | a view state, or a second dialog | |
|
|
61
|
+
| Leaves everyone listed out of the picker | a filter over your directory | |
|
|
62
|
+
|
|
63
|
+
## Props
|
|
64
|
+
|
|
65
|
+
<Controls of={WhoFollowsDialogStories.Default} />
|
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
import type { Meta, StoryObj } from '@storybook/react-vite'
|
|
2
|
+
import { WhoFollowsDialog } from './WhoFollowsDialog'
|
|
3
|
+
|
|
4
|
+
const people = [
|
|
5
|
+
{ id: 'ana', label: 'Ana Duarte' },
|
|
6
|
+
{ id: 'ravi', label: 'Ravi Mehta' },
|
|
7
|
+
{ id: 'marta', label: 'Marta Silva' },
|
|
8
|
+
{ id: 'jonas', label: 'Jonas Weber' },
|
|
9
|
+
]
|
|
10
|
+
|
|
11
|
+
const meta = {
|
|
12
|
+
title: 'People/WhoFollowsDialog',
|
|
13
|
+
component: WhoFollowsDialog,
|
|
14
|
+
args: {
|
|
15
|
+
title: 'Item one',
|
|
16
|
+
all: [{ id: 'ana', name: 'Ana Duarte', caption: 'Chose it' }],
|
|
17
|
+
important: [
|
|
18
|
+
{ id: 'me', name: 'You', caption: 'In Group one' },
|
|
19
|
+
{ id: 'ravi', name: 'Ravi Mehta', caption: 'Added by Ana Duarte' },
|
|
20
|
+
],
|
|
21
|
+
candidates: people,
|
|
22
|
+
onAdd: () => {},
|
|
23
|
+
onClose: () => {},
|
|
24
|
+
},
|
|
25
|
+
} satisfies Meta<typeof WhoFollowsDialog>
|
|
26
|
+
|
|
27
|
+
export default meta
|
|
28
|
+
type Story = StoryObj<typeof meta>
|
|
29
|
+
|
|
30
|
+
/** All, then Important, each counted, and "Add someone" on top. */
|
|
31
|
+
export const Default: Story = {}
|
|
32
|
+
|
|
33
|
+
/** Nobody at All yet. */
|
|
34
|
+
export const NobodyAtAll: Story = { args: { all: [] } }
|
|
35
|
+
|
|
36
|
+
/** No `onAdd`: the list alone, with nobody to add from here. */
|
|
37
|
+
export const ListOnly: Story = { args: { onAdd: undefined } }
|
|
38
|
+
|
|
39
|
+
/** Opened from a menu's "Add someone…": straight on the add layer, whose back arrow returns to the list. */
|
|
40
|
+
export const Adding: Story = { args: { initialView: 'add' } }
|
|
@@ -0,0 +1,74 @@
|
|
|
1
|
+
import { useState } from 'react'
|
|
2
|
+
import { DialogShell } from './DialogShell'
|
|
3
|
+
import { EmptyState } from './EmptyState'
|
|
4
|
+
import { AddPeopleLayer, AddRow, RosterRow, type MembersDialogCandidate, type MembersDialogMember } from './MembersDialog'
|
|
5
|
+
import { SectionLabel } from './SectionLabel'
|
|
6
|
+
|
|
7
|
+
export interface WhoFollowsDialogProps {
|
|
8
|
+
/** The place's name: the title reads "Who follows <title>". */
|
|
9
|
+
title: string
|
|
10
|
+
/** Who follows it at All, in the order to draw them. A row is a `MembersDialogMember`; its caption says how they are in it. */
|
|
11
|
+
all: MembersDialogMember[]
|
|
12
|
+
/** Who follows it at Important. */
|
|
13
|
+
important: MembersDialogMember[]
|
|
14
|
+
/** Who "Add someone" may offer. Everyone listed is left out by id; leave the viewer out yourself — they join with the switch, not by adding themselves. */
|
|
15
|
+
candidates?: MembersDialogCandidate[]
|
|
16
|
+
/**
|
|
17
|
+
* Adds the people chosen. With it, the "Add someone" row shows and opens the
|
|
18
|
+
* same add layer as `MembersDialog`'s. Return `false` to stay on it.
|
|
19
|
+
*/
|
|
20
|
+
onAdd?: (chosen: MembersDialogCandidate[]) => void | boolean | Promise<void | boolean>
|
|
21
|
+
/** `add` opens straight on the add layer, as a menu's "Add someone…" does. */
|
|
22
|
+
initialView?: 'list' | 'add'
|
|
23
|
+
onClose: () => void
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
/**
|
|
27
|
+
* Who follows a place, in two groups, All then Important, each with its count
|
|
28
|
+
* and "Nobody" when empty; and "Add someone" on top, which opens the add layer
|
|
29
|
+
* `MembersDialog` uses. Nobody's level is changed here: each person changes
|
|
30
|
+
* their own on the place's `FollowSwitch`.
|
|
31
|
+
*/
|
|
32
|
+
export function WhoFollowsDialog({ title, all, important, candidates = [], onAdd, initialView = 'list', onClose }: WhoFollowsDialogProps) {
|
|
33
|
+
const [view, setView] = useState<'list' | 'add'>(onAdd ? initialView : 'list')
|
|
34
|
+
const heading = `Who follows ${title}`
|
|
35
|
+
|
|
36
|
+
if (view === 'add' && onAdd) {
|
|
37
|
+
return (
|
|
38
|
+
<AddPeopleLayer
|
|
39
|
+
title="Add someone"
|
|
40
|
+
backLabel="Back to who follows"
|
|
41
|
+
candidates={candidates}
|
|
42
|
+
excludeIds={[...all, ...important].map((m) => m.id)}
|
|
43
|
+
onAdd={onAdd}
|
|
44
|
+
onBack={() => setView('list')}
|
|
45
|
+
onClose={onClose}
|
|
46
|
+
/>
|
|
47
|
+
)
|
|
48
|
+
}
|
|
49
|
+
|
|
50
|
+
const group = (label: string, rows: MembersDialogMember[]) => (
|
|
51
|
+
<div className="flex flex-col pt-2">
|
|
52
|
+
<SectionLabel tone="muted" className="px-5">{`${label} · ${rows.length}`}</SectionLabel>
|
|
53
|
+
{rows.length === 0 ? (
|
|
54
|
+
<div className="px-5">
|
|
55
|
+
<EmptyState scope="rows" message="Nobody" />
|
|
56
|
+
</div>
|
|
57
|
+
) : (
|
|
58
|
+
rows.map((m) => <RosterRow key={m.id} member={m} />)
|
|
59
|
+
)}
|
|
60
|
+
</div>
|
|
61
|
+
)
|
|
62
|
+
|
|
63
|
+
return (
|
|
64
|
+
<DialogShell title={heading} onClose={onClose} bodyMaxHeight="max-h-[400px]" bodyClassName="p-0 py-2">
|
|
65
|
+
{onAdd && (
|
|
66
|
+
<div className="flex flex-col px-2">
|
|
67
|
+
<AddRow label="Add someone" onClick={() => setView('add')} />
|
|
68
|
+
</div>
|
|
69
|
+
)}
|
|
70
|
+
{group('All', all)}
|
|
71
|
+
{group('Important', important)}
|
|
72
|
+
</DialogShell>
|
|
73
|
+
)
|
|
74
|
+
}
|
|
@@ -8,7 +8,7 @@ import { bindingOfTag, partsOfFile, type Node, type Parser, type PartBinding } f
|
|
|
8
8
|
* the browser shows it as its tooltip. `no-native-title.test.ts` holds this
|
|
9
9
|
* list to the catalogue: a part that gains a `title` of its own joins it.
|
|
10
10
|
*/
|
|
11
|
-
export const PARTS_WITH_A_TITLE = ['ArchiveDialog', 'CollapsibleSection', 'ConfirmDialog', 'ContainerHeader', 'ConversationLayout', 'DialogShell', 'FormDialog', 'ListColumn', 'MoveDialog', 'NavTree', 'NavTreeSection', 'PageHeader', 'Panel', 'SectionHeader', 'Thread'] as const
|
|
11
|
+
export const PARTS_WITH_A_TITLE = ['ArchiveDialog', 'CollapsibleSection', 'ConfirmDialog', 'ContainerHeader', 'ConversationLayout', 'DialogShell', 'FormDialog', 'ListColumn', 'MoveDialog', 'NavTree', 'NavTreeSection', 'PageHeader', 'Panel', 'SectionHeader', 'Thread', 'WhoFollowsDialog'] as const
|
|
12
12
|
|
|
13
13
|
const child = (node: Node, key: string) => node[key] as Node | null | undefined
|
|
14
14
|
const nameOf = (node: Node | null | undefined): string | undefined =>
|
package/src/index.ts
CHANGED
|
@@ -16,6 +16,8 @@ export { Avatar, hueFor, initialsFor, type AvatarProps } from './Avatar'
|
|
|
16
16
|
export { AvatarGroup, type AvatarGroupMember, type AvatarGroupProps } from './AvatarGroup'
|
|
17
17
|
export { MembersPill, type MembersPillProps } from './MembersPill'
|
|
18
18
|
export { MoveDialog, type MoveCheck, type MoveChoice, type MoveDialogProps, type MoveFolder, type MovePlace } from './MoveDialog'
|
|
19
|
+
export { FollowSwitch, LevelIcon, type FollowChoice, type FollowLevel, type FollowSwitchProps, type LevelIconProps } from './FollowSwitch'
|
|
20
|
+
export { WhoFollowsDialog, type WhoFollowsDialogProps } from './WhoFollowsDialog'
|
|
19
21
|
export { MembersDialog, type MembersDialogCandidate, type MembersDialogMember, type MembersDialogProps, type MembersDialogSelfAction } from './MembersDialog'
|
|
20
22
|
export { Banner, type BannerProps, type BannerTone } from './Banner'
|
|
21
23
|
export { BlockHandle, blockAtY, type BlockHandleProps, type BlockHandleEditing, type HandleBlock } from './BlockHandle'
|
|
@@ -48,20 +48,20 @@ describe('the registry builds', () => {
|
|
|
48
48
|
expect(registry.entries.map((one) => one.name).sort()).toEqual(values.map((one) => one.name).sort())
|
|
49
49
|
})
|
|
50
50
|
|
|
51
|
-
it('counts
|
|
51
|
+
it('counts 250 names over 127 files: 165 components, 78 helpers and 7 hooks (FollowSwitch, LevelIcon and WhoFollowsDialog, how you follow a place and who follows it (TEA-6), on 6 November; goneWords and GONE_CLOSED, what stands in a gone comment’s place and under its thread in every app (ONE-9), on 6 November; DeletedNotice and NoAccessNotice, the cards on a deleted file and on one you cannot open (ALO-4), on 3 November; useFormBusy, whether a Form around it is sending, read by the editor’s DocumentField from the main entry, in the review of 2 November; useLeftAt, sendsInLayout, useSeenOnScreen, showInConversation and showInConversationWhenDrawn, where a conversation scrolls, what was seen and a link landing on a comment, moved from Peek for every app, on 2 November; useRememberedOpen, the fold a section remembers, read by the app, and NAV_TREE_PENDING_MS and isPlainClick, Peek’s Folder timer and plain-click check, moved in, on 2 November; FormDialog, MoveDialog and ArchiveDialog, the dialogs Peek wired by hand, on 2 November; ConversationPlace, the line saying where a comment was said, and DocumentField, a rich-text field of a form, moved from Peek, on 2 November; ArchivedNotice, the card on an archived file, from Peek, Ship and Leaf, on 31 October; caretOnOpen, the box at a thread’s foot taking the caret when a ConversationLayout opens it, without scrolling, on 31 October; the conversation from Peek for every app, with PageHeader and PinnedComment, on 31 October, and ResolutionNote and ResolutionHistory gone with the resolved looks not picked, on 1 November; useSidebarFold, a folded sidebar kept folded in every app, on 31 October; cardShapeMemory, a card’s last shape on this device, lifted from Peek and Ship for Leaf, and ReferenceCards and useReferenceCards gone with their deprecated page, in the widget review, on 30 October; inTheBox, a card or part in a box being written in, on the files’ fill and in words, on 29 October; archivedLine, the line on an archived file in every app (PEEKM-2), on 23 October; keepCommentBoxWarm, a box built ahead, exported as 0.84.0 promised (PEEKM-1), on 21 October;linkedFrom and linkStateFrom, one card for a file in every app (5ebf2756), on 21 October; ComposeBox, ComposeKeys and COMPOSE_EDITOR_CLASSES gone into CommentBox’s own frame (one box), on 21 October; LinkPlaces with linkPlaceAt and staysChip, a link in a document drawn where it sits (WBD-4), on 20 October; DocumentEditor, one document editor for every app, and PersonReference, `@` in a document (WBD-3), on 20 October; toggleTableHeaderRow, a table’s header row on and off (LEAF-12), on 19 October;EntryShell, the screen while nobody is signed in, moved from Peek (AUT-3), on 17 October; CommentBox with commentBoxRows, and ReactionRow with AddReactionButton and whoReacted, the shared comment box and reaction row (COMM-2), on 17 October; the link widgets — LinkChip, LinkRow, LinkCard, CardUnder, PartCard, LinkPreview and their parts, with useCanHover, chosenOf, loadingShapeOf and unavailableMemory — from the Widgets 2 prototype, on 16 October; InlineText, a title or the line under it edited where it stands (SUM-4), on 16 October; ComposeBox with ComposeKeys and its classes, CommentHighlights with its five helpers, and keepSelection and releaseSelection, from the Leaf prototype (LEAF-4), on 16 October;NavTree, NavTreeSection, the composer triggers and UnreadDot joined on 2 October; BlockHandle and EditorBlockHandle (RIC-18) on 2 October, moveBlock and blockDropCursor, the drop in the gutter, on 5 October, MembersPill and MembersDialog, moved from Peek (SHI-31), on 6 October, ShowMore on 7 October, AppProvider on 8 October, and KindIcon, thingKindOf and PastedImages with its two helpers, moved from Peek, on 8 October; CodeBlockColours, the coloured code block of the editor, on 9 October; Checklist, Callout, isChecklistTick and calloutLook (RIC-19) on 13 October; EditorTableControls and its four actions (RIC-21) on 13 October; ReferenceCards, useReferenceCards and its three helpers, the card a chip in a document asks for, on 14 October; LinkChips and its two helpers, a URL in a document read as its chip, on 14 October; ReferenceMenu, ReferenceMenuView and three helpers, the menu of a chip while writing, on 14 October; PastedMarkdown, markdown pasted as the blocks it spells (LEAF-10), on 15 October; turnIntoRows, turnListInto and turnQuoteInto, the block menu’s Turn into for a list and a quote (LEAF-11), on 15 October)', () => {
|
|
52
52
|
// The reconciliation GATES.md §24 explains. If this changes, that changes.
|
|
53
53
|
// The `EDITOR_EXTENSIONS` count as components by their names; they are
|
|
54
54
|
// editor extensions, documented on SelectionToolbar's, BlockNodes' and
|
|
55
55
|
// ComposerTriggers' pages.
|
|
56
56
|
const kinds = registry.entries.reduce<Record<string, number>>((all, one) => ({ ...all, [one.kind]: (all[one.kind] ?? 0) + 1 }), {})
|
|
57
|
-
expect(kinds).toEqual({ component:
|
|
58
|
-
expect(new Set(registry.entries.map((one) => one.sourceFile)).size).toBe(
|
|
57
|
+
expect(kinds).toEqual({ component: 165, helper: 78, hook: 7 })
|
|
58
|
+
expect(new Set(registry.entries.map((one) => one.sourceFile)).size).toBe(127)
|
|
59
59
|
})
|
|
60
60
|
|
|
61
61
|
it('gives every entry a purpose, from its own page or from the comment above it', () => {
|
|
62
62
|
expect(registry.entries.filter((one) => one.purpose.trim() === '')).toEqual([])
|
|
63
|
-
expect(registry.entries.filter((one) => one.purposeFrom === 'page').length).toBe(
|
|
64
|
-
expect(registry.entries.filter((one) => one.purposeFrom === 'comment').length).toBe(
|
|
63
|
+
expect(registry.entries.filter((one) => one.purposeFrom === 'page').length).toBe(114)
|
|
64
|
+
expect(registry.entries.filter((one) => one.purposeFrom === 'comment').length).toBe(136)
|
|
65
65
|
})
|
|
66
66
|
|
|
67
67
|
it('takes a name with a page of its own from the page, and a name without one from the code', () => {
|
|
@@ -325,7 +325,7 @@ describe('the ids point at something', () => {
|
|
|
325
325
|
describe('a second parser agrees', async () => {
|
|
326
326
|
const docgen = await import('react-docgen').catch(() => null)
|
|
327
327
|
|
|
328
|
-
it.skipIf(!docgen)('finds the same props on all
|
|
328
|
+
it.skipIf(!docgen)('finds the same props on all 88 components', async () => {
|
|
329
329
|
if (!docgen) return
|
|
330
330
|
const resolver = new docgen.builtinResolvers.FindExportedDefinitionsResolver({ limit: 0 })
|
|
331
331
|
const byName = new Map(registry.entries.map((one) => [one.name, one]))
|
package/stories/Choosing.mdx
CHANGED
|
@@ -54,6 +54,8 @@ fork freely, owe nothing back, mention it on the package's ticket.
|
|
|
54
54
|
| Several faces, overlapping | **AvatarGroup** |
|
|
55
55
|
| Who is in it, at a glance, opening the list | **MembersPill** |
|
|
56
56
|
| Who is in it, with Join, Leave and adding people | **MembersDialog** |
|
|
57
|
+
| How you follow a place — Not following, Important or All — before its title | **FollowSwitch**; the icon alone, in a list, is **LevelIcon** |
|
|
58
|
+
| Who follows a place, at which level, and adding someone | **WhoFollowsDialog**, opened from a **MembersPill** |
|
|
57
59
|
| Face and name in a row | **Person** |
|
|
58
60
|
| The face that opens a menu | **PersonTrigger** |
|
|
59
61
|
| Who you are, where you are, sign out | **IdentityMenu** — the account menu, ready-made |
|