@citrusworx/juiceui 0.9.4 → 0.9.6
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +73 -89
- package/dist/index.css +385 -0
- package/dist/index.d.ts +4 -0
- package/dist/index.js +1772 -1104
- package/dist/js/juice.d.ts +4 -0
- package/dist/js/src/keyboard-avoider/keyboard-avoider-runtime.d.ts +96 -0
- package/dist/js/src/shared/overlays.d.ts +3 -2
- package/dist/js/src/sheet/sheet-runtime.d.ts +94 -0
- package/package.json +1 -1
package/dist/js/juice.d.ts
CHANGED
|
@@ -58,6 +58,10 @@ export { createPressable, initPressable, startPressableRuntime, stopPressableRun
|
|
|
58
58
|
export type { PressableController, PressableOptions, PressableState } from "./src/pressable/pressable-runtime.js";
|
|
59
59
|
export { createTouchableRow, initTouchableRow, startTouchableRowRuntime, stopTouchableRowRuntime } from "./src/touchable-row/touchable-row-runtime.js";
|
|
60
60
|
export type { TouchableRowController, TouchableRowOptions, TouchableRowState } from "./src/touchable-row/touchable-row-runtime.js";
|
|
61
|
+
export { createKeyboardAvoider, initKeyboardAvoider, startKeyboardAvoiderRuntime, stopKeyboardAvoiderRuntime } from "./src/keyboard-avoider/keyboard-avoider-runtime.js";
|
|
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";
|
|
61
65
|
export { JUICE_CHANGE_EVENT } from "./src/shared/change.js";
|
|
62
66
|
export type { JuiceChangeDetail } from "./src/shared/change.js";
|
|
63
67
|
export { prefersReducedMotion, subscribeReducedMotion, createMotionCancelToken, runMotion, createElementMotion } from "./src/shared/motion.js";
|
|
@@ -0,0 +1,96 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* DOM-first runtime for Juice keyboard-avoider chrome.
|
|
3
|
+
*
|
|
4
|
+
* Markup contract (Slice A — do not rename attrs):
|
|
5
|
+
* [keyboard-avoider] host. Padding mode. Any unknown
|
|
6
|
+
* value is still a host. Words
|
|
7
|
+
* compose, same as the CSS.
|
|
8
|
+
* [keyboard-avoider="padding"] padding mode. Matches ~= .
|
|
9
|
+
* [keyboard-avoider~="translate"] translateY by the inset.
|
|
10
|
+
* [keyboard-avoider~="footer"] sticky; bottom is the inset.
|
|
11
|
+
* [keyboard-avoider~="noscroll"] this runtime does not
|
|
12
|
+
* scrollIntoView a focus inside
|
|
13
|
+
* that host. The word is behavior,
|
|
14
|
+
* not a layout mode. CSS ignores it.
|
|
15
|
+
* [keyboard-open] set on <html> and on each host
|
|
16
|
+
* while the keyboard is open.
|
|
17
|
+
* Slice A does not select it. The
|
|
18
|
+
* inset is the layout input.
|
|
19
|
+
*
|
|
20
|
+
* The overlap is the layout viewport minus the visual viewport:
|
|
21
|
+
*
|
|
22
|
+
* inset = max(0, round(innerHeight - (visualViewport.height + visualViewport.offsetTop)))
|
|
23
|
+
*
|
|
24
|
+
* iOS reports part of that overlap as offsetTop. Leaving it out
|
|
25
|
+
* counts the keyboard twice. Chrome Android with
|
|
26
|
+
* interactive-widget=resizes-content shrinks innerHeight with the
|
|
27
|
+
* keyboard, so the same formula is about 0 and this runtime does not
|
|
28
|
+
* pad on top of the layout viewport. Pinch zoom (visualViewport.scale
|
|
29
|
+
* other than 1) skips the update and leaves the previous inset.
|
|
30
|
+
*
|
|
31
|
+
* While open, the inset is written as `<n>px` on
|
|
32
|
+
* document.documentElement (the <html> element), not on each host.
|
|
33
|
+
* --juice-keyboard-inset inherits. When the keyboard is not open the
|
|
34
|
+
* inline property is removed. A closed keyboard must not leave an
|
|
35
|
+
* inline length behind: an inline value beats both the 0px role on
|
|
36
|
+
* :root and the @supports env(keyboard-inset-height) fallback. Clearing
|
|
37
|
+
* it is what lets that fallback show through. getState().inset is still
|
|
38
|
+
* the measured overlap. Only the custom property is cleared.
|
|
39
|
+
*
|
|
40
|
+
* open is inset > threshold (default 80) and an editable element has
|
|
41
|
+
* focus. Editable is a text-like input, the same set as the Input
|
|
42
|
+
* runtime (missing type, empty type, text, email, password, search,
|
|
43
|
+
* tel, url, number), plus a textarea, a select, or [contenteditable]
|
|
44
|
+
* (including a focused descendant). A hardware keyboard does not
|
|
45
|
+
* shrink the visual viewport, so a focused field stays closed. Every
|
|
46
|
+
* other input type is not editable: checkbox, radio, range, date,
|
|
47
|
+
* time, datetime-local, month, week, color, file, hidden, button,
|
|
48
|
+
* submit, reset, and image.
|
|
49
|
+
*
|
|
50
|
+
* Listeners: visualViewport resize and scroll, window resize and
|
|
51
|
+
* orientationchange, focusin and focusout on root. Updates are
|
|
52
|
+
* coalesced with requestAnimationFrame. This runtime does not set
|
|
53
|
+
* navigator.virtualKeyboard.overlaysContent.
|
|
54
|
+
*
|
|
55
|
+
* Scroll-into-view is on by default. focusin inside a host remembers
|
|
56
|
+
* the focused element. The scroll runs two frames after geometry
|
|
57
|
+
* events go quiet, so a resize burst settles before the element moves,
|
|
58
|
+
* and the inset written on the first of those frames is the one layout
|
|
59
|
+
* sees. A focus that never resizes still scrolls on that quiet window.
|
|
60
|
+
* The call is element.scrollIntoView({ block: 'nearest', behavior })
|
|
61
|
+
* with behavior 'auto' when prefersReducedMotion() is true and 'smooth'
|
|
62
|
+
* otherwise. [keyboard-avoider~="noscroll"] or scrollIntoView: false
|
|
63
|
+
* opts out. destroy cancels a pending scroll.
|
|
64
|
+
*
|
|
65
|
+
* State is { open, inset }. juice:change bubbles from each host with
|
|
66
|
+
* detail { runtime: 'keyboard-avoider', state }. The first observation
|
|
67
|
+
* is silent. Later events fire when open flips, or when the inset has
|
|
68
|
+
* moved by at least `threshold` pixels from the last published inset
|
|
69
|
+
* while open. Smaller steps still update the custom property and
|
|
70
|
+
* getState. They accumulate against the last published inset, so a
|
|
71
|
+
* slow drift still publishes once it is stale by `threshold`.
|
|
72
|
+
*
|
|
73
|
+
* No window, or no visualViewport, is a no-op (SSR and old browsers).
|
|
74
|
+
* getState then returns { open: false, inset: 0 }. No Sig
|
|
75
|
+
* KeyboardAvoider factory. Keyboard-avoider is the thirty-first
|
|
76
|
+
* Emerging auto-enhance runtime.
|
|
77
|
+
*/
|
|
78
|
+
export type KeyboardAvoiderOptions = {
|
|
79
|
+
root?: ParentNode;
|
|
80
|
+
keyboardAvoiderSelector?: string;
|
|
81
|
+
threshold?: number;
|
|
82
|
+
scrollIntoView?: boolean;
|
|
83
|
+
};
|
|
84
|
+
export type KeyboardAvoiderState = {
|
|
85
|
+
open: boolean;
|
|
86
|
+
inset: number;
|
|
87
|
+
};
|
|
88
|
+
export type KeyboardAvoiderController = {
|
|
89
|
+
destroy: () => void;
|
|
90
|
+
sync: () => void;
|
|
91
|
+
getState: (target?: HTMLElement | null) => KeyboardAvoiderState | null;
|
|
92
|
+
};
|
|
93
|
+
export declare const createKeyboardAvoider: (options?: KeyboardAvoiderOptions) => KeyboardAvoiderController;
|
|
94
|
+
export declare const initKeyboardAvoider: (options?: KeyboardAvoiderOptions) => KeyboardAvoiderController;
|
|
95
|
+
export declare const startKeyboardAvoiderRuntime: () => KeyboardAvoiderController | null;
|
|
96
|
+
export declare const stopKeyboardAvoiderRuntime: () => void;
|
|
@@ -3,9 +3,10 @@
|
|
|
3
3
|
* Selectors match the polish A/B overlay contract.
|
|
4
4
|
*
|
|
5
5
|
* Yield order (highest owns Escape first):
|
|
6
|
-
* modal/drawer overlay → popover ≈ menu (same band) → combobox →
|
|
6
|
+
* modal/drawer/sheet overlay → popover ≈ menu (same band) → combobox →
|
|
7
7
|
* toast / tooltip. Menu closed vs open is native `hidden` on `[menu]`,
|
|
8
|
-
* not on `[menu-root]`.
|
|
8
|
+
* not on `[menu-root]`. Sheet closed vs open is native `hidden` on
|
|
9
|
+
* `[sheet-overlay]`, including `sheet-overlay="none"`.
|
|
9
10
|
*/
|
|
10
11
|
export declare const hasOpenDialogOverlay: () => boolean;
|
|
11
12
|
export declare const hasOpenPopover: () => boolean;
|
|
@@ -0,0 +1,94 @@
|
|
|
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
|
+
* the open dialog for Escape and the focus trap until that commit, and a
|
|
13
|
+
* new open of that same overlay cancels it.
|
|
14
|
+
*
|
|
15
|
+
* Openers: any element whose `aria-controls` token list includes a
|
|
16
|
+
* `[sheet-overlay]` id. `[sheet-close]` closes the containing overlay.
|
|
17
|
+
* Backdrop click closes unless `sheet-overlay="static"` or
|
|
18
|
+
* `closeOnBackdrop` is false. `sheet-overlay="none"` is non-modal: no
|
|
19
|
+
* focus trap, no scroll lock, no backdrop close. Escape still closes.
|
|
20
|
+
*
|
|
21
|
+
* Scroll lock is modal only (boolean / omitted / "static"). A shared
|
|
22
|
+
* counter locks `document.body` overflow on the first modal sheet and
|
|
23
|
+
* restores the previous inline overflow when the last one closes, so
|
|
24
|
+
* nested and sibling modal sheets do not unlock early. Several sheets
|
|
25
|
+
* may be open together. This runtime does not close siblings.
|
|
26
|
+
*
|
|
27
|
+
* Detents. `sheet-detents` on `[sheet]` is the allowed set (`~=` words).
|
|
28
|
+
* Absent, or with no known word, the set is "half full". Rank is
|
|
29
|
+
* peek < half < full. On open the sheet rests at half when half is
|
|
30
|
+
* allowed, otherwise full when full is allowed, otherwise peek — the
|
|
31
|
+
* same rest slice A paints when `[detent]` is absent. `[detent]` is
|
|
32
|
+
* written whenever that rest changes. An already-open sheet keeps a
|
|
33
|
+
* valid `[detent]` until a gesture, the keyboard, or an open transition
|
|
34
|
+
* replaces it.
|
|
35
|
+
*
|
|
36
|
+
* Drag. Pointer events on `[sheet-handle]` and `[sheet-header]` track
|
|
37
|
+
* the finger after an 8px slop. `[sheet-body]` hands off only when
|
|
38
|
+
* `scrollTop` is 0 and the gesture moves down. `[dragging]` is set on
|
|
39
|
+
* the sheet and `data-motion-state` is `entered` for the gesture so the
|
|
40
|
+
* enter/exit animation does not fight the inline height. The finger is
|
|
41
|
+
* followed with inline height, plus `translateY` rubber-band (0.35 of
|
|
42
|
+
* the overflow) past the highest detent and below the lowest. Reduced
|
|
43
|
+
* motion clamps that visual and does not rubber-band; the logical
|
|
44
|
+
* height still tracks so a close can commit. Release snaps by projecting
|
|
45
|
+
* the logical height with velocity over 180ms and choosing the nearest
|
|
46
|
+
* allowed detent. Downward velocity of at least 0.5px/ms at or below the
|
|
47
|
+
* lowest detent, or a logical height more than 80px below it, closes.
|
|
48
|
+
* `pointercancel` drops the gesture and restores the detent it started
|
|
49
|
+
* on. Inline height/transform clear on the next frame after a snap so
|
|
50
|
+
* the detent height transition can run.
|
|
51
|
+
*
|
|
52
|
+
* Keyboard. A MutationObserver on `documentElement` attributes watches
|
|
53
|
+
* `[keyboard-open]`. While a sheet is open, gaining that attribute snaps
|
|
54
|
+
* it to `full` when full is allowed, otherwise the highest detent.
|
|
55
|
+
* Opening while the attribute is already set uses that same rest.
|
|
56
|
+
*
|
|
57
|
+
* State is `{ open, detent, dragging, modal }`. `juice:change` bubbles
|
|
58
|
+
* from the overlay with `detail.runtime === "sheet"`. The first
|
|
59
|
+
* observation is silent. Disabled (`disabled` / `aria-disabled="true"`)
|
|
60
|
+
* and invalid hosts (an overlay with no `[sheet]`) are ignored.
|
|
61
|
+
* Back button history is out of scope.
|
|
62
|
+
*
|
|
63
|
+
* Sheet is the thirty-second Emerging auto-enhance runtime.
|
|
64
|
+
*/
|
|
65
|
+
export type SheetDetent = 'peek' | 'half' | 'full';
|
|
66
|
+
export type SheetOptions = {
|
|
67
|
+
root?: ParentNode;
|
|
68
|
+
overlaySelector?: string;
|
|
69
|
+
dialogSelector?: string;
|
|
70
|
+
closeSelector?: string;
|
|
71
|
+
handleSelector?: string;
|
|
72
|
+
headerSelector?: string;
|
|
73
|
+
bodySelector?: string;
|
|
74
|
+
closeOnBackdrop?: boolean;
|
|
75
|
+
};
|
|
76
|
+
export type SheetState = {
|
|
77
|
+
open: boolean;
|
|
78
|
+
detent: SheetDetent;
|
|
79
|
+
dragging: boolean;
|
|
80
|
+
modal: boolean;
|
|
81
|
+
};
|
|
82
|
+
export type SheetController = {
|
|
83
|
+
destroy: () => void;
|
|
84
|
+
sync: () => void;
|
|
85
|
+
open: (target?: HTMLElement | null) => void;
|
|
86
|
+
close: (target?: HTMLElement | null) => void;
|
|
87
|
+
toggle: (target?: HTMLElement | null) => void;
|
|
88
|
+
isOpen: (target?: HTMLElement | null) => boolean;
|
|
89
|
+
getState: (target?: HTMLElement | null) => SheetState | null;
|
|
90
|
+
};
|
|
91
|
+
export declare const createSheet: (options?: SheetOptions) => SheetController;
|
|
92
|
+
export declare const initSheet: (options?: SheetOptions) => SheetController;
|
|
93
|
+
export declare const startSheetRuntime: () => SheetController | null;
|
|
94
|
+
export declare const stopSheetRuntime: () => void;
|