@oxy.so/bloom 1.0.8 → 1.1.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.
@@ -23,6 +23,37 @@
23
23
  * content rather than displacing it). They render BEFORE the content wrapper so
24
24
  * z-index — not DOM order — decides layering.
25
25
  *
26
+ * That sticky/`100dvh` sizing is itself a CHOICE, not the only mode — see
27
+ * `overlaySizing`. It is correct exactly when the panel's own DOM height can
28
+ * exceed one viewport in a document that actually scrolls (dvh gives the
29
+ * overlay a fixed, viewport-sized height that a percentage cannot: percentage
30
+ * heights need a definite ancestor height, which an auto-height document-flow
31
+ * ancestor never has). A consumer whose OWN shell already bounds the panel's
32
+ * height (no document scroll) doesn't have that problem, and viewport-sizing
33
+ * there is actively wrong — the overlay reads `100dvh` regardless of how much
34
+ * of the viewport is actually the panel's, so anything the consumer placed
35
+ * outside the panel (a header above it, say) gets painted over.
36
+ * `overlaySizing="panel"` is that second mode: CSS Grid layer-stacking (every
37
+ * child placed in the same `grid-area: 1/1`) instead of sticky/dvh/negative-
38
+ * margin — each child fills exactly the grid cell, i.e. exactly the panel's
39
+ * own box, whatever that box's real height is. No `position: absolute` (that
40
+ * takes the content wrapper out of flow, which is not what "panel" mode
41
+ * changes — only the two overlays' sizing mechanism changes) and no percentage
42
+ * margin (the well-known CSS quirk where a vertical margin percentage resolves
43
+ * against the containing block's WIDTH, not its height, so it cannot express
44
+ * "100% of my own height" at all).
45
+ *
46
+ * The bleed-mask's `clip-path` also changes with the mode, not just its box
47
+ * size: `inset(-12px)` (viewport mode) is a deliberate small halo — the
48
+ * `box-shadow`'s `GUTTER_MASK_SPREAD` is 40px, and the clip-path caps how much
49
+ * of that is actually allowed to paint past the box edge. A document-scroll
50
+ * consumer has nothing else positioned right above/below the panel for that
51
+ * halo to land on. A bounded-shell consumer might — the whole reason for
52
+ * `overlaySizing="panel"` is that something IS placed right outside the panel
53
+ * — so panel mode clips the shadow flush to the box (`inset(0)`, zero bleed)
54
+ * rather than merely resizing the box and leaving a smaller bleed that could
55
+ * still reach a close sibling.
56
+ *
26
57
  * Framing is tri-state via the `framed` prop:
27
58
  *
28
59
  * - `undefined` (DEFAULT) → RESPONSIVE, driven purely by NativeWind: full-bleed
@@ -120,6 +151,8 @@ const ContentPanelComponent: React.FC<ContentPanelProps> = ({
120
151
  contentStyle,
121
152
  showStickyFrame,
122
153
  maskColor,
154
+ overlaySizing = 'viewport',
155
+ overlayTopOffset,
123
156
  }) => {
124
157
  // Dev-only invariant — must run unconditionally (before deriving any
125
158
  // mode-specific branch) so the hook order stays stable (rules of hooks).
@@ -133,6 +166,7 @@ const ContentPanelComponent: React.FC<ContentPanelProps> = ({
133
166
  // Responsive mode selects a pre-shipped literal breakpoint bundle by value;
134
167
  // `framed === true`/`false` ignore `framedFrom` (fixed always/never framing).
135
168
  const bp = RESPONSIVE_WEB[framedFrom];
169
+ const boundToPanel = overlaySizing === 'panel';
136
170
 
137
171
  // Whole literal class strings selected per mode (the Tailwind content-scan
138
172
  // over `lib/**` requires each arbitrary/`min-*`/`max-*`/`web:` token stay
@@ -148,25 +182,64 @@ const ContentPanelComponent: React.FC<ContentPanelProps> = ({
148
182
  : framed
149
183
  ? 'flex-1 rounded-radius-28 web:overflow-x-clip'
150
184
  : 'flex-1';
151
- const surfaceClass = [surfaceBase, surfaceClassName ?? 'bg-card'].join(' ');
152
- const contentClass = [contentBase, contentClassName].filter(Boolean).join(' ');
185
+ // `overlaySizing="panel"`: the surface becomes a single-cell CSS Grid so the
186
+ // overlays and the content wrapper below can all be placed in that ONE cell
187
+ // (`web:[grid-area:1/1]`) and each fill it exactly — `minmax(0,1fr)` (not
188
+ // `1fr` alone) on both axes so the track can still SHRINK below its content's
189
+ // intrinsic size, the grid-track equivalent of the flex `min-height: 0`
190
+ // fix — without it, a tall scrollable child would grow the row instead of
191
+ // being clipped/scrolled inside a fixed-height cell.
192
+ const gridStackClass = boundToPanel
193
+ ? 'web:grid web:[grid-template-columns:minmax(0,1fr)] web:[grid-template-rows:minmax(0,1fr)]'
194
+ : '';
195
+ const surfaceClass = [surfaceBase, gridStackClass, surfaceClassName ?? 'bg-card'].filter(Boolean).join(' ');
196
+ const contentClass = [contentBase, boundToPanel ? 'web:[grid-area:1/1]' : '', contentClassName]
197
+ .filter(Boolean)
198
+ .join(' ');
199
+
200
+ // `overlayTopOffset`: the viewport-mode overlays are sized/positioned from
201
+ // literal Tailwind classes (`top-2`, `h-[calc(100dvh-16px)]`, a matching
202
+ // negative `margin-bottom`) because those values are constants known at
203
+ // build time. An offset is a runtime number (a consumer's measured header
204
+ // height), which a Tailwind arbitrary class can't express — content-scanning
205
+ // needs the literal class string in source, not a value computed later — so
206
+ // this shifts the same three properties via inline `style` instead, which
207
+ // has no such constraint. No-op in `panel` mode (already starts at the
208
+ // panel's own box) and when unset (0/undefined) — the className values are
209
+ // left standing on their own in both of those cases.
210
+ // RN's `ViewStyle.height`/`marginBottom` types only accept a number or a
211
+ // `${number}%` string (not an arbitrary CSS `calc()` string), because most
212
+ // of this type is shared with native, where `calc()` doesn't exist. This
213
+ // file is web-only, where it's a real, valid CSS value react-native-web
214
+ // passes straight through — the same reasoning `WebViewStyle`/`asViewStyle`
215
+ // document in OxyHQ/Mention's `types/webStyles.ts` for the identical need.
216
+ const topOffsetStyle = !boundToPanel && overlayTopOffset
217
+ ? ({
218
+ top: 8 + overlayTopOffset,
219
+ height: `calc(100dvh - ${16 + overlayTopOffset}px)`,
220
+ marginBottom: `calc(-100dvh + ${16 + overlayTopOffset}px)`,
221
+ } as unknown as ViewStyle)
222
+ : undefined;
153
223
 
154
224
  return (
155
225
  <ContentPanelNestingContext.Provider value={true}>
156
- <StyledView className={surfaceClass} style={surfaceStyle}>
226
+ <StyledView testID="content-panel-surface" className={surfaceClass} style={surfaceStyle}>
157
227
  {/* (1) Bleed-mask overlay — gutter box-shadow ring, below chrome. Not
158
228
  rendered when never-framed; `max-md:hidden` (display:none <md) when
159
229
  responsive, so the breakpoint is decided in CSS, not by remounting. */}
160
230
  {showOverlays && (
161
231
  <StyledView
162
232
  key="bleed-mask"
233
+ testID="content-panel-bleed-mask"
163
234
  pointerEvents="none"
164
235
  className={
165
- responsive
166
- ? `web:sticky web:top-2 z-30 h-[calc(100dvh-16px)] w-full rounded-radius-28 ${bp.overlayHidden} web:[margin-bottom:calc(-100dvh+16px)] web:[clip-path:inset(-12px)]`
167
- : 'web:sticky web:top-2 z-30 h-[calc(100dvh-16px)] w-full rounded-radius-28 web:[margin-bottom:calc(-100dvh+16px)] web:[clip-path:inset(-12px)]'
236
+ boundToPanel
237
+ ? `web:[grid-area:1/1] z-30 h-full w-full rounded-radius-28 ${responsive ? bp.overlayHidden : ''} web:[clip-path:inset(0)]`
238
+ : responsive
239
+ ? `web:sticky web:top-2 z-30 h-[calc(100dvh-16px)] w-full rounded-radius-28 ${bp.overlayHidden} web:[margin-bottom:calc(-100dvh+16px)] web:[clip-path:inset(-12px)]`
240
+ : 'web:sticky web:top-2 z-30 h-[calc(100dvh-16px)] w-full rounded-radius-28 web:[margin-bottom:calc(-100dvh+16px)] web:[clip-path:inset(-12px)]'
168
241
  }
169
- style={{ boxShadow: `0 0 0 ${GUTTER_MASK_SPREAD}px ${maskColor ?? colors.background}` }}
242
+ style={{ ...topOffsetStyle, boxShadow: `0 0 0 ${GUTTER_MASK_SPREAD}px ${maskColor ?? colors.background}` }}
170
243
  />
171
244
  )}
172
245
  {/* (2) Border-frame overlay — one continuous rounded border, above all.
@@ -174,11 +247,15 @@ const ContentPanelComponent: React.FC<ContentPanelProps> = ({
174
247
  {showOverlays && showStickyFrame !== false && (
175
248
  <StyledView
176
249
  key="border-frame"
250
+ testID="content-panel-border-frame"
177
251
  pointerEvents="none"
252
+ style={topOffsetStyle}
178
253
  className={
179
- responsive
180
- ? `web:sticky web:top-2 z-[120] h-[calc(100dvh-16px)] w-full rounded-radius-28 border border-border ${bp.overlayHidden} web:[margin-bottom:calc(-100dvh+16px)]`
181
- : 'web:sticky web:top-2 z-[120] h-[calc(100dvh-16px)] w-full rounded-radius-28 border border-border web:[margin-bottom:calc(-100dvh+16px)]'
254
+ boundToPanel
255
+ ? `web:[grid-area:1/1] z-[120] h-full w-full rounded-radius-28 border border-border ${responsive ? bp.overlayHidden : ''}`
256
+ : responsive
257
+ ? `web:sticky web:top-2 z-[120] h-[calc(100dvh-16px)] w-full rounded-radius-28 border border-border ${bp.overlayHidden} web:[margin-bottom:calc(-100dvh+16px)]`
258
+ : 'web:sticky web:top-2 z-[120] h-[calc(100dvh-16px)] w-full rounded-radius-28 border border-border web:[margin-bottom:calc(-100dvh+16px)]'
182
259
  }
183
260
  />
184
261
  )}
@@ -186,7 +263,7 @@ const ContentPanelComponent: React.FC<ContentPanelProps> = ({
186
263
  in place instead of remounting `{children}` (which would reset feed
187
264
  scroll/virtualizer + refetch on a breakpoint cross). Clipped to the
188
265
  rounded panel shape on web when framed. */}
189
- <StyledView key="content" className={contentClass} style={contentStyle}>
266
+ <StyledView key="content" testID="content-panel-content" className={contentClass} style={contentStyle}>
190
267
  {children}
191
268
  </StyledView>
192
269
  </StyledView>
@@ -46,4 +46,40 @@ export interface ContentPanelProps {
46
46
  * API parity — no-op on native (there is no bleed-mask), like `framed`.
47
47
  */
48
48
  maskColor?: string;
49
+ /**
50
+ * How the WEB overlays (bleed-mask, border-frame) size themselves. No-op on
51
+ * native (there are no overlays to size).
52
+ * - `'viewport'` (DEFAULT) — sized to the dynamic viewport height (`100dvh`)
53
+ * and `position: sticky`-pinned, so they read as a constant frame around
54
+ * the visible slice of a panel whose own DOM height can exceed one screen
55
+ * — the document-scroll case (e.g. a feed whose page grows with content).
56
+ * Requires the panel to sit in a document that actually scrolls; see
57
+ * `ContentPanel.web.tsx`'s doc comment.
58
+ * - `'panel'` — sized to the panel's own real box via CSS Grid layer-
59
+ * stacking (the overlays and the content wrapper all occupy the same
60
+ * grid cell) instead of viewport math. The right mode for a consumer
61
+ * whose own shell already bounds the panel's height (no document
62
+ * scroll — a fixed app shell with its own internal scroll containers),
63
+ * where anything the consumer places outside the panel (e.g. a header
64
+ * above it) must never be overlapped by an overlay sized to the whole
65
+ * viewport.
66
+ */
67
+ overlaySizing?: 'viewport' | 'panel';
68
+ /**
69
+ * Pixels of REAL, persistent chrome the consumer has placed above the panel
70
+ * — outside it, in normal document flow — that the viewport-mode overlays
71
+ * (`overlaySizing="viewport"`, the default) do not otherwise know about.
72
+ * No-op when `overlaySizing="panel"` (that mode already starts at the
73
+ * panel's own box, wherever that is) and on native (no overlays there).
74
+ *
75
+ * The overlays are sized/positioned off the VIEWPORT (`top: 8px`,
76
+ * `height: calc(100dvh - 16px)`) on the assumption that the panel begins
77
+ * near the true top of the screen. A consumer with its own sticky chrome
78
+ * above the panel (a header, say, kept sticky-pinned the same way) shifts
79
+ * where the panel visually starts without moving the panel's own DOM
80
+ * position, so the overlays would still read from viewport 0 and paint
81
+ * over that chrome. This shifts their `top` down and shrinks their height
82
+ * by the same amount, so they begin exactly where the panel visually does.
83
+ */
84
+ overlayTopOffset?: number;
49
85
  }
@@ -1,20 +0,0 @@
1
- /**
2
- * A barrel that DELIBERATELY offers one name from two declarations, so that
3
- * `barrel-name-collisions.test.ts` can prove its detector fires. It reproduces
4
- * the shipped `Item` shape: a star export carrying `Item` from `item/`, and an
5
- * explicit re-export binding that same name to a different component.
6
- *
7
- * Nothing imports this at runtime. bob's `exclude` keeps it out of `lib/`, and
8
- * `files: ["src", …]` does ship it inside the tarball's `src/` like the other
9
- * test files there — but no entry point reaches it, so no bundler links it, and
10
- * `package.json#exports` never names it.
11
- *
12
- * The `Card` lines below are the other half of the
13
- * control: one name offered twice from ONE declaration, which the detector must
14
- * stay quiet about — otherwise its cheapest fix would be deleting a legitimate
15
- * redundant re-export.
16
- */
17
- export * from '../../item';
18
- export { Card as Item } from '../../card';
19
- export { Card } from '../../card';
20
- export * from '../../card';
@@ -1,68 +0,0 @@
1
- /**
2
- * A spec-shaped stand-in for constructed stylesheets, for the jsdom suites.
3
- *
4
- * jsdom 26 ships the `CSSStyleSheet` CONSTRUCTOR but neither `replaceSync` nor
5
- * `document.adoptedStyleSheets`, so every jsdom test takes Bloom's `<style>`
6
- * fallback. That makes the whole CSP-safe path — the reason
7
- * `styles/adopt-style-sheet.ts` exists — invisible to jest unless a test
8
- * installs the API itself. Without this, a mutation that deleted the adoption
9
- * branch entirely would leave the suite green.
10
- *
11
- * Not collected as a suite: jest's `testMatch` wants `*.test.ts` / `*.spec.ts`.
12
- */
13
-
14
- export interface FakeStyleSheet {
15
- /** The CSS most recently handed to `replaceSync`. */
16
- cssText: string;
17
- /** How many times the sheet has been re-parsed, so a test can prove it wasn't. */
18
- replaceSyncCalls: number;
19
- replaceSync(css: string): void;
20
- }
21
-
22
- export interface ConstructedStyleSheetsHarness {
23
- /** The document's adopted sheets, read live (the code reassigns the array). */
24
- adopted(): readonly FakeStyleSheet[];
25
- /** Drop the API again, restoring jsdom's own `CSSStyleSheet`. */
26
- uninstall(): void;
27
- }
28
-
29
- export function installConstructedStyleSheets(): ConstructedStyleSheetsHarness {
30
- class FakeCSSStyleSheet implements FakeStyleSheet {
31
- cssText = '';
32
- replaceSyncCalls = 0;
33
-
34
- replaceSync(css: string): void {
35
- this.cssText = css;
36
- this.replaceSyncCalls += 1;
37
- }
38
- }
39
-
40
- const previousConstructor = Object.getOwnPropertyDescriptor(
41
- globalThis,
42
- 'CSSStyleSheet',
43
- );
44
-
45
- Object.defineProperty(globalThis, 'CSSStyleSheet', {
46
- value: FakeCSSStyleSheet,
47
- writable: true,
48
- configurable: true,
49
- });
50
- Object.defineProperty(document, 'adoptedStyleSheets', {
51
- value: [],
52
- writable: true,
53
- configurable: true,
54
- });
55
-
56
- return {
57
- adopted: () =>
58
- document.adoptedStyleSheets as unknown as readonly FakeStyleSheet[],
59
- uninstall: () => {
60
- Reflect.deleteProperty(document, 'adoptedStyleSheets');
61
- if (previousConstructor) {
62
- Object.defineProperty(globalThis, 'CSSStyleSheet', previousConstructor);
63
- } else {
64
- Reflect.deleteProperty(globalThis, 'CSSStyleSheet');
65
- }
66
- },
67
- };
68
- }
@@ -1,30 +0,0 @@
1
- /**
2
- * Pressing a component's OWN host node, and proving the component is what
3
- * installed the handler being measured.
4
- *
5
- * `fireEvent.press` walks UP from the element it is handed to the nearest
6
- * ancestor carrying an `onPress` prop, and it does not stop at host nodes — a
7
- * COMPOSITE counts, because `getEventHandler` only reads `element.props`. So
8
- * `<Thing onPress={fn}>` written in a test's own JSX catches the press itself.
9
- * Measured on `ProfileCard`: with the handler deleted from the component the
10
- * card rendered as an inert `View`, and the test still reported exactly one
11
- * call. Green, and measuring nothing. Nine suites had the same shape.
12
- *
13
- * Asserting the host node's own `onPress` FIRST closes both halves:
14
- *
15
- * - a component that installs no handler at all fails here, and
16
- * - a component that installs one which drops the caller's fails on the call
17
- * count, because `fireEvent` now finds a handler AT the node and never walks
18
- * past it to the test's own JSX.
19
- *
20
- * `host` must therefore be the node the component itself made pressable — the
21
- * one carrying its `testID` / `accessibilityLabel` — not a `Text` deep inside
22
- * it, or the walk-up is back and so is the hole.
23
- */
24
- import { fireEvent } from '@testing-library/react-native';
25
- import type { ReactTestInstance } from 'react-test-renderer';
26
-
27
- export function pressHost(host: ReactTestInstance): void {
28
- expect(typeof host.props.onPress).toBe('function');
29
- fireEvent.press(host);
30
- }
@@ -1,99 +0,0 @@
1
- /**
2
- * Reading what actually landed on a rendered node — shared by every suite that
3
- * asserts the "className lands on the node the parent lays out" rule.
4
- *
5
- * Three components had the same two-node defect (`Button`, then `Fab` and
6
- * `FrostedIconButton`), and asserting it needs the same two things each time:
7
- * the HOST tree (composites do not appear in `toJSON()`, so a wrapper is only
8
- * visible there) and a deep flatten of the `style` prop, because react-native-css
9
- * merges a caller's class in as a `{ $$css: true, className }` descriptor
10
- * ALONGSIDE the style objects rather than in a prop of its own.
11
- */
12
- import type { ReactTestRendererJSON } from 'react-test-renderer';
13
-
14
- export type StyleEntry = Record<string, unknown>;
15
-
16
- export interface HostNode {
17
- type: string;
18
- props: Record<string, unknown>;
19
- children: Array<HostNode | string> | null;
20
- }
21
-
22
- /**
23
- * Deep-flatten an RN `style` prop (nested arrays, `false`/`null` holes) into the
24
- * list of style objects that actually reached the node.
25
- */
26
- export function styleEntries(style: unknown, out: StyleEntry[] = []): StyleEntry[] {
27
- if (!style || typeof style !== 'object') return out;
28
- if (Array.isArray(style)) {
29
- for (const entry of style) styleEntries(entry, out);
30
- return out;
31
- }
32
- out.push(style as StyleEntry);
33
- return out;
34
- }
35
-
36
- /** Every style key/value that landed on a node, later entries winning. */
37
- export function resolvedStyle(style: unknown): StyleEntry {
38
- return Object.assign({}, ...styleEntries(style)) as StyleEntry;
39
- }
40
-
41
- /** The class tokens react-native-css accepted for a node, in arrival order. */
42
- export function classNamesOn(style: unknown): string[] {
43
- return styleEntries(style)
44
- .filter((entry) => entry.$$css === true && typeof entry.className === 'string')
45
- .map((entry) => String(entry.className));
46
- }
47
-
48
- export function isHostNode(value: unknown): value is HostNode {
49
- return (
50
- typeof value === 'object' && value !== null && typeof (value as HostNode).type === 'string'
51
- );
52
- }
53
-
54
- /** Walk the HOST tree (composites are absent from `toJSON()`) for a testID. */
55
- export function findHost(
56
- node: ReactTestRendererJSON | ReactTestRendererJSON[] | unknown,
57
- testID: string,
58
- ): HostNode | null {
59
- if (Array.isArray(node)) {
60
- for (const child of node) {
61
- const hit = findHost(child, testID);
62
- if (hit) return hit;
63
- }
64
- return null;
65
- }
66
- if (!isHostNode(node)) return null;
67
- if (node.props.testID === testID) return node;
68
- return findHost(node.children, testID);
69
- }
70
-
71
- /**
72
- * Every host node in a rendered tree, in document order.
73
- *
74
- * The reason to walk `toJSON()` rather than `UNSAFE_root.findAll` is that the
75
- * latter yields COMPOSITE instances too, so a `memo(fn)` component contributes
76
- * two matches for one rendered element and every count is silently doubled —
77
- * which reads as "the component rendered the thing twice", not as an artefact
78
- * of the query.
79
- */
80
- export function hostNodes(tree: unknown, out: HostNode[] = []): HostNode[] {
81
- if (Array.isArray(tree)) {
82
- for (const child of tree) hostNodes(child, out);
83
- return out;
84
- }
85
- if (!isHostNode(tree)) return out;
86
- out.push(tree);
87
- return hostNodes(tree.children, out);
88
- }
89
-
90
- /**
91
- * The host nodes a parent laid out. Callers assert the LENGTH themselves —
92
- * "exactly one" is the property, and a helper that returned only the first would
93
- * hide the second.
94
- */
95
- export function renderedChildren(tree: unknown, hostTestID: string): HostNode[] {
96
- const host = findHost(tree, hostTestID);
97
- if (host === null) throw new Error(`no host rendered for testID "${hostTestID}"`);
98
- return (host.children ?? []).filter(isHostNode);
99
- }
@@ -1,33 +0,0 @@
1
- /**
2
- * A module that DELIBERATELY throws away one of the values a hook hands back, so
3
- * `hook-subscriptions-are-read.test.ts` can prove its detector fires. It carries
4
- * both halves of the control: `unreadFlag` is bound and never read, which the
5
- * detector must report, and `readFlag` is bound and read, which it must stay
6
- * quiet about — otherwise the cheapest way to green the gate would be deleting a
7
- * binding that is doing its job.
8
- *
9
- * Nothing imports this at runtime. bob's `exclude` keeps it out of `lib/`, and
10
- * `files: ["src", …]` does ship it inside the tarball's `src/` like the other
11
- * 137 test files there — but no entry point reaches it, so no bundler links it.
12
- * It is a plain `.ts` with no React import because the
13
- * detector reads source, never types: a call named `use…` bound to a name is all
14
- * the shape there is.
15
- *
16
- * The destructuring RENAMES, which is not decoration — it reproduces the shipped
17
- * shape (`const { state: pressed, onIn: onPressIn } = useInteractionState()`) and
18
- * it is what keeps the control honest. A hook declared in the same file as its
19
- * caller mentions its own property names in its return type and its return
20
- * object, and the detector counts every occurrence of a spelling as a possible
21
- * read, so an unrenamed fixture would be silently unreportable for a reason no
22
- * real call site has.
23
- */
24
-
25
- /** Stands in for a real subscription — a hook by name, with two return values. */
26
- function useFixtureInteractionState(): { first: boolean; second: boolean } {
27
- return { first: false, second: false };
28
- }
29
-
30
- export function fixtureComponentBody(): boolean {
31
- const { first: readFlag, second: unreadFlag } = useFixtureInteractionState();
32
- return readFlag;
33
- }