asma-ui-core 3.108.2 → 3.108.4
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/dist/asma-ui-core.css +1 -1
- package/dist/components/feedback/dialog/StyledDialog.js +139 -96
- package/dist/components/feedback/minimizable-dialog/MinimizableDialog.js +180 -171
- package/dist/components/feedback/minimizable-dialog/v2/MinimizableDialogV2.js +115 -106
- package/dist/components/inputs/select/StyledSelect.js +56 -50
- package/dist/components/inputs/select-autocomplete/StyledSelectAutocomplete.js +102 -96
- package/dist/components/navigation/drawer/StyledDrawer.js +55 -51
- package/dist/components/utils/bottom-sheet/StyledBottomSheet.js +158 -118
- package/dist/components/utils/popover/PopoverSheet.js +95 -85
- package/dist/components/utils/popover/StyledPopover.js +81 -71
- package/dist/datetime/components/date-picker/StyledDatePicker.js +33 -28
- package/dist/datetime/components/date-picker/components/StyledCalendarPicker.js +9 -8
- package/dist/datetime/components/time-picker/StyledTimePicker.js +56 -51
- package/dist/datetime/hooks/useBackNavigationClose.hook.js +16 -7
- package/dist/hooks/useBackCloses.hook.js +100 -0
- package/dist/src/components/feedback/dialog/StyledDialog.d.ts +6 -1
- package/dist/src/components/navigation/drawer/StyledDrawer.d.ts +2 -0
- package/dist/src/components/utils/bottom-sheet/StyledBottomSheet.d.ts +6 -2
- package/dist/src/components/utils/popover/StyledPopover.d.ts +3 -1
- package/dist/src/datetime/hooks/useBackNavigationClose.hook.d.ts +2 -1
- package/dist/src/hooks/useBackCloses.hook.d.ts +101 -0
- package/dist/src/hooks/useBackCloses.hook.test.d.ts +1 -0
- package/package.json +1 -1
|
@@ -16,7 +16,12 @@ interface DialogPaperProps {
|
|
|
16
16
|
*/
|
|
17
17
|
export interface IStyledDialogProps {
|
|
18
18
|
open: boolean;
|
|
19
|
-
|
|
19
|
+
/**
|
|
20
|
+
* ✕, Escape and (ASMA-8471) native Back all funnel through this. Returning a Promise (a dirty or
|
|
21
|
+
* async confirmation) latches the dialog against Back while it is pending (`requestCloseTopOverlayBack`);
|
|
22
|
+
* returning nothing leaves it unlatched, so a repeated Back repeats the same dismissal attempt.
|
|
23
|
+
*/
|
|
24
|
+
onClose?: (event: SyntheticEvent | Event, reason: DialogCloseReason) => void | Promise<unknown>;
|
|
20
25
|
children?: ReactNode;
|
|
21
26
|
dataTest: string;
|
|
22
27
|
maxWidth?: DialogMaxWidth;
|
|
@@ -22,6 +22,8 @@ export interface DrawerProps {
|
|
|
22
22
|
};
|
|
23
23
|
/** Trigger element — when inside a modal `<dialog>`, portal into it so the sheet is interactive. */
|
|
24
24
|
anchorEl?: Element | null;
|
|
25
|
+
/** Set `false` when a wrapper already owns the Back-close registration. */
|
|
26
|
+
registerBackClose?: boolean;
|
|
25
27
|
children?: ReactNode;
|
|
26
28
|
}
|
|
27
29
|
/**
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { ReactNode } from 'react';
|
|
1
|
+
import { ReactNode, RefObject } from 'react';
|
|
2
2
|
import { PopoverSlot } from '../popover/PopoverSheet';
|
|
3
3
|
export type BottomSheetCloseReason = 'closeButton' | 'scrim' | 'escape' | 'drag' | 'viewResults' | 'action';
|
|
4
4
|
/** @figmaNode 9Q7C7JYPgnUSsrX1L8v40t#5354-169163 (Ad-Voca-concept · "_bottom sheet") */
|
|
@@ -41,6 +41,10 @@ export interface StyledBottomSheetProps {
|
|
|
41
41
|
closeLabel?: string;
|
|
42
42
|
/** @figmaProp none — style escape hatch, applied to the sheet container */
|
|
43
43
|
className?: string;
|
|
44
|
+
/** Set `false` when a wrapper already owns the Back-close registration. */
|
|
45
|
+
registerBackClose?: boolean;
|
|
46
|
+
/** Logical owner supplied by a wrapper that must keep one identity across responsive variants. */
|
|
47
|
+
ownerRef?: RefObject<Element | null>;
|
|
44
48
|
}
|
|
45
49
|
/**
|
|
46
50
|
* ASMA Design System **Bottom Sheet** (ASMA-8184) — the mobile (0–743px) form of the Action popover:
|
|
@@ -56,4 +60,4 @@ export interface StyledBottomSheetProps {
|
|
|
56
60
|
* Focus moves to the sheet on open (so the title is announced first) and back to the trigger on
|
|
57
61
|
* close. `PopoverSheet` with `variant='action'` renders this automatically below 744px.
|
|
58
62
|
*/
|
|
59
|
-
export declare const StyledBottomSheet: ({ dataTest, id, open, onClose, title, ariaLabel, children, viewResultsAction, resetAction, footerActions, resultCount, closeLabel, className, }: StyledBottomSheetProps) => JSX.Element | null;
|
|
63
|
+
export declare const StyledBottomSheet: ({ dataTest, id, open, onClose, title, ariaLabel, children, viewResultsAction, resetAction, footerActions, resultCount, closeLabel, className, registerBackClose, ownerRef, }: StyledBottomSheetProps) => JSX.Element | null;
|
|
@@ -35,6 +35,8 @@ export interface StyledPopoverProps {
|
|
|
35
35
|
* dialog in the same tick it opens.
|
|
36
36
|
*/
|
|
37
37
|
keepMounted?: boolean;
|
|
38
|
+
/** Set `false` when a wrapper already owns the Back-close registration. */
|
|
39
|
+
registerBackClose?: boolean;
|
|
38
40
|
}
|
|
39
41
|
/**
|
|
40
42
|
* @figmaNode none — no standalone Figma component
|
|
@@ -51,4 +53,4 @@ export interface StyledPopoverProps {
|
|
|
51
53
|
* mapping to MUI's `onClose(event, reason)`. `anchorOrigin`/`transformOrigin`/`slotProps.paper`
|
|
52
54
|
* preserved (DEC-003). TASK-302.
|
|
53
55
|
*/
|
|
54
|
-
export declare const StyledPopover: ({ open, anchorEl, onClose, anchorOrigin, transformOrigin, id, className, sx, slotProps, onClick, children, keepMounted, tabIntoContent, }: StyledPopoverProps) => JSX.Element | null;
|
|
56
|
+
export declare const StyledPopover: ({ open, anchorEl, onClose, anchorOrigin, transformOrigin, id, className, sx, slotProps, onClick, children, keepMounted, tabIntoContent, registerBackClose, }: StyledPopoverProps) => JSX.Element | null;
|
|
@@ -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 {};
|