@citrusworx/juiceui 0.9.5 → 0.9.7
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/README.md +30 -27
- package/dist/index.css +280 -0
- package/dist/index.d.ts +2 -0
- package/dist/index.js +2349 -1590
- package/dist/js/juice.d.ts +2 -0
- package/dist/js/src/combobox/combobox-runtime.d.ts +7 -7
- package/dist/js/src/drawer/drawer-runtime.d.ts +10 -3
- package/dist/js/src/menu/menu-runtime.d.ts +12 -11
- package/dist/js/src/modal/modal-runtime.d.ts +10 -3
- package/dist/js/src/popover/popover-runtime.d.ts +9 -7
- package/dist/js/src/shared/dialog-layer.d.ts +62 -0
- package/dist/js/src/shared/layer-stack.d.ts +88 -0
- package/dist/js/src/shared/light-layer.d.ts +52 -0
- package/dist/js/src/shared/overlays.d.ts +10 -5
- package/dist/js/src/sheet/sheet-runtime.d.ts +103 -0
- package/dist/js/src/toast/toast-runtime.d.ts +6 -5
- package/dist/js/src/tooltip/tooltip-runtime.d.ts +6 -5
- package/package.json +216 -216
package/dist/js/juice.d.ts
CHANGED
|
@@ -60,6 +60,8 @@ export { createTouchableRow, initTouchableRow, startTouchableRowRuntime, stopTou
|
|
|
60
60
|
export type { TouchableRowController, TouchableRowOptions, TouchableRowState } from "./src/touchable-row/touchable-row-runtime.js";
|
|
61
61
|
export { createKeyboardAvoider, initKeyboardAvoider, startKeyboardAvoiderRuntime, stopKeyboardAvoiderRuntime } from "./src/keyboard-avoider/keyboard-avoider-runtime.js";
|
|
62
62
|
export type { KeyboardAvoiderController, KeyboardAvoiderOptions, KeyboardAvoiderState } from "./src/keyboard-avoider/keyboard-avoider-runtime.js";
|
|
63
|
+
export { createSheet, initSheet, startSheetRuntime, stopSheetRuntime } from "./src/sheet/sheet-runtime.js";
|
|
64
|
+
export type { SheetController, SheetDetent, SheetOptions, SheetState } from "./src/sheet/sheet-runtime.js";
|
|
63
65
|
export { JUICE_CHANGE_EVENT } from "./src/shared/change.js";
|
|
64
66
|
export type { JuiceChangeDetail } from "./src/shared/change.js";
|
|
65
67
|
export { prefersReducedMotion, subscribeReducedMotion, createMotionCancelToken, runMotion, createElementMotion } from "./src/shared/motion.js";
|
|
@@ -21,12 +21,12 @@
|
|
|
21
21
|
* `aria-activedescendant` plus `combobox-option="active"` paint.
|
|
22
22
|
* Committed choice is `aria-selected="true"`.
|
|
23
23
|
*
|
|
24
|
-
* Open on input focus, typing, or trigger click. Close on Escape
|
|
25
|
-
* (
|
|
26
|
-
*
|
|
27
|
-
*
|
|
28
|
-
*
|
|
29
|
-
*
|
|
24
|
+
* Open on input focus, typing, or trigger click. Close on Escape from
|
|
25
|
+
* the layer stack (the last layer opened owns it; this runtime does not
|
|
26
|
+
* handle Escape itself), outside pointerdown when this list is the top
|
|
27
|
+
* layer, blur (option mousedown preventDefault so the input keeps focus
|
|
28
|
+
* through click-to-select), or after select. A cascade close uses the
|
|
29
|
+
* same hide path and does not move focus.
|
|
30
30
|
*
|
|
31
31
|
* Filter: case-insensitive substring against option text and, when
|
|
32
32
|
* present, `data-value`. Non-matches get `hidden` on the option.
|
|
@@ -38,7 +38,7 @@
|
|
|
38
38
|
* Home / End first / last visible option while open
|
|
39
39
|
* (closed: native input cursor)
|
|
40
40
|
* Enter select the active option
|
|
41
|
-
* Escape close
|
|
41
|
+
* Escape close when this list is the top layer
|
|
42
42
|
* Tab close without committing the active option
|
|
43
43
|
* (APG manual selection). Focus moves on.
|
|
44
44
|
*
|
|
@@ -7,9 +7,16 @@
|
|
|
7
7
|
* Enter removes `hidden`, then plays. Exit plays first; `hidden` is set
|
|
8
8
|
* only after it finishes. Focus moves in when `hidden` is removed and
|
|
9
9
|
* restores when `hidden` is set. Reduced motion (or a zero computed
|
|
10
|
-
* duration) does both in the same turn. An in-flight exit stays the
|
|
11
|
-
*
|
|
12
|
-
* cancels it.
|
|
10
|
+
* duration) does both in the same turn. An in-flight exit stays on the
|
|
11
|
+
* layer stack for Escape and the focus trap until that commit, and a new
|
|
12
|
+
* open cancels it. Escape and backdrop presses follow open order on the
|
|
13
|
+
* internal layer stack. This runtime does not handle Escape itself, so a
|
|
14
|
+
* defaultPrevented Escape never closes the dialog. Tab and focus-in trap
|
|
15
|
+
* only when this overlay is the top of the stack and that layer is modal.
|
|
16
|
+
* A non-modal layer on top suspends the trap until it closes. Replacing
|
|
17
|
+
* another open drawer pops it, so layers above that drawer dismiss with
|
|
18
|
+
* reason 'cascade'. A cascade close does not return focus. Escape, an
|
|
19
|
+
* explicit close, and a backdrop close still do.
|
|
13
20
|
*
|
|
14
21
|
* Openers: any element whose `aria-controls` token list includes a
|
|
15
22
|
* `[drawer-overlay]` id. `[drawer-close]` closes the containing overlay.
|
|
@@ -29,17 +29,18 @@
|
|
|
29
29
|
* Open on opener click / Enter / Space (native buttons use click).
|
|
30
30
|
* ArrowDown on a closed opener opens and focuses the first enabled item
|
|
31
31
|
* (or the previously active item). ArrowUp opens onto the last enabled
|
|
32
|
-
* item. Close on Escape (
|
|
33
|
-
*
|
|
34
|
-
*
|
|
35
|
-
* to the opener so Tab's default
|
|
36
|
-
* or after activating an item.
|
|
37
|
-
*
|
|
38
|
-
*
|
|
39
|
-
*
|
|
40
|
-
*
|
|
41
|
-
*
|
|
42
|
-
*
|
|
32
|
+
* item. Close on Escape from the layer stack (the last layer opened owns
|
|
33
|
+
* it; this runtime does not handle Escape itself), outside pointerdown
|
|
34
|
+
* when this menu is the top layer, Tab (closes without activating only
|
|
35
|
+
* while it is the top layer; focus returns to the opener so Tab's default
|
|
36
|
+
* can move to the next/previous control), or after activating an item.
|
|
37
|
+
* Activating an item clicks it and restores focus to the opener. A
|
|
38
|
+
* cascade close does not restore focus. Disabled items are intercepted
|
|
39
|
+
* on capture so author click handlers never run. Opening one managed
|
|
40
|
+
* menu closes the others. Modal / drawer / popover are not auto-closed.
|
|
41
|
+
* ArrowUp/Down on a closed menu apply only to the opener. A controller
|
|
42
|
+
* claims opener clicks only when it can resolve a panel (custom
|
|
43
|
+
* `menuSelector` can coexist with the auto singleton).
|
|
43
44
|
*/
|
|
44
45
|
export type MenuOptions = {
|
|
45
46
|
root?: ParentNode;
|
|
@@ -7,9 +7,16 @@
|
|
|
7
7
|
* Enter removes `hidden`, then plays. Exit plays first; `hidden` is set
|
|
8
8
|
* only after it finishes. Focus moves in when `hidden` is removed and
|
|
9
9
|
* restores when `hidden` is set. Reduced motion (or a zero computed
|
|
10
|
-
* duration) does both in the same turn. An in-flight exit stays the
|
|
11
|
-
*
|
|
12
|
-
* cancels it.
|
|
10
|
+
* duration) does both in the same turn. An in-flight exit stays on the
|
|
11
|
+
* layer stack for Escape and the focus trap until that commit, and a new
|
|
12
|
+
* open cancels it. Escape and backdrop presses follow open order on the
|
|
13
|
+
* internal layer stack. This runtime does not handle Escape itself, so a
|
|
14
|
+
* defaultPrevented Escape never closes the dialog. Tab and focus-in trap
|
|
15
|
+
* only when this overlay is the top of the stack and that layer is modal.
|
|
16
|
+
* A non-modal layer on top suspends the trap until it closes. Replacing
|
|
17
|
+
* another open modal pops it, so layers above that modal dismiss with
|
|
18
|
+
* reason 'cascade'. A cascade close does not return focus. Escape, an
|
|
19
|
+
* explicit close, and a backdrop close still do.
|
|
13
20
|
*
|
|
14
21
|
* Openers: any element whose `aria-controls` token list includes a
|
|
15
22
|
* `[modal-overlay]` id. `[modal-close]` closes the containing overlay.
|
|
@@ -34,13 +34,15 @@
|
|
|
34
34
|
* No shift / size middleware. Repositions on open, window resize, and
|
|
35
35
|
* capture scroll (rAF-throttled).
|
|
36
36
|
*
|
|
37
|
-
* Escape
|
|
38
|
-
*
|
|
39
|
-
*
|
|
40
|
-
*
|
|
41
|
-
*
|
|
42
|
-
*
|
|
43
|
-
*
|
|
37
|
+
* Escape and outside pointerdown come from the internal layer stack.
|
|
38
|
+
* The last layer opened owns them. This runtime does not handle Escape
|
|
39
|
+
* itself, so a defaultPrevented Escape never closes the popover. An
|
|
40
|
+
* outside pointer closes only this layer when it is on top. Closing a
|
|
41
|
+
* layer under this popover dismisses it with reason 'cascade' and does
|
|
42
|
+
* not restore focus; Escape and an explicit close still restore focus
|
|
43
|
+
* to the opener. Outside click does not. Tab traps only while this
|
|
44
|
+
* popover is the top of the stack. Opening one managed popover closes
|
|
45
|
+
* the others. Modal / drawer / menu are not auto-closed.
|
|
44
46
|
*/
|
|
45
47
|
export type PopoverPlacement = 'top' | 'bottom' | 'left' | 'right';
|
|
46
48
|
export type PopoverOptions = {
|
|
@@ -0,0 +1,62 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Internal binding from modal, drawer, and sheet onto the layer stack.
|
|
3
|
+
* Not a public export.
|
|
4
|
+
*
|
|
5
|
+
* Each open overlay is one stack slot. push happens on open. pop happens
|
|
6
|
+
* when the close commits (hidden is set), so an in-flight exit stays the
|
|
7
|
+
* open dialog until then. Destroy drops the slot with no dismiss.
|
|
8
|
+
* Replacing an open dialog pops it, so layers above dismiss top-down with
|
|
9
|
+
* reason 'cascade'. A cascade dismiss closes that dialog and skips opener
|
|
10
|
+
* focus restore. The dialog that was popped still restores when its own
|
|
11
|
+
* close asked for one. The focus trap belongs to a runtime only when its
|
|
12
|
+
* overlay is the top of the stack and that layer is modal. A non-modal
|
|
13
|
+
* sheet on top suspends the trap until it closes.
|
|
14
|
+
*
|
|
15
|
+
* A backdrop press is a pointer whose target is the overlay element.
|
|
16
|
+
* The stack treats that press as outside every layer that does not
|
|
17
|
+
* contain the target, so a lower backdrop dismisses only the top dialog.
|
|
18
|
+
* The top dialog's own backdrop is inside its layer; the runtime closes
|
|
19
|
+
* that one from click, and only if it was the top layer when the press
|
|
20
|
+
* began. Presses on openers or the rest of the page are not backdrop
|
|
21
|
+
* presses, so they do not dismiss a dialog.
|
|
22
|
+
*/
|
|
23
|
+
import { type LayerDismissReason, type LayerKind } from './layer-stack.js';
|
|
24
|
+
/**
|
|
25
|
+
* Cascade means a parent layer closed this dialog. That close skips
|
|
26
|
+
* opener restore. Escape and outside still restore.
|
|
27
|
+
*/
|
|
28
|
+
export declare const dialogDismissRestoresFocus: (reason: LayerDismissReason) => reason is "escape" | "outside";
|
|
29
|
+
export type DialogLayerController = {
|
|
30
|
+
/** Stack an open overlay. bringToTop re-pushes an existing slot to the top. */
|
|
31
|
+
connect: (overlay: HTMLElement, bringToTop?: boolean) => void;
|
|
32
|
+
/** Remove this slot without dismissing layers above it. */
|
|
33
|
+
drop: (overlay: HTMLElement) => void;
|
|
34
|
+
/** Pop this slot. Layers above it dismiss with reason 'cascade'. */
|
|
35
|
+
pop: (overlay: HTMLElement) => void;
|
|
36
|
+
/** Match the stack to overlays that are currently open. */
|
|
37
|
+
reconcile: () => void;
|
|
38
|
+
destroy: () => void;
|
|
39
|
+
};
|
|
40
|
+
/**
|
|
41
|
+
* Top layer when the pointer went down, before the stack dismissed anyone.
|
|
42
|
+
* undefined when this click was not preceded by a pointerdown. Callers
|
|
43
|
+
* then read the live top, which is what click-only tests dispatch.
|
|
44
|
+
*/
|
|
45
|
+
export declare const backdropPressTop: () => HTMLElement | null | undefined;
|
|
46
|
+
/**
|
|
47
|
+
* True when the latest pointerdown target is a dialog overlay element.
|
|
48
|
+
* Dialog dismiss('outside') ignores every other press.
|
|
49
|
+
*/
|
|
50
|
+
export declare const outsidePressIsBackdrop: () => boolean;
|
|
51
|
+
/** Clears the backdrop-press snapshot. Test-only. */
|
|
52
|
+
export declare const __resetDialogLayersForTests: () => void;
|
|
53
|
+
export declare const createDialogLayers: (config: {
|
|
54
|
+
kind: Extract<LayerKind, "modal" | "drawer" | "sheet">;
|
|
55
|
+
selector: string;
|
|
56
|
+
getOverlays: () => readonly HTMLElement[];
|
|
57
|
+
isOpen: (overlay: HTMLElement) => boolean;
|
|
58
|
+
isClosing: (overlay: HTMLElement) => boolean;
|
|
59
|
+
isModal: (overlay: HTMLElement) => boolean;
|
|
60
|
+
shouldStack: (overlay: HTMLElement) => boolean;
|
|
61
|
+
dismiss: (overlay: HTMLElement, reason: LayerDismissReason) => void;
|
|
62
|
+
}) => DialogLayerController;
|
|
@@ -0,0 +1,88 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Internal open-order overlay stack. Not a public export.
|
|
3
|
+
*
|
|
4
|
+
* Modal, drawer, sheet, popover, menu, and combobox share this stack
|
|
5
|
+
* so the last one opened owns Escape and outside pointerdown. Dialog
|
|
6
|
+
* outside presses stay backdrop-only. Toast and tooltip stay off the
|
|
7
|
+
* stack. Sheet body scroll lock is acquireScrollLock. Modal and drawer
|
|
8
|
+
* do not lock scroll.
|
|
9
|
+
*
|
|
10
|
+
* Order is open time. The last push is the top. Pushing an element that
|
|
11
|
+
* is already stacked refreshes that slot in place (kind, modal, dismiss,
|
|
12
|
+
* focus opt-in, containsTarget). It does not move the slot and it does
|
|
13
|
+
* not add a second entry. Pop it and push it again to bring it to the
|
|
14
|
+
* top. Every pop function returned for that element closes the same
|
|
15
|
+
* slot. Calling pop again is a no-op.
|
|
16
|
+
*
|
|
17
|
+
* pop() removes this entry without calling its dismiss, because the
|
|
18
|
+
* caller is already closing it. Layers above it are dismissed first,
|
|
19
|
+
* top-down, with reason 'cascade', and then this entry is removed.
|
|
20
|
+
* Pass { cascade: false } or call removeLayer(el) to drop one entry
|
|
21
|
+
* with no dismiss calls and no focus return. That is the destroy path.
|
|
22
|
+
*
|
|
23
|
+
* Focus return is opt-in so a runtime that already restores focus does
|
|
24
|
+
* not do it twice. Omit restoreFocus to skip it. Set restoreFocus to an
|
|
25
|
+
* element or null to opt in. pop() focuses that opener when it is still
|
|
26
|
+
* connected and is not inside a layer this pop closed. Otherwise it
|
|
27
|
+
* focuses the new top layer's element, if one remains. The fallback
|
|
28
|
+
* focuses that element itself, not a descendant. When the element has
|
|
29
|
+
* no tabindex, the fallback sets tabindex="-1" so programmatic focus
|
|
30
|
+
* works without putting the layer in tab order. An existing tabindex
|
|
31
|
+
* is left as it is.
|
|
32
|
+
*
|
|
33
|
+
* One document keydown listener and one document pointerdown listener,
|
|
34
|
+
* both capture, attach on the first push and detach when the stack is
|
|
35
|
+
* empty. They call dismiss. They do not pop. dismiss must call the pop
|
|
36
|
+
* function or removeLayer, or that layer stays on top. An outside
|
|
37
|
+
* pointerdown walks from the top until a layer contains the target, or
|
|
38
|
+
* through the whole stack when none do. If dismiss leaves the same
|
|
39
|
+
* element on top, the walk stops.
|
|
40
|
+
*
|
|
41
|
+
* containsTarget is the portal seam. The default check is
|
|
42
|
+
* el.contains(target). TODO(portal): a portaled panel is not a
|
|
43
|
+
* descendant of el, so the runtime passes containsTarget that also
|
|
44
|
+
* includes the portaled node.
|
|
45
|
+
*
|
|
46
|
+
* acquireScrollLock is the ref-counted inline body overflow lock sheet
|
|
47
|
+
* uses. Modal and drawer do not lock scroll in S3.
|
|
48
|
+
* The first acquire saves body.style.overflow and sets 'hidden'. The
|
|
49
|
+
* last release restores the saved inline value. Release is idempotent.
|
|
50
|
+
* A stylesheet overflow is not read or written.
|
|
51
|
+
*
|
|
52
|
+
* Every function no-ops when document is undefined.
|
|
53
|
+
* __resetLayerStackForTests is for unit tests, not the public entry.
|
|
54
|
+
*/
|
|
55
|
+
export type LayerKind = 'modal' | 'drawer' | 'sheet' | 'popover' | 'menu' | 'combobox';
|
|
56
|
+
export type LayerDismissReason = 'escape' | 'outside' | 'cascade';
|
|
57
|
+
export interface LayerEntry {
|
|
58
|
+
el: HTMLElement;
|
|
59
|
+
kind: LayerKind;
|
|
60
|
+
modal: boolean;
|
|
61
|
+
dismiss(reason: LayerDismissReason): void;
|
|
62
|
+
/**
|
|
63
|
+
* Opt in to stack-managed focus return. Omit the property when the
|
|
64
|
+
* runtime restores focus itself. null opts in with no opener.
|
|
65
|
+
*/
|
|
66
|
+
restoreFocus?: HTMLElement | null;
|
|
67
|
+
/**
|
|
68
|
+
* Portal seam. Default containment is el.contains(target).
|
|
69
|
+
* TODO(portal): include the portaled node here. It is not inside el.
|
|
70
|
+
*/
|
|
71
|
+
containsTarget?: (target: EventTarget | null) => boolean;
|
|
72
|
+
}
|
|
73
|
+
export type PopLayerOptions = {
|
|
74
|
+
/**
|
|
75
|
+
* When false, remove this entry only. Do not dismiss layers above it
|
|
76
|
+
* and do not run focus return. Default true.
|
|
77
|
+
*/
|
|
78
|
+
cascade?: boolean;
|
|
79
|
+
};
|
|
80
|
+
export type PopLayer = (options?: PopLayerOptions) => void;
|
|
81
|
+
export declare const pushLayer: (entry: LayerEntry) => PopLayer;
|
|
82
|
+
export declare const removeLayer: (el: HTMLElement) => void;
|
|
83
|
+
export declare const topLayer: () => LayerEntry | null;
|
|
84
|
+
export declare const isTopLayer: (el: HTMLElement) => boolean;
|
|
85
|
+
export declare const topModalLayer: () => LayerEntry | null;
|
|
86
|
+
export declare const acquireScrollLock: () => (() => void);
|
|
87
|
+
/** Clears stack, listeners, and scroll-lock state. Test-only. */
|
|
88
|
+
export declare const __resetLayerStackForTests: () => void;
|
|
@@ -0,0 +1,52 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Internal binding from popover, menu, and combobox onto the layer stack.
|
|
3
|
+
* Not a public export.
|
|
4
|
+
*
|
|
5
|
+
* Each open widget is one stack slot. push happens on open. pop happens
|
|
6
|
+
* when the close commits, so a popover's in-flight exit stays the open
|
|
7
|
+
* layer until `hidden` is set. Destroy drops the slot and does not
|
|
8
|
+
* dismiss anything above it. These layers are not modal. Focus return
|
|
9
|
+
* stays in the runtime.
|
|
10
|
+
*
|
|
11
|
+
* Outside pointerdown dismisses only the top layer. dismiss('outside')
|
|
12
|
+
* hides the widget and removes the slot after the stack's pointer walk,
|
|
13
|
+
* so a lower layer stays up. The click that follows that pointer is not
|
|
14
|
+
* a second outside close. Openers that live outside the layer element
|
|
15
|
+
* belong in containsTarget, so pressing the opener is not outside and
|
|
16
|
+
* the click handler can still toggle.
|
|
17
|
+
*
|
|
18
|
+
* Toast and tooltip are not light layers. They stay off the stack.
|
|
19
|
+
*/
|
|
20
|
+
import { type LayerDismissReason, type LayerKind } from './layer-stack.js';
|
|
21
|
+
export type LightLayerController = {
|
|
22
|
+
/** Stack an open widget. bringToTop re-pushes an existing slot to the top. */
|
|
23
|
+
connect: (el: HTMLElement, bringToTop?: boolean) => void;
|
|
24
|
+
/** Remove this slot without dismissing layers above it. */
|
|
25
|
+
drop: (el: HTMLElement) => void;
|
|
26
|
+
/** Pop this slot. Layers above it dismiss with reason 'cascade'. */
|
|
27
|
+
pop: (el: HTMLElement) => void;
|
|
28
|
+
/**
|
|
29
|
+
* Pop after the current stack pointer walk. dismiss('outside') uses
|
|
30
|
+
* this so the walk still sees this element on top and stops.
|
|
31
|
+
*/
|
|
32
|
+
popAfterPointer: (el: HTMLElement) => void;
|
|
33
|
+
/** Match the stack to widgets that are currently open. */
|
|
34
|
+
reconcile: () => void;
|
|
35
|
+
destroy: () => void;
|
|
36
|
+
};
|
|
37
|
+
/**
|
|
38
|
+
* True when this click follows a stack outside-dismiss in the same
|
|
39
|
+
* gesture. Click handlers skip a second outside close.
|
|
40
|
+
*/
|
|
41
|
+
export declare const lightOutsideAlreadyDismissed: () => boolean;
|
|
42
|
+
export declare const markLightOutsideDismissed: () => void;
|
|
43
|
+
/** Clears the outside-dismiss snapshot and handle map. Test-only. */
|
|
44
|
+
export declare const __resetLightLayersForTests: () => void;
|
|
45
|
+
export declare const createLightLayers: (config: {
|
|
46
|
+
kind: Extract<LayerKind, "popover" | "menu" | "combobox">;
|
|
47
|
+
getElements: () => readonly HTMLElement[];
|
|
48
|
+
isOpen: (el: HTMLElement) => boolean;
|
|
49
|
+
isClosing?: (el: HTMLElement) => boolean;
|
|
50
|
+
containsTarget?: (el: HTMLElement, target: EventTarget | null) => boolean;
|
|
51
|
+
dismiss: (el: HTMLElement, reason: LayerDismissReason) => void;
|
|
52
|
+
}) => LightLayerController;
|
|
@@ -1,11 +1,16 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* Internal open-surface queries
|
|
2
|
+
* Internal open-surface queries. Not a public export.
|
|
3
3
|
* Selectors match the polish A/B overlay contract.
|
|
4
4
|
*
|
|
5
|
-
*
|
|
6
|
-
*
|
|
7
|
-
*
|
|
8
|
-
*
|
|
5
|
+
* Modal, drawer, sheet, popover, menu, and combobox take Escape from
|
|
6
|
+
* the layer stack (last opened wins). These queries stay because toast
|
|
7
|
+
* and disclosure are not stack layers and still yield when one of those
|
|
8
|
+
* surfaces is open in the DOM. Tooltip does not consult them: an open
|
|
9
|
+
* tip consumes Escape itself and does not close the layer under it.
|
|
10
|
+
*
|
|
11
|
+
* Menu closed vs open is native `hidden` on `[menu]`, not on
|
|
12
|
+
* `[menu-root]`. Sheet closed vs open is native `hidden` on
|
|
13
|
+
* `[sheet-overlay]`, including `sheet-overlay="none"`.
|
|
9
14
|
*/
|
|
10
15
|
export declare const hasOpenDialogOverlay: () => boolean;
|
|
11
16
|
export declare const hasOpenPopover: () => boolean;
|
|
@@ -0,0 +1,103 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* DOM-first dialog runtime for Juice sheet chrome.
|
|
3
|
+
*
|
|
4
|
+
* Markup contract (slice A — do not rename attrs):
|
|
5
|
+
* [sheet-overlay][hidden] > [sheet role="dialog"]
|
|
6
|
+
* [sheet-handle] [sheet-header] [sheet-body] [sheet-footer] [sheet-close]
|
|
7
|
+
* Closed vs open is the native `hidden` attribute on the overlay.
|
|
8
|
+
* Enter removes `hidden`, then plays. Exit plays first; `hidden` is set
|
|
9
|
+
* only after it finishes. Focus moves in when a modal `hidden` is removed
|
|
10
|
+
* and restores when that `hidden` is set. Reduced motion (or a zero
|
|
11
|
+
* computed duration) does both in the same turn. An in-flight exit stays
|
|
12
|
+
* on the layer stack for Escape and the focus trap until that commit, and
|
|
13
|
+
* a new open of that same overlay cancels it. Escape and backdrop presses
|
|
14
|
+
* follow open order on the internal layer stack. This runtime does not
|
|
15
|
+
* handle Escape itself, so a defaultPrevented Escape never closes the
|
|
16
|
+
* sheet. Tab and focus-in trap only when this overlay is the top of the
|
|
17
|
+
* stack and that layer is modal. `sheet-overlay="none"` never traps, and
|
|
18
|
+
* while that non-modal sheet is the top layer it suspends the trap of a
|
|
19
|
+
* modal underneath. The trap resumes when the sheet closes. Focus return
|
|
20
|
+
* stays here. A cascade close does not return focus. Escape, an explicit
|
|
21
|
+
* close, and a backdrop close still do.
|
|
22
|
+
*
|
|
23
|
+
* Openers: any element whose `aria-controls` token list includes a
|
|
24
|
+
* `[sheet-overlay]` id. `[sheet-close]` closes the containing overlay.
|
|
25
|
+
* Backdrop click closes unless `sheet-overlay="static"` or
|
|
26
|
+
* `closeOnBackdrop` is false. `sheet-overlay="none"` is non-modal: no
|
|
27
|
+
* focus trap, no scroll lock, no backdrop close. Escape still closes.
|
|
28
|
+
*
|
|
29
|
+
* Scroll lock is modal only (boolean / omitted / "static"). It uses the
|
|
30
|
+
* layer stack's ref-counted body overflow lock: the first modal sheet
|
|
31
|
+
* saves the inline overflow and sets `hidden`, and the last release
|
|
32
|
+
* restores that saved value. Nested and sibling modal sheets do not
|
|
33
|
+
* unlock early. Non-modal sheets do not lock. Several sheets may be
|
|
34
|
+
* open together. This runtime does not close siblings.
|
|
35
|
+
*
|
|
36
|
+
* Detents. `sheet-detents` on `[sheet]` is the allowed set (`~=` words).
|
|
37
|
+
* Absent, or with no known word, the set is "half full". Rank is
|
|
38
|
+
* peek < half < full. On open the sheet rests at half when half is
|
|
39
|
+
* allowed, otherwise full when full is allowed, otherwise peek — the
|
|
40
|
+
* same rest slice A paints when `[detent]` is absent. `[detent]` is
|
|
41
|
+
* written whenever that rest changes. An already-open sheet keeps a
|
|
42
|
+
* valid `[detent]` until a gesture, the keyboard, or an open transition
|
|
43
|
+
* replaces it.
|
|
44
|
+
*
|
|
45
|
+
* Drag. Pointer events on `[sheet-handle]` and `[sheet-header]` track
|
|
46
|
+
* the finger after an 8px slop. `[sheet-body]` hands off only when
|
|
47
|
+
* `scrollTop` is 0 and the gesture moves down. `[dragging]` is set on
|
|
48
|
+
* the sheet and `data-motion-state` is `entered` for the gesture so the
|
|
49
|
+
* enter/exit animation does not fight the inline height. The finger is
|
|
50
|
+
* followed with inline height, plus `translateY` rubber-band (0.35 of
|
|
51
|
+
* the overflow) past the highest detent and below the lowest. Reduced
|
|
52
|
+
* motion clamps that visual and does not rubber-band; the logical
|
|
53
|
+
* height still tracks so a close can commit. Release snaps by projecting
|
|
54
|
+
* the logical height with velocity over 180ms and choosing the nearest
|
|
55
|
+
* allowed detent. Downward velocity of at least 0.5px/ms at or below the
|
|
56
|
+
* lowest detent, or a logical height more than 80px below it, closes.
|
|
57
|
+
* `pointercancel` drops the gesture and restores the detent it started
|
|
58
|
+
* on. Inline height/transform clear on the next frame after a snap so
|
|
59
|
+
* the detent height transition can run.
|
|
60
|
+
*
|
|
61
|
+
* Keyboard. A MutationObserver on `documentElement` attributes watches
|
|
62
|
+
* `[keyboard-open]`. While a sheet is open, gaining that attribute snaps
|
|
63
|
+
* it to `full` when full is allowed, otherwise the highest detent.
|
|
64
|
+
* Opening while the attribute is already set uses that same rest.
|
|
65
|
+
*
|
|
66
|
+
* State is `{ open, detent, dragging, modal }`. `juice:change` bubbles
|
|
67
|
+
* from the overlay with `detail.runtime === "sheet"`. The first
|
|
68
|
+
* observation is silent. Disabled (`disabled` / `aria-disabled="true"`)
|
|
69
|
+
* and invalid hosts (an overlay with no `[sheet]`) are ignored.
|
|
70
|
+
* Back button history is out of scope.
|
|
71
|
+
*
|
|
72
|
+
* Sheet is the thirty-second Emerging auto-enhance runtime.
|
|
73
|
+
*/
|
|
74
|
+
export type SheetDetent = 'peek' | 'half' | 'full';
|
|
75
|
+
export type SheetOptions = {
|
|
76
|
+
root?: ParentNode;
|
|
77
|
+
overlaySelector?: string;
|
|
78
|
+
dialogSelector?: string;
|
|
79
|
+
closeSelector?: string;
|
|
80
|
+
handleSelector?: string;
|
|
81
|
+
headerSelector?: string;
|
|
82
|
+
bodySelector?: string;
|
|
83
|
+
closeOnBackdrop?: boolean;
|
|
84
|
+
};
|
|
85
|
+
export type SheetState = {
|
|
86
|
+
open: boolean;
|
|
87
|
+
detent: SheetDetent;
|
|
88
|
+
dragging: boolean;
|
|
89
|
+
modal: boolean;
|
|
90
|
+
};
|
|
91
|
+
export type SheetController = {
|
|
92
|
+
destroy: () => void;
|
|
93
|
+
sync: () => void;
|
|
94
|
+
open: (target?: HTMLElement | null) => void;
|
|
95
|
+
close: (target?: HTMLElement | null) => void;
|
|
96
|
+
toggle: (target?: HTMLElement | null) => void;
|
|
97
|
+
isOpen: (target?: HTMLElement | null) => boolean;
|
|
98
|
+
getState: (target?: HTMLElement | null) => SheetState | null;
|
|
99
|
+
};
|
|
100
|
+
export declare const createSheet: (options?: SheetOptions) => SheetController;
|
|
101
|
+
export declare const initSheet: (options?: SheetOptions) => SheetController;
|
|
102
|
+
export declare const startSheetRuntime: () => SheetController | null;
|
|
103
|
+
export declare const stopSheetRuntime: () => void;
|
|
@@ -23,11 +23,12 @@
|
|
|
23
23
|
*
|
|
24
24
|
* Auto-dismiss pauses while pointer or focus is inside the toast, then resumes.
|
|
25
25
|
*
|
|
26
|
-
* Escape dismisses the most recently shown visible toast, but only when
|
|
27
|
-
* open
|
|
28
|
-
*
|
|
29
|
-
*
|
|
30
|
-
*
|
|
26
|
+
* Escape dismisses the most recently shown visible toast, but only when
|
|
27
|
+
* the layer stack is empty and no open dialog, popover, menu, combobox
|
|
28
|
+
* list, or tooltip is in the DOM. Toast is not a stack layer. It listens
|
|
29
|
+
* on bubble, so a stack Escape (capture, stopPropagation) never reaches
|
|
30
|
+
* it, and it does not preventDefault when it yields. An open tip hides
|
|
31
|
+
* while toasts remain — toast does not steal Escape from tooltip.
|
|
31
32
|
*
|
|
32
33
|
* Live region: sync fills missing aria-live="polite" and
|
|
33
34
|
* aria-relevant="additions" on [toast-region]. Opt into assertive with
|
|
@@ -32,11 +32,12 @@
|
|
|
32
32
|
* flip once to the opposite side. Repositions on open, window resize,
|
|
33
33
|
* and capture scroll (rAF-throttled).
|
|
34
34
|
*
|
|
35
|
-
* Escape hides the open tip on
|
|
36
|
-
*
|
|
37
|
-
*
|
|
38
|
-
*
|
|
39
|
-
*
|
|
35
|
+
* Escape hides the open tip on window capture, before the layer stack's
|
|
36
|
+
* document listener. The tip is not a stack layer, so it does not take
|
|
37
|
+
* a place in last-opened-wins. One Escape dismisses only the tip and
|
|
38
|
+
* does not close a dialog, popover, menu, or listbox underneath. The
|
|
39
|
+
* next Escape is the stack's. A defaultPrevented or composing Escape
|
|
40
|
+
* does not hide the tip. Toast does not block tooltip Escape — the tip
|
|
40
41
|
* can hide while toasts remain. Opening one managed tooltip closes the
|
|
41
42
|
* others.
|
|
42
43
|
*/
|