@oxy.so/bloom 22.0.0 → 22.0.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.
Files changed (53) hide show
  1. package/docs/adoption-matrix.mdx +4 -4
  2. package/docs/list.mdx +1 -1
  3. package/docs/sidebar.mdx +16 -0
  4. package/docs/task-catalog.json +1 -1
  5. package/docs/task-catalog.mdx +1 -1
  6. package/lib/commonjs/list/ListItemBase.js +62 -58
  7. package/lib/commonjs/list/ListItemBase.js.map +1 -1
  8. package/lib/commonjs/list/list-style.js +2 -1
  9. package/lib/commonjs/list/list-style.js.map +1 -1
  10. package/lib/commonjs/sidebar/SidebarFolder.js +61 -74
  11. package/lib/commonjs/sidebar/SidebarFolder.js.map +1 -1
  12. package/lib/commonjs/sidebar/SidebarTreeSection.js +30 -38
  13. package/lib/commonjs/sidebar/SidebarTreeSection.js.map +1 -1
  14. package/lib/commonjs/sidebar/tree.js +2 -2
  15. package/lib/commonjs/sidebar/tree.js.map +1 -1
  16. package/lib/module/list/ListItemBase.js +63 -59
  17. package/lib/module/list/ListItemBase.js.map +1 -1
  18. package/lib/module/list/list-style.js +1 -0
  19. package/lib/module/list/list-style.js.map +1 -1
  20. package/lib/module/sidebar/SidebarFolder.js +61 -74
  21. package/lib/module/sidebar/SidebarFolder.js.map +1 -1
  22. package/lib/module/sidebar/SidebarTreeSection.js +30 -38
  23. package/lib/module/sidebar/SidebarTreeSection.js.map +1 -1
  24. package/lib/module/sidebar/tree.js +2 -2
  25. package/lib/module/sidebar/tree.js.map +1 -1
  26. package/lib/typescript/commonjs/list/ListItemBase.d.ts.map +1 -1
  27. package/lib/typescript/commonjs/list/list-style.d.ts +1 -0
  28. package/lib/typescript/commonjs/list/list-style.d.ts.map +1 -1
  29. package/lib/typescript/commonjs/list/types.d.ts +10 -3
  30. package/lib/typescript/commonjs/list/types.d.ts.map +1 -1
  31. package/lib/typescript/commonjs/sidebar/SidebarFolder.d.ts +3 -12
  32. package/lib/typescript/commonjs/sidebar/SidebarFolder.d.ts.map +1 -1
  33. package/lib/typescript/commonjs/sidebar/SidebarTreeSection.d.ts.map +1 -1
  34. package/lib/typescript/commonjs/sidebar/types.d.ts +1 -1
  35. package/lib/typescript/commonjs/sidebar/types.d.ts.map +1 -1
  36. package/lib/typescript/module/list/ListItemBase.d.ts.map +1 -1
  37. package/lib/typescript/module/list/list-style.d.ts +1 -0
  38. package/lib/typescript/module/list/list-style.d.ts.map +1 -1
  39. package/lib/typescript/module/list/types.d.ts +10 -3
  40. package/lib/typescript/module/list/types.d.ts.map +1 -1
  41. package/lib/typescript/module/sidebar/SidebarFolder.d.ts +3 -12
  42. package/lib/typescript/module/sidebar/SidebarFolder.d.ts.map +1 -1
  43. package/lib/typescript/module/sidebar/SidebarTreeSection.d.ts.map +1 -1
  44. package/lib/typescript/module/sidebar/types.d.ts +1 -1
  45. package/lib/typescript/module/sidebar/types.d.ts.map +1 -1
  46. package/package.json +1 -1
  47. package/src/list/ListItemBase.tsx +59 -65
  48. package/src/list/list-style.ts +1 -0
  49. package/src/list/types.ts +11 -3
  50. package/src/sidebar/SidebarFolder.tsx +101 -91
  51. package/src/sidebar/SidebarTreeSection.tsx +36 -35
  52. package/src/sidebar/tree.ts +2 -2
  53. package/src/sidebar/types.ts +5 -1
@@ -1,9 +1,11 @@
1
1
  import React, { memo } from 'react';
2
- import { Pressable, View, type GestureResponderEvent } from 'react-native';
2
+ import { Pressable, View } from 'react-native';
3
3
 
4
4
  import { borderRadius } from '../styles/tokens';
5
5
  import Svg, { Path } from 'react-native-svg';
6
6
 
7
+ import { ListItem } from '../list';
8
+ import { LIST_ROW_INSET, LIST_ROW_MIN_HEIGHT } from '../list/list-style';
7
9
  import { Collapsible } from '../collapsible';
8
10
  import { DropZone } from '../drop-zone';
9
11
  import { useControllableState } from '../hooks/use-controllable-state';
@@ -23,8 +25,8 @@ import type { SurfaceTransition } from '../motion/types';
23
25
 
24
26
  /** A tree branch's reveal: height and opacity together, 300ms ease-in-out. */
25
27
  export const SIDEBAR_TREE_REVEAL: SurfaceTransition = { duration: 300, easing: [0.4, 0, 0.2, 1] };
26
- const ROW_PITCH = 32; // a 30px row and its 2px gap
27
- const FIRST_CENTER = 15;
28
+ const ROW_PITCH = LIST_ROW_MIN_HEIGHT + 2;
29
+ const FIRST_CENTER = LIST_ROW_MIN_HEIGHT / 2;
28
30
 
29
31
  /**
30
32
  * The curved connector: a guide dropping from the folder glyph with a rounded
@@ -87,89 +89,106 @@ export function SidebarTreeRow({
87
89
  onPress?(item: SidebarTreeItem, folder?: SidebarTreeFolder): void;
88
90
  palette: SidebarPalette;
89
91
  }) {
90
- const { state: hovered, onIn, onOut } = useInteractionState();
91
- const { lit, zone } = useTreeRowDrop(item.drop);
92
+ const { lit, zone } = useTreeRowDrop(item.disabled ? undefined : item.drop);
92
93
  const { tree } = useSidebarMetrics();
93
- const style: WebCssStyle = {
94
- flex: 1,
95
- minWidth: 0,
96
- flexDirection: 'row',
97
- alignItems: 'center',
98
- gap: 10,
99
- borderRadius: borderRadius.full,
100
- paddingTop: tree.padding,
101
- paddingBottom: tree.padding,
102
- paddingInlineEnd: 8,
103
- // In a folder the label clears the connector and lines up with the
104
- // folder's own label; a section row starts where a folder's glyph does.
105
- paddingInlineStart: folder ? 36 : 8,
106
- backgroundColor: lit
107
- ? palette.selected
108
- : selected || hovered
109
- ? palette.rowHover
110
- : 'transparent',
111
- '--bloom-sidebar-ring': palette.ring,
112
- };
94
+ const Icon = item.icon;
113
95
  const row = (
114
96
  <View
115
- style={{ flexDirection: 'row', alignItems: 'center', width: '100%' }}
116
- onPointerEnter={item.onPrefetch}
117
- onTouchStart={item.onPrefetch}
97
+ style={{
98
+ flexDirection: 'row',
99
+ alignItems: 'center',
100
+ width: '100%',
101
+ paddingInlineStart: folder ? 36 - LIST_ROW_INSET : 0,
102
+ backgroundColor: lit ? palette.selected : 'transparent',
103
+ borderRadius: borderRadius.full,
104
+ }}
105
+ testID={`sidebar-tree-row-${item.key}`}
118
106
  >
119
- <Pressable
120
- {...(IS_WEB
121
- ? {
122
- dataSet: { bloomSidebar: 'ring' },
123
- ...(item.href ? { href: item.href } : null),
124
- ...(selected ? { 'aria-current': 'page' } : null),
125
- }
126
- : {})}
127
- role={item.href ? 'link' : 'button'}
128
- accessibilityLabel={item.meta ? `${item.label}, ${item.meta}` : item.label}
129
- accessibilityState={{ selected }}
130
- focusable={focusable}
131
- onHoverIn={onIn}
132
- onHoverOut={onOut}
107
+ <ListItem
108
+ style={{ flex: 1, minWidth: 0 }}
109
+ active={item.selected ?? selected}
110
+ label={[item.label, item.description, item.meta].filter(Boolean).join(', ')}
111
+ href={item.href}
112
+ onPrefetch={item.onPrefetch}
133
113
  onLongPress={item.onLongPress}
134
- onPress={(event: GestureResponderEvent) => {
135
- item.onPrefetch?.();
136
- if (!onPress) return;
137
- if (IS_WEB && item.href) event.preventDefault();
138
- onPress(item, folder);
139
- }}
140
- style={style}
141
- >
142
- <Text
143
- variant={tree.label}
144
- numberOfLines={1}
145
- style={{
146
- minWidth: 0,
147
- flex: 1,
148
- color: lit ? palette.selectedForeground : palette.textSecondary,
149
- }}
150
- >
151
- {item.label}
152
- </Text>
153
- {item.meta ? (
154
- <View
155
- style={{
156
- flexShrink: 0,
157
- alignItems: 'center',
158
- justifyContent: 'center',
159
- borderRadius: 4,
160
- backgroundColor: palette.tertiary,
161
- paddingLeft: 4,
162
- paddingRight: 4,
163
- paddingTop: 1,
164
- paddingBottom: 1,
165
- }}
114
+ onPress={
115
+ item.onPress || onPress
116
+ ? () => {
117
+ item.onPrefetch?.();
118
+ item.onPress?.();
119
+ onPress?.(item, folder);
120
+ }
121
+ : undefined
122
+ }
123
+ checked={item.checked}
124
+ onCheckedChange={item.onCheckedChange}
125
+ selecting={item.selecting}
126
+ selectionLabel={item.selectionLabel}
127
+ contextMenu={item.contextMenu}
128
+ disabled={item.disabled || !focusable}
129
+ trigger={(props) => (
130
+ <Pressable
131
+ {...props}
132
+ aria-current={(item.selected ?? selected) ? 'page' : undefined}
133
+ focusable={focusable}
134
+ />
135
+ )}
136
+ leading={
137
+ Icon || item.leading ? (
138
+ <View pointerEvents="none">
139
+ {Icon ? (
140
+ <Icon
141
+ width={tree.icon}
142
+ height={tree.icon}
143
+ fill={lit ? palette.selectedForeground : palette.textSecondary}
144
+ />
145
+ ) : (
146
+ item.leading
147
+ )}
148
+ </View>
149
+ ) : undefined
150
+ }
151
+ title={
152
+ <Text
153
+ variant={tree.label}
154
+ numberOfLines={1}
155
+ style={{ color: lit ? palette.selectedForeground : palette.textSecondary }}
166
156
  >
167
- <Text variant={tree.meta} numberOfLines={1} style={{ color: palette.textSecondary }}>
168
- {item.meta}
157
+ {item.label}
158
+ </Text>
159
+ }
160
+ supporting={
161
+ item.description ? (
162
+ <Text
163
+ variant={tree.meta}
164
+ numberOfLines={1}
165
+ style={{ color: lit ? palette.selectedForeground : palette.textTertiary }}
166
+ >
167
+ {item.description}
169
168
  </Text>
170
- </View>
171
- ) : null}
172
- </Pressable>
169
+ ) : undefined
170
+ }
171
+ trailing={
172
+ item.meta ? (
173
+ <View
174
+ pointerEvents="none"
175
+ style={{
176
+ alignItems: 'center',
177
+ justifyContent: 'center',
178
+ borderRadius: 4,
179
+ backgroundColor: palette.tertiary,
180
+ paddingHorizontal: 4,
181
+ paddingVertical: 1,
182
+ }}
183
+ >
184
+ <Text variant={tree.meta} numberOfLines={1} style={{ color: palette.textSecondary }}>
185
+ {item.meta}
186
+ </Text>
187
+ </View>
188
+ ) : undefined
189
+ }
190
+ testID={`sidebar-tree-item-${item.key}`}
191
+ />
173
192
  {item.actions}
174
193
  </View>
175
194
  );
@@ -177,18 +196,9 @@ export function SidebarTreeRow({
177
196
  }
178
197
 
179
198
  /**
180
- * An expandable folder of the sidebar's tree (the AI chat's repositories).
181
- *
182
- * row p 8, radius 10, gap 8: a 20px folder glyph (open while expanded)
183
- * and the label, body-medium text-secondary, truncating;
184
- * background-secondary-hover on hover
185
- * rows pt 2, 2 apart, the curved connector behind them; each py 5 / pr 8 /
186
- * pl 36, radius 10, gap 10: the label (body-medium text-secondary,
187
- * truncating) and its meta chip (radius 4, background-tertiary, px 4 /
188
- * py 1, caption-1-medium); background-secondary-hover while selected
189
- * or hovered
190
- * motion the rows' height and opacity ease open and shut together (300ms
191
- * ease-in-out); collapsed rows leave the tab order
199
+ * An expandable folder whose items use the shared ListItem anatomy and input
200
+ * handlers. The folder owns disclosure, indentation and curved connectors;
201
+ * collapsed content leaves interaction and accessibility via Collapsible.
192
202
  */
193
203
  function SidebarFolderComponent({
194
204
  folder,
@@ -6,7 +6,6 @@ import {
6
6
  StyleSheet,
7
7
  View,
8
8
  type AccessibilityActionEvent,
9
- type GestureResponderEvent,
10
9
  type KeyDownEvent,
11
10
  } from 'react-native';
12
11
  import { Gesture, GestureDetector } from 'react-native-gesture-handler';
@@ -407,7 +406,7 @@ const TreeRow = memo(function TreeRow({
407
406
  const drag = useTreeDrag();
408
407
  const anyDragging = useTreeDragging();
409
408
  const { dragging, indicator } = useTreeRowDrag(item.key);
410
- const { lit, zone } = useTreeRowDrop(item.drop);
409
+ const { lit, zone } = useTreeRowDrop(item.disabled ? undefined : item.drop);
411
410
  const [open, setOpen] = useControllableState<boolean>({
412
411
  value: item.open,
413
412
  defaultValue: item.defaultOpen ?? false,
@@ -417,9 +416,10 @@ const TreeRow = memo(function TreeRow({
417
416
  const children = item.items ?? [];
418
417
  const expanded = expandable && (open || (searching && children.length > 0));
419
418
  const selected = item.selected ?? item.key === selectedTreeItem;
420
- const canDrag = drag != null && item.draggable === true;
419
+ const canDrag = drag != null && item.draggable === true && !item.disabled;
421
420
  const accepts =
422
421
  drag != null &&
422
+ !item.disabled &&
423
423
  section.droppable !== false &&
424
424
  (item.droppable !== false || item.dropBeside !== false);
425
425
  const insideAllowed = item.droppable !== false;
@@ -516,14 +516,14 @@ const TreeRow = memo(function TreeRow({
516
516
  runOnJS(end)(success, Math.abs(event.translationY) < 4);
517
517
  });
518
518
 
519
- const onPress = (event: GestureResponderEvent) => {
520
- if (anyDragging) return;
521
- item.onPrefetch?.();
522
- item.onPress?.();
523
- if (!onTreeItemPress) return;
524
- if (IS_WEB && item.href) event.preventDefault();
525
- onTreeItemPress(item, undefined);
526
- };
519
+ const onPress =
520
+ item.onPress || onTreeItemPress
521
+ ? () => {
522
+ item.onPrefetch?.();
523
+ item.onPress?.();
524
+ onTreeItemPress?.(item, undefined);
525
+ }
526
+ : undefined;
527
527
 
528
528
  const { tree } = useSidebarMetrics();
529
529
  const lane = tree.icon;
@@ -537,10 +537,6 @@ const TreeRow = memo(function TreeRow({
537
537
  ref={ref}
538
538
  collapsable={false}
539
539
  {...(IS_WEB ? { dataSet: { bloomSidebarRow: item.actionsVisibility ?? 'always' } } : {})}
540
- onPointerEnter={() => {
541
- item.onPrefetch?.();
542
- }}
543
- onTouchStart={item.onPrefetch}
544
540
  style={{
545
541
  position: 'relative',
546
542
  width: '100%',
@@ -570,6 +566,7 @@ const TreeRow = memo(function TreeRow({
570
566
  }
571
567
  aria-expanded={expanded}
572
568
  accessibilityState={{ expanded }}
569
+ disabled={item.disabled}
573
570
  onPress={() => setOpen(!open)}
574
571
  hitSlop={4}
575
572
  style={
@@ -601,26 +598,26 @@ const TreeRow = memo(function TreeRow({
601
598
  active={selected}
602
599
  label={[item.label, item.description, item.meta].filter(Boolean).join(', ')}
603
600
  style={{ flex: 1, minWidth: 0 }}
604
- trigger={
601
+ href={item.href}
602
+ onPress={onPress}
603
+ onPrefetch={item.onPrefetch}
604
+ onLongPress={item.onLongPress}
605
+ checked={item.checked}
606
+ onCheckedChange={item.onCheckedChange}
607
+ selecting={item.selecting}
608
+ selectionLabel={item.selectionLabel}
609
+ contextMenu={item.contextMenu}
610
+ disabled={item.disabled}
611
+ trigger={(props) => (
605
612
  <Pressable
606
- {...(IS_WEB
607
- ? {
608
- dataSet: { bloomListLink: '' },
609
- ...(item.href ? { href: item.href } : null),
610
- ...(selected ? { 'aria-current': 'page' } : null),
611
- }
612
- : {})}
613
- role={item.href ? 'link' : 'button'}
614
- accessibilityLabel={[item.label, item.description, item.meta]
615
- .filter(Boolean)
616
- .join(', ')}
617
- accessibilityState={{ selected }}
618
- accessibilityActions={accessibilityActions}
613
+ {...props}
614
+ aria-current={selected ? 'page' : undefined}
615
+ accessibilityActions={accessibilityActions ?? props.accessibilityActions}
619
616
  onAccessibilityAction={
620
617
  canDrag
621
618
  ? (event: AccessibilityActionEvent) =>
622
619
  runMove(event.nativeEvent.actionName as TreeMove)
623
- : undefined
620
+ : props.onAccessibilityAction
624
621
  }
625
622
  onKeyDown={
626
623
  IS_WEB && canDrag
@@ -640,12 +637,16 @@ const TreeRow = memo(function TreeRow({
640
637
  }
641
638
  : undefined
642
639
  }
643
- onLongPress={canDrag ? undefined : item.onLongPress}
644
- onPress={onPress}
645
- onFocus={item.onPrefetch}
646
- style={[StyleSheet.absoluteFill, { borderRadius: borderRadius.full }]}
640
+ onLongPress={canDrag ? undefined : props.onLongPress}
641
+ onPress={(event) => {
642
+ if (anyDragging) {
643
+ event.preventDefault();
644
+ return;
645
+ }
646
+ props.onPress?.(event);
647
+ }}
647
648
  />
648
- }
649
+ )}
649
650
  leading={
650
651
  Icon || item.leading != null ? (
651
652
  <View
@@ -84,12 +84,12 @@ export function canDrop(
84
84
  position: SidebarTreeDrop['position'],
85
85
  ): boolean {
86
86
  const source = places.get(sourceKey);
87
- if (!source || source.item.draggable !== true) return false;
87
+ if (!source || source.item.disabled || source.item.draggable !== true) return false;
88
88
  if (targetSection.droppable === false) return false;
89
89
  if (targetKey === undefined) return position === 'inside';
90
90
  if (targetKey === sourceKey) return false;
91
91
  const target = places.get(targetKey);
92
- if (!target) return false;
92
+ if (!target || target.item.disabled) return false;
93
93
  if (target.ancestors.includes(sourceKey)) return false;
94
94
  if (position === 'inside' && target.item.droppable === false) return false;
95
95
  if (position !== 'inside' && target.item.dropBeside === false) return false;
@@ -572,7 +572,11 @@ export interface SidebarProps {
572
572
  }
573
573
 
574
574
  /** A row of a tree section, directly under its label, inside a folder or under another row. */
575
- export interface SidebarTreeItem {
575
+ export interface SidebarTreeItem
576
+ extends Pick<
577
+ import('../list/types').ListCommonProps,
578
+ 'checked' | 'onCheckedChange' | 'selecting' | 'selectionLabel' | 'contextMenu' | 'disabled'
579
+ > {
576
580
  /** Secondary controls beside the row, never nested inside its press target. */
577
581
  actions?: ReactNode;
578
582
  /**