@oxyhq/bloom 0.54.0 → 0.55.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.
- package/lib/commonjs/tab-bar/TabBarBase.js +101 -16
- package/lib/commonjs/tab-bar/TabBarBase.js.map +1 -1
- package/lib/commonjs/tab-bar/shared.js +15 -1
- package/lib/commonjs/tab-bar/shared.js.map +1 -1
- package/lib/commonjs/toast/ToastRow.js +35 -10
- package/lib/commonjs/toast/ToastRow.js.map +1 -1
- package/lib/commonjs/toast/ToastSwipeHandler.js +15 -5
- package/lib/commonjs/toast/ToastSwipeHandler.js.map +1 -1
- package/lib/commonjs/toast/constants.js +18 -1
- package/lib/commonjs/toast/constants.js.map +1 -1
- package/lib/commonjs/toast/toast-store.js +39 -1
- package/lib/commonjs/toast/toast-store.js.map +1 -1
- package/lib/commonjs/toast/use-stack-hover.js +175 -0
- package/lib/commonjs/toast/use-stack-hover.js.map +1 -0
- package/lib/commonjs/toast/use-stack-hover.native.js +42 -0
- package/lib/commonjs/toast/use-stack-hover.native.js.map +1 -0
- package/lib/module/tab-bar/TabBarBase.js +103 -18
- package/lib/module/tab-bar/TabBarBase.js.map +1 -1
- package/lib/module/tab-bar/shared.js +14 -0
- package/lib/module/tab-bar/shared.js.map +1 -1
- package/lib/module/toast/ToastRow.js +35 -10
- package/lib/module/toast/ToastRow.js.map +1 -1
- package/lib/module/toast/ToastSwipeHandler.js +16 -4
- package/lib/module/toast/ToastSwipeHandler.js.map +1 -1
- package/lib/module/toast/constants.js +18 -1
- package/lib/module/toast/constants.js.map +1 -1
- package/lib/module/toast/toast-store.js +39 -1
- package/lib/module/toast/toast-store.js.map +1 -1
- package/lib/module/toast/use-stack-hover.js +168 -0
- package/lib/module/toast/use-stack-hover.js.map +1 -0
- package/lib/module/toast/use-stack-hover.native.js +35 -0
- package/lib/module/toast/use-stack-hover.native.js.map +1 -0
- package/lib/typescript/commonjs/tab-bar/TabBarBase.d.ts.map +1 -1
- package/lib/typescript/commonjs/tab-bar/shared.d.ts +13 -0
- package/lib/typescript/commonjs/tab-bar/shared.d.ts.map +1 -1
- package/lib/typescript/commonjs/tab-bar/types.d.ts +12 -0
- package/lib/typescript/commonjs/tab-bar/types.d.ts.map +1 -1
- package/lib/typescript/commonjs/toast/ToastRow.d.ts.map +1 -1
- package/lib/typescript/commonjs/toast/ToastSwipeHandler.d.ts +4 -0
- package/lib/typescript/commonjs/toast/ToastSwipeHandler.d.ts.map +1 -1
- package/lib/typescript/commonjs/toast/constants.d.ts.map +1 -1
- package/lib/typescript/commonjs/toast/toast-store.d.ts +15 -0
- package/lib/typescript/commonjs/toast/toast-store.d.ts.map +1 -1
- package/lib/typescript/commonjs/toast/use-stack-hover.d.ts +55 -0
- package/lib/typescript/commonjs/toast/use-stack-hover.d.ts.map +1 -0
- package/lib/typescript/commonjs/toast/use-stack-hover.native.d.ts +26 -0
- package/lib/typescript/commonjs/toast/use-stack-hover.native.d.ts.map +1 -0
- package/lib/typescript/module/tab-bar/TabBarBase.d.ts.map +1 -1
- package/lib/typescript/module/tab-bar/shared.d.ts +13 -0
- package/lib/typescript/module/tab-bar/shared.d.ts.map +1 -1
- package/lib/typescript/module/tab-bar/types.d.ts +12 -0
- package/lib/typescript/module/tab-bar/types.d.ts.map +1 -1
- package/lib/typescript/module/toast/ToastRow.d.ts.map +1 -1
- package/lib/typescript/module/toast/ToastSwipeHandler.d.ts +4 -0
- package/lib/typescript/module/toast/ToastSwipeHandler.d.ts.map +1 -1
- package/lib/typescript/module/toast/constants.d.ts.map +1 -1
- package/lib/typescript/module/toast/toast-store.d.ts +15 -0
- package/lib/typescript/module/toast/toast-store.d.ts.map +1 -1
- package/lib/typescript/module/toast/use-stack-hover.d.ts +55 -0
- package/lib/typescript/module/toast/use-stack-hover.d.ts.map +1 -0
- package/lib/typescript/module/toast/use-stack-hover.native.d.ts +26 -0
- package/lib/typescript/module/toast/use-stack-hover.native.d.ts.map +1 -0
- package/package.json +1 -1
- package/src/__tests__/TabBarNoSelection.test.tsx +458 -0
- package/src/__tests__/TabBarReanimatedDeps.test.ts +28 -4
- package/src/__tests__/Toaster.test.tsx +554 -0
- package/src/__tests__/animated-style-deps.test.ts +30 -6
- package/src/__tests__/toast-position-utils.test.ts +28 -0
- package/src/__tests__/toast-stack-hover.test.ts +92 -0
- package/src/__tests__/toast-store.test.ts +72 -0
- package/src/tab-bar/TabBar.stories.tsx +52 -1
- package/src/tab-bar/TabBarBase.tsx +113 -31
- package/src/tab-bar/shared.ts +12 -0
- package/src/tab-bar/types.ts +12 -0
- package/src/toast/Toast.stories.tsx +10 -0
- package/src/toast/ToastRow.tsx +33 -10
- package/src/toast/ToastSwipeHandler.tsx +14 -2
- package/src/toast/constants.ts +18 -1
- package/src/toast/toast-store.ts +39 -1
- package/src/toast/use-stack-hover.native.ts +34 -0
- package/src/toast/use-stack-hover.ts +182 -0
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["_tokens","require","ESTIMATED_TOAST_HEIGHT","exports","CLOSE_BUTTON_HIT_AREA","OUTSIDE_PRESS_PADDING","MIN_STACK_SCALE_X","TOAST_MAX_ROW_WIDTH","space","lg","ENTERING_ANIMATION_DURATION","STACKING_ANIMATION_DURATION","toastDefaults","duration","position","offset","swipeToDismissDirection","variant","undefined","visibleToasts","closeButton","dismissible","unstyled","invert","pauseWhenPageIsHidden","gap","theme","autoWiggleOnUpdate","richColors","enableStacking","stackGap","allowFontScaling"],"sourceRoot":"../../../src","sources":["toast/constants.ts"],"mappings":";;;;;;AAQA,IAAAA,OAAA,GAAAC,OAAA;AARA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAUA;AACO,MAAMC,sBAAsB,GAAAC,OAAA,CAAAD,sBAAA,GAAG,EAAE;AACjC,MAAME,qBAAqB,GAAAD,OAAA,CAAAC,qBAAA,GAAG,EAAE;AAChC,MAAMC,qBAAqB,GAAAF,OAAA,CAAAE,qBAAA,GAAG,EAAE;AACvC;AACO,MAAMC,iBAAiB,GAAAH,OAAA,CAAAG,iBAAA,GAAG,GAAG;;AAEpC;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACO,MAAMC,mBAAmB,GAAAJ,OAAA,CAAAI,mBAAA,GAAG,GAAG,GAAGC,aAAK,CAACC,EAAE,GAAG,CAAC;;AAErD;AACO,MAAMC,2BAA2B,GAAAP,OAAA,CAAAO,2BAAA,GAAG,GAAG;AACvC,MAAMC,2BAA2B,GAAAR,OAAA,CAAAQ,2BAAA,GAAG,GAAG;AAEvC,MAAMC,aAmBZ,GAAAT,OAAA,CAAAS,aAAA,GAAG;EACFC,QAAQ,EAAE,IAAI;EACdC,QAAQ,EAAE,eAAe;EACzB;AACF;AACA;AACA;AACA;EACEC,MAAM,EAAE,CAAC;EACTC,uBAAuB,EAAE,MAAM;EAC/B;AACF;AACA;AACA;AACA;EACEC,OAAO,EAAEC,SAAS;EAClBC,aAAa,EAAE,CAAC;EAChBC,WAAW,EAAE,KAAK;EAClBC,WAAW,EAAE,IAAI;EACjBC,QAAQ,EAAE,KAAK;EACfC,MAAM,EAAE,KAAK;EACbC,qBAAqB,EAAE,IAAI;EAC3BC,GAAG,EAAE,CAAC;EACNC,KAAK,EAAE,QAAQ;EACfC,kBAAkB,EAAE,OAAO;EAC3BC,UAAU,EAAE,KAAK;
|
|
1
|
+
{"version":3,"names":["_tokens","require","ESTIMATED_TOAST_HEIGHT","exports","CLOSE_BUTTON_HIT_AREA","OUTSIDE_PRESS_PADDING","MIN_STACK_SCALE_X","TOAST_MAX_ROW_WIDTH","space","lg","ENTERING_ANIMATION_DURATION","STACKING_ANIMATION_DURATION","toastDefaults","duration","position","offset","swipeToDismissDirection","variant","undefined","visibleToasts","closeButton","dismissible","unstyled","invert","pauseWhenPageIsHidden","gap","theme","autoWiggleOnUpdate","richColors","enableStacking","stackGap","allowFontScaling"],"source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AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;EACEC,cAAc,EAAE,IAAI;EACpBC,QAAQ,EAAE,CAAC;EACXC,gBAAgB,EAAE;AACpB,CAAC","ignoreList":[]}
|
|
@@ -39,6 +39,7 @@ class ToastStore {
|
|
|
39
39
|
pendingPromises = new Set();
|
|
40
40
|
collapseCooldown = false;
|
|
41
41
|
collapseCooldownTimeout = null;
|
|
42
|
+
expansionHold = null;
|
|
42
43
|
subscribe = callback => {
|
|
43
44
|
this.subscribers.add(callback);
|
|
44
45
|
return () => {
|
|
@@ -53,6 +54,23 @@ class ToastStore {
|
|
|
53
54
|
setConfig = config => {
|
|
54
55
|
this.config = config;
|
|
55
56
|
};
|
|
57
|
+
|
|
58
|
+
/**
|
|
59
|
+
* Something outside the store can HOLD an expanded stack open — on web, a pointer
|
|
60
|
+
* resting on it. Registered by the platform trigger (`use-stack-hover`) so this
|
|
61
|
+
* module stays pure JS with no DOM and no platform branch; native registers
|
|
62
|
+
* nothing and the predicate stays `null`.
|
|
63
|
+
*
|
|
64
|
+
* It is asked at DECISION time rather than tracked as state on purpose: a row can
|
|
65
|
+
* stop being under the pointer with no event at all — rows unmount under the
|
|
66
|
+
* cursor and move under a stationary one, and neither fires `pointerleave` —
|
|
67
|
+
* so any cached boolean goes stale. Nothing renders from this, so it is
|
|
68
|
+
* deliberately not part of the snapshot.
|
|
69
|
+
*/
|
|
70
|
+
setExpansionHold = hold => {
|
|
71
|
+
this.expansionHold = hold;
|
|
72
|
+
};
|
|
73
|
+
isHeldOpen = () => this.expansionHold?.() === true;
|
|
56
74
|
notify = () => {
|
|
57
75
|
this.subscribers.forEach(callback => callback());
|
|
58
76
|
};
|
|
@@ -245,7 +263,27 @@ class ToastStore {
|
|
|
245
263
|
...this.state.toastRefs
|
|
246
264
|
};
|
|
247
265
|
delete updatedRefs[id];
|
|
248
|
-
|
|
266
|
+
|
|
267
|
+
/**
|
|
268
|
+
* An expanded stack collapses itself once a single row is left, because
|
|
269
|
+
* "expanded" then means nothing visually — a lone row resolves to the SAME
|
|
270
|
+
* offset and scale either way (`toast-position-utils.test.ts` pins that) — while
|
|
271
|
+
* `isExpanded` keeps every timer paused, so staying expanded would leave that
|
|
272
|
+
* last toast on screen forever with no visible reason. Inherited from
|
|
273
|
+
* sonner-native and kept deliberately: on native it is invisible and it is the
|
|
274
|
+
* only thing that stops the last row hanging.
|
|
275
|
+
*
|
|
276
|
+
* UNLESS something is holding the stack open. On web that is a pointer resting
|
|
277
|
+
* on it, and collapsing under the cursor would resume the timers hover had just
|
|
278
|
+
* paused — the toast would then expire while the user is reading it, which is
|
|
279
|
+
* exactly what hover exists to prevent.
|
|
280
|
+
*
|
|
281
|
+
* An EMPTY stack always resets, hold or no hold: it no longer exists to be held,
|
|
282
|
+
* and once the rows unmount no `pointerleave` will ever arrive to release it.
|
|
283
|
+
*/
|
|
284
|
+
const isEmpty = filteredToasts.length === 0;
|
|
285
|
+
const heldOpen = !isEmpty && this.isHeldOpen();
|
|
286
|
+
const shouldAutoCollapse = filteredToasts.length <= 1 && this.state.isExpanded && !heldOpen;
|
|
249
287
|
const updatedIndex = this.cloneIndex();
|
|
250
288
|
updatedIndex.delete(id);
|
|
251
289
|
this.state = {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["React","_interopRequireWildcard","require","_constants","_toastComparator","_toastTimers","e","t","WeakMap","r","n","__esModule","o","i","f","__proto__","default","has","get","set","hasOwnProperty","call","Object","defineProperty","getOwnPropertyDescriptor","COLLAPSE_COOLDOWN","ToastStore","state","toasts","toastsById","Map","toastsCounter","toastRefs","shouldShowOverlay","toastHeights","isExpanded","subscribers","Set","config","timers","ToastTimerRegistry","hideOverlayTimeout","pendingPromises","collapseCooldown","collapseCooldownTimeout","subscribe","callback","add","delete","getSnapshot","setConfig","notify","forEach","cloneIndex","resolveDuration","duration","toastDefaults","scheduleAutoClose","id","start","onComplete","dismissToast","pauseTimer","pause","resumeTimer","resume","pauseAllTimers","pauseAll","resumeAllTimers","resumeAll","handlePromise","toast","promiseOptions","title","promise","addToast","variant","undefined","styles","success","error","options","providedId","length","nextCounter","newToast","numberOfToasts","index","orderedToastIds","existingToast","shouldWiggle","autoWiggleOnUpdate","areToastsEqual","wiggleToast","updatedToasts","map","currentToast","updatedIndex","updatedEntry","find","newToasts","newToastRefs","createRef","visibleToasts","newIndex","updatedHeights","heightsChanged","removedToast","shift","clear","clearTimeout","origin","clearAll","onDismiss","onAutoClose","scheduleHideOverlay","toastForCallback","filteredToasts","filter","updatedRefs","shouldAutoCollapse","setTimeout","ENTERING_ANIMATION_DURATION","current","wiggle","getToastRef","setToastHeight","height","expand","collapse","toggleExpand","toastStore","exports"],"sourceRoot":"../../../src","sources":["toast/toast-store.ts"],"mappings":";;;;;;AAUA,IAAAA,KAAA,GAAAC,uBAAA,CAAAC,OAAA;AACA,IAAAC,UAAA,GAAAD,OAAA;AACA,IAAAE,gBAAA,GAAAF,OAAA;AACA,IAAAG,YAAA,GAAAH,OAAA;AAAoD,SAAAD,wBAAAK,CAAA,EAAAC,CAAA,6BAAAC,OAAA,MAAAC,CAAA,OAAAD,OAAA,IAAAE,CAAA,OAAAF,OAAA,YAAAP,uBAAA,YAAAA,CAAAK,CAAA,EAAAC,CAAA,SAAAA,CAAA,IAAAD,CAAA,IAAAA,CAAA,CAAAK,UAAA,SAAAL,CAAA,MAAAM,CAAA,EAAAC,CAAA,EAAAC,CAAA,KAAAC,SAAA,QAAAC,OAAA,EAAAV,CAAA,iBAAAA,CAAA,uBAAAA,CAAA,yBAAAA,CAAA,SAAAQ,CAAA,MAAAF,CAAA,GAAAL,CAAA,GAAAG,CAAA,GAAAD,CAAA,QAAAG,CAAA,CAAAK,GAAA,CAAAX,CAAA,UAAAM,CAAA,CAAAM,GAAA,CAAAZ,CAAA,GAAAM,CAAA,CAAAO,GAAA,CAAAb,CAAA,EAAAQ,CAAA,gBAAAP,CAAA,IAAAD,CAAA,gBAAAC,CAAA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5B,IAAI,IAAI,CAACC,uBAAuB,EAAE;MAChCkE,YAAY,CAAC,IAAI,CAAClE,uBAAuB,CAAC;IAC5C;IACA,IAAI,CAACA,uBAAuB,GAAG6E,UAAU,CAAC,MAAM;MAC9C,IAAI,CAAC9E,gBAAgB,GAAG,KAAK;MAC7B,IAAI,CAACC,uBAAuB,GAAG,IAAI;IACrC,CAAC,EAAEnB,iBAAiB,CAAC;IAErB,IAAI,CAACc,MAAM,CAAC8B,SAAS,CAAC,CAAC;IACvB,IAAI,CAAClB,MAAM,CAAC,CAAC;EACf,CAAC;EAED+E,YAAY,GAAGA,CAAA,KAAM;IACnB,IAAI,CAAC,IAAI,CAACvG,KAAK,CAACQ,UAAU,IAAI,IAAI,CAACQ,gBAAgB,EAAE;MACnD;IACF;IAEA,IAAI,IAAI,CAAChB,KAAK,CAACQ,UAAU,EAAE;MACzB,IAAI,CAAC8F,QAAQ,CAAC,CAAC;IACjB,CAAC,MAAM;MACL,IAAI,CAACD,MAAM,CAAC,CAAC;IACf;EACF,CAAC;AACH;AAEO,MAAMG,UAAU,GAAAC,OAAA,CAAAD,UAAA,GAAG,IAAIzG,UAAU,CAAC,CAAC","ignoreList":[]}
|
|
1
|
+
{"version":3,"names":["React","_interopRequireWildcard","require","_constants","_toastComparator","_toastTimers","e","t","WeakMap","r","n","__esModule","o","i","f","__proto__","default","has","get","set","hasOwnProperty","call","Object","defineProperty","getOwnPropertyDescriptor","COLLAPSE_COOLDOWN","ToastStore","state","toasts","toastsById","Map","toastsCounter","toastRefs","shouldShowOverlay","toastHeights","isExpanded","subscribers","Set","config","timers","ToastTimerRegistry","hideOverlayTimeout","pendingPromises","collapseCooldown","collapseCooldownTimeout","expansionHold","subscribe","callback","add","delete","getSnapshot","setConfig","setExpansionHold","hold","isHeldOpen","notify","forEach","cloneIndex","resolveDuration","duration","toastDefaults","scheduleAutoClose","id","start","onComplete","dismissToast","pauseTimer","pause","resumeTimer","resume","pauseAllTimers","pauseAll","resumeAllTimers","resumeAll","handlePromise","toast","promiseOptions","title","promise","addToast","variant","undefined","styles","success","error","options","providedId","length","nextCounter","newToast","numberOfToasts","index","orderedToastIds","existingToast","shouldWiggle","autoWiggleOnUpdate","areToastsEqual","wiggleToast","updatedToasts","map","currentToast","updatedIndex","updatedEntry","find","newToasts","newToastRefs","createRef","visibleToasts","newIndex","updatedHeights","heightsChanged","removedToast","shift","clear","clearTimeout","origin","clearAll","onDismiss","onAutoClose","scheduleHideOverlay","toastForCallback","filteredToasts","filter","updatedRefs","isEmpty","heldOpen","shouldAutoCollapse","setTimeout","ENTERING_ANIMATION_DURATION","current","wiggle","getToastRef","setToastHeight","height","expand","collapse","toggleExpand","toastStore","exports"],"sourceRoot":"../../../src","sources":["toast/toast-store.ts"],"mappings":";;;;;;AAUA,IAAAA,KAAA,GAAAC,uBAAA,CAAAC,OAAA;AACA,IAAAC,UAAA,GAAAD,OAAA;AACA,IAAAE,gBAAA,GAAAF,OAAA;AACA,IAAAG,YAAA,GAAAH,OAAA;AAAoD,SAAAD,wBAAAK,CAAA,EAAAC,CAAA,6BAAAC,OAAA,MAAAC,CAAA,OAAAD,OAAA,IAAAE,CAAA,OAAAF,OAAA,YAAAP,uBAAA,YAAAA,CAAAK,CAAA,EAAAC,CAAA,SAAAA,CAAA,IAAAD,CAAA,IAAAA,CAAA,CAAAK,UAAA,SAAAL,CAAA,MAAAM,CAAA,EAAAC,CAAA,EAAAC,CAAA,KAAAC,SAAA,QAAAC,OAAA,EAAAV,CAAA,iBAAAA,CAAA,uBAAAA,CAAA,yBAAAA,CAAA,SAAAQ,CAAA,MAAAF,CAAA,GAAAL,CAAA,GAAAG,CAAA,GAAAD,CAAA,QAAAG,CAAA,CAAAK,GAAA,CAAAX,CAAA,UAAAM,CAAA,CAAAM,GAAA,CAAAZ,CAAA,GAAAM,CAAA,CAAAO,GAAA,CAAAb,CAAA,EAAAQ,CAAA,gBAAAP,CAAA,IAAAD,CAAA,gBAAAC,CAAA,OAAAa,cAAA,CAAA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 +1,175 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports.HOVER_LEAVE_GRACE = void 0;
|
|
7
|
+
exports.isStackHovered = isStackHovered;
|
|
8
|
+
exports.resetStackHoverForTests = resetStackHoverForTests;
|
|
9
|
+
exports.useStackHover = useStackHover;
|
|
10
|
+
var _react = require("react");
|
|
11
|
+
var _toastStore = require("./toast-store.js");
|
|
12
|
+
/**
|
|
13
|
+
* Bloom-original — WEB/default. `use-stack-hover.native.ts` is the native no-op,
|
|
14
|
+
* filename-resolved by Metro exactly as `ToastHost.native.tsx` is, so `toast/`
|
|
15
|
+
* stays one universal engine with no `index.web` fork.
|
|
16
|
+
*
|
|
17
|
+
* sonner expands its stack on HOVER; sonner-native only has press, because a phone
|
|
18
|
+
* has no pointer. Bloom needs both: press is the touch and native affordance, hover
|
|
19
|
+
* is what a desktop user expects, and a touch-capable web device must not get a
|
|
20
|
+
* phantom hover from its own taps.
|
|
21
|
+
*
|
|
22
|
+
* THIS IS A TRIGGER, NOT A SECOND MECHANISM. It drives the store's existing
|
|
23
|
+
* `expand`/`collapse`, which already pause and resume the auto-close timers
|
|
24
|
+
* (`ToastStore.expand` calls `timers.pauseAll()`, `collapse` calls `resumeAll()`),
|
|
25
|
+
* so hovering to read a toast cannot let it expire under the cursor — no new
|
|
26
|
+
* pausing path, no new store state. With stacking OFF there is nothing to expand,
|
|
27
|
+
* so the pointer pauses the timers directly instead: the reason sonner pauses is
|
|
28
|
+
* that the pointer is over the toast, which has nothing to do with stacking.
|
|
29
|
+
*
|
|
30
|
+
* TWO THINGS ARE LOAD-BEARING:
|
|
31
|
+
*
|
|
32
|
+
* - `pointerType === 'mouse'`. Touch fires `pointerenter` before `pointerdown`
|
|
33
|
+
* and `pointerleave` after `pointerup` (the pointer ceases to exist), so
|
|
34
|
+
* without this guard every TAP on a touch-capable web device would expand then
|
|
35
|
+
* collapse the stack while the press toggle fired too — three handlers fighting
|
|
36
|
+
* over one tap. Hover is additive: pens and touch fall through to press.
|
|
37
|
+
* - THE LEAVE IS DEFERRED BY A FRAME-ISH GRACE PERIOD, and any enter cancels it.
|
|
38
|
+
* Rows are separate absolutely-positioned boxes with `gap` between them once
|
|
39
|
+
* expanded, so moving the pointer from one row to the next leaves the first
|
|
40
|
+
* before entering the second. Collapsing on that would snap the stack shut and
|
|
41
|
+
* reopen it on whatever row ends up under the pointer — a jitter loop, plus a
|
|
42
|
+
* resume/pause pair per crossing that re-banks each timer's remaining time.
|
|
43
|
+
*
|
|
44
|
+
* The state is module-level on purpose: there is ONE stack per document, the same
|
|
45
|
+
* reason `toastStore` is a module singleton. It is written and read only inside
|
|
46
|
+
* event handlers — never in render — so the React Compiler has nothing to freeze.
|
|
47
|
+
*/
|
|
48
|
+
|
|
49
|
+
/**
|
|
50
|
+
* How long a leave waits for a neighbouring row to claim the pointer. One frame is
|
|
51
|
+
* enough for the same-tick leave/enter pair a row crossing produces; this is a
|
|
52
|
+
* little more so a slow frame cannot flash the stack shut. Exported so the suite
|
|
53
|
+
* asserts against the real value rather than a copy of it.
|
|
54
|
+
*/
|
|
55
|
+
const HOVER_LEAVE_GRACE = exports.HOVER_LEAVE_GRACE = 80;
|
|
56
|
+
|
|
57
|
+
/** The portal root every toast row lives under — see `portal/index.web.tsx`. */
|
|
58
|
+
const PORTAL_ROOT_ID = 'bloom-portal-root';
|
|
59
|
+
let hovered = false;
|
|
60
|
+
let leaveTimeout = null;
|
|
61
|
+
const isMouse = event => event.nativeEvent.pointerType === 'mouse';
|
|
62
|
+
const cancelPendingLeave = () => {
|
|
63
|
+
if (leaveTimeout !== null) {
|
|
64
|
+
clearTimeout(leaveTimeout);
|
|
65
|
+
leaveTimeout = null;
|
|
66
|
+
}
|
|
67
|
+
};
|
|
68
|
+
|
|
69
|
+
/**
|
|
70
|
+
* Whether the pointer is over the stack RIGHT NOW.
|
|
71
|
+
*
|
|
72
|
+
* Two sources, and both are load-bearing:
|
|
73
|
+
*
|
|
74
|
+
* - the `hovered` latch answers "a mouse entered and has not left", which is the
|
|
75
|
+
* only thing available where there is no DOM (jest runs on `testEnvironment:
|
|
76
|
+
* 'node'`), and is a cheap early-out.
|
|
77
|
+
* - the live `:hover` query answers "a row is under the pointer", which the latch
|
|
78
|
+
* CANNOT: a row can stop being hovered with no event whatsoever. Measured — a row
|
|
79
|
+
* culled by `visibleToasts` under a stationary cursor fires no `pointerleave`,
|
|
80
|
+
* `pointerout` or `mouseleave` at all, and the restack then slides the remaining
|
|
81
|
+
* rows out from under the pointer. A latch alone therefore sticks TRUE, which
|
|
82
|
+
* would disable the press toggle for the rest of the session and suppress every
|
|
83
|
+
* later auto-collapse.
|
|
84
|
+
*
|
|
85
|
+
* Requiring both means a stale latch is corrected by the DOM and a stray DOM match
|
|
86
|
+
* (a pen, a touch) is rejected by the latch.
|
|
87
|
+
*
|
|
88
|
+
* COVERAGE, stated plainly: jest cannot see the DOM half at all
|
|
89
|
+
* (`testEnvironment: 'node'`), and a browser cannot isolate it either — its two
|
|
90
|
+
* consequences are a press toggle standing down (unreachable with a mouse, which
|
|
91
|
+
* always hovers what it presses) and a suppressed auto-collapse (which the deferred
|
|
92
|
+
* leave below independently corrects the moment any boundary event fires). Both
|
|
93
|
+
* halves are kept because each is measurably more accurate than the other alone, not
|
|
94
|
+
* because a test proves the composite.
|
|
95
|
+
*
|
|
96
|
+
* `ToastRow` asks so a press does not TOGGLE what hover already opened, and
|
|
97
|
+
* `toastStore` asks before auto-collapsing a stack down to its last row. The press
|
|
98
|
+
* still runs the toast's own `onPress`; only the expansion toggle steps aside.
|
|
99
|
+
*/
|
|
100
|
+
function isStackHovered() {
|
|
101
|
+
return hovered && rowUnderPointer() !== false;
|
|
102
|
+
}
|
|
103
|
+
|
|
104
|
+
/**
|
|
105
|
+
* The live DOM answer, or `undefined` where there is no DOM to ask (jest runs on
|
|
106
|
+
* `testEnvironment: 'node'`). Deliberately tri-state: "unknowable" and "no" must not
|
|
107
|
+
* collapse into the same value, because the two callers want opposite defaults —
|
|
108
|
+
* `isStackHovered` trusts the latch when it cannot check, while the deferred leave
|
|
109
|
+
* only stands down on a positive "yes, still hovered".
|
|
110
|
+
*/
|
|
111
|
+
function rowUnderPointer() {
|
|
112
|
+
if (typeof document === 'undefined') {
|
|
113
|
+
return undefined;
|
|
114
|
+
}
|
|
115
|
+
return document.querySelector(`#${PORTAL_ROOT_ID} [aria-live]:hover`) !== null;
|
|
116
|
+
}
|
|
117
|
+
|
|
118
|
+
/**
|
|
119
|
+
* A pointer resting on the stack HOLDS it open, so the store must not auto-collapse
|
|
120
|
+
* it out from under the cursor. Registered here rather than passed in because this
|
|
121
|
+
* file is the one that knows what hovering means; the store only knows that
|
|
122
|
+
* something says "not yet". Native's fork registers nothing.
|
|
123
|
+
*/
|
|
124
|
+
_toastStore.toastStore.setExpansionHold(isStackHovered);
|
|
125
|
+
function useStackHover({
|
|
126
|
+
enableStacking
|
|
127
|
+
}) {
|
|
128
|
+
// Stable per outlet configuration: these land on the row box as props, and every
|
|
129
|
+
// row re-renders on each stack change.
|
|
130
|
+
return (0, _react.useMemo)(() => ({
|
|
131
|
+
onPointerEnter: event => {
|
|
132
|
+
if (!isMouse(event)) {
|
|
133
|
+
return;
|
|
134
|
+
}
|
|
135
|
+
cancelPendingLeave();
|
|
136
|
+
hovered = true;
|
|
137
|
+
if (enableStacking) {
|
|
138
|
+
// Pauses the timers as part of expanding.
|
|
139
|
+
_toastStore.toastStore.expand();
|
|
140
|
+
} else {
|
|
141
|
+
_toastStore.toastStore.pauseAllTimers();
|
|
142
|
+
}
|
|
143
|
+
},
|
|
144
|
+
onPointerLeave: event => {
|
|
145
|
+
if (!isMouse(event) || !hovered) {
|
|
146
|
+
return;
|
|
147
|
+
}
|
|
148
|
+
cancelPendingLeave();
|
|
149
|
+
leaveTimeout = setTimeout(() => {
|
|
150
|
+
leaveTimeout = null;
|
|
151
|
+
// The rows may have moved rather than the pointer: an expand, a collapse
|
|
152
|
+
// or a restack slides them under a stationary cursor without firing a
|
|
153
|
+
// single pointer event, so re-ask the DOM before acting on a leave that
|
|
154
|
+
// fired 80ms ago. Only a positive "still hovered" stands the collapse down.
|
|
155
|
+
if (rowUnderPointer() === true) {
|
|
156
|
+
return;
|
|
157
|
+
}
|
|
158
|
+
hovered = false;
|
|
159
|
+
if (enableStacking) {
|
|
160
|
+
// Resumes the timers as part of collapsing.
|
|
161
|
+
_toastStore.toastStore.collapse();
|
|
162
|
+
} else {
|
|
163
|
+
_toastStore.toastStore.resumeAllTimers();
|
|
164
|
+
}
|
|
165
|
+
}, HOVER_LEAVE_GRACE);
|
|
166
|
+
}
|
|
167
|
+
}), [enableStacking]);
|
|
168
|
+
}
|
|
169
|
+
|
|
170
|
+
/** Test-only reset: the module state outlives a render tree, so a suite must clear it. */
|
|
171
|
+
function resetStackHoverForTests() {
|
|
172
|
+
cancelPendingLeave();
|
|
173
|
+
hovered = false;
|
|
174
|
+
}
|
|
175
|
+
//# sourceMappingURL=use-stack-hover.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"names":["_react","require","_toastStore","HOVER_LEAVE_GRACE","exports","PORTAL_ROOT_ID","hovered","leaveTimeout","isMouse","event","nativeEvent","pointerType","cancelPendingLeave","clearTimeout","isStackHovered","rowUnderPointer","document","undefined","querySelector","toastStore","setExpansionHold","useStackHover","enableStacking","useMemo","onPointerEnter","expand","pauseAllTimers","onPointerLeave","setTimeout","collapse","resumeAllTimers","resetStackHoverForTests"],"sourceRoot":"../../../src","sources":["toast/use-stack-hover.ts"],"mappings":";;;;;;;;;AAoCA,IAAAA,MAAA,GAAAC,OAAA;AAEA,IAAAC,WAAA,GAAAD,OAAA;AAtCA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;A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BN,OAAO,GAAG,IAAI;MACd,IAAIgB,cAAc,EAAE;QAClB;QACAH,sBAAU,CAACM,MAAM,CAAC,CAAC;MACrB,CAAC,MAAM;QACLN,sBAAU,CAACO,cAAc,CAAC,CAAC;MAC7B;IACF,CAAC;IACDC,cAAc,EAAGlB,KAAiB,IAAK;MACrC,IAAI,CAACD,OAAO,CAACC,KAAK,CAAC,IAAI,CAACH,OAAO,EAAE;QAC/B;MACF;MACAM,kBAAkB,CAAC,CAAC;MACpBL,YAAY,GAAGqB,UAAU,CAAC,MAAM;QAC9BrB,YAAY,GAAG,IAAI;QACnB;QACA;QACA;QACA;QACA,IAAIQ,eAAe,CAAC,CAAC,KAAK,IAAI,EAAE;UAC9B;QACF;QACAT,OAAO,GAAG,KAAK;QACf,IAAIgB,cAAc,EAAE;UAClB;UACAH,sBAAU,CAACU,QAAQ,CAAC,CAAC;QACvB,CAAC,MAAM;UACLV,sBAAU,CAACW,eAAe,CAAC,CAAC;QAC9B;MACF,CAAC,EAAE3B,iBAAiB,CAAC;IACvB;EACF,CAAC,CAAC,EACF,CAACmB,cAAc,CACjB,CAAC;AACH;;AAEA;AACO,SAASS,uBAAuBA,CAAA,EAAS;EAC9CnB,kBAAkB,CAAC,CAAC;EACpBN,OAAO,GAAG,KAAK;AACjB","ignoreList":[]}
|
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports.HOVER_LEAVE_GRACE = void 0;
|
|
7
|
+
exports.isStackHovered = isStackHovered;
|
|
8
|
+
exports.resetStackHoverForTests = resetStackHoverForTests;
|
|
9
|
+
exports.useStackHover = useStackHover;
|
|
10
|
+
/**
|
|
11
|
+
* Bloom-original — NATIVE. Metro resolves this over `use-stack-hover.ts` on iOS and
|
|
12
|
+
* Android, the same filename split `ToastHost.native.tsx` uses.
|
|
13
|
+
*
|
|
14
|
+
* Native keeps PRESS as the only way to expand a stack, so this hands back no
|
|
15
|
+
* handlers at all. Two reasons it is a fork rather than a runtime `Platform` check:
|
|
16
|
+
* the web file's module-level hover state and its `setTimeout` have no business
|
|
17
|
+
* existing in a native bundle, and `onPointerEnter`/`onPointerLeave` DO fire on
|
|
18
|
+
* native for touch (RN's pointer events unify touch and mouse), which would make
|
|
19
|
+
* every tap expand-then-collapse while the press toggle fired as well.
|
|
20
|
+
*
|
|
21
|
+
* Keep the shape identical to the web file — `ToastSwipeHandler` spreads whatever
|
|
22
|
+
* this returns onto the row box, and `ToastRow` calls `isStackHovered()`
|
|
23
|
+
* unconditionally.
|
|
24
|
+
*/
|
|
25
|
+
|
|
26
|
+
/** Parity with the web file's export; nothing here waits for anything. */
|
|
27
|
+
const HOVER_LEAVE_GRACE = exports.HOVER_LEAVE_GRACE = 0;
|
|
28
|
+
|
|
29
|
+
/** Nothing hovers on a touch screen. */
|
|
30
|
+
function isStackHovered() {
|
|
31
|
+
return false;
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
/** One frozen object, so spreading it never changes the row box's props. */
|
|
35
|
+
const NO_HOVER_PROPS = Object.freeze({});
|
|
36
|
+
function useStackHover(_options) {
|
|
37
|
+
return NO_HOVER_PROPS;
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
/** Parity with the web file so the shared suite can call it on either platform. */
|
|
41
|
+
function resetStackHoverForTests() {}
|
|
42
|
+
//# sourceMappingURL=use-stack-hover.native.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"names":["HOVER_LEAVE_GRACE","exports","isStackHovered","NO_HOVER_PROPS","Object","freeze","useStackHover","_options","resetStackHoverForTests"],"sourceRoot":"../../../src","sources":["toast/use-stack-hover.native.ts"],"mappings":";;;;;;;;;AAAA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAGA;AACO,MAAMA,iBAAiB,GAAAC,OAAA,CAAAD,iBAAA,GAAG,CAAC;;AAElC;AACO,SAASE,cAAcA,CAAA,EAAY;EACxC,OAAO,KAAK;AACd;;AAEA;AACA,MAAMC,cAA+B,GAAGC,MAAM,CAACC,MAAM,CAAC,CAAC,CAAC,CAAC;AAElD,SAASC,aAAaA,CAACC,QAAqC,EAAmB;EACpF,OAAOJ,cAAc;AACvB;;AAEA;AACO,SAASK,uBAAuBA,CAAA,EAAS,CAAC","ignoreList":[]}
|
|
@@ -18,11 +18,11 @@
|
|
|
18
18
|
import { Children, createContext, useCallback, useContext, useEffect, useMemo } from 'react';
|
|
19
19
|
import { Pressable, StyleSheet, useWindowDimensions, View } from 'react-native';
|
|
20
20
|
import { Gesture, GestureDetector } from 'react-native-gesture-handler';
|
|
21
|
-
import Animated, { Extrapolation, interpolate, interpolateColor, runOnJS, useAnimatedStyle, useSharedValue, withSpring } from 'react-native-reanimated';
|
|
21
|
+
import Animated, { Extrapolation, interpolate, interpolateColor, runOnJS, useAnimatedStyle, useSharedValue, withSpring, withTiming } from 'react-native-reanimated';
|
|
22
22
|
import { useSafeAreaInsets } from 'react-native-safe-area-context';
|
|
23
23
|
import { useHaptics } from "../hooks/useHaptics.js";
|
|
24
24
|
import { setMinimized, useMinimizeState } from "./minimize-context.js";
|
|
25
|
-
import { BAR_MARGIN, BLUR_BLEED, EXPANDED_HEIGHT, HIGHLIGHT_EXPANDED, HIGHLIGHT_MINIMIZED, ICON_SIZE, ITEM_GAP, ITEM_PAD_V, LABEL_FONT_SIZE, LONG_PRESS_MIN_DURATION, MINIMIZED_HEIGHT, MINIMIZED_INSET, ROW_PAD_H, SLIDE_SPRING, tabBarBottomGap, useTabBarTheme } from "./shared.js";
|
|
25
|
+
import { BAR_MARGIN, BLUR_BLEED, EXPANDED_HEIGHT, HIGHLIGHT_EXPANDED, HIGHLIGHT_FADE, HIGHLIGHT_MINIMIZED, ICON_SIZE, ITEM_GAP, ITEM_PAD_V, LABEL_FONT_SIZE, LONG_PRESS_MIN_DURATION, MINIMIZED_HEIGHT, MINIMIZED_INSET, ROW_PAD_H, SLIDE_SPRING, tabBarBottomGap, useTabBarTheme } from "./shared.js";
|
|
26
26
|
|
|
27
27
|
/**
|
|
28
28
|
* What a `TabBarButton` needs from the bar it sits in. `null` when a button is
|
|
@@ -55,10 +55,31 @@ function TabBarBody({
|
|
|
55
55
|
} = useWindowDimensions();
|
|
56
56
|
const minimized = useMinimizeState();
|
|
57
57
|
const progress = minimized.progress;
|
|
58
|
+
const tabCount = Math.max(Children.count(children), 1);
|
|
59
|
+
|
|
60
|
+
// Is a tab selected at all?
|
|
61
|
+
//
|
|
62
|
+
// The two states this distinguishes are NOT the same thing, and collapsing
|
|
63
|
+
// them would silently kill the highlight for every router consumer:
|
|
64
|
+
//
|
|
65
|
+
// - `activeIndex === undefined` is the FOCUS-DRIVEN path. The bar is not
|
|
66
|
+
// the writer at all — each `TabBarButton` supplies `isFocused` and drives
|
|
67
|
+
// the highlight itself (that is how the adapter keeps it correct through
|
|
68
|
+
// deep links and back gestures), so from the bar's side there is always a
|
|
69
|
+
// selection and the highlight is always visible.
|
|
70
|
+
// - NO SELECTION is `activeIndex` being a number that names no tab:
|
|
71
|
+
// negative, past the last tab, or fractional. Every consumer whose route
|
|
72
|
+
// set is larger than its tab set produces one — a `usePathname()`-derived
|
|
73
|
+
// index is -1 on every screen that is not a tab — and the highlight must
|
|
74
|
+
// then be gone rather than parked outside the pill.
|
|
75
|
+
const hasSelection = activeIndex === undefined || Number.isInteger(activeIndex) && activeIndex >= 0 && activeIndex < tabCount;
|
|
58
76
|
const slideIndex = useSharedValue(0);
|
|
77
|
+
// Seeded from the CURRENT state, not from 0: a bar that mounts with a
|
|
78
|
+
// selection must show its highlight on the first frame exactly as it always
|
|
79
|
+
// has, and one that mounts without a selection must never flash it.
|
|
80
|
+
const highlightOpacity = useSharedValue(hasSelection ? 1 : 0);
|
|
59
81
|
const isDragging = useSharedValue(false);
|
|
60
82
|
const lastTicked = useSharedValue(-1);
|
|
61
|
-
const tabCount = Math.max(Children.count(children), 1);
|
|
62
83
|
const theme = useTabBarTheme(themeOverrides);
|
|
63
84
|
const impact = useHaptics();
|
|
64
85
|
|
|
@@ -102,8 +123,25 @@ function TabBarBody({
|
|
|
102
123
|
if (activeIndex === undefined) return;
|
|
103
124
|
// While scrubbing the finger owns the highlight; never fight it.
|
|
104
125
|
if (isDragging.value) return;
|
|
105
|
-
|
|
106
|
-
|
|
126
|
+
if (!hasSelection) {
|
|
127
|
+
// Fade out where it stands. `slideIndex` is deliberately left alone: it
|
|
128
|
+
// is the highlight's POSITION, and there is no position that means
|
|
129
|
+
// "nowhere" — springing it to a sentinel would drag the capsule across
|
|
130
|
+
// the bar on its way out, dragging the active tint over every tab it
|
|
131
|
+
// passed. Visibility is the thing that changed, so visibility is the only
|
|
132
|
+
// thing that animates.
|
|
133
|
+
highlightOpacity.value = withTiming(0, HIGHLIGHT_FADE);
|
|
134
|
+
return;
|
|
135
|
+
}
|
|
136
|
+
// Coming back from fully hidden the capsule APPEARS at the new tab instead
|
|
137
|
+
// of travelling to it: a slide says "the selection moved from here to
|
|
138
|
+
// there", and while it was invisible there was no "here" — sliding from the
|
|
139
|
+
// stale index would animate out of a position the user never saw, and would
|
|
140
|
+
// light up every tab in between on the way. Interrupted mid-fade it is
|
|
141
|
+
// still on screen, so from there it slides as it always does.
|
|
142
|
+
slideIndex.value = highlightOpacity.value === 0 ? activeIndex : withSpring(activeIndex, SLIDE_SPRING);
|
|
143
|
+
highlightOpacity.value = withTiming(1, HIGHLIGHT_FADE);
|
|
144
|
+
}, [activeIndex, hasSelection, slideIndex, highlightOpacity, isDragging]);
|
|
107
145
|
|
|
108
146
|
// Scrubbing: the highlight tracks the finger 1:1 while dragging (no spring —
|
|
109
147
|
// it must feel attached), haptic ticks fire on boundary crossings, and
|
|
@@ -126,8 +164,17 @@ function TabBarBody({
|
|
|
126
164
|
const raw = (x - ROW_PAD_H) / itemWidth - 0.5;
|
|
127
165
|
return Math.min(Math.max(raw, 0), tabCount - 1);
|
|
128
166
|
};
|
|
129
|
-
const pan = Gesture.Pan().activeOffsetX([-6, 6]).failOffsetY([-14, 14]).onStart(
|
|
167
|
+
const pan = Gesture.Pan().activeOffsetX([-6, 6]).failOffsetY([-14, 14]).onStart(event => {
|
|
130
168
|
isDragging.value = true;
|
|
169
|
+
// Arming from the no-selection state: a hidden capsule has no position
|
|
170
|
+
// the finger can pick up, so it starts under the finger rather than at
|
|
171
|
+
// the index it faded out on — which would also make the first boundary
|
|
172
|
+
// tick fire against a phantom position. Mid-fade it is still visible,
|
|
173
|
+
// so it keeps the position it is at, exactly as it always has.
|
|
174
|
+
if (highlightOpacity.value === 0) {
|
|
175
|
+
slideIndex.value = indexAtX(event.x, progress.value);
|
|
176
|
+
}
|
|
177
|
+
highlightOpacity.value = withTiming(1, HIGHLIGHT_FADE);
|
|
131
178
|
lastTicked.value = Math.round(slideIndex.value);
|
|
132
179
|
// Scrubbing is a deliberate bar interaction — surface the labels.
|
|
133
180
|
setMinimized(minimized, 0);
|
|
@@ -158,7 +205,10 @@ function TabBarBody({
|
|
|
158
205
|
return;
|
|
159
206
|
}
|
|
160
207
|
const index = Math.round(indexAtX(event.x, progress.value));
|
|
161
|
-
|
|
208
|
+
// Same rule as the controlled path above: appear at the tapped tab when
|
|
209
|
+
// hidden, slide to it when already on screen.
|
|
210
|
+
slideIndex.value = highlightOpacity.value === 0 ? index : withSpring(index, SLIDE_SPRING);
|
|
211
|
+
highlightOpacity.value = withTiming(1, HIGHLIGHT_FADE);
|
|
162
212
|
setMinimized(minimized, 0);
|
|
163
213
|
runOnJS(selectIndex)(index);
|
|
164
214
|
});
|
|
@@ -177,7 +227,7 @@ function TabBarBody({
|
|
|
177
227
|
runOnJS(longPressIndex)(Math.round(indexAtX(event.x, progress.value)));
|
|
178
228
|
});
|
|
179
229
|
return Gesture.Race(pan, tap, longPress);
|
|
180
|
-
}, [barOuterWidth, tabCount, selectIndex, hasLongPress, longPressIndex, tick, isDragging, lastTicked, slideIndex, minimized, progress]);
|
|
230
|
+
}, [barOuterWidth, tabCount, selectIndex, hasLongPress, longPressIndex, tick, isDragging, lastTicked, slideIndex, highlightOpacity, minimized, progress]);
|
|
181
231
|
|
|
182
232
|
// CRITICAL — every shared value and every scalar a mapper READS must appear
|
|
183
233
|
// in its dependency array. On web WITHOUT the react-native-worklets babel
|
|
@@ -237,11 +287,16 @@ function TabBarBody({
|
|
|
237
287
|
width: itemWidth,
|
|
238
288
|
borderRadius: height / 2,
|
|
239
289
|
top: (barHeight - height) / 2,
|
|
290
|
+
// With no selection there is nothing to highlight, and the capsule has to
|
|
291
|
+
// stop being drawn: `slideIndex` is a position in tab units, so an
|
|
292
|
+
// out-of-range one is a real place — one item-width to the LEFT of the
|
|
293
|
+
// first tab, i.e. half outside the pill — not an absence.
|
|
294
|
+
opacity: highlightOpacity.value,
|
|
240
295
|
transform: [{
|
|
241
296
|
translateX: ROW_PAD_H + itemWidth * slideIndex.value
|
|
242
297
|
}]
|
|
243
298
|
};
|
|
244
|
-
}, [progress, slideIndex, barOuterWidth, tabCount]);
|
|
299
|
+
}, [progress, slideIndex, highlightOpacity, barOuterWidth, tabCount]);
|
|
245
300
|
|
|
246
301
|
// Shared with `useTabBarFootprint`, so a consumer accounting for the bar in
|
|
247
302
|
// its own layout can never drift from where the bar actually sits.
|
|
@@ -264,11 +319,12 @@ function TabBarBody({
|
|
|
264
319
|
};
|
|
265
320
|
const barContext = useMemo(() => ({
|
|
266
321
|
slideIndex,
|
|
322
|
+
highlightOpacity,
|
|
267
323
|
isDragging,
|
|
268
324
|
theme,
|
|
269
325
|
activeIndex,
|
|
270
326
|
selectIndex
|
|
271
|
-
}), [slideIndex, isDragging, theme, activeIndex, selectIndex]);
|
|
327
|
+
}), [slideIndex, highlightOpacity, isDragging, theme, activeIndex, selectIndex]);
|
|
272
328
|
return /*#__PURE__*/_jsxs(View, {
|
|
273
329
|
...viewProps,
|
|
274
330
|
style: [styles.root, style],
|
|
@@ -327,6 +383,7 @@ function TabBarButtonBody({
|
|
|
327
383
|
const standaloneTheme = useTabBarTheme();
|
|
328
384
|
const theme = bar?.theme ?? standaloneTheme;
|
|
329
385
|
const slideIndex = bar?.slideIndex;
|
|
386
|
+
const highlightOpacity = bar?.highlightOpacity;
|
|
330
387
|
// The two paths meet here: an explicit `isFocused` (router adapter) wins;
|
|
331
388
|
// otherwise focus comes from the bar's controlled `activeIndex`.
|
|
332
389
|
const focused = isFocused ?? bar?.activeIndex === index;
|
|
@@ -345,14 +402,37 @@ function TabBarButtonBody({
|
|
|
345
402
|
// Tint follows the sliding highlight, not navigation focus: whatever the pill
|
|
346
403
|
// is over lights up — live while scrubbing, traveling on taps. Without a bar
|
|
347
404
|
// there is nothing to follow, so it falls back to plain focus.
|
|
405
|
+
//
|
|
406
|
+
// Scaled by the highlight's own visibility, so a bar with NO selection leaves
|
|
407
|
+
// nothing lit: distance alone would keep the tab the capsule faded out on
|
|
408
|
+
// fully tinted, which is the same bug as a stray capsule wearing a different
|
|
409
|
+
// hat — a tab that looks selected while nothing is.
|
|
348
410
|
// (Deps: see the CRITICAL note in `TabBarBody`.)
|
|
349
|
-
const activeGlyphStyle = useAnimatedStyle(() =>
|
|
350
|
-
|
|
351
|
-
|
|
352
|
-
|
|
353
|
-
|
|
354
|
-
|
|
355
|
-
|
|
411
|
+
const activeGlyphStyle = useAnimatedStyle(() => {
|
|
412
|
+
if (!slideIndex || !highlightOpacity) return {
|
|
413
|
+
opacity: focused ? 1 : 0
|
|
414
|
+
};
|
|
415
|
+
const proximity = 1 - Math.min(Math.abs(slideIndex.value - index), 1);
|
|
416
|
+
return {
|
|
417
|
+
opacity: highlightOpacity.value * proximity
|
|
418
|
+
};
|
|
419
|
+
}, [slideIndex, highlightOpacity, index, focused]);
|
|
420
|
+
const labelStyle = useAnimatedStyle(() => {
|
|
421
|
+
const opacity = interpolate(progress.value, [0, 0.4], [1, 0], Extrapolation.CLAMP);
|
|
422
|
+
if (!slideIndex || !highlightOpacity) {
|
|
423
|
+
return {
|
|
424
|
+
opacity,
|
|
425
|
+
color: focused ? theme.activeTint : theme.inactiveTint
|
|
426
|
+
};
|
|
427
|
+
}
|
|
428
|
+
// Same quantity as the glyph crossfade above, so a label can never disagree
|
|
429
|
+
// with the icon it sits under.
|
|
430
|
+
const proximity = 1 - Math.min(Math.abs(slideIndex.value - index), 1);
|
|
431
|
+
return {
|
|
432
|
+
opacity,
|
|
433
|
+
color: interpolateColor(highlightOpacity.value * proximity, [0, 1], [theme.inactiveTint, theme.activeTint])
|
|
434
|
+
};
|
|
435
|
+
}, [progress, slideIndex, highlightOpacity, index, focused, theme]);
|
|
356
436
|
|
|
357
437
|
// Height is animated EXPLICITLY (not derived from children) so the icon stays
|
|
358
438
|
// perfectly centered every frame — layout-driven sizing lags a frame behind
|
|
@@ -373,7 +453,12 @@ function TabBarButtonBody({
|
|
|
373
453
|
onPress: event => {
|
|
374
454
|
// The bar's GestureDetector normally consumes touches; this still fires
|
|
375
455
|
// for assistive-technology activation (VoiceOver) and keyboard focus.
|
|
376
|
-
if (bar)
|
|
456
|
+
if (bar) {
|
|
457
|
+
// Appear at the tab when hidden, slide to it when visible — the same
|
|
458
|
+
// rule the tap gesture and the controlled path follow.
|
|
459
|
+
bar.slideIndex.value = bar.highlightOpacity.value === 0 ? index : withSpring(index, SLIDE_SPRING);
|
|
460
|
+
bar.highlightOpacity.value = withTiming(1, HIGHLIGHT_FADE);
|
|
461
|
+
}
|
|
377
462
|
setMinimized(minimized, 0);
|
|
378
463
|
// Controlled path only. On the focus-driven path the trigger's own
|
|
379
464
|
// `onPress` below performs the navigation, so reporting the selection
|