@oxy.so/bloom 19.9.0 → 19.10.0

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 (74) hide show
  1. package/docs/adoption-matrix.mdx +5 -5
  2. package/docs/conversation-sidebar.mdx +1 -1
  3. package/docs/menubar.mdx +3 -3
  4. package/docs/sidebar.mdx +2 -2
  5. package/docs/task-catalog.json +1 -1
  6. package/docs/task-catalog.mdx +1 -1
  7. package/lib/commonjs/conversation-sidebar/create-conversation-sidebar.js +6 -3
  8. package/lib/commonjs/conversation-sidebar/create-conversation-sidebar.js.map +1 -1
  9. package/lib/commonjs/conversation-sidebar/index.js +1 -1
  10. package/lib/commonjs/conversation-sidebar/index.web.js +1 -1
  11. package/lib/commonjs/menubar/declared.js +171 -66
  12. package/lib/commonjs/menubar/declared.js.map +1 -1
  13. package/lib/commonjs/menubar/description.js +293 -0
  14. package/lib/commonjs/menubar/description.js.map +1 -0
  15. package/lib/commonjs/menubar/use-edit-action.js +1 -0
  16. package/lib/commonjs/menubar/use-edit-action.js.map +1 -1
  17. package/lib/commonjs/sidebar/SidebarToolbar.js +24 -9
  18. package/lib/commonjs/sidebar/SidebarToolbar.js.map +1 -1
  19. package/lib/commonjs/sidebar/SidebarTreeSection.js +17 -6
  20. package/lib/commonjs/sidebar/SidebarTreeSection.js.map +1 -1
  21. package/lib/module/conversation-sidebar/create-conversation-sidebar.js +6 -3
  22. package/lib/module/conversation-sidebar/create-conversation-sidebar.js.map +1 -1
  23. package/lib/module/conversation-sidebar/index.js +1 -1
  24. package/lib/module/conversation-sidebar/index.web.js +1 -1
  25. package/lib/module/menubar/declared.js +145 -43
  26. package/lib/module/menubar/declared.js.map +1 -1
  27. package/lib/module/menubar/description.js +286 -0
  28. package/lib/module/menubar/description.js.map +1 -0
  29. package/lib/module/menubar/use-edit-action.js +1 -1
  30. package/lib/module/menubar/use-edit-action.js.map +1 -1
  31. package/lib/module/sidebar/SidebarToolbar.js +24 -9
  32. package/lib/module/sidebar/SidebarToolbar.js.map +1 -1
  33. package/lib/module/sidebar/SidebarTreeSection.js +16 -5
  34. package/lib/module/sidebar/SidebarTreeSection.js.map +1 -1
  35. package/lib/typescript/commonjs/conversation-sidebar/create-conversation-sidebar.d.ts.map +1 -1
  36. package/lib/typescript/commonjs/conversation-sidebar/index.d.ts +1 -1
  37. package/lib/typescript/commonjs/conversation-sidebar/index.web.d.ts +1 -1
  38. package/lib/typescript/commonjs/menubar/declared.d.ts +29 -20
  39. package/lib/typescript/commonjs/menubar/declared.d.ts.map +1 -1
  40. package/lib/typescript/commonjs/menubar/description.d.ts +90 -0
  41. package/lib/typescript/commonjs/menubar/description.d.ts.map +1 -0
  42. package/lib/typescript/commonjs/menubar/types.d.ts +7 -6
  43. package/lib/typescript/commonjs/menubar/types.d.ts.map +1 -1
  44. package/lib/typescript/commonjs/menubar/use-edit-action.d.ts +4 -1
  45. package/lib/typescript/commonjs/menubar/use-edit-action.d.ts.map +1 -1
  46. package/lib/typescript/commonjs/sidebar/SidebarToolbar.d.ts +5 -1
  47. package/lib/typescript/commonjs/sidebar/SidebarToolbar.d.ts.map +1 -1
  48. package/lib/typescript/commonjs/sidebar/SidebarTreeSection.d.ts +7 -1
  49. package/lib/typescript/commonjs/sidebar/SidebarTreeSection.d.ts.map +1 -1
  50. package/lib/typescript/module/conversation-sidebar/create-conversation-sidebar.d.ts.map +1 -1
  51. package/lib/typescript/module/conversation-sidebar/index.d.ts +1 -1
  52. package/lib/typescript/module/conversation-sidebar/index.web.d.ts +1 -1
  53. package/lib/typescript/module/menubar/declared.d.ts +29 -20
  54. package/lib/typescript/module/menubar/declared.d.ts.map +1 -1
  55. package/lib/typescript/module/menubar/description.d.ts +90 -0
  56. package/lib/typescript/module/menubar/description.d.ts.map +1 -0
  57. package/lib/typescript/module/menubar/types.d.ts +7 -6
  58. package/lib/typescript/module/menubar/types.d.ts.map +1 -1
  59. package/lib/typescript/module/menubar/use-edit-action.d.ts +4 -1
  60. package/lib/typescript/module/menubar/use-edit-action.d.ts.map +1 -1
  61. package/lib/typescript/module/sidebar/SidebarToolbar.d.ts +5 -1
  62. package/lib/typescript/module/sidebar/SidebarToolbar.d.ts.map +1 -1
  63. package/lib/typescript/module/sidebar/SidebarTreeSection.d.ts +7 -1
  64. package/lib/typescript/module/sidebar/SidebarTreeSection.d.ts.map +1 -1
  65. package/package.json +1 -1
  66. package/src/conversation-sidebar/create-conversation-sidebar.tsx +3 -2
  67. package/src/conversation-sidebar/index.ts +1 -1
  68. package/src/conversation-sidebar/index.web.ts +1 -1
  69. package/src/menubar/declared.tsx +166 -39
  70. package/src/menubar/description.ts +337 -0
  71. package/src/menubar/types.ts +7 -6
  72. package/src/menubar/use-edit-action.ts +2 -2
  73. package/src/sidebar/SidebarToolbar.tsx +22 -10
  74. package/src/sidebar/SidebarTreeSection.tsx +15 -4
@@ -0,0 +1,337 @@
1
+ /**
2
+ * A closed menu's DESCRIPTION, read from its declaration's elements without
3
+ * mounting them (OxyOS ADR 0021).
4
+ *
5
+ * A closed menu's rows are known to its bar so that their shortcuts work while
6
+ * it is closed. Mounting them headless did that by rendering every row, which
7
+ * cost every bar render a render of every closed menu's rows (OxyOS's shell has
8
+ * a Window menu of some 27). A menu's content is a declaration: Bloom's own
9
+ * parts (an item, a check item, a radio group and its items, a label, a
10
+ * separator, a group, a submenu), with their props. So a closed menu's entries
11
+ * are read from those elements here, as a Mac's bar keeps a menu's items as
12
+ * data and builds its rows as it opens: the label, the shortcut, the state, and
13
+ * what choosing it runs, the element's own handler.
14
+ *
15
+ * POSITIONS are the ones `DeclaredChildren` gives the mounted rows (arrays and
16
+ * fragments flattened, every child, `null` included, taking a place), so the
17
+ * order a description sorts by is the same open or closed.
18
+ *
19
+ * What is not one of Bloom's parts (an application's own component that
20
+ * renders rows) cannot be read without rendering it: it is returned as
21
+ * `unread`, with its place, for the caller to mount headless as before.
22
+ */
23
+ import { Fragment, isValidElement, type ReactNode } from 'react';
24
+
25
+ import { openHref } from '../hooks/link-activation';
26
+ import { type Chord, parseChord } from '../kbd/chord';
27
+ import type { PlatformEditAction, PlatformMenuAction } from '../platform-surface/types';
28
+ import type { MenuEntryKind } from './registry';
29
+ import { actionShortcut, isMenuAction } from './use-edit-action';
30
+
31
+ /** Which of Bloom's menubar parts a component is (`createMenubarRows` marks each). */
32
+ export type MenubarPart =
33
+ | 'item'
34
+ | 'checkbox'
35
+ | 'radioGroup'
36
+ | 'radio'
37
+ | 'label'
38
+ | 'separator'
39
+ | 'group'
40
+ | 'sub'
41
+ | 'subTrigger'
42
+ | 'subContent';
43
+
44
+ const PART = Symbol.for('bloom.menubarPart');
45
+ const HINTS = new WeakSet<object>();
46
+
47
+ /** Marks `component` as one of Bloom's menubar parts, so a description can read its elements. */
48
+ export function markMenubarPart<T extends object>(component: T, part: MenubarPart): T {
49
+ (component as Record<symbol, MenubarPart>)[PART] = part;
50
+ return component;
51
+ }
52
+
53
+ /** Marks a row's shortcut hint, which a label's text leaves out. */
54
+ export function markMenubarHint(component: unknown): void {
55
+ if ((typeof component === 'function' || typeof component === 'object') && component !== null) {
56
+ HINTS.add(component);
57
+ }
58
+ }
59
+
60
+ function partOf(type: unknown): MenubarPart | undefined {
61
+ if ((typeof type !== 'function' && typeof type !== 'object') || type === null) return undefined;
62
+ return (type as Record<symbol, MenubarPart | undefined>)[PART];
63
+ }
64
+
65
+ const isMarkedHint = (type: unknown) =>
66
+ (typeof type === 'function' || typeof type === 'object') && type !== null && HINTS.has(type);
67
+
68
+ /**
69
+ * The text of a part's children, as the platform's bar shows it: every string
70
+ * and number under it, element children included, except a shortcut hint
71
+ * (`isHint`), which is not part of the name.
72
+ */
73
+ export function textOf(children: ReactNode, isHint: (type: unknown) => boolean): string {
74
+ const parts: string[] = [];
75
+ const visit = (node: ReactNode) => {
76
+ if (typeof node === 'string' || typeof node === 'number') parts.push(String(node));
77
+ else if (Array.isArray(node)) node.forEach(visit);
78
+ else if (isValidElement<{ children?: ReactNode }>(node) && !isHint(node.type)) {
79
+ visit(node.props.children);
80
+ }
81
+ };
82
+ visit(children);
83
+ return parts.join('').replace(/\s+/g, ' ').trim();
84
+ }
85
+
86
+ const labelOf = (children: ReactNode) => textOf(children, isMarkedHint);
87
+
88
+ /** A radio group's selection, as its items read it. */
89
+ export interface RadioSelection {
90
+ readonly value: string | undefined;
91
+ readonly onValueChange: (value: string) => void;
92
+ }
93
+
94
+ /** One entry of a closed menu, read from its element. */
95
+ export interface DescribedEntry {
96
+ /** Stable while the element keeps its place: its kind and its path. */
97
+ readonly key: string;
98
+ readonly kind: MenuEntryKind;
99
+ /** The key of the submenu it is in; null for the menu's own content. */
100
+ readonly parentKey: string | null;
101
+ /** Its position under the content's own path. */
102
+ readonly path: readonly number[];
103
+ readonly label: string;
104
+ readonly enabled: boolean;
105
+ readonly shortcut: Chord | null;
106
+ readonly checked?: boolean;
107
+ readonly keepOpen?: boolean;
108
+ readonly action?: PlatformMenuAction;
109
+ /** An editing action: its state and what choosing it does are the focused field's while one is. */
110
+ readonly editAction?: PlatformEditAction;
111
+ /** The element's own handler, as a press on its row would run it; undefined for none. */
112
+ readonly run?: () => void;
113
+ /** Whether choosing it runs something: every item does, a label and a submenu's trigger do not. */
114
+ readonly runs: boolean;
115
+ }
116
+
117
+ /** What a description could not read: an element to mount headless at its place. */
118
+ export interface UnreadElement {
119
+ readonly node: ReactNode;
120
+ readonly parentKey: string | null;
121
+ readonly path: readonly number[];
122
+ readonly radio: RadioSelection | null;
123
+ /**
124
+ * Set for an element placed directly in a submenu (beside its trigger and
125
+ * content): the submenu (`parentKey`) is its owner, and this is the key of
126
+ * the menu or submenu the submenu is in.
127
+ */
128
+ readonly owner: { readonly parentKey: string | null } | null;
129
+ }
130
+
131
+ export interface MenuDescription {
132
+ readonly entries: DescribedEntry[];
133
+ readonly unread: UnreadElement[];
134
+ }
135
+
136
+ interface ItemProps {
137
+ children?: ReactNode;
138
+ accessibilityLabel?: string;
139
+ disabled?: boolean;
140
+ keepOpen?: boolean;
141
+ shortcut?: string;
142
+ action?: PlatformEditAction | PlatformMenuAction;
143
+ onPress?: () => void;
144
+ href?: string;
145
+ checked?: boolean;
146
+ onCheckedChange?: (checked: boolean) => void;
147
+ value?: string;
148
+ onValueChange?: (value: string) => void;
149
+ }
150
+
151
+ /** The children of a container as `DeclaredChildren` places them: one per place. */
152
+ function places(children: ReactNode): ReactNode[] {
153
+ const out: ReactNode[] = [];
154
+ const visit = (node: ReactNode) => {
155
+ if (Array.isArray(node)) {
156
+ node.forEach(visit);
157
+ return;
158
+ }
159
+ if (isValidElement<{ children?: ReactNode }>(node) && node.type === Fragment) {
160
+ visit(node.props.children);
161
+ return;
162
+ }
163
+ out.push(node);
164
+ };
165
+ visit(children);
166
+ return out;
167
+ }
168
+
169
+ /** The chord a `shortcut` declares; null when it is none (the mounted row warns once). */
170
+ function chordOf(shortcut: string | undefined): Chord | null {
171
+ return shortcut === undefined ? null : parseChord(shortcut);
172
+ }
173
+
174
+ const keyOf = (path: readonly number[]) => `d${path.join('.')}`;
175
+
176
+ /**
177
+ * `children`'s description: its entries, each at `[...path, place]` under
178
+ * `parentKey`, and what it could not read.
179
+ */
180
+ export function describeMenu(children: ReactNode): MenuDescription {
181
+ const entries: DescribedEntry[] = [];
182
+ const unread: UnreadElement[] = [];
183
+
184
+ const visit = (
185
+ nodes: ReactNode,
186
+ path: readonly number[],
187
+ parentKey: string | null,
188
+ radio: RadioSelection | null,
189
+ ) => {
190
+ places(nodes).forEach((node, place) => {
191
+ const at = [...path, place];
192
+ if (node === null || node === undefined || typeof node === 'boolean') return;
193
+ if (!isValidElement<ItemProps>(node)) {
194
+ // Text placed in a menu draws nowhere in a description.
195
+ return;
196
+ }
197
+ const part = partOf(node.type);
198
+ const props = node.props;
199
+ const label = labelOf(props.children) || (props.accessibilityLabel ?? '');
200
+ switch (part) {
201
+ case 'item': {
202
+ const { action } = props;
203
+ const handler =
204
+ props.onPress ??
205
+ (props.href != null ? () => openHref(props.href as string) : undefined);
206
+ const menuAction = isMenuAction(action) ? action : undefined;
207
+ const editAction = isMenuAction(action) ? undefined : action;
208
+ entries.push({
209
+ key: keyOf(at),
210
+ kind: 'item',
211
+ parentKey,
212
+ path: at,
213
+ label,
214
+ // An item with an action needs its own handler when no field takes the action (an
215
+ // application's own command never is a field's); while a field takes an editing
216
+ // action, its state is the field's (`DescribedEntry.editAction`).
217
+ enabled: !props.disabled && (action === undefined || handler !== undefined),
218
+ shortcut: chordOf(props.shortcut ?? actionShortcut(action)),
219
+ keepOpen: props.keepOpen ?? false,
220
+ ...(menuAction ? { action: menuAction } : null),
221
+ ...(editAction ? { editAction } : null),
222
+ run: handler,
223
+ runs: true,
224
+ });
225
+ return;
226
+ }
227
+ case 'checkbox': {
228
+ const { checked = false, onCheckedChange } = props;
229
+ entries.push({
230
+ key: keyOf(at),
231
+ kind: 'item',
232
+ parentKey,
233
+ path: at,
234
+ label,
235
+ enabled: !props.disabled,
236
+ shortcut: chordOf(props.shortcut),
237
+ checked,
238
+ keepOpen: props.keepOpen ?? false,
239
+ run: onCheckedChange ? () => onCheckedChange(!checked) : undefined,
240
+ runs: true,
241
+ });
242
+ return;
243
+ }
244
+ case 'radioGroup': {
245
+ const { value, onValueChange } = props;
246
+ visit(props.children, at, parentKey, onValueChange ? { value, onValueChange } : null);
247
+ return;
248
+ }
249
+ case 'radio': {
250
+ const { value } = props;
251
+ entries.push({
252
+ key: keyOf(at),
253
+ kind: 'item',
254
+ parentKey,
255
+ path: at,
256
+ label,
257
+ enabled: !props.disabled,
258
+ shortcut: chordOf(props.shortcut),
259
+ checked: radio !== null && radio.value === value,
260
+ keepOpen: props.keepOpen ?? false,
261
+ run: radio && value !== undefined ? () => radio.onValueChange(value) : undefined,
262
+ runs: true,
263
+ });
264
+ return;
265
+ }
266
+ case 'label':
267
+ // A group's label is shown, never chosen: an item that is never enabled.
268
+ entries.push({
269
+ key: keyOf(at),
270
+ kind: 'item',
271
+ parentKey,
272
+ path: at,
273
+ label: labelOf(props.children),
274
+ enabled: false,
275
+ shortcut: null,
276
+ runs: false,
277
+ });
278
+ return;
279
+ case 'separator':
280
+ entries.push({
281
+ key: keyOf(at),
282
+ kind: 'separator',
283
+ parentKey,
284
+ path: at,
285
+ label: '',
286
+ enabled: true,
287
+ shortcut: null,
288
+ runs: false,
289
+ });
290
+ return;
291
+ case 'group':
292
+ visit(props.children, at, parentKey, radio);
293
+ return;
294
+ case 'sub': {
295
+ // A submenu: its trigger names it, its content is its entries, at the submenu's place.
296
+ const key = keyOf(at);
297
+ for (const child of places(props.children)) {
298
+ if (!isValidElement<ItemProps>(child)) continue;
299
+ const childPart = partOf(child.type);
300
+ if (childPart === 'subTrigger') {
301
+ entries.push({
302
+ key,
303
+ kind: 'submenu',
304
+ parentKey,
305
+ path: at,
306
+ label: labelOf(child.props.children) || (child.props.accessibilityLabel ?? ''),
307
+ enabled: !child.props.disabled,
308
+ shortcut: null,
309
+ runs: false,
310
+ });
311
+ } else if (childPart === 'subContent') {
312
+ visit(child.props.children, at, key, null);
313
+ } else {
314
+ unread.push({
315
+ node: child,
316
+ parentKey: key,
317
+ path: at,
318
+ radio: null,
319
+ owner: { parentKey },
320
+ });
321
+ }
322
+ }
323
+ return;
324
+ }
325
+ case 'subTrigger':
326
+ case 'subContent':
327
+ // Outside a submenu they declare nothing, mounted or not.
328
+ return;
329
+ default:
330
+ unread.push({ node, parentKey, path: at, radio, owner: null });
331
+ }
332
+ });
333
+ };
334
+
335
+ visit(children, [], null, null);
336
+ return { entries, unread };
337
+ }
@@ -45,12 +45,13 @@ export interface MenubarProps {
45
45
  /** The keyboard moved across the bar, or left it (`undefined`). */
46
46
  onFocusValueChange?: (value: string | undefined) => void;
47
47
  /**
48
- * Whether a closed menu's content is mounted headless, so its rows' `shortcut`s work while the
49
- * menu is closed (the default, `true`). A bar whose rows run no chords of their own (an OS
50
- * shell's, whose rows only show the chord another part runs) passes `false`: a closed menu then
51
- * mounts nothing but its title, as a Mac's menu bar draws titles and builds a menu as it opens,
52
- * and its rows render again only while it is open or the popup is changing from it. Ignored
53
- * where the platform draws the bar (`menu-bar`), which needs every menu declared.
48
+ * Whether a closed menu's rows are known to the bar, so their `shortcut`s work while the menu is
49
+ * closed (the default, `true`). Known, not mounted: Bloom reads them from the content's elements
50
+ * (a closed menu's rows never render) and mounts headless only an application's own component
51
+ * placed in it, which it cannot read without rendering. A bar whose rows run no chords of their
52
+ * own (an OS shell's, whose rows only show the chord another part runs) passes `false`: a closed
53
+ * menu then declares nothing, and its shortcuts are the open menu's only. Ignored where the
54
+ * platform draws the bar (`menu-bar`), which needs every menu declared.
54
55
  */
55
56
  declareClosedMenus?: boolean;
56
57
  /** Accessible name for the bar. */
@@ -68,9 +68,9 @@ export function actionShortcut(
68
68
  const subscribeNowhere = () => () => undefined;
69
69
 
70
70
  /** What a field can do with `action` now: 'none' with no field focused. */
71
- type Responder = 'none' | 'enabled' | 'disabled';
71
+ export type Responder = 'none' | 'enabled' | 'disabled';
72
72
 
73
- function responderOf(
73
+ export function responderOf(
74
74
  editing: PlatformEditing | null,
75
75
  action: PlatformEditAction | undefined,
76
76
  ): Responder {
@@ -22,8 +22,14 @@ const AnimatedView = Animated.createAnimatedComponent(StyledView);
22
22
 
23
23
  /** How long after the field loses focus the empty search closes. */
24
24
  const BLUR_CLOSE_MS = 150;
25
+ /** Between two slots of the row. */
26
+ const SLOT_GAP = 8;
25
27
 
26
- /** Search and fixed action slots share one row; the sidebar owns its viewport. */
28
+ /**
29
+ * The search's slot and one per action share the row in equal parts, however many actions there
30
+ * are; the closed search covers the first slot and opens across all of them. The sidebar owns its
31
+ * viewport.
32
+ */
27
33
  export function SidebarToolbar({ actions = [], search, style, testID }: SidebarToolbarProps) {
28
34
  const common = useCommonMessages();
29
35
  const palette = useSidebarPalette();
@@ -54,17 +60,21 @@ export function SidebarToolbar({ actions = [], search, style, testID }: SidebarT
54
60
  return undefined;
55
61
  }, [search.open, reduced, progress, actionsProgress]);
56
62
  const slots = actions.length + 1;
57
- const collapsedWidth = width > 0 ? (width - 8 * (slots - 1)) / slots : 76;
63
+ const gaps = SLOT_GAP * (slots - 1);
64
+ // The first slot's width. Web states it in CSS, so it holds before any layout and through
65
+ // resizes; native animates between numbers, so it measures the row (a share of it until then).
66
+ const webCollapsedWidth = slots === 1 ? '100%' : `calc((100% - ${gaps}px) / ${slots})`;
67
+ const collapsedWidth = width > 0 ? (width - gaps) / slots : null;
58
68
  const searchWidth = useAnimatedStyle(
59
69
  () => ({
60
70
  width:
61
- width > 0
71
+ collapsedWidth != null
62
72
  ? collapsedWidth + (width - collapsedWidth) * progress.value
63
73
  : progress.value > 0
64
74
  ? '100%'
65
- : collapsedWidth,
75
+ : `${100 / slots}%`,
66
76
  }),
67
- [width, collapsedWidth, progress],
77
+ [width, collapsedWidth, slots, progress],
68
78
  );
69
79
  const actionsStyle = useAnimatedStyle(() => {
70
80
  const hidden = actionsProgress.value;
@@ -99,15 +109,16 @@ export function SidebarToolbar({ actions = [], search, style, testID }: SidebarT
99
109
  onLayout={(event) => setWidth(event.nativeEvent.layout.width)}
100
110
  >
101
111
  <StyledView
102
- className="grid h-full grid-cols-3 gap-2"
103
- style={{ flexDirection: 'row', gap: 8 }}
112
+ testID={testID ? `${testID}-slots` : undefined}
113
+ className="h-full flex-row gap-2"
114
+ style={{ height: '100%', flexDirection: 'row', gap: SLOT_GAP }}
104
115
  >
105
- <StyledView aria-hidden style={{ flex: 1 }} />
116
+ <StyledView aria-hidden style={{ flex: 1, minWidth: 0 }} />
106
117
  {actions.map((action, index) => (
107
118
  <AnimatedView
108
119
  key={index}
109
120
  className={`flex ${IS_WEB ? `transition-[opacity,transform] duration-200 motion-reduce:transition-none ${search.open ? `pointer-events-none ${rtl ? '-translate-x-2' : 'translate-x-2'} scale-95 opacity-0` : 'translate-x-0 scale-100 opacity-100'}` : ''}`}
110
- style={[{ flex: 1 }, !IS_WEB && actionsStyle]}
121
+ style={[{ flex: 1, minWidth: 0 }, !IS_WEB && actionsStyle]}
111
122
  pointerEvents={search.open ? 'none' : 'auto'}
112
123
  aria-hidden={search.open}
113
124
  accessibilityElementsHidden={search.open}
@@ -119,6 +130,7 @@ export function SidebarToolbar({ actions = [], search, style, testID }: SidebarT
119
130
  ))}
120
131
  </StyledView>
121
132
  <AnimatedView
133
+ testID={testID ? `${testID}-search` : undefined}
122
134
  className={`absolute inset-y-0 start-0 z-10 overflow-hidden rounded-full bg-background-tertiary-default ${IS_WEB ? 'transition-[width] duration-300 ease-in-out motion-reduce:transition-none' : ''}`}
123
135
  style={[
124
136
  {
@@ -129,7 +141,7 @@ export function SidebarToolbar({ actions = [], search, style, testID }: SidebarT
129
141
  borderRadius: 999,
130
142
  backgroundColor: palette.tertiary,
131
143
  },
132
- IS_WEB ? { width: search.open ? '100%' : collapsedWidth } : searchWidth,
144
+ IS_WEB ? { width: search.open ? '100%' : webCollapsedWidth } : searchWidth,
133
145
  ]}
134
146
  >
135
147
  {!search.open ? (
@@ -48,6 +48,13 @@ import { usePrefersReducedMotion } from '../hooks/use-prefers-reduced-motion';
48
48
  const EASE_IN_OUT = Easing.bezier(0.4, 0, 0.2, 1);
49
49
  /** One level of nesting: a row's content starts this much further in than its parent's. */
50
50
  export const TREE_INDENT = 16;
51
+ /**
52
+ * Where a top-level row's content starts (its disclosure, glyph, avatar or label), and so where
53
+ * the section's label and status start: one edge from the title down.
54
+ */
55
+ export const TREE_INSET = 8;
56
+ /** Where a row's `actions` end: the section's own `actions` end there too. */
57
+ const TREE_ACTIONS_INSET = 4;
51
58
  /** Long enough that a press opens the row and a swipe still scrolls the sidebar. */
52
59
  const LIFT_AFTER_MS = 350;
53
60
  const DRAG_MIME = 'application/x-bloom-sidebar-row';
@@ -57,7 +64,8 @@ type TreePress = (item: SidebarTreeItem, folder?: SidebarTreeFolder) => void;
57
64
  /**
58
65
  * One labelled section of the sidebar's tree.
59
66
  *
60
- * label `tree.label` text-secondary, its `actions` at the end. A
67
+ * label `tree.label` text-secondary, inset 8 like the rows' content (its
68
+ * `actions` at the end, inset 4 like theirs). A
61
69
  * `collapsible` section's label is a disclosure (16px chevron,
62
70
  * turning 90° open) that shows and hides the rows (300ms).
63
71
  * status `loading` / `error` (an alert, in the danger role) / `emptyLabel`,
@@ -177,7 +185,7 @@ export const SidebarTreeSection = memo(function SidebarTreeSection({
177
185
  );
178
186
  });
179
187
 
180
- const statusStyle = { paddingLeft: 8, paddingRight: 8 };
188
+ const statusStyle = { paddingLeft: TREE_INSET, paddingRight: TREE_INSET };
181
189
 
182
190
  function SectionLabel({
183
191
  section,
@@ -224,6 +232,9 @@ function SectionLabel({
224
232
  alignItems: 'center',
225
233
  justifyContent: 'space-between',
226
234
  gap: 8,
235
+ // The title starts where its rows' content does, and its actions end where theirs do.
236
+ paddingInlineStart: TREE_INSET,
237
+ paddingInlineEnd: section.actions != null ? TREE_ACTIONS_INSET : TREE_INSET,
227
238
  borderRadius: borderRadius.full,
228
239
  ...(dropHere ? { boxShadow: `inset 0 0 0 2px ${palette.ring}` } : null),
229
240
  }}
@@ -522,7 +533,7 @@ const TreeRow = memo(function TreeRow({
522
533
  // A row with a description is a contact (picture, name, last line): its picture is as tall as the
523
534
  // two lines. Any other `leading` stays in the glyph's box.
524
535
  const leadingBox = item.leading != null && item.description != null ? tree.avatar : tree.icon;
525
- const inset = 8 + depth * TREE_INDENT;
536
+ const inset = TREE_INSET + depth * TREE_INDENT;
526
537
  const Icon = item.icon;
527
538
  const row = (
528
539
  <View
@@ -544,7 +555,7 @@ const TreeRow = memo(function TreeRow({
544
555
  // With a disclosure lane the inset comes before it; without one it is
545
556
  // part of the row's press target, as a folder's row is.
546
557
  paddingInlineStart: nests ? inset : 0,
547
- paddingInlineEnd: item.actions != null ? 4 : 0,
558
+ paddingInlineEnd: item.actions != null ? TREE_ACTIONS_INSET : 0,
548
559
  backgroundColor: lit
549
560
  ? palette.selected
550
561
  : indicator === 'inside'