asma-ui-core 3.108.1 → 3.108.3

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.
@@ -0,0 +1,101 @@
1
+ import { RefObject } from 'react';
2
+ /**
3
+ * ASMA-8471 — native Back closes the top ui-core overlay through its own close path.
4
+ *
5
+ * This module owns ONLY the overlay side of the contract: a LIFO registry of open overlays plus the
6
+ * arbitration that decides which one a Back press (or a native dialog `cancel`/`close`) acts on. It
7
+ * never touches browser history — no `pushState`, `back()` or `go()` — that lives in
8
+ * `asma-core-helpers`' `getHistory()` adapter (PR #51, ASMA-8476), published at
9
+ * `window.__ASMA__SHELL__.overlayBack = { v, enabled, register }`. When that adapter is live (`v ===
10
+ * 1` and `register` is a function) this module registers ONE long-lived closer with it as soon as the
11
+ * stack goes from empty to non-empty, and unregisters it once the stack drains back to empty — see
12
+ * {@link registerOverlayBackCloser}. When the adapter is absent, or on a version this module doesn't
13
+ * speak, it runs registry-only and never touches `window.__ASMA__SHELL__` at all.
14
+ *
15
+ * **Window-scoped, not module-scoped** — same reasoning as `useTopLayer.hook.ts`'s
16
+ * `__asmaOpenModalDialogRegistry__`: a normal (non-`KERNEL_EXTERNAL`) build instantiates this module
17
+ * once per micro-frontend bundle, so a module-level array would give every bundle its own stack and
18
+ * "close only the top" would silently become "close only MY top" — and TWO bundles would each try to
19
+ * register their own adapter closer. `document.defaultView` (or `rawWindow` under the `asma-micro-app`
20
+ * sandbox) is the one object every bundle in the page shares, so the adapter registration state lives
21
+ * there too.
22
+ */
23
+ export declare const OVERLAY_BACK_REGISTRY_VERSION = 1;
24
+ /** Returns nothing: no latch, a repeated Back repeats the dismissal. Returns a Promise: the entry
25
+ * latches until it settles, and Back on a latched top does nothing (see `requestCloseTopOverlayBack`). */
26
+ export type OverlayBackRequestClose = (event?: Event) => false | void | Promise<unknown>;
27
+ interface OverlayBackEntry {
28
+ requestClose: OverlayBackRequestClose;
29
+ pending: boolean;
30
+ owner: Element | null;
31
+ parentOwner: Element | null;
32
+ ownerRef?: RefObject<Element | null>;
33
+ parentOwnerRef?: RefObject<Element | null>;
34
+ }
35
+ interface OverlayBackAdapterState {
36
+ /** The adapter's own unregister for our one long-lived closer, once `register()` has been called. */
37
+ unregister: (() => void) | null;
38
+ }
39
+ interface OverlayBackRegistry {
40
+ version: number;
41
+ entries: OverlayBackEntry[];
42
+ adapter: OverlayBackAdapterState;
43
+ }
44
+ /** The `asma-core-helpers` contract (PR #51, ASMA-8476): `register` hands it the current top's close
45
+ * function and gets back that registration's unregister. Absent, or `v` other than `1`, means no
46
+ * history adapter is live. */
47
+ interface OverlayBackAdapter {
48
+ v?: number;
49
+ enabled?: boolean;
50
+ pendingNavigation?: boolean;
51
+ register?: (requestClose: OverlayBackRequestClose) => () => void;
52
+ continuePendingNavigation?: () => void;
53
+ failOpenPendingNavigation?: () => void;
54
+ }
55
+ declare global {
56
+ interface Window {
57
+ rawWindow?: Window;
58
+ __asmaOverlayBackRegistry__?: OverlayBackRegistry;
59
+ __ASMA__SHELL__?: {
60
+ overlayBack?: OverlayBackAdapter;
61
+ };
62
+ }
63
+ }
64
+ /**
65
+ * Push a LIFO entry onto the overlay-back stack. The returned unregister must run when the overlay
66
+ * stops being eligible to receive Back (closes, or is no longer the active layer) — see
67
+ * {@link useBackCloses} for the React lifecycle wrapper every consumer actually uses.
68
+ */
69
+ export declare function registerOverlayBackCloser(requestClose: OverlayBackRequestClose, owner?: Element | null, parentOwner?: Element | null, ownerRef?: RefObject<Element | null>, parentOwnerRef?: RefObject<Element | null>): () => void;
70
+ export declare const OverlayBackOwnerContext: import('react').Context<RefObject<Element | null> | undefined>;
71
+ /**
72
+ * Act on the topmost registered overlay, honouring the close contract's latch: a top entry whose
73
+ * previous `requestClose` returned a Promise that hasn't settled yet is skipped entirely (one
74
+ * documented dead press), never passed through to the next entry down — BACK-2 is "one press closes
75
+ * one layer", not "closes the nearest dismissible one".
76
+ *
77
+ * `StyledDialog`'s native `cancel`/`close` arbitration calls this directly, and it is exactly what the
78
+ * one closer registered with the history adapter (`asma-core-helpers`, a separate package) delegates
79
+ * to on an owned traversal.
80
+ */
81
+ export declare function requestCloseTopOverlayBack(event?: Event): false | void | Promise<unknown>;
82
+ /** Number of overlays currently registered. */
83
+ export declare function getOverlayBackStackSize(): number;
84
+ /** `true` when a live `asma-core-helpers` history adapter (PAT-002) has published `overlayBack.v === 1`. */
85
+ export declare function hasOverlayBackAdapter(): boolean;
86
+ /** Native close-watcher events are part of the feature and must respect the host kill switch. */
87
+ export declare function isOverlayBackEnabled(): boolean;
88
+ /**
89
+ * Register a surface onto the overlay-back stack while `active`, so native Back closes it through its
90
+ * own `requestClose` — see {@link requestCloseTopOverlayBack} for the arbitration. This hook never
91
+ * installs a `popstate`/history listener of its own, with or without a live adapter — that would race
92
+ * `asma-core-helpers`' own listener (CON-002/CON-009) and duplicate work the adapter already owns. The
93
+ * adapter registration itself (see {@link registerOverlayBackCloser}) is driven purely by the stack's
94
+ * empty/non-empty transitions, not by this hook.
95
+ */
96
+ export declare function useBackCloses({ active, requestClose, ownerRef, }: {
97
+ active: boolean;
98
+ requestClose: OverlayBackRequestClose;
99
+ ownerRef?: RefObject<Element | null>;
100
+ }): void;
101
+ export {};
@@ -0,0 +1 @@
1
+ export {};
package/package.json CHANGED
@@ -3,7 +3,7 @@
3
3
  "publishConfig": {
4
4
  "access": "public"
5
5
  },
6
- "version": "3.108.1",
6
+ "version": "3.108.3",
7
7
  "type": "module",
8
8
  "sideEffects": [
9
9
  "**/*.css",
@@ -1,10 +0,0 @@
1
- import { useEffect as r } from "react";
2
- var o = ({ open: t, onClose: e }) => (r(() => {
3
- if (t)
4
- return window.history.pushState({ modal: !0 }, ""), window.addEventListener("popstate", e), () => {
5
- window.removeEventListener("popstate", e), window.history.state?.modal && window.history.back();
6
- };
7
- }, [t]), null);
8
- export {
9
- o as useBackNavigationClose
10
- };
@@ -1,4 +0,0 @@
1
- export declare const useBackNavigationClose: ({ open, onClose }: {
2
- open: boolean;
3
- onClose: () => void;
4
- }) => null;