@oxyhq/bloom 1.0.5 → 1.0.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.
- package/lib/commonjs/floating/menu-sub-flyout.js +77 -5
- package/lib/commonjs/floating/menu-sub-flyout.js.map +1 -1
- package/lib/module/floating/menu-sub-flyout.js +77 -5
- package/lib/module/floating/menu-sub-flyout.js.map +1 -1
- package/lib/typescript/commonjs/floating/menu-sub-flyout.d.ts.map +1 -1
- package/lib/typescript/module/floating/menu-sub-flyout.d.ts.map +1 -1
- package/package.json +1 -1
- package/src/floating/menu-sub-flyout.tsx +97 -6
- package/src/__tests__/support/collision-fixture-barrel.ts +0 -20
- package/src/__tests__/support/constructed-style-sheets.ts +0 -68
- package/src/__tests__/support/press-host.ts +0 -30
- package/src/__tests__/support/rendered-style.ts +0 -99
- package/src/__tests__/support/unread-hook-fixture.ts +0 -33
- package/src/theme/__tests__/__fixtures__/golden-resolved-tokens.json +0 -7682
- package/src/theme/__tests__/fixtures/color-engine-golden.json +0 -1
|
@@ -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
|
-
}
|