@oxy.so/bloom 22.1.4 → 22.1.6

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 (62) hide show
  1. package/docs/adoption-matrix.mdx +3 -3
  2. package/docs/list.mdx +2 -0
  3. package/docs/page-header.mdx +7 -5
  4. package/docs/task-catalog.json +1 -1
  5. package/docs/task-catalog.mdx +1 -1
  6. package/docs/verification.mdx +27 -0
  7. package/lib/commonjs/list/ListItemBase.js +23 -5
  8. package/lib/commonjs/list/ListItemBase.js.map +1 -1
  9. package/lib/commonjs/page-footer/PageFooter.js +1 -0
  10. package/lib/commonjs/page-footer/PageFooter.js.map +1 -1
  11. package/lib/commonjs/page-header/EdgeScrim.js +38 -10
  12. package/lib/commonjs/page-header/EdgeScrim.js.map +1 -1
  13. package/lib/commonjs/page-header/PageHeader.js +1 -0
  14. package/lib/commonjs/page-header/PageHeader.js.map +1 -1
  15. package/lib/commonjs/sidebar/SidebarFolder.js +2 -0
  16. package/lib/commonjs/sidebar/SidebarFolder.js.map +1 -1
  17. package/lib/commonjs/sidebar/SidebarTreeSection.js +2 -0
  18. package/lib/commonjs/sidebar/SidebarTreeSection.js.map +1 -1
  19. package/lib/module/list/ListItemBase.js +24 -6
  20. package/lib/module/list/ListItemBase.js.map +1 -1
  21. package/lib/module/page-footer/PageFooter.js +2 -1
  22. package/lib/module/page-footer/PageFooter.js.map +1 -1
  23. package/lib/module/page-header/EdgeScrim.js +37 -9
  24. package/lib/module/page-header/EdgeScrim.js.map +1 -1
  25. package/lib/module/page-header/PageHeader.js +2 -1
  26. package/lib/module/page-header/PageHeader.js.map +1 -1
  27. package/lib/module/sidebar/SidebarFolder.js +2 -0
  28. package/lib/module/sidebar/SidebarFolder.js.map +1 -1
  29. package/lib/module/sidebar/SidebarTreeSection.js +2 -0
  30. package/lib/module/sidebar/SidebarTreeSection.js.map +1 -1
  31. package/lib/typescript/commonjs/list/ListItemBase.d.ts.map +1 -1
  32. package/lib/typescript/commonjs/list/types.d.ts +4 -0
  33. package/lib/typescript/commonjs/list/types.d.ts.map +1 -1
  34. package/lib/typescript/commonjs/page-footer/PageFooter.d.ts.map +1 -1
  35. package/lib/typescript/commonjs/page-footer/types.d.ts +1 -1
  36. package/lib/typescript/commonjs/page-header/EdgeScrim.d.ts +14 -6
  37. package/lib/typescript/commonjs/page-header/EdgeScrim.d.ts.map +1 -1
  38. package/lib/typescript/commonjs/page-header/PageHeader.d.ts.map +1 -1
  39. package/lib/typescript/commonjs/page-header/types.d.ts +1 -1
  40. package/lib/typescript/commonjs/page-header/types.d.ts.map +1 -1
  41. package/lib/typescript/commonjs/sidebar/SidebarFolder.d.ts.map +1 -1
  42. package/lib/typescript/module/list/ListItemBase.d.ts.map +1 -1
  43. package/lib/typescript/module/list/types.d.ts +4 -0
  44. package/lib/typescript/module/list/types.d.ts.map +1 -1
  45. package/lib/typescript/module/page-footer/PageFooter.d.ts.map +1 -1
  46. package/lib/typescript/module/page-footer/types.d.ts +1 -1
  47. package/lib/typescript/module/page-header/EdgeScrim.d.ts +14 -6
  48. package/lib/typescript/module/page-header/EdgeScrim.d.ts.map +1 -1
  49. package/lib/typescript/module/page-header/PageHeader.d.ts.map +1 -1
  50. package/lib/typescript/module/page-header/types.d.ts +1 -1
  51. package/lib/typescript/module/page-header/types.d.ts.map +1 -1
  52. package/lib/typescript/module/sidebar/SidebarFolder.d.ts.map +1 -1
  53. package/package.json +1 -1
  54. package/src/list/ListItemBase.tsx +26 -6
  55. package/src/list/types.ts +4 -0
  56. package/src/page-footer/PageFooter.tsx +2 -1
  57. package/src/page-footer/types.ts +1 -1
  58. package/src/page-header/EdgeScrim.tsx +49 -10
  59. package/src/page-header/PageHeader.tsx +2 -1
  60. package/src/page-header/types.ts +1 -1
  61. package/src/sidebar/SidebarFolder.tsx +2 -0
  62. package/src/sidebar/SidebarTreeSection.tsx +2 -0
@@ -4,7 +4,7 @@ import { ListCall } from './ListCall';
4
4
  import { ListConversation } from './ListConversation';
5
5
  import { ListMail } from './ListMail';
6
6
  import { ChipRow } from '../chip';
7
- import { memo, useEffect } from 'react';
7
+ import { memo, useEffect, useRef } from 'react';
8
8
  import { Pressable, StyleSheet, View, type PressableProps } from 'react-native';
9
9
  import { Checkbox } from '../checkbox';
10
10
  import { openHref } from '../hooks/link-activation';
@@ -44,6 +44,8 @@ export function createListItem({
44
44
  DropdownMenuItem,
45
45
  }: Bindings) {
46
46
  const Shell = memo(function ListItemShell({
47
+ density = 'comfortable',
48
+ compactPadding = 4,
47
49
  label: labelProp,
48
50
  contextMenu,
49
51
  role,
@@ -80,6 +82,7 @@ export function createListItem({
80
82
  const theme = useTheme();
81
83
  const surface = useSurfaceFill();
82
84
  const touch = useTouchInput();
85
+ const consumedLongPress = useRef(false);
83
86
  const swipeAvailable = useSwipeAvailable();
84
87
  const common = useCommonMessages();
85
88
  useEffect(() => {
@@ -183,11 +186,28 @@ export function createListItem({
183
186
  onPress();
184
187
  } else if (!IS_WEB && href) openHref(href);
185
188
  },
186
- // Keep this mounted throughout selection: RNW only suppresses the release
187
- // click after a long press while the handler remains on the same Pressable.
189
+ // Cancel the browser's compatibility click at its touch source. A consumed
190
+ // long press can move the layout before release, retargeting that click to
191
+ // another row whose RNW responder never received the long press.
192
+ ...(IS_WEB
193
+ ? {
194
+ onTouchStart: () => {
195
+ consumedLongPress.current = false;
196
+ },
197
+ onTouchCancel: () => {
198
+ consumedLongPress.current = false;
199
+ },
200
+ onTouchEnd: (event: import('react-native').GestureResponderEvent) => {
201
+ if (consumedLongPress.current) event.preventDefault();
202
+ consumedLongPress.current = false;
203
+ },
204
+ }
205
+ : {}),
206
+ // Keep this mounted throughout selection for RNW's own responder lifecycle.
188
207
  onLongPress: touch
189
208
  ? () => {
190
209
  if (disabled) return;
210
+ if (IS_WEB && (onCheckedChange || onLongPress)) consumedLongPress.current = true;
191
211
  if (onCheckedChange) {
192
212
  if (!selecting) onCheckedChange(true);
193
213
  } else onLongPress?.();
@@ -212,7 +232,7 @@ export function createListItem({
212
232
  style={[
213
233
  {
214
234
  opacity: disabled ? DISABLED_OPACITY : 1,
215
- minHeight: LIST_ROW_MIN_HEIGHT,
235
+ minHeight: density === 'compact' ? 0 : LIST_ROW_MIN_HEIGHT,
216
236
  borderRadius: 28,
217
237
  '--bloom-list-selected': selectedFill,
218
238
  '--bloom-list-ring': theme.colors.primary,
@@ -238,12 +258,12 @@ export function createListItem({
238
258
  <View
239
259
  pointerEvents="box-none"
240
260
  style={{
241
- minHeight: LIST_ROW_MIN_HEIGHT,
261
+ minHeight: density === 'compact' ? 0 : LIST_ROW_MIN_HEIGHT,
242
262
  flexDirection: 'row',
243
263
  alignItems: 'center',
244
264
  gap: 10,
245
265
  paddingHorizontal: LIST_ROW_INSET,
246
- paddingVertical: 8,
266
+ paddingVertical: density === 'compact' ? compactPadding : 8,
247
267
  }}
248
268
  >
249
269
  {selection ? (
package/src/list/types.ts CHANGED
@@ -141,6 +141,10 @@ export type ListAction = import('../swipe-row/types').SwipeRowAction;
141
141
 
142
142
  /** The shared compact row anatomy for conversations, mail, members and content. */
143
143
  export interface ListCommonProps {
144
+ /** Row density. Comfortable preserves the standard 56px list row; compact lets content and insets set its height. */
145
+ density?: 'comfortable' | 'compact';
146
+ /** Vertical inset for a compact row. Defaults to 4px. */
147
+ compactPadding?: number;
144
148
  /** Structured menu content for commands with groups, submenus or custom controls. */
145
149
  contextMenu?: import('react').ReactNode;
146
150
  /** Semantic choice role when a parent owns radio/listbox navigation. */
@@ -12,7 +12,7 @@ import Animated, { useAnimatedStyle } from 'react-native-reanimated';
12
12
  import { remainingScrollDistance, useScrollMetricsValue } from '../layout/scroll-metrics';
13
13
  import { BloomScope } from '../appearance';
14
14
  import { useBottomEdgeInset } from '../layout/bottom-edge';
15
- import { EdgeScrim, SCRIM_TAIL_RATIO } from '../page-header/EdgeScrim';
15
+ import { EdgeScrim, SCRIM_CHROME_FRACTION, SCRIM_TAIL_RATIO } from '../page-header/EdgeScrim';
16
16
  import { BREAKPOINTS } from '../styles/breakpoints';
17
17
  import { adoptStyleSheet } from '../styles/adopt-style-sheet';
18
18
  import { dataHook } from '../styles/data-hook';
@@ -147,6 +147,7 @@ function PageFooterComponent({
147
147
  >
148
148
  <EdgeScrim
149
149
  edge="bottom"
150
+ opaqueFraction={SCRIM_CHROME_FRACTION}
150
151
  color={scrimColor ?? fill}
151
152
  testID={testID ? `${testID}-scrim-gradient` : undefined}
152
153
  />
@@ -23,7 +23,7 @@ export interface PageFooterProps {
23
23
  */
24
24
  safeArea?: boolean;
25
25
  /**
26
- * Mirrored PageHeader gradient. Default always preserves existing behavior.
26
+ * Mirrored PageHeader gradient: opaque behind measured chrome, fading above it. Default always.
27
27
  * auto follows ScrollMetricsProvider: hidden at the bottom or for short /
28
28
  * unmeasured content, fading in over scrollThreshold of remaining content.
29
29
  */
@@ -30,12 +30,13 @@ import { withAlpha } from '../theme/color-utils';
30
30
  *
31
31
  * ── THE STOPS ───────────────────────────────────────────────────────────────
32
32
  *
33
- * Four of them, shaped as an ease-out rather than a straight line. A LINEAR
33
+ * Four of them describe the fading portion, after any opaque chrome region.
34
+ * They are shaped as an ease-out rather than a straight line. A LINEAR
34
35
  * ramp of opacity is perceptually not linear: it holds too much colour through
35
36
  * the middle and then falls off visibly in the last fifth, which puts a soft
36
37
  * but findable band across the content. Weighting the fall earlier spends the
37
- * gradient's height where the eye is looking — the region behind the title —
38
- * and arrives at zero gently.
38
+ * fading portion's height and arrives at zero gently. Header/footer chrome
39
+ * stays opaque before that portion so scrolling text cannot cross its labels.
39
40
  *
40
41
  * `TAIL_RATIO` extends the ramp BELOW the header's own box. The header is as
41
42
  * tall as its islands plus its padding; the fade needs room after that, or it
@@ -75,12 +76,13 @@ import { withAlpha } from '../theme/color-utils';
75
76
 
76
77
  /** How far past the header's own height the fade continues, as a ratio of it. */
77
78
  export const SCRIM_TAIL_RATIO = 0.55;
79
+ /** Measured chrome occupies this fraction of its chrome + external tail box. */
80
+ export const SCRIM_CHROME_FRACTION = 1 / (1 + SCRIM_TAIL_RATIO);
78
81
 
79
82
  /**
80
83
  * Offset down the ramp -> how much of the page colour survives there.
81
84
  *
82
- * Read as: solid behind the title, nine tenths gone by three quarters of the
83
- * way down, nothing at the bottom.
85
+ * Applied to the fading portion only; any opaque chrome region precedes it.
84
86
  */
85
87
  export const SCRIM_STOPS = [
86
88
  { offset: 0, opacity: 1 },
@@ -105,9 +107,34 @@ export interface EdgeScrimProps {
105
107
  edge?: 'top' | 'bottom';
106
108
  /** Smooth legibility curve by default; linear has only the opaque and transparent endpoints. */
107
109
  falloff?: 'smooth' | 'linear';
110
+ /**
111
+ * Fraction of the gradient box kept opaque from its anchored edge, in [0, 1].
112
+ * Defaults to 0 for a full-box fade. Header/footer supply their measured
113
+ * chrome's share of the box; the curve then occupies only the external tail.
114
+ */
115
+ opaqueFraction?: number;
108
116
  testID?: string;
109
117
  }
110
118
 
119
+ /** Both renderers use the same normalized positions, including the solid region. */
120
+ function scrimStops(falloff: 'smooth' | 'linear', opaqueFraction: number) {
121
+ const fraction = Number.isFinite(opaqueFraction) ? Math.max(0, Math.min(1, opaqueFraction)) : 0;
122
+ const stops = falloff === 'linear' ? LINEAR_STOPS : SCRIM_STOPS;
123
+ if (fraction === 0) return stops;
124
+ if (fraction === 1)
125
+ return [
126
+ { offset: 0, opacity: 1 },
127
+ { offset: 1, opacity: 1 },
128
+ ];
129
+ return [
130
+ { offset: 0, opacity: 1 },
131
+ ...stops.map((stop) => ({
132
+ offset: fraction + (1 - fraction) * stop.offset,
133
+ opacity: stop.opacity,
134
+ })),
135
+ ];
136
+ }
137
+
111
138
  /**
112
139
  * The ramp as a CSS gradient, for Android's own `experimental_backgroundImage`.
113
140
  *
@@ -122,9 +149,11 @@ export function edgeScrimGradient(
122
149
  color: string,
123
150
  edge: 'top' | 'bottom',
124
151
  falloff: 'smooth' | 'linear' = 'smooth',
152
+ opaqueFraction = 0,
125
153
  ): string {
126
- const stops = (falloff === 'linear' ? LINEAR_STOPS : SCRIM_STOPS)
127
- .map((stop) => `${withAlpha(color, stop.opacity)} ${Math.round(stop.offset * 100)}%`)
154
+ const stops = scrimStops(falloff, opaqueFraction)
155
+ // Keep fractional positions: rounding down can expose the last chrome pixels.
156
+ .map((stop) => `${withAlpha(color, stop.opacity)} ${stop.offset * 100}%`)
128
157
  .join(', ');
129
158
  return `linear-gradient(to ${edge === 'bottom' ? 'top' : 'bottom'}, ${stops})`;
130
159
  }
@@ -133,6 +162,7 @@ const EdgeScrimComponent: React.FC<EdgeScrimProps> = ({
133
162
  color,
134
163
  edge = 'top',
135
164
  falloff = 'smooth',
165
+ opaqueFraction = 0,
136
166
  testID,
137
167
  }) => {
138
168
  if (Platform.OS === 'android') {
@@ -141,18 +171,27 @@ const EdgeScrimComponent: React.FC<EdgeScrimProps> = ({
141
171
  testID={testID}
142
172
  style={[
143
173
  StyleSheet.absoluteFill,
144
- { experimental_backgroundImage: edgeScrimGradient(color, edge, falloff) },
174
+ { experimental_backgroundImage: edgeScrimGradient(color, edge, falloff, opaqueFraction) },
145
175
  ]}
146
176
  />
147
177
  );
148
178
  }
149
- return <SvgEdgeScrim color={color} edge={edge} falloff={falloff} testID={testID} />;
179
+ return (
180
+ <SvgEdgeScrim
181
+ color={color}
182
+ edge={edge}
183
+ falloff={falloff}
184
+ opaqueFraction={opaqueFraction}
185
+ testID={testID}
186
+ />
187
+ );
150
188
  };
151
189
 
152
190
  const SvgEdgeScrim: React.FC<EdgeScrimProps> = ({
153
191
  color,
154
192
  edge = 'top',
155
193
  falloff = 'smooth',
194
+ opaqueFraction = 0,
156
195
  testID,
157
196
  }) => {
158
197
  const id = `${useSvgIdPrefix('bloom-page-header-scrim')}gradient`;
@@ -167,7 +206,7 @@ const SvgEdgeScrim: React.FC<EdgeScrimProps> = ({
167
206
  x2="0"
168
207
  y2={fromBottom ? '0' : '1'}
169
208
  >
170
- {(falloff === 'linear' ? LINEAR_STOPS : SCRIM_STOPS).map((stop) => (
209
+ {scrimStops(falloff, opaqueFraction).map((stop) => (
171
210
  <Stop
172
211
  key={stop.offset}
173
212
  offset={String(stop.offset)}
@@ -59,7 +59,7 @@ import { useSurfaceFillRecipe } from '../styles/surface-levels';
59
59
  import { Title, Subtitle } from '../typography';
60
60
  import { Surface } from '../surface/Surface';
61
61
  import { PageHeaderIdentity } from './PageHeaderIdentity';
62
- import { EdgeScrim, SCRIM_TAIL_RATIO } from './EdgeScrim';
62
+ import { EdgeScrim, SCRIM_CHROME_FRACTION, SCRIM_TAIL_RATIO } from './EdgeScrim';
63
63
  import type { PageHeaderProps } from './types';
64
64
  import { useCommonMessages } from '../locale/common-messages';
65
65
  import { useCssSafeAreaInsets } from '../hooks/use-css-safe-area-insets';
@@ -886,6 +886,7 @@ function PageHeaderComponent({
886
886
  // falling back to the page. Explicit scrimColor remains an override.
887
887
  color={scrimColor ?? (imageScrim ? '#000000' : surfaceFill)}
888
888
  falloff={scrimFalloff}
889
+ opaqueFraction={tone !== 'onImage' && scrimFalloff === 'smooth' ? SCRIM_CHROME_FRACTION : 0}
889
890
  testID={testID ? `${testID}-scrim-gradient` : undefined}
890
891
  />
891
892
  </Animated.View>
@@ -170,7 +170,7 @@ export interface PageHeaderProps {
170
170
  transparent?: boolean;
171
171
  /** `presentation="floating"` only. Default `auto`. */
172
172
  scrim?: PageHeaderScrim;
173
- /** Floating gradient curve. Default smooth; linear fades uniformly from opaque to transparent. */
173
+ /** Default smooth protects measured chrome and fades outside it; linear/onImage fade across the full box. */
174
174
  scrimFalloff?: 'smooth' | 'linear';
175
175
  /**
176
176
  * The colour the edge effect fades FROM. Defaults to `theme.colors.background`
@@ -105,6 +105,8 @@ export function SidebarTreeRow({
105
105
  testID={`sidebar-tree-row-${item.key}`}
106
106
  >
107
107
  <ListItem
108
+ density="compact"
109
+ compactPadding={tree.padding}
108
110
  style={{ flex: 1, minWidth: 0 }}
109
111
  active={item.selected ?? selected}
110
112
  label={[item.label, item.description, item.meta].filter(Boolean).join(', ')}
@@ -594,6 +594,8 @@ const TreeRow = memo(function TreeRow({
594
594
  )
595
595
  ) : null}
596
596
  <ListItem
597
+ density="compact"
598
+ compactPadding={tree.padding}
597
599
  testID={`sidebar-tree-item-${item.key}`}
598
600
  active={selected}
599
601
  label={[item.label, item.description, item.meta].filter(Boolean).join(', ')}